"EOF while parsing" in Python loop

bobulator Source

im trying to transform ohlcv data from kraken downloaded via ccxt library into longer candles (longer ohlcv data)

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]
    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])


        i_len_end += (n_minutes)
        i_len_start += (n_minutes)
    return results

I think that the results should be the same as the source however im getting error while parsing somewhere EOF!! so please help me find where the rogue entry is. best regards :)



answered 1 week ago L3gionOfDooM #1

Your error is in the last line at


You are missing the closing parenthesis, so the last line should look like this...


comments powered by Disqus