Support order staging from slow chart using `.get_cursor()`

history_view
Tyler Goodlet 2022-09-07 11:30:41 -04:00
parent 1c685189d1
commit 161448c31a
2 changed files with 17 additions and 12 deletions

View File

@ -110,11 +110,11 @@ class LineEditor(Struct):
line: LevelLine, line: LevelLine,
) -> LevelLine: ) -> LevelLine:
"""Stage a line at the current chart's cursor position '''
Stage a line at the current chart's cursor position
and return it. and return it.
""" '''
# add a "staged" cursor-tracking line to view # add a "staged" cursor-tracking line to view
# and cash it in a a var # and cash it in a a var
if self._active_staged_line: if self._active_staged_line:

View File

@ -112,6 +112,7 @@ class OrderMode:
mouse click and drag -> modify current order under cursor mouse click and drag -> modify current order under cursor
''' '''
godw: GodWidget
feed: Feed feed: Feed
chart: ChartPlotWidget # type: ignore # noqa chart: ChartPlotWidget # type: ignore # noqa
hist_chart: ChartPlotWidget # type: ignore # noqa hist_chart: ChartPlotWidget # type: ignore # noqa
@ -251,12 +252,15 @@ class OrderMode:
action: str, action: str,
trigger_type: str, trigger_type: str,
) -> None: ) -> list[LevelLine]:
'''Stage an order for submission. '''
Stage an order for submission by showing level lines and
configuring the order request message dynamically based on
allocator settings.
''' '''
# not initialized yet # not initialized yet
chart = self.chart chart = self.godw.get_cursor().linked.chart
cursor = chart.linked.cursor cursor = chart.linked.cursor
if not (chart and cursor and cursor.active_plot): if not (chart and cursor and cursor.active_plot):
@ -277,7 +281,7 @@ class OrderMode:
exec_mode=trigger_type, # dark or live exec_mode=trigger_type, # dark or live
) )
line = self.line_from_order( lines = self.lines_from_order(
order, order,
show_markers=True, show_markers=True,
# just for the stage line to avoid # just for the stage line to avoid
@ -290,15 +294,15 @@ class OrderMode:
# prevent flickering of marker while moving/tracking cursor # prevent flickering of marker while moving/tracking cursor
only_show_markers_on_hover=False, only_show_markers_on_hover=False,
) )
line = self.lines.stage_line(line) for line in lines:
line = self.lines.stage_line(line)
# add line to cursor trackers
cursor._trackers.add(line)
# hide crosshair y-line and label # hide crosshair y-line and label
cursor.hide_xhair() cursor.hide_xhair()
# add line to cursor trackers return lines
cursor._trackers.add(line)
return line
def submit_order( def submit_order(
self, self,
@ -770,6 +774,7 @@ async def open_order_mode(
# top level abstraction which wraps all this crazyness into # top level abstraction which wraps all this crazyness into
# a namespace.. # a namespace..
mode = OrderMode( mode = OrderMode(
godw,
feed, feed,
chart, chart,
hist_chart, hist_chart,