Hi guys, it's not an issue but kind begging for help, I'm pretty new to ansychronous stuff and websockets overall, I would just use REST API but Huobi feeds resonable historical data only with websockets. I just have one small issue. Here is my code:
from huobi.client.market import MarketClient
from huobi.client.market import CandlestickInterval
import pandas as pd
from pandas import DataFrame as df
Dataframe = df(columns = ["Date", "Open", "High", "Low", "Close", "Volume"])
def callback(candlestick_req: "CandlestickReq"):
Candles = candlestick_req
Dataframe["Date"] = [Candles.data[f].id for f in range(len(Candles.data))]
Dataframe["Open"] = [Candles.data[f].open for f in range(len(Candles.data))]
Dataframe["High"] = [Candles.data[f].high for f in range(len(Candles.data))]
Dataframe["Low"] = [Candles.data[f].low for f in range(len(Candles.data))]
Dataframe["Close"] = [Candles.data[f].close for f in range(len(Candles.data))]
Dataframe["Volume"] = [Candles.data[f].vol for f in range(len(Candles.data))]
print(Dataframe)
Market_client = MarketClient()
Market_client.req_candlestick("btcusdt", CandlestickInterval.MIN60, callback, from_ts_second = 1609526859, end_ts_second = 1610736459)
How can I return the new Dataframe that has all the data from inside the callback function so I can use it outside of the defined function? Simple return doesn't work as I'm not calling the callback function, it's only used in the market_client.req_candlestick.
Thanks!
Hi guys, it's not an issue but kind begging for help, I'm pretty new to ansychronous stuff and websockets overall, I would just use REST API but Huobi feeds resonable historical data only with websockets. I just have one small issue. Here is my code:
How can I return the new Dataframe that has all the data from inside the callback function so I can use it outside of the defined function? Simple return doesn't work as I'm not calling the callback function, it's only used in the market_client.req_candlestick. Thanks!