Avoid loading volume FSPs on symbols without any data

vwap_fsp
Tyler Goodlet 2020-12-28 13:31:15 -05:00
parent 42761438f6
commit bd73d02cfb
1 changed files with 18 additions and 4 deletions

View File

@ -841,10 +841,6 @@ async def _async_main(
# eventually we'll support some kind of n-compose syntax # eventually we'll support some kind of n-compose syntax
fsp_conf = { fsp_conf = {
'vwap': {
'overlay': True,
'anchor': 'session',
},
'rsi': { 'rsi': {
'period': 14, 'period': 14,
'chart_kwargs': { 'chart_kwargs': {
@ -854,6 +850,24 @@ async def _async_main(
} }
# make sure that the instrument supports volume history
# (sometimes this is not the case for some commodities and derivatives)
volm = ohlcv.array['volume']
if (
np.all(np.isin(volm, -1)) or
np.all(np.isnan(volm))
):
log.warning(
f"{sym} does not seem to have volume info,"
" dropping volume signals")
else:
fsp_conf.update({
'vwap': {
'overlay': True,
'anchor': 'session',
},
})
async with trio.open_nursery() as n: async with trio.open_nursery() as n:
# load initial fsp chain (otherwise known as "indicators") # load initial fsp chain (otherwise known as "indicators")