Include vwap in kraken historical bars

unleash_the_kraken
Tyler Goodlet 2020-09-09 21:20:07 -04:00
parent 0b42ac1420
commit b13da849d0
1 changed files with 8 additions and 4 deletions

View File

@ -27,7 +27,7 @@ _url = 'https://api.kraken.com/0'
# conversion to numpy worthy types # conversion to numpy worthy types
ohlc_dtype = [ _ohlc_dtype = [
('index', int), ('index', int),
('time', int), ('time', int),
('open', float), ('open', float),
@ -39,6 +39,10 @@ ohlc_dtype = [
('count', int) ('count', int)
] ]
# UI components allow this to be declared such that additional
# (historical) fields can be exposed.
ohlc_dtype = np.dtype(_ohlc_dtype)
class Client: class Client:
@ -103,11 +107,11 @@ class Client:
lambda i, bar: lambda i, bar:
(i,) + tuple( (i,) + tuple(
ftype(bar[i]) for i, (name, ftype) ftype(bar[i]) for i, (name, ftype)
in enumerate(ohlc_dtype[1:]) in enumerate(_ohlc_dtype[1:])
), ),
enumerate(bars)) enumerate(bars))
) )
return np.array(bars, dtype=ohlc_dtype) if as_np else bars return np.array(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}')
@ -193,7 +197,7 @@ def normalize(
# in subscription systems... # in subscription systems...
topic = quote['pair'].replace('/', '') topic = quote['pair'].replace('/', '')
print(quote) # print(quote)
return topic, quote return topic, quote