Task 5 — Bot feed provider switch + Task 1 — cTrader live tick stream
Summary
- Added
feed_providercolumn tobots(migration0014_bot_feed_provider.sql). - Schema/types/repository updated end-to-end so a bot can be created or updated with
feedProvider: 'finnhub' | 'ctrader'(defaults tofinnhub). BotExecutorDOnow reads the bot's feed provider and routes realtime subscriptions to the matching stream DO.CreateBotPageexposes a Tick Feed Provider dropdown (Finnhub default; cTrader option for accounts with cTrader OAuth credentials).MarketMetadataBadgesaccepts an optionalfeedProviderprop so live bots show the active tick feed instead of the candle provider label.- New
CTraderStreamDOscaffold connects to cTrader Open API JSON over WebSocket (wss://demo.ctraderapi.com:5036), runs the standardProtoOAApplicationAuthReq → ProtoOAAccountAuthReq → ProtoOASubscribeSpotsReqhandshake, and forwards spot ticks toMARKET_DATA_DO. Per-tick interval is logged and aconsole.warnis emitted when the gap is outside the expected 10-100 ms window. wrangler.jsoncregisters the newCTRADER_STREAM_DObinding under migration tagv6.
Files
services/backend/src/db/migrations/0014_bot_feed_provider.sql(new)services/backend/src/realtime/ctrader-stream-do.ts(new)services/backend/src/realtime/bot-executor-do.tsservices/backend/src/routes/bots/bots-{schema,types,repository,service}.tsservices/backend/src/index.ts,worker-types.ts,wrangler.jsoncservices/frontend/src/routes/bots/CreateBotPage.tsxservices/frontend/src/components/market/MarketMetadataBadges.tsxshared/types.ts
Migration status
Applied 0013_bot_strategies.sql and 0014_bot_feed_provider.sql to both dev and prod Neon DBs prior to push.
Verification
pnpm --dir services/backend typecheckcleanpnpm --dir services/frontend typecheckcleanpnpm --dir services/frontend test28/28 passing