Handle vwap overlay with shm

bar_select
Tyler Goodlet 2020-09-26 14:12:33 -04:00
parent 8a4528c006
commit d4eb5ccca4
1 changed files with 4 additions and 9 deletions

View File

@ -379,7 +379,7 @@ class ChartPlotWidget(pg.PlotWidget):
def update(index: int) -> None: def update(index: int) -> None:
label.setText( label.setText(
"{name}[{index}] -> O:{} H:{} L:{} C:{} V:{}".format( "{name}[{index}] -> O:{} H:{} L:{} C:{} V:{}".format(
*self._array[index].item()[2:], *self._array[index].item()[2:8],
name=name, name=name,
index=index, index=index,
) )
@ -423,9 +423,6 @@ class ChartPlotWidget(pg.PlotWidget):
self.addItem(curve) self.addItem(curve)
# register overlay curve with name # register overlay curve with name
if not self._graphics and name is None:
name = 'a_stupid_line_bby'
self._graphics[name] = curve self._graphics[name] = curve
# XXX: How to stack labels vertically? # XXX: How to stack labels vertically?
@ -485,6 +482,7 @@ class ChartPlotWidget(pg.PlotWidget):
array: np.ndarray, array: np.ndarray,
**kwargs, **kwargs,
) -> pg.GraphicsObject: ) -> pg.GraphicsObject:
if name not in self._overlays:
self._array = array self._array = array
graphics = self._graphics[name] graphics = self._graphics[name]
@ -712,10 +710,7 @@ async def chart_from_quotes(
last_price_sticky.update_from_data(*last[['index', 'close']]) last_price_sticky.update_from_data(*last[['index', 'close']])
chart._set_yrange() chart._set_yrange()
vwap = quote.get('vwap') if vwap_in_history:
if vwap and vwap_in_history:
last['vwap'] = vwap
print(f"vwap: {quote['vwap']}")
# update vwap overlay line # update vwap overlay line
chart.update_from_array('vwap', ohlcv.array['vwap']) chart.update_from_array('vwap', ohlcv.array['vwap'])