Skip to content

Commit

Permalink
In the case where they requested an empty date range (such as to and …
Browse files Browse the repository at this point in the history
…from the same day, and some other circumstances)

You'll get none back for the data frame, so we should check for that and only perform updates if its not
  • Loading branch information
Alan Jones committed Apr 26, 2021
1 parent 14e30ad commit e3b95d4
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions python/fastquant/data/crypto/crypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,18 @@ def get_crypto_data(
# This request's end date should now be set as current for the next loop
previous_request_end_date_epoch = current_request_end_date_epoch

# Convert the unix timestampe to datetime
ohlcv_df["dt"] = pd.to_datetime(ohlcv_df["dt"], unit="ms")
# Trim off any records which were returned beyond the end
ohlcv_df = ohlcv_df[ohlcv_df.dt <= end_date]
# Save input parameters into dataframe
ohlcv_df.start_date = start_date
ohlcv_df.end_date = end_date
ohlcv_df.symbol = ticker
return ohlcv_df.set_index("dt")
if ohlcv_df is not None:
# Convert the unix timestampe to datetime
ohlcv_df["dt"] = pd.to_datetime(ohlcv_df["dt"], unit="ms")
# Trim off any records which were returned beyond the end
ohlcv_df = ohlcv_df[ohlcv_df.dt <= end_date]
# Save input parameters into dataframe
ohlcv_df.start_date = start_date
ohlcv_df.end_date = end_date
ohlcv_df.symbol = ticker
ohlcv_df.set_index("dt")

return ohlcv_df
else:
raise NotImplementedError(
"The exchange " + exchange + " is not yet supported. Available exchanges: "
Expand Down

0 comments on commit e3b95d4

Please sign in to comment.