Add vlm axis titles and humanized $vlm y-range

overlayed_dvlm
Tyler Goodlet 2022-01-17 18:56:58 -05:00
parent f011234285
commit 5c2d3125b4
1 changed files with 83 additions and 56 deletions

View File

@ -33,7 +33,9 @@ import pyqtgraph as pg
import trio
from trio_typing import TaskStatus
from ._axes import PriceAxis
from .._cacheables import maybe_open_context
from ..calc import humanize
from ..data._sharedmem import (
ShmArray,
maybe_open_shm_array,
@ -661,8 +663,11 @@ async def open_vlm_displays(
# size view to data once at outset
chart.view._set_yrange()
if not dvlm:
return
# add axis title
axis = chart.getAxis('right')
axis.set_title(' vlm')
if dvlm:
# spawn and overlay $ vlm on the same subchart
shm, started = await admin.start_engine_task(
@ -685,7 +690,22 @@ async def open_vlm_displays(
pi = chart.overlay_plotitem(
'dolla_vlm',
axis_kwargs={
# 'humanize': True,
# 'text': 'dvlm',
'typical_max_str': ' 99.9 M ',
'formatter': partial(
humanize,
digits=2,
),
},
)
# add axis title
raxis = pi.getAxis('right')
raxis.set_title(' $vlm', view=pi.getViewBox())
# add custom auto range handler
pi.vb._maxmin = partial(maxmin, name='dolla_vlm')
@ -710,7 +730,8 @@ async def open_vlm_displays(
# ``.draw_curve()``.
chart._overlays['dolla_vlm'] = shm
# XXX: old dict-style config before it was moved into the helper task
# XXX: old dict-style config before it was moved into the
# helper task
# 'dolla_vlm': {
# 'func_name': 'dolla_vlm',
# 'zero_on_step': True,
@ -729,6 +750,12 @@ async def open_vlm_displays(
# }
for name, axis_info in pi.axes.items():
# lol this sux XD
axis = axis_info['item']
if isinstance(axis, PriceAxis):
axis.size_to_values()
# built-in vlm fsps
for display_name, conf in {
'vwap': {