Drop `bar_wap` from default ohlc field set

Turns out no backend (including kraken) requires it and really this
kinda of measure should be implemented and recorded from our fsp layer
instead of (hackily) sometimes expecting it to be in "source data".
basic_buy_bot
Tyler Goodlet 2023-06-02 12:15:33 -04:00
parent 7b4f4bf804
commit 0ba3c798d7
5 changed files with 17 additions and 14 deletions

View File

@ -82,10 +82,7 @@ from piker.brokers._util import (
get_logger,
)
# Broker specific ohlc schema which includes a vwap field
_ohlc_dtype: list[tuple[str, type]] = [
('index', int),
_bar_load_dtype: list[tuple[str, type]] = [
# NOTE XXX: only part that's diff
# from our default fields where
# time is normally an int.
@ -99,9 +96,15 @@ _ohlc_dtype: list[tuple[str, type]] = [
('close', float),
('volume', float),
('count', int),
('bar_wap', float), # Wait do we need this?
]
# Broker specific ohlc schema which includes a vwap field
_ohlc_dtype: list[tuple[str, type]] = _bar_load_dtype.copy()
_ohlc_dtype.insert(
0,
('index', int),
)
_time_units = {
's': ' sec',
@ -317,7 +320,7 @@ def bars_to_np(bars: list) -> np.ndarray:
nparr = np.array(
np_ready,
dtype=_ohlc_dtype,
dtype=_bar_load_dtype,
)
assert nparr['time'][0] == bars[0].date.timestamp()
assert nparr['time'][-1] == bars[-1].date.timestamp()

View File

@ -455,7 +455,6 @@ class Client:
('low', float),
('close', float),
('volume', float),
('bar_wap', float), # will be zeroed by sampler if not filled
]
'''
@ -520,7 +519,7 @@ class Client:
# volume
float(bar[5]),
# bar_wap
0.0,
# 0.0,
)
)

View File

@ -505,6 +505,7 @@ async def open_sample_stream(
},
) as (ctx, first)
):
assert len(first) > 1
async with (
ctx.open_stream() as istream,
@ -591,14 +592,14 @@ async def sample_and_broadcast(
'high',
'low',
'close',
'bar_wap', # can be optionally provided
# 'bar_wap', # can be optionally provided
'volume',
]][-1] = (
o,
max(high, last),
min(low, last),
last,
quote.get('bar_wap', 0),
# quote.get('bar_wap', 0),
volume,
)

View File

@ -47,7 +47,7 @@ def_iohlcv_fields: list[tuple[str, type]] = [
# TODO: can we elim this from default field set to save on mem?
# i think only kraken really uses this in terms of what we get from
# their ohlc history API?
('bar_wap', float), # shouldn't be default right?
# ('bar_wap', float), # shouldn't be default right?
]
# remove index field

View File

@ -215,8 +215,8 @@ class ContentsLabel(pg.LabelItem):
"<b>H</b>:{}<br/>"
"<b>L</b>:{}<br/>"
"<b>C</b>:{}<br/>"
"<b>V</b>:{}<br/>"
"<b>wap</b>:{}".format(
"<b>V</b>:{}<br/>".format(
# "<b>wap</b>:{}".format(
*array[ix][
[
'time',
@ -225,7 +225,7 @@ class ContentsLabel(pg.LabelItem):
'low',
'close',
'volume',
'bar_wap',
# 'bar_wap',
]
],
# name=name,