jesse-ai/jesse

binance does not offer 3h candles for 30m extra

movy opened this issue · 1 comments

Very basic stuff: extra candles state that 30m candles will fetch 3h as extras:
https://github.com/jesse-ai/jesse/blob/dc9a9ca1dd591ca920d4f6b3603a0ec1c82624ce/jesse/utils.py#L26C1-L27C1

and naturally it works fine during backtesting. Yet Binance does not offer 3h candles, so going live is impossible with such strategy, error goes:

  error: 'ValueError: Invalid timeframe: 3h',
  traceback: 'Traceback (most recent call last):\n' +
    '  File "/usr/lib/python3.11/threading.py", line 1045, in _bootstrap_inner\n' +
    '    self.run()\n' +
    '  File "/usr/lib/python3.11/threading.py", line 982, in run\n' +
    '    self._target(*self._args, **self._kwargs)\n' +
    '  File "/home/ubuntu/.local/lib/python3.11/site-packages/jesse/services/api.py", line 27, in initiate_ws\n' +
    '    self.drivers[exchange_name] = exchange_class()\n' +
    '                                  ^^^^^^^^^^^^^^^^\n' +
    '  File "jesse_live/exchanges/Binance/BinancePerpetualFutures.py", line 7, in jesse_live.exchanges.Binance.BinancePerpetualFutures.BinancePerpetualFutures.__init__\n' +
    '  File "jesse_live/exchanges/Binance/BinancePerpetualFuturesMain.py", line 25, in jesse_live.exchanges.Binance.BinancePerpetualFuturesMain.BinancePerpetualFuturesMain.__init__\n' +
    '  File "jesse_live/exchanges/LiveExchange.py", line 171, in jesse_live.exchanges.LiveExchange.LiveExchange.__init__\n' +
    '  File "jesse_live/exchanges/LiveExchange.py", line 1322, in jesse_live.exchanges.LiveExchange.LiveExchange._fetch_initial_candles_for_all_timeframes\n' +
    '  File "/home/ubuntu/.local/lib/python3.11/site-packages/jesse/modes/import_candles_mode/drivers/Binance/BinanceMain.py", line 46, in fetch\n' +
    '    interval = timeframe_to_interval(timeframe)\n' +
    '               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n' +
    '  File "/home/ubuntu/.local/lib/python3.11/site-packages/jesse/modes/import_candles_mode/drivers/Binance/binance_utils.py", line 51, in timeframe_to_interval\n' +
    "    raise ValueError('Invalid timeframe: {}'.format(timeframe))\n" +
    'ValueError: Invalid timeframe: 3h\n'
}

A simple fix would be to offer extra tf conditionally based on the exchange used. I think manually generating 3h candles not worth the effort in such case.

My bad, I forgot that local candle generation can be activated by user!