Drop dvlm 'rates' (they're just means), add default params, period -> 6
parent
8f467bf4f0
commit
326b2c089a
|
@ -97,7 +97,10 @@ async def tina_vwap(
|
||||||
# vwap_tot = h_vwap[-1]
|
# vwap_tot = h_vwap[-1]
|
||||||
|
|
||||||
async for quote in source:
|
async for quote in source:
|
||||||
for tick in iterticks(quote, types=['trade']):
|
for tick in iterticks(
|
||||||
|
quote,
|
||||||
|
types=['trade'],
|
||||||
|
):
|
||||||
|
|
||||||
# c, h, l, v = ohlcv.array[-1][
|
# c, h, l, v = ohlcv.array[-1][
|
||||||
# ['closes', 'high', 'low', 'volume']
|
# ['closes', 'high', 'low', 'volume']
|
||||||
|
@ -150,7 +153,7 @@ async def dolla_vlm(
|
||||||
}
|
}
|
||||||
|
|
||||||
i = ohlcv.index
|
i = ohlcv.index
|
||||||
output = dvlm = vlm = 0
|
dvlm = vlm = 0
|
||||||
dark_trade_count = trade_count = 0
|
dark_trade_count = trade_count = 0
|
||||||
|
|
||||||
async for quote in source:
|
async for quote in source:
|
||||||
|
@ -172,7 +175,6 @@ async def dolla_vlm(
|
||||||
i = li
|
i = li
|
||||||
trade_count = dark_trade_count = dvlm = vlm = 0
|
trade_count = dark_trade_count = dvlm = vlm = 0
|
||||||
|
|
||||||
|
|
||||||
# TODO: for marginned instruments (futes, etfs?) we need to
|
# TODO: for marginned instruments (futes, etfs?) we need to
|
||||||
# show the margin $vlm by multiplying by whatever multiplier
|
# show the margin $vlm by multiplying by whatever multiplier
|
||||||
# is reported in the sym info.
|
# is reported in the sym info.
|
||||||
|
@ -232,7 +234,11 @@ async def flow_rates(
|
||||||
# FSPs, user input, and possibly any general event stream in
|
# FSPs, user input, and possibly any general event stream in
|
||||||
# real-time. Hint: ideally implemented with caching until mutated
|
# real-time. Hint: ideally implemented with caching until mutated
|
||||||
# ;)
|
# ;)
|
||||||
period: 'Param[int]' = 16, # noqa
|
period: 'Param[int]' = 6, # noqa
|
||||||
|
|
||||||
|
# TODO: support other means by providing a map
|
||||||
|
# to weights `partial()`-ed with `wma()`?
|
||||||
|
mean_type: str = 'arithmetic',
|
||||||
|
|
||||||
# TODO (idea): a generic for declaring boxed fsps much like ``pytest``
|
# TODO (idea): a generic for declaring boxed fsps much like ``pytest``
|
||||||
# fixtures? This probably needs a lot of thought if we want to offer
|
# fixtures? This probably needs a lot of thought if we want to offer
|
||||||
|
@ -262,11 +268,11 @@ async def flow_rates(
|
||||||
'dark_dvlm_rate': None,
|
'dark_dvlm_rate': None,
|
||||||
}
|
}
|
||||||
|
|
||||||
ltr = 0
|
|
||||||
lvr = 0
|
|
||||||
|
|
||||||
# TODO: 3.10 do ``anext()``
|
# TODO: 3.10 do ``anext()``
|
||||||
quote = await source.__anext__()
|
quote = await source.__anext__()
|
||||||
|
|
||||||
|
# ltr = 0
|
||||||
|
# lvr = 0
|
||||||
tr = quote.get('tradeRate')
|
tr = quote.get('tradeRate')
|
||||||
yield '1m_trade_rate', tr or 0
|
yield '1m_trade_rate', tr or 0
|
||||||
vr = quote.get('volumeRate')
|
vr = quote.get('volumeRate')
|
||||||
|
@ -294,12 +300,12 @@ async def flow_rates(
|
||||||
log.error("OH WTF NO QUOTE IN FSP")
|
log.error("OH WTF NO QUOTE IN FSP")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
dvlm_wma = _wma(
|
# dvlm_wma = _wma(
|
||||||
dvlm_shm.array['dolla_vlm'],
|
# dvlm_shm.array['dolla_vlm'],
|
||||||
period,
|
# period,
|
||||||
weights=weights,
|
# weights=weights,
|
||||||
)
|
# )
|
||||||
yield 'dvlm_rate', dvlm_wma[-1]
|
# yield 'dvlm_rate', dvlm_wma[-1]
|
||||||
|
|
||||||
if period > 1:
|
if period > 1:
|
||||||
trade_rate_wma = _wma(
|
trade_rate_wma = _wma(
|
||||||
|
@ -317,12 +323,12 @@ async def flow_rates(
|
||||||
|
|
||||||
# TODO: skip this if no dark vlm is declared
|
# TODO: skip this if no dark vlm is declared
|
||||||
# by symbol info (eg. in crypto$)
|
# by symbol info (eg. in crypto$)
|
||||||
dark_dvlm_wma = _wma(
|
# dark_dvlm_wma = _wma(
|
||||||
dvlm_shm.array['dark_vlm'],
|
# dvlm_shm.array['dark_vlm'],
|
||||||
period,
|
# period,
|
||||||
weights=weights,
|
# weights=weights,
|
||||||
)
|
# )
|
||||||
yield 'dark_dvlm_rate', dark_dvlm_wma[-1]
|
# yield 'dark_dvlm_rate', dark_dvlm_wma[-1]
|
||||||
|
|
||||||
if period > 1:
|
if period > 1:
|
||||||
dark_trade_rate_wma = _wma(
|
dark_trade_rate_wma = _wma(
|
||||||
|
@ -338,13 +344,13 @@ async def flow_rates(
|
||||||
|
|
||||||
# XXX: ib specific schema we should
|
# XXX: ib specific schema we should
|
||||||
# probably pre-pack ourselves.
|
# probably pre-pack ourselves.
|
||||||
|
|
||||||
# tr = quote.get('tradeRate')
|
# tr = quote.get('tradeRate')
|
||||||
# if tr is not None and tr != ltr:
|
# if tr is not None and tr != ltr:
|
||||||
# # print(f'trade rate: {tr}')
|
# # print(f'trade rate: {tr}')
|
||||||
# yield '1m_trade_rate', tr
|
# yield '1m_trade_rate', tr
|
||||||
# ltr = tr
|
# ltr = tr
|
||||||
|
|
||||||
# # TODO: we *could* do an ohlc3
|
|
||||||
# vr = quote.get('volumeRate')
|
# vr = quote.get('volumeRate')
|
||||||
# if vr is not None and vr != lvr:
|
# if vr is not None and vr != lvr:
|
||||||
# # print(f'vlm rate: {vr}')
|
# # print(f'vlm rate: {vr}')
|
||||||
|
|
Loading…
Reference in New Issue