csv binance api get_historical_klines返回错误值

xqk2d5yq  于 2022-12-06  发布在  其他
关注(0)|答案(1)|浏览(134)

下面的代码:

def gethistory(symbol, LT):

    df = pd.DataFrame(client.get_historical_klines(symbol, '1d',limit=1000,start_str = 
                                                         str(delta), end_str = None)) 
                                              //delta = date.today() - timedelta(days = LT)
    closes = pd.DataFrame(df[4])
    closes.columns = ['Close']
    
    closes['ST'] = closes.Close.rolling(ST-1).sum() //ST = 7
    closes['LT'] = closes.Close.rolling(LT-1).sum()
    
    return closes

historicals = gethistory('BTCUSDT', LT)  // LT = 25

返回:

Close         ST  LT
0  43893.22000000        NaN NaN
1  42454.70000000        NaN NaN
2  39148.36000000        NaN NaN
3  39398.19000000        NaN NaN
4  38420.80000000        NaN NaN
5  38061.30000000  241376.57 NaN

为什么它只返回6行?限制是1000,我要求25天,所以它应该返回25行。

bjp0bcyl

bjp0bcyl1#

以下是一个示例

frame = pd.DataFrame(client.get_historical_klines(symbol, '1d', '365 days ago UTC'))
女巫!

相关问题