Correctly load order mode for first fqsn in overlay set

multichartz_backup
Tyler Goodlet 2023-01-02 16:21:23 -05:00
parent 4984be182f
commit 73f48d6336
2 changed files with 31 additions and 45 deletions

View File

@ -1043,6 +1043,10 @@ async def display_symbol_data(
group_key=True group_key=True
) )
# (TODO: make this not so shit XD)
# close group status once a symbol feed fully loads to view.
# sbar._status_groups[loading_sym_key][1]()
# TODO: ctl over update loop's maximum frequency. # TODO: ctl over update loop's maximum frequency.
# - load this from a config.toml! # - load this from a config.toml!
# - allow dyanmic configuration from chart UI? # - allow dyanmic configuration from chart UI?
@ -1125,6 +1129,8 @@ async def display_symbol_data(
# and sub-charts for FSPs # and sub-charts for FSPs
fqsn, flume = fitems[0] fqsn, flume = fitems[0]
# TODO NOTE: THIS CONTROLS WHAT SYMBOL IS USED FOR ORDER MODE
# SUBMISSIONS, we need to make this switch based on selection.
rt_linked._symbol = flume.symbol rt_linked._symbol = flume.symbol
hist_linked._symbol = flume.symbol hist_linked._symbol = flume.symbol
@ -1215,9 +1221,6 @@ async def display_symbol_data(
# get a new color from the palette # get a new color from the palette
bg_chart_color, bg_last_bar_color = next(palette) bg_chart_color, bg_last_bar_color = next(palette)
rt_linked._symbol = flume.symbol
hist_linked._symbol = flume.symbol
ohlcv: ShmArray = flume.rt_shm ohlcv: ShmArray = flume.rt_shm
hist_ohlcv: ShmArray = flume.hist_shm hist_ohlcv: ShmArray = flume.hist_shm
@ -1228,9 +1231,14 @@ async def display_symbol_data(
name=fqsn, name=fqsn,
axis_title=fqsn, axis_title=fqsn,
) )
hist_pi.hideAxis('left') # only show a singleton bottom-bottom axis by default.
hist_pi.hideAxis('bottom') hist_pi.hideAxis('bottom')
# XXX: TODO: THIS WILL CAUSE A GAP ON OVERLAYS,
# i think it needs to be "removed" instead when there
# are none?
hist_pi.hideAxis('left')
viz = hist_chart.draw_curve( viz = hist_chart.draw_curve(
fqsn, fqsn,
hist_ohlcv, hist_ohlcv,
@ -1307,36 +1315,14 @@ async def display_symbol_data(
# XXX: if we wanted it at the bottom? # XXX: if we wanted it at the bottom?
# rt_linked.splitter.addWidget(hist_linked) # rt_linked.splitter.addWidget(hist_linked)
rt_linked.focus()
godwidget.resize_all() # greedily do a view range default and pane resizing
# on startup before loading the order-mode machinery.
# add all additional symbols as overlays
for fqsn, flume in feed.flumes.items(): for fqsn, flume in feed.flumes.items():
# size view to data prior to order mode init # size view to data prior to order mode init
rt_chart.default_view() rt_chart.default_view()
rt_linked.graphics_cycle() rt_linked.graphics_cycle()
await trio.sleep(0)
hist_chart.default_view(
bars_from_y=int(len(hist_ohlcv.array)), # size to data
y_offset=6116*2, # push it a little away from the y-axis
)
hist_linked.graphics_cycle()
await trio.sleep(0)
godwidget.resize_all()
# trigger another view reset if no sub-chart
hist_chart.default_view()
rt_chart.default_view()
# let qt run to render all widgets and make sure the
# sidepanes line up vertically.
await trio.sleep(0)
# dynamic resize steps
godwidget.resize_all()
# TODO: look into this because not sure why it was # TODO: look into this because not sure why it was
# commented out / we ever needed it XD # commented out / we ever needed it XD
@ -1346,21 +1332,11 @@ async def display_symbol_data(
# determine if auto-range adjustements should be made. # determine if auto-range adjustements should be made.
# rt_linked.subplots.pop('volume', None) # rt_linked.subplots.pop('volume', None)
# TODO: make this not so shit XD hist_chart.default_view()
# close group status
# sbar._status_groups[loading_sym_key][1]()
hist_linked.graphics_cycle() hist_linked.graphics_cycle()
rt_chart.default_view()
await trio.sleep(0)
bars_in_mem = int(len(hist_ohlcv.array))
hist_chart.default_view(
bars_from_y=bars_in_mem, # size to data
# push it 1/16th away from the y-axis
y_offset=round(bars_in_mem / 16),
)
godwidget.resize_all() godwidget.resize_all()
await trio.sleep(0)
await link_views_with_region( await link_views_with_region(
rt_chart, rt_chart,
@ -1368,7 +1344,7 @@ async def display_symbol_data(
flume, flume,
) )
# start graphics update loop after receiving first live quote # start update loop task
ln.start_soon( ln.start_soon(
graphics_update_loop, graphics_update_loop,
ln, ln,
@ -1379,20 +1355,31 @@ async def display_symbol_data(
vlm_charts, vlm_charts,
) )
# boot order-mode
order_ctl_symbol: str = fqsns[0]
mode: OrderMode mode: OrderMode
async with ( async with (
open_order_mode( open_order_mode(
feed, feed,
godwidget, godwidget,
fqsns[-1], fqsns[0],
order_mode_started order_mode_started
) as mode ) as mode
): ):
rt_linked.mode = mode rt_linked.mode = mode
viz = rt_chart.get_viz(order_ctl_symbol)
viz.plot.setFocus()
# default view adjuments and sidepane alignment
# as final default UX touch.
rt_chart.default_view() rt_chart.default_view()
rt_chart.view.enable_auto_yrange() rt_chart.view.enable_auto_yrange()
hist_chart.default_view() hist_chart.default_view()
hist_chart.view.enable_auto_yrange() hist_chart.view.enable_auto_yrange()
godwidget.resize_all()
await trio.sleep_forever() # let the app run.. bby await trio.sleep_forever() # let the app run.. bby

View File

@ -349,7 +349,7 @@ class OrderMode:
''' '''
if not order: if not order:
staged = self._staged_order staged: Order = self._staged_order
# apply order fields for ems # apply order fields for ems
oid = str(uuid.uuid4()) oid = str(uuid.uuid4())
order = staged.copy() order = staged.copy()
@ -703,7 +703,6 @@ async def open_order_mode(
# symbol id # symbol id
symbol = chart.linked.symbol symbol = chart.linked.symbol
symkey = symbol.front_fqsn()
# map of per-provider account keys to position tracker instances # map of per-provider account keys to position tracker instances
trackers: dict[str, PositionTracker] = {} trackers: dict[str, PositionTracker] = {}
@ -864,7 +863,7 @@ async def open_order_mode(
# the expected symbol key in its positions msg. # the expected symbol key in its positions msg.
for (broker, acctid), msgs in position_msgs.items(): for (broker, acctid), msgs in position_msgs.items():
for msg in msgs: for msg in msgs:
log.info(f'Loading pp for {symkey}:\n{pformat(msg)}') log.info(f'Loading pp for {acctid}@{broker}:\n{pformat(msg)}')
await process_trade_msg( await process_trade_msg(
mode, mode,
book, book,