Skip to content

Instantly share code, notes, and snippets.

@macd2
Last active January 4, 2021 06:29
Show Gist options
  • Save macd2/0430c7c77a6630c21c6167dfe034b660 to your computer and use it in GitHub Desktop.
Save macd2/0430c7c77a6630c21c6167dfe034b660 to your computer and use it in GitHub Desktop.

Revisions

  1. macd2 revised this gist Jan 4, 2021. No changes.
  2. macd2 created this gist Jan 4, 2021.
    32 changes: 32 additions & 0 deletions get_candles.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    # add this file to YOUR_PROJECT_ROOT
    from YOUR_PROJECT_ROOT.symbols_ import symbols
    from jesse import register_custom_exception_handler
    from jesse.modes import import_candles_mode
    from jesse.services import db
    from jesse.routes import router


    def get_candles(start_date, routes_, extra_candles_):
    router.set_routes(routes_)
    router.set_extra_candles(extra_candles_)

    for i in symbols:
    try:
    tmfrm = [x[2] for x in routes_ if x[1] == i][0]
    print('Downloading:', i, tmfrm)

    register_custom_exception_handler()
    import_candles_mode.run(exchange='Binance', symbol=i, start_date_str=start_date, skip_confirmation=True)
    db.close_connection()
    except IndexError:
    print(f'Please add {i} to routes_')
    except Exception as e:
    print(e)


    if __name__ == '__main__':
    # Set start_date and timeframe than run python3 get_candles.py
    start_date = '2020-01-01'
    timeframe = '4h'

    get_candles(start_date=start_date, routes_=[('Binance', x, timeframe, 'YOURS_STRATEGY') for x in symbols], extra_candles_=[])
    2 changes: 2 additions & 0 deletions symboles_.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    # add this file to YOUR_PROJECT_ROOT and insert your desired symbols
    symbols = ["BTC-USDT", "ETH-USDT",add_your_symbols...]