rodrigo-brito / backtrader-binance-bot

:money_with_wings: A example of bot using Backtrader to trade Bitcoins in Binance Exchange.
MIT License
263 stars 118 forks source link

how to use it in a different broker #6

Closed rrfaria closed 3 years ago

rrfaria commented 4 years ago

I was taking a look on your code and it is pretty good but it is to binance

I need use it in iqoption as a broker there is a community behind iqoption trying to use iqoption api but no one know how to put it on backtrader

do you know how to create a broker on backtrader Is there any video on internet about it ?

rodrigo-brito commented 4 years ago

Hi @rrfaria, You can create a custom class with iqoption operations like this: https://gist.github.com/rodrigo-brito/8c82020f04e946e3f0c39c7243cfe1ee. In the code, you can create an instance of this custom class in the constructor of your strategy and execute the buy or sell function instead of backtrader built-in functions.

The main problem is the data feed. You should create a class which provides some fields: https://www.backtrader.com/docu/datafeed-develop-general/datafeed-develop-general/

rrfaria commented 4 years ago

thanks @rodrigo-brito

but if I use this class on strategy I'll not lose boker functionalities ?

I need mensure if it is getting profit or not ?

iqoption uses spread on forex and crypto I would like to use a strategy where use it as a important property to do buy or sell because some time when spread is too high doesn't compensate do any thing and it is hold time

I found oanda code: https://github.com/ftomassetti/backtrader-oandav20/tree/master/btoandav20

he implements store, broker, sizer and feed I tried to read backtrader docs but it is not so clear

there is a open source api witch give us realtime data https://github.com/Lu-Yi-Hsun/iqoptionapi

and there is a entire group trying to develop their on bot with different strategies https://t.me/joinchat/OiGH3w5ceyvVxK8SFqV50g

so if I could create it it can help a lot