Kismuz / btgym

Scalable, event-driven, deep-learning-friendly backtesting library
https://kismuz.github.io/btgym/
GNU Lesser General Public License v3.0
981 stars 259 forks source link

Ingesting real-time streaming data feed (Live) from Interactive Broker instead of .CSV #55

Closed developeralgo8888 closed 5 years ago

developeralgo8888 commented 6 years ago

@Kismuz ,

Can you give some insights on how best to ingest realtime streaming FOREX data feed from Interactive Broker into btgym instead of .CSV for continuous online training , testing and trading

what i am trying working on .

With BT , it already has infrastructure in place to get realtime streaming datafeed from IB, so that's not an issue. my issue is how to integrate it with BTGYM infrastructure with minimal changes to Btgym core structure . ( Less work/maintenance means more time to work on improving and testing Algorithms offline )

Interactive Brokers Realtime Data feed => DB for persistence ( Influx/Postgresql/Mongo) ==> Btgym (online training & validation ) ==> signals/Action ( Buy /Sell/Hold) ==> Trade sent to interactive Brokers

Kismuz commented 6 years ago

@developeralgo8888 ,

btgym.datafeed module contains several DataSet classes (data iterators) to construct data input pipeline. Yes, in its current form it is: CSV[source data]-->btgym.Dataset_iterator -->bt.feed -->btgym.strategy btgym.Dataset iterators are self-contained in a sense it hold data-management logic and API (sampling, train|test splitting etc..) and data serving upon requests from decision RL algorithm ( for example RL algorithm could request one validation episode after ten train episodes via parameters of env.reset() methods, and it is exactly btgym.Dataset which provides executive btgym.strategy with relevant data) So in a first glance, it is straightforward to make btgy.Dataset wrapper for any source other than CSV and define all data management logic inside it: bt.stores.IBStore-->btgym.Dataset_wrapper-->btgym.strategy ...but in a case of live data it is a bit more complicated:

developeralgo8888 commented 6 years ago

@Kismuz , Thanks for that great explanation . I was thinking on having a trained model and just to validate/test it with real-time streaming data to trade. I do understand live online training of streaming data is really massively expensive .

initial thought of a continuous loop:

IB Realtime Streaming data ==> btgym ==> continuously update and validate/test offline Trained model ==> get buy/sell signals ==> send live trade ==> IB

Continuous updating and validating/test offline model will require some rolling window model . Do we do a continuous offline training of model and update or append or rewrite the live trading model every 15 mins, 30 mins or 1 hour depending on our trading timeframe ?

Kismuz commented 6 years ago

@developeralgo8888 ,

Do we do a continuous offline training of model and update or append or rewrite the live trading model every 15 mins, 30 mins or 1 hour depending on our trading timeframe ?

developeralgo8888 commented 6 years ago

@Kismuz , thanks for the great clarification . well appreciated . The REACTOR algorithm is very impressive and i am going through it to see how it can be applied to btgym