dydxprotocol / dydx-v3-python

Python client for dYdX (API v3)
Apache License 2.0
304 stars 174 forks source link

Error: Data issue with get_candles function #203

Open albertwong08 opened 1 year ago

albertwong08 commented 1 year ago

When I try to use client.public.get_candles() to retrieve the OHLC information for date: Mar 3 2021 to Mar 30 2021, all the date in the "updatedAt" field are all "2021-03-29T20:08:58.xxxZ", where xxx is in range 006-029.

Here is the code I am using as below, with results being attached:

Get the OHLC from DYDX

dict_candles = {"Date":[],"Open":[],"High":[],"Low":[],"Close":[]}

ETHEREUM_ADDRESS = 'xxxxxxxxxxxxxxxxxxxxxxxxx' client = Client( network_id=NETWORK_ID_MAINNET, host=API_HOST_MAINNET, default_ethereum_address=ETHEREUM_ADDRESS)

toTime = getDateinISOFormat('2021-03-31') fromTime = getDateinISOFormat('2021-02-28')

candles = client.public.get_candles(market=MARKET_ETH_USD,resolution='1DAY',from_iso=fromTime,to_iso=toTime)

ohlcv = client.get_ohlcv("ETH-USD","1d")

for item in candles.data["candles"]: dict_candles["Date"].append(item["updatedAt"]) dict_candles["Open"].append(item["open"]) dict_candles["High"].append(item["high"]) dict_candles["Low"].append(item["low"]) dict_candles["Close"].append(item["close"]) fromTime = (datetime.datetime.fromisoformat(fromTime) - datetime.timedelta(days=1)).strftime("%Y-%m-%dT%H:%M:%S") toTime = (datetime.datetime.fromisoformat(toTime) - datetime.timedelta(days=1)).strftime("%Y-%m-%dT%H:%M:%S")

df_candles =pd.DataFrame.from_dict(dict_candles) df_candles

wrongResult