use buy/sell signal from previous candle, not current to avoid seeing to the future

This commit is contained in:
Janne Sinivirta 2018-06-06 13:56:08 +03:00
parent c75b70463b
commit 7f8e0ba25f

View File

@ -162,6 +162,10 @@ class Backtesting(object):
pair_data['buy'], pair_data['sell'] = 0, 0 # cleanup from previous run
ticker_data = self.populate_sell_trend(self.populate_buy_trend(pair_data))[headers]
# to avoid using data from future, we buy/sell with signal from previous candle, not current
ticker_data.buy = ticker_data.buy.shift(1)
ticker_data.sell = ticker_data.sell.shift(1)
ticker = [x for x in ticker_data.itertuples()]
lock_pair_until = None