miro-ka / mosquito

Trading Bot with focus on Evolutionary Algorithms and Machine Learning
GNU General Public License v3.0
261 stars 53 forks source link

Strategy gets wrong DataFrame #69

Open sertans opened 6 years ago

sertans commented 6 years ago

Hello, I hope this Issue is correct. I was testing the ema strategy and started to take a look at the code. I followed the path of the DataFrame when pairs are traded. I printed the pairs within the exchange.py get_offline_ticker() function and they were right. this function returns the DataFrame which later gets into the strategy calculate() function. I printed the dataframe within the calculate function and saw the following: 102 5ba222ce1cdd4b98740401ac polo-USDT_ETH-1537352100 1537352100 ... USDT_ETH USDT ETH 103 5ba21fa31cdd4b9874031ab7 polo-USDT_BCH-1537350900 1537350900 ... USDT_BCH USDT BCH 104 5ba2230d1cdd4b9874040200 polo-USDT_BTC-1537352100 1537352100 ... USDT_BTC USDT BTC 105 5ba223081cdd4b98740401fe polo-USDT_LTC-1537351500 1537351500 ... USDT_LTC USDT LTC 106 5ba222ce1cdd4b98740401ac polo-USDT_ETH-1537352100 1537352100 ... USDT_ETH USDT ETH

this is the head of the df with these pairs: ['USDT_BTC', 'USDT_LTC', 'USDT_ETH', 'USDT_BCH']

The problem I see here is how ema is calculated: ema5 = talib.EMA(close[-5:], timeperiod=5)[-1] ema10 = talib.EMA(close[-10:], timeperiod=10)[-1] ema20 = talib.EMA(close[-20:], timeperiod=20)[-1] It takes the last 5/10/20 entries of the dataframe, even if those are entries from another pair. With the given example I get this output : close_price: 6378.0 ema: 1775.8421071704997 which is the close_price from bitcoin and the ema calculated over all other currencies, which might be a reason why the algorithm fails. Is this a bug or isn't the multi pair feature not already build in?