Adding new exchange
-
I've started using backtrader to backtest some strategies for trading crypto currencies. I'd like to move forward and eventually paper trade and live trade some of these strategies.
For that, I would need to implement the broker and the store for a crypto currency exchange (I am thinking of Poloniex or Bittrex). Could anyone give me some pointers on how to get started on that? Do I just need to reimplement the broker and store for say IB for the feature set of the exchange I would like to add? Are there any more components expect broker and store I would need to touch? Any tips are appreciated.
Also, is someone interested in live trading crypto currencies that would like to collaborate on this?
-
@gindeleo said in Adding new exchange:
Could anyone give me some pointers on how to get started on that?
The best pointers are in the source code, being the recommendation to look into Oanda which was the latest implementation and thus the one that gained from past experiences.
Each broker/data provider is a different beast and although some general principles apply (like keeping background threads for communication with the entity without blocking the main thread), the actual API and way to speak with it will guide the process.
This is not only a backtrader thing. See how Quantopian has chosen to discontinue IB trading to avoid maintenance of the implementation: Quantopian - Phasing Out Brokerage Integrations
The 'Store' is meant as the actual entity talking to the broker/data provider. It shall provide an internal interface to the data feed and the broker to perform actions and will be in charge of keeping the background threads and when messages are received to pre-process them before passing them on to the data feed/broker (usually over a thread-safe queue) to keep the latter as generic as possible
-
Thanks a lot for that answer and the explanation on the Store. I'll dive into the Oanda implementation and see how it goes.
More generally, are there any other exchanges to be implemented on the roadmap?
-
None at the moment. The development of this line of the software is not pursuing new targets.
-
@gindeleo I would also like to know more about implementing our own broker. I am already looking at https://github.com/mementum/backtrader/blob/master/backtrader/brokers/oandabroker.py. Did you get the answers you needed from there?
-
@roch_02 Yes, I think it is quite illustrative. First, I am looking to create the live data feed and implement the store. Then, I'll try to make the broker work as a second step.
As @backtrader mentioned you'll have to follow the API of the exchange for guidance. This will determine the functions to implement and how to feed the data.
What exchange are you trying to connect to?
-
@gindeleo thanks for your answer. I am not using Oanda data feed. I want to use an internal data feed that I have. Will try to understand the one implemented with Oanda (in the link I sent) and see if I can adapt for my case.