enzoampil / fastquant

fastquant — Backtest and optimize your ML trading strategies with only 3 lines of code!
MIT License
1.51k stars 236 forks source link

[FEATURE] Request hourly crypto data #372

Closed nickthorpie closed 2 years ago

nickthorpie commented 3 years ago

Is your feature request related to a problem? Please describe. I would like to be able to run analysis on hourly data because I'm testing strategies for young cryptos.

Describe the solution you'd like The solution takes no more than a minute. I've worked around it on my computer by fastquant.py: line 544: get_crypto_data(ticker, start_date, end_date,granularity = "1d"): and line 552: ohlcv_lol = binance.fetch_ohlcv(ticker, granularity, since=start_date_epoch)

jannctu commented 3 years ago

Hi @nickthorpie

I am not a part of the team and don't have much time to send a pull request.

Here is the quick solution

go to: fastquant/data/crypto/crypto.py

then change the time format.

  1. Line 20
    #dt = datetime.strptime(date, "%Y-%m-%d")
    dt = datetime.strptime(date, "%Y-%m-%d %H:%M:%S")
  2. Line 73
    #request_start_date_epoch = unix_time_millis(pd.to_datetime(request_start_date_epoch, unit="ms").strftime('%Y-%m-%d'))
    request_start_date_epoch = unix_time_millis(pd.to_datetime(request_start_date_epoch, unit="ms").strftime('%Y-%m-%d %H:%M:%S'))

Hope it helps.

mikeejazmines commented 2 years ago

Fixed with recent PR https://github.com/enzoampil/fastquant/pull/396