Lumiwealth / lumibot

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

Screener strategy not working in live mode #18

Closed grzesir closed 3 years ago

grzesir commented 3 years ago

Here is the result of running the strategy:

(base) Roberts-MBP:alpaca-bots robertgrzesik$ python main.py screener -l
2021-01-05 14:15:19,727: INFO: Strategy Screener: Executing the initialize lifecycle method
2021-01-05 14:15:20,045: INFO: Strategy Screener: Executing the before_starting_trading lifecycle method
2021-01-05 14:15:20,046: WARNING: Strategy Screener: sell all
2021-01-05 14:15:20,083: INFO: Strategy Screener: Executing the on_trading_iteration lifecycle method
2021-01-05 14:15:20,084: INFO: Strategy Screener: Porfolio value of 40000
2021-01-05 14:15:20,084: INFO: Requesting asset bars from alpaca API
2021-01-05 14:15:24,496: INFO: Note: NumExpr detected 12 cores but "NUMEXPR_MAX_THREADS" not set, so enforcing safe limit of 8.
2021-01-05 14:15:24,497: INFO: NumExpr defaulting to 8 threads.
2021-01-05 14:16:17,100: INFO: Selecting best positions
2021-01-05 14:16:17,105: ERROR: index -1 is out of bounds for axis 0 with size 0
2021-01-05 14:16:17,110: ERROR: Traceback (most recent call last):
  File "/Users/robertgrzesik/Development/alpaca-bots/strategies/strategy.py", line 523, in run
    self._run_trading_session()
  File "/Users/robertgrzesik/Development/alpaca-bots/strategies/strategy.py", line 482, in _run_trading_session
    self.on_trading_iteration()
  File "/Users/robertgrzesik/Development/alpaca-bots/tools/decorators.py", line 64, in func_output
    frame, result = call_function_get_frame(func_input, *args, **kwargs)
  File "/Users/robertgrzesik/Development/alpaca-bots/tools/decorators.py", line 24, in call_function_get_frame
    result = func(*args, **kwargs)
  File "/Users/robertgrzesik/Development/alpaca-bots/strategies/screener.py", line 36, in on_trading_iteration
    self.buy_winning_stocks(
  File "/Users/robertgrzesik/Development/alpaca-bots/strategies/screener.py", line 60, in buy_winning_stocks
    new_positions = self.select_assets(data, min_increase_target)
  File "/Users/robertgrzesik/Development/alpaca-bots/strategies/screener.py", line 82, in select_assets
    momentum = bars.get_momentum()
  File "/Users/robertgrzesik/Development/alpaca-bots/entities/bars.py", line 25, in get_momentum
    momentum = self.df["close"].pct_change(n_rows - 1)[-1]
  File "/Users/robertgrzesik/opt/anaconda3/lib/python3.8/site-packages/pandas/core/series.py", line 879, in __getitem__
    return self._values[key]
IndexError: index -1 is out of bounds for axis 0 with size 0

2021-01-05 14:16:17,110: WARNING: Strategy Screener: sell all
The end
SlimBeji commented 3 years ago

Strategy deleted for the time being.