在Python循环中“解析时的EOF”

时间:2018-03-13 18:06:44

标签: python list loops debugging eof

我试图将通过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时会出现错误!!所以请帮我找一下流氓入口的位置。最好的问候:)

1 个答案:

答案 0 :(得分:2)

您的错误位于

的最后一行
print(transform_ohlcv(source_ohlcv,n_minutes)

您缺少右括号,因此最后一行应如下所示......

print(transform_ohlcv(source_ohlcv,n_minutes))