diff --git a/piker/ui/_chart.py b/piker/ui/_chart.py index c27f57e0..7ba23f5b 100644 --- a/piker/ui/_chart.py +++ b/piker/ui/_chart.py @@ -841,10 +841,6 @@ async def _async_main( # eventually we'll support some kind of n-compose syntax fsp_conf = { - 'vwap': { - 'overlay': True, - 'anchor': 'session', - }, 'rsi': { 'period': 14, '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: # load initial fsp chain (otherwise known as "indicators")