我试图将通过 ccxt 库下载的 kraken 中的 ohlcv 数据转换为更长的蜡烛(更长的 ohlcv 数据)
import ccxt
import numpy as np
source_ohlcv = exchange.fetch_ohlcv("BTC/USD", '15m')
n_minutes = 3
def transform_ohlcv(source_ohlcv,n_minutes):
i = 0
i_len = 0
i_len_end = (n_minutes-1)
timestamp = [x[0] for x in source_ohlcv]
o = [x[1] for x in source_ohlcv]
h = [x[2] for x in source_ohlcv]
l = [x[3] for x in source_ohlcv]
c = [x[4] for x in source_ohlcv]
v = [x[5] for x in source_ohlcv]
print(len(timestamp))
while i_len_start < len(timestamp):
ts = timestamp[i_len_start]
op = o[i_len_start]
hi = np.amax(h[i_len_start:i_len_end])
lo = np.amin(l[i_len_start:i_len_end])
cl = c[i_len_end]
vo = sum(v[i_len_start:i_len_end])
results.append(ts,op,hi,lo,cl,vo)
i_len_end += (n_minutes)
i_len_start += (n_minutes)
return results
print(transform_ohlcv(source_ohlcv,n_minutes)
我认为结果应该与源相同,但是在解析某处 EOF 时出现错误!所以请帮我找到流氓条目在哪里。此致 :)