Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Data issue with get_candles function #203

Open
albertwong08 opened this issue Mar 16, 2023 · 0 comments
Open

Error: Data issue with get_candles function #203

albertwong08 opened this issue Mar 16, 2023 · 0 comments

Comments

@albertwong08
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant