kieran-mackle / AutoTrader

A Python-based development platform for automated trading systems - from backtesting to optimisation to livetrading.
https://kieran-mackle.github.io/AutoTrader/
GNU General Public License v3.0
945 stars 217 forks source link

Periodic Live trading works for only one Instrument #41

Closed SeifallahSnoussi closed 2 years ago

SeifallahSnoussi commented 2 years ago

Describe the bug I had an issue when I run the script in live trading for more than one Instrument. Only the last Instrument in Watchlist variable is traded.

To Reproduce

Configuration:

When I run the script I see that 3 bots have been assigned to the three instruments, However, only the last one is traded In fact, the function generate_signal() is called once in each interval (I added a print inside this function to check which Instrument is traded)

Below the console output when the script is running in live trading: `AutoTraderBot assigned to trade XAG_USD with oanda broker using Difkara Mean Reversion Strategy.

AutoTraderBot assigned to trade EUR_USD with oanda broker using Difkara Mean Reversion Strategy.

AutoTraderBot assigned to trade AUD_USD with oanda broker using Difkara Mean Reversion Strategy. Update bot for instrument AUD_USD Instrument AUD_USD , MACD Value= 25.1`

I fixed this by adding a for loop inside autotrader.py in line 1175 for bot in self._bots_deployed:

image

Could you please add that line in the upcoming release ?

Thanks,

kieran-mackle commented 2 years ago

Thanks for raising this. I've just fixed it in the version 0.7 development branch, which I am hoping to release relatively soon.

I've also patched it on the main branch in case that is more convenient for the time being.

I'll leave this issue open until I publish the next release.

Thanks

kieran-mackle commented 2 years ago

Fixed in version 0.7.