Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

strategy.backtest without to argument should infer start_time and end_time #240

Open
c0indev3l opened this issue Jul 16, 2023 · 0 comments

Comments

@c0indev3l
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant