Copy forward stupid kraken zeroed vwaps
parent
b13da849d0
commit
14a5d047c3
|
@ -103,15 +103,22 @@ class Client:
|
||||||
bars = next(iter(res.values()))
|
bars = next(iter(res.values()))
|
||||||
|
|
||||||
# convert all fields to native types
|
# convert all fields to native types
|
||||||
bars = list(starmap(
|
new_bars = []
|
||||||
lambda i, bar:
|
last_nz_vwap = None
|
||||||
|
for i, bar in enumerate(bars):
|
||||||
|
# normalize weird zero-ed vwap values..cmon kraken..
|
||||||
|
vwap = float(bar[-3])
|
||||||
|
if vwap != 0:
|
||||||
|
last_nz_vwap = vwap
|
||||||
|
if vwap == 0:
|
||||||
|
bar[-3] = last_nz_vwap
|
||||||
|
|
||||||
|
new_bars.append(
|
||||||
(i,) + tuple(
|
(i,) + tuple(
|
||||||
ftype(bar[i]) for i, (name, ftype)
|
ftype(bar[j]) for j, (name, ftype) in enumerate(_ohlc_dtype[1:])
|
||||||
in enumerate(_ohlc_dtype[1:])
|
|
||||||
),
|
|
||||||
enumerate(bars))
|
|
||||||
)
|
)
|
||||||
return np.array(bars, dtype=_ohlc_dtype) if as_np else bars
|
)
|
||||||
|
return np.array(new_bars, dtype=_ohlc_dtype) if as_np else bars
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise SymbolNotFound(json['error'][0] + f': {symbol}')
|
raise SymbolNotFound(json['error'][0] + f': {symbol}')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue