我正在尝试从 binance 的最后几个“收盘价”值中列出一个列表。这是我目前拥有的代码。
from binance.client import Client
client= Client(API_KEY,API_SECRET)
klines = client.get_historical_klines("BTCUSDT",
Client.KLINE_INTERVAL_1MINUTE, "1 day ago UTC")
print(klines)
输出是多个列表,描述如下:
[
[
1499040000000, // Open time
"0.01634790", // Open
"0.80000000", // High
"0.01575800", // Low
"0.01577100", // Close
"148976.11427815", // Volume
1499644799999, // Close time
"2434.19055334", // Quote asset volume
308, // Number of trades
"1756.87402397", // Taker buy base asset volume
"28.46694368", // Taker buy quote asset volume
"17928899.62484339" // Ignore.
]
]
以下是删除了中间部分的输出示例:
[[1611072420000, '37716.64000000', '37805.00000000', '37702.18000000',
'37787.54000000', '198.73546400', 1611072479999, '7507515.26251034', 3959,
'139.54353300', '5272053.83992940', '0'], [1611072480000, '37787.54000000',
'37805.00000000', '37654.11000000', '37756.09000000', '123.42784000',
1611072539999, '4658049.45239573', 3060, '56.22527600', '2122388.53330171',
'0'], [1611072540000, '37754.74000000', '37768.11000000', '37671.15000000',
'37691.71000000', '137.19280300', 1611072599999, '5175284.11293547', 2775,
'59.11196400', '2230236.36825285', '0'],..........................................................................
... [1611158700000, '33757.21000000', '33758.90000000', '33408.06000000',
'33511.26000000', '455.99996000', 1611158759999, '15289773.46630533', 7233,
'145.59824900', '4882553.68773912', '0'], [1611158760000, '33511.27000000',
'33527.38000000', '33400.00000000', '33471.00000000', '308.54631700',
1611158819999, '10323394.45427450', 4736, '157.52705800',
'5271808.11720111', '0']]
我想制作一个由最后一个说 20 个列表的第 5 个 [4] 值组成的列表。
不确定是否有更好的函数可以在 python 中使用。