Use `Viz.update_graphics()` throughout remainder of graphics loop where possible
parent
934b32c342
commit
4003729231
|
@ -214,7 +214,7 @@ async def increment_history_view(
|
||||||
(
|
(
|
||||||
uppx,
|
uppx,
|
||||||
liv,
|
liv,
|
||||||
do_append,
|
do_px_step,
|
||||||
i_diff_t,
|
i_diff_t,
|
||||||
append_diff,
|
append_diff,
|
||||||
do_rt_update,
|
do_rt_update,
|
||||||
|
@ -226,7 +226,7 @@ async def increment_history_view(
|
||||||
)
|
)
|
||||||
|
|
||||||
if (
|
if (
|
||||||
do_append
|
do_px_step
|
||||||
and liv
|
and liv
|
||||||
):
|
):
|
||||||
hist_viz.plot.vb._set_yrange(viz=hist_viz)
|
hist_viz.plot.vb._set_yrange(viz=hist_viz)
|
||||||
|
@ -465,11 +465,11 @@ def graphics_update_cycle(
|
||||||
|
|
||||||
chart = ds.chart
|
chart = ds.chart
|
||||||
hist_chart = ds.hist_chart
|
hist_chart = ds.hist_chart
|
||||||
|
|
||||||
flume = ds.flume
|
flume = ds.flume
|
||||||
sym = flume.symbol
|
sym = flume.symbol
|
||||||
fqsn = sym.fqsn
|
fqsn = sym.fqsn
|
||||||
main_viz = chart._vizs[fqsn]
|
main_viz = chart._vizs[fqsn]
|
||||||
|
hist_viz = hist_chart._vizs[fqsn]
|
||||||
index_field = main_viz.index_field
|
index_field = main_viz.index_field
|
||||||
|
|
||||||
profiler = Profiler(
|
profiler = Profiler(
|
||||||
|
@ -493,7 +493,7 @@ def graphics_update_cycle(
|
||||||
(
|
(
|
||||||
uppx,
|
uppx,
|
||||||
liv,
|
liv,
|
||||||
do_append,
|
do_px_step,
|
||||||
i_diff_t,
|
i_diff_t,
|
||||||
append_diff,
|
append_diff,
|
||||||
do_rt_update,
|
do_rt_update,
|
||||||
|
@ -501,7 +501,7 @@ def graphics_update_cycle(
|
||||||
) = main_viz.incr_info(ds=ds)
|
) = main_viz.incr_info(ds=ds)
|
||||||
|
|
||||||
# TODO: we should only run mxmn when we know
|
# TODO: we should only run mxmn when we know
|
||||||
# an update is due via ``do_append`` above.
|
# an update is due via ``do_px_step`` above.
|
||||||
(
|
(
|
||||||
mx_in_view,
|
mx_in_view,
|
||||||
mn_in_view,
|
mn_in_view,
|
||||||
|
@ -519,18 +519,16 @@ def graphics_update_cycle(
|
||||||
# update ohlc sampled price bars
|
# update ohlc sampled price bars
|
||||||
if (
|
if (
|
||||||
do_rt_update
|
do_rt_update
|
||||||
or do_append
|
or do_px_step
|
||||||
or trigger_all
|
or trigger_all
|
||||||
):
|
):
|
||||||
chart.update_graphics_from_flow(
|
main_viz.update_graphics(array_key=fqsn)
|
||||||
fqsn,
|
hist_viz.draw_last(array_key=fqsn)
|
||||||
# do_append=do_append,
|
|
||||||
)
|
|
||||||
main_viz.draw_last(array_key=fqsn)
|
|
||||||
|
|
||||||
hist_chart.update_graphics_from_flow(
|
else:
|
||||||
fqsn,
|
main_viz.draw_last(
|
||||||
# do_append=do_append,
|
array_key=fqsn,
|
||||||
|
only_last_uppx=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
# don't real-time "shift" the curve to the
|
# don't real-time "shift" the curve to the
|
||||||
|
@ -538,7 +536,7 @@ def graphics_update_cycle(
|
||||||
if (
|
if (
|
||||||
(
|
(
|
||||||
should_tread
|
should_tread
|
||||||
and do_append
|
and do_px_step
|
||||||
and liv
|
and liv
|
||||||
)
|
)
|
||||||
or trigger_all
|
or trigger_all
|
||||||
|
@ -592,7 +590,7 @@ def graphics_update_cycle(
|
||||||
|
|
||||||
if wap_in_history:
|
if wap_in_history:
|
||||||
# update vwap overlay line
|
# update vwap overlay line
|
||||||
chart.update_graphics_from_flow('bar_wap')
|
chart.get_viz('bar_wap').update_graphics()
|
||||||
|
|
||||||
# L1 book label-line updates
|
# L1 book label-line updates
|
||||||
if typ in ('last',):
|
if typ in ('last',):
|
||||||
|
@ -629,7 +627,8 @@ def graphics_update_cycle(
|
||||||
):
|
):
|
||||||
l1.bid_label.update_fields({'level': price, 'size': size})
|
l1.bid_label.update_fields({'level': price, 'size': size})
|
||||||
|
|
||||||
# check for y-autorange re-size
|
# Y-autoranging: adjust y-axis limits based on state tracking
|
||||||
|
# of previous "last" L1 values which are in view.
|
||||||
lmx = varz['last_mx']
|
lmx = varz['last_mx']
|
||||||
lmn = varz['last_mn']
|
lmn = varz['last_mn']
|
||||||
mx_diff = mx - lmx
|
mx_diff = mx - lmx
|
||||||
|
@ -639,6 +638,8 @@ def graphics_update_cycle(
|
||||||
mx_diff
|
mx_diff
|
||||||
or mn_diff
|
or mn_diff
|
||||||
):
|
):
|
||||||
|
# complain about out-of-range outliers which can show up
|
||||||
|
# in certain annoying feeds (like ib)..
|
||||||
if (
|
if (
|
||||||
abs(mx_diff) > .25 * lmx
|
abs(mx_diff) > .25 * lmx
|
||||||
or
|
or
|
||||||
|
@ -653,7 +654,8 @@ def graphics_update_cycle(
|
||||||
f'mx_diff: {mx_diff}\n'
|
f'mx_diff: {mx_diff}\n'
|
||||||
f'mn_diff: {mn_diff}\n'
|
f'mn_diff: {mn_diff}\n'
|
||||||
)
|
)
|
||||||
# fast chart resize case
|
|
||||||
|
# FAST CHART resize case
|
||||||
elif (
|
elif (
|
||||||
liv
|
liv
|
||||||
and not chart._static_yrange == 'axis'
|
and not chart._static_yrange == 'axis'
|
||||||
|
@ -665,7 +667,7 @@ def graphics_update_cycle(
|
||||||
):
|
):
|
||||||
yr = (mn, mx)
|
yr = (mn, mx)
|
||||||
# print(
|
# print(
|
||||||
# f'updating y-range due to mxmn\n'
|
# f'MAIN VIZ yrange update\n'
|
||||||
# f'{fqsn}: {yr}'
|
# f'{fqsn}: {yr}'
|
||||||
# )
|
# )
|
||||||
|
|
||||||
|
@ -679,8 +681,7 @@ def graphics_update_cycle(
|
||||||
yrange=yr
|
yrange=yr
|
||||||
)
|
)
|
||||||
|
|
||||||
# check if slow chart needs a resize
|
# SLOW CHART resize case
|
||||||
hist_viz = hist_chart._vizs[fqsn]
|
|
||||||
(
|
(
|
||||||
_,
|
_,
|
||||||
hist_liv,
|
hist_liv,
|
||||||
|
@ -696,15 +697,16 @@ def graphics_update_cycle(
|
||||||
if hist_liv:
|
if hist_liv:
|
||||||
hist_viz.plot.vb._set_yrange(viz=hist_viz)
|
hist_viz.plot.vb._set_yrange(viz=hist_viz)
|
||||||
|
|
||||||
# XXX: update this every draw cycle to make
|
# XXX: update this every draw cycle to ensure y-axis auto-ranging
|
||||||
|
# only adjusts when the in-view data co-domain actually expands or
|
||||||
|
# contracts.
|
||||||
varz['last_mx'], varz['last_mn'] = mx, mn
|
varz['last_mx'], varz['last_mn'] = mx, mn
|
||||||
|
|
||||||
# run synchronous update on all linked viz
|
# run synchronous update on all `Viz` overlays
|
||||||
# TODO: should the "main" (aka source) viz be special?
|
|
||||||
for curve_name, viz in chart._vizs.items():
|
for curve_name, viz in chart._vizs.items():
|
||||||
|
|
||||||
# update any overlayed fsp flows
|
# update any overlayed fsp flows
|
||||||
if (
|
if (
|
||||||
# curve_name != chart.data_key
|
|
||||||
curve_name != fqsn
|
curve_name != fqsn
|
||||||
and not viz.is_ohlc
|
and not viz.is_ohlc
|
||||||
):
|
):
|
||||||
|
@ -719,21 +721,28 @@ def graphics_update_cycle(
|
||||||
# px column to give the user the mx/mn
|
# px column to give the user the mx/mn
|
||||||
# range of that set.
|
# range of that set.
|
||||||
if (
|
if (
|
||||||
liv
|
curve_name != fqsn
|
||||||
# and not do_append
|
and liv
|
||||||
|
# and not do_px_step
|
||||||
# and not do_rt_update
|
# and not do_rt_update
|
||||||
):
|
):
|
||||||
viz.draw_last(
|
viz.draw_last(
|
||||||
array_key=curve_name,
|
array_key=curve_name,
|
||||||
|
|
||||||
|
# TODO: XXX this is currently broken for the
|
||||||
|
# `FlattenedOHLC` case since we aren't returning the
|
||||||
|
# full x/y uppx's worth of src-data from
|
||||||
|
# `draw_last_datum()` ..
|
||||||
only_last_uppx=True,
|
only_last_uppx=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
# volume chart logic..
|
# volume chart logic..
|
||||||
# TODO: can we unify this with the above loop?
|
# TODO: can we unify this with the above loop?
|
||||||
if vlm_chart:
|
if vlm_chart:
|
||||||
# print(f"DOING VLM {fqsn}")
|
|
||||||
vlm_vizs = vlm_chart._vizs
|
vlm_vizs = vlm_chart._vizs
|
||||||
|
|
||||||
|
main_vlm_viz = vlm_vizs['volume']
|
||||||
|
|
||||||
# always update y-label
|
# always update y-label
|
||||||
ds.vlm_sticky.update_from_data(
|
ds.vlm_sticky.update_from_data(
|
||||||
*array[-1][[
|
*array[-1][[
|
||||||
|
@ -745,19 +754,20 @@ def graphics_update_cycle(
|
||||||
if (
|
if (
|
||||||
(
|
(
|
||||||
do_rt_update
|
do_rt_update
|
||||||
or do_append
|
or do_px_step
|
||||||
and liv
|
and liv
|
||||||
)
|
)
|
||||||
or trigger_all
|
or trigger_all
|
||||||
):
|
):
|
||||||
# TODO: make it so this doesn't have to be called
|
# TODO: make it so this doesn't have to be called
|
||||||
# once the $vlm is up?
|
# once the $vlm is up?
|
||||||
vlm_chart.update_graphics_from_flow(
|
main_vlm_viz.update_graphics(
|
||||||
'volume',
|
|
||||||
# UGGGh, see ``maxmin()`` impl in `._fsp` for
|
# UGGGh, see ``maxmin()`` impl in `._fsp` for
|
||||||
# the overlayed plotitems... we need a better
|
# the overlayed plotitems... we need a better
|
||||||
# bay to invoke a maxmin per overlay..
|
# bay to invoke a maxmin per overlay..
|
||||||
render=False,
|
render=False,
|
||||||
|
|
||||||
# XXX: ^^^^ THIS IS SUPER IMPORTANT! ^^^^
|
# XXX: ^^^^ THIS IS SUPER IMPORTANT! ^^^^
|
||||||
# without this, since we disable the
|
# without this, since we disable the
|
||||||
# 'volume' (units) chart after the $vlm starts
|
# 'volume' (units) chart after the $vlm starts
|
||||||
|
@ -766,7 +776,7 @@ def graphics_update_cycle(
|
||||||
# connected to update accompanying overlay
|
# connected to update accompanying overlay
|
||||||
# graphics..
|
# graphics..
|
||||||
)
|
)
|
||||||
profiler('`vlm_chart.update_graphics_from_flow()`')
|
profiler('`main_vlm_viz.update_graphics()`')
|
||||||
|
|
||||||
if (
|
if (
|
||||||
mx_vlm_in_view != varz['last_mx_vlm']
|
mx_vlm_in_view != varz['last_mx_vlm']
|
||||||
|
@ -774,50 +784,49 @@ def graphics_update_cycle(
|
||||||
vlm_yr = (0, mx_vlm_in_view * 1.375)
|
vlm_yr = (0, mx_vlm_in_view * 1.375)
|
||||||
vlm_chart.view._set_yrange(yrange=vlm_yr)
|
vlm_chart.view._set_yrange(yrange=vlm_yr)
|
||||||
profiler('`vlm_chart.view._set_yrange()`')
|
profiler('`vlm_chart.view._set_yrange()`')
|
||||||
# print(f'mx vlm: {last_mx_vlm} -> {mx_vlm_in_view}')
|
|
||||||
varz['last_mx_vlm'] = mx_vlm_in_view
|
varz['last_mx_vlm'] = mx_vlm_in_view
|
||||||
|
|
||||||
# update all downstream FSPs
|
# update all downstream FSPs
|
||||||
for curve_name, viz in vlm_vizs.items():
|
for curve_name, viz in vlm_vizs.items():
|
||||||
|
|
||||||
|
if curve_name == 'volume':
|
||||||
|
continue
|
||||||
|
|
||||||
if (
|
if (
|
||||||
curve_name not in {'volume', fqsn}
|
viz.render
|
||||||
and viz.render
|
|
||||||
and (
|
and (
|
||||||
liv and do_rt_update
|
liv and do_rt_update
|
||||||
or do_append
|
or do_px_step
|
||||||
)
|
)
|
||||||
# and not viz.is_ohlc
|
and curve_name not in {fqsn,}
|
||||||
# and curve_name != fqsn
|
|
||||||
):
|
):
|
||||||
update_fsp_chart(
|
update_fsp_chart(
|
||||||
viz,
|
viz,
|
||||||
curve_name,
|
curve_name,
|
||||||
array_key=curve_name,
|
array_key=curve_name,
|
||||||
# do_append=uppx < update_uppx,
|
|
||||||
# do_append=do_append,
|
|
||||||
)
|
)
|
||||||
# is this even doing anything?
|
# is this even doing anything?
|
||||||
# (pretty sure it's the real-time
|
# (pretty sure it's the real-time
|
||||||
# resizing from last quote?)
|
# resizing from last quote?)
|
||||||
fvb = viz.plot.vb
|
fvb = viz.plot.vb
|
||||||
|
|
||||||
|
# XXX: without this we get completely
|
||||||
|
# mangled/empty vlm display subchart..
|
||||||
fvb._set_yrange(
|
fvb._set_yrange(
|
||||||
viz=viz,
|
viz=viz,
|
||||||
)
|
)
|
||||||
|
|
||||||
elif (
|
|
||||||
curve_name != 'volume'
|
|
||||||
and not do_append
|
|
||||||
and liv
|
|
||||||
and uppx >= 1
|
|
||||||
# even if we're downsampled bigly
|
# even if we're downsampled bigly
|
||||||
# draw the last datum in the final
|
# draw the last datum in the final
|
||||||
# px column to give the user the mx/mn
|
# px column to give the user the mx/mn
|
||||||
# range of that set.
|
# range of that set.
|
||||||
|
elif (
|
||||||
|
not do_px_step
|
||||||
|
and liv
|
||||||
|
and uppx >= 1
|
||||||
):
|
):
|
||||||
# always update the last datum-element
|
# always update the last datum-element
|
||||||
# graphic for all vizs
|
# graphic for all vizs
|
||||||
# print(f'drawing last {viz.name}')
|
|
||||||
viz.draw_last(array_key=curve_name)
|
viz.draw_last(array_key=curve_name)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1145,7 +1154,6 @@ async def display_symbol_data(
|
||||||
# for zoom-interaction purposes.
|
# for zoom-interaction purposes.
|
||||||
hist_chart.get_viz(fqsn).draw_last(
|
hist_chart.get_viz(fqsn).draw_last(
|
||||||
array_key=fqsn,
|
array_key=fqsn,
|
||||||
# only_last_uppx=True,
|
|
||||||
)
|
)
|
||||||
pis.setdefault(fqsn, [None, None])[1] = hist_chart.plotItem
|
pis.setdefault(fqsn, [None, None])[1] = hist_chart.plotItem
|
||||||
|
|
||||||
|
@ -1249,7 +1257,6 @@ async def display_symbol_data(
|
||||||
# for zoom-interaction purposes.
|
# for zoom-interaction purposes.
|
||||||
viz.draw_last(
|
viz.draw_last(
|
||||||
array_key=fqsn,
|
array_key=fqsn,
|
||||||
# only_last_uppx=True,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
hist_pi.vb.maxmin = partial(
|
hist_pi.vb.maxmin = partial(
|
||||||
|
|
Loading…
Reference in New Issue