Lumiwealth / lumibot

Backtesting and Trading Bots Made Easy for Crypto, Stocks, Options, Futures, FOREX and more
GNU General Public License v3.0
913 stars 170 forks source link

Intraday Momentum not working for backtesting #23

Closed grzesir closed 2 years ago

grzesir commented 3 years ago

This is the CLI output:

INFO:root:Fetching past trading days
INFO:root:Waiting for the socket stream connection to be established, 
            method _stream_established must be called
INFO:root:Risk Free Rate 0.08%
2021-01-06 12:56:08,614: INFO: Strategy IntradayMomentum: Executing the initialize lifecycle method
2021-01-06 12:56:08,614: INFO: Strategy IntradayMomentum: Executing the before_market_opens lifecycle method
2021-01-06 12:56:08,614: INFO: Current backtesting datetime 2018-01-02 09:30:00
2021-01-06 12:56:08,615: INFO: Strategy IntradayMomentum: Executing the before_starting_trading lifecycle method
2021-01-06 12:56:08,615: INFO: Strategy IntradayMomentum: Executing the on_trading_iteration lifecycle method
2021-01-06 12:56:08,615: INFO: Strategy IntradayMomentum: Porfolio value of 40000
2021-01-06 12:56:08,615: ERROR: time_unit datetime.timedelta(seconds=60) did not match
2021-01-06 12:56:08,619: ERROR: Traceback (most recent call last):
  File "/Users/robertgrzesik/Google Drive/Lumiwealth /Academy/Live Classes /Day10/lumibot/strategies/strategy.py", line 529, in run
    self._run_trading_session()
  File "/Users/robertgrzesik/Google Drive/Lumiwealth /Academy/Live Classes /Day10/lumibot/strategies/strategy.py", line 488, in _run_trading_session
    self.on_trading_iteration()
  File "/Users/robertgrzesik/Google Drive/Lumiwealth /Academy/Live Classes /Day10/lumibot/tools/decorators.py", line 64, in func_output
    frame, result = call_function_get_frame(func_input, *args, **kwargs)
  File "/Users/robertgrzesik/Google Drive/Lumiwealth /Academy/Live Classes /Day10/lumibot/tools/decorators.py", line 24, in call_function_get_frame
    result = func(*args, **kwargs)
  File "/Users/robertgrzesik/Google Drive/Lumiwealth /Academy/Live Classes /Day10/lumibot/strategies/examples/intraday_momentum.py", line 22, in on_trading_iteration
    momentums = self.get_assets_momentums()
  File "/Users/robertgrzesik/Google Drive/Lumiwealth /Academy/Live Classes /Day10/lumibot/strategies/examples/intraday_momentum.py", line 54, in get_assets_momentums
    bars_set = self.get_symbol_bars(
  File "/Users/robertgrzesik/Google Drive/Lumiwealth /Academy/Live Classes /Day10/lumibot/strategies/strategy.py", line 333, in get_symbol_bars
    return self.data_source.get_symbol_bars(
  File "/Users/robertgrzesik/Google Drive/Lumiwealth /Academy/Live Classes /Day10/lumibot/data_sources/data_source.py", line 34, in get_symbol_bars
    response = self._pull_source_symbol_bars(
  File "/Users/robertgrzesik/Google Drive/Lumiwealth /Academy/Live Classes /Day10/lumibot/backtesting/yahoo_backtesting.py", line 21, in _pull_source_symbol_bars
    result = YahooData._pull_source_symbol_bars(
  File "/Users/robertgrzesik/Google Drive/Lumiwealth /Academy/Live Classes /Day10/lumibot/data_sources/yahoo.py", line 37, in _pull_source_symbol_bars
    self._parse_source_time_unit(time_unit, reverse=True)
  File "/Users/robertgrzesik/Google Drive/Lumiwealth /Academy/Live Classes /Day10/lumibot/data_sources/yahoo.py", line 34, in _parse_source_time_unit
    raise ValueError("time_unit %r did not match" % time_unit)
ValueError: time_unit datetime.timedelta(seconds=60) did not match

2021-01-06 12:56:08,620: WARNING: Strategy IntradayMomentum: sell all
grzesir commented 2 years ago

This is now in the library