strategy.backtest without `to` argument should infer `start_time` and `end_time`
c0indev3l opened this issue · comments
working4coins commented
Hi,
Running RSI example with
def main():
# Define exchange as KeylessExchange
exchange = blankly.KeylessExchange(
price_reader=blankly.data.data_reader.PriceReader("./XBTUSDT_1D.csv", "BTC-USD")
)
# Use our strategy helper on Binance
strategy = blankly.Strategy(exchange)
# Run the price event function every time we check for a new price - by default that is 15 seconds
strategy.add_price_event(price_event, symbol='BTC-USD', resolution='1d', init=init)
#strategy.start()
strategy.backtest(initial_values={'USD': 10000})
if __name__ == "__main__":
main()
ie when no to = "1y"
argument is passed
raises
backtest-run_trading-1 | File "/usr/local/lib/python3.11/site-packages/blankly/exchanges/interfaces/paper_trade/backtest_controller.py", line 384, in sync_prices
backtest-run_trading-1 | end_time = self.__user_added_times[i][self.PriceIdentifiers.epoch_stop] - resolution
backtest-run_trading-1 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
backtest-run_trading-1 | TypeError: unsupported operand type(s) for -: 'NoneType' and 'int'
Ideally in such a case backtest should use as much data as it can and define start_time and end_time automatically from data
If there is several PriceReader start_time should be max of start_time accross PriceReaders.
and end_time should be min of end_time to consider that a backtest can be done only for overlapping data.
Kind regards