Stage line only on active cursor chart

history_view
Tyler Goodlet 2022-09-07 13:24:17 -04:00
parent 58fe220fde
commit 8f2823d5f0
1 changed files with 27 additions and 11 deletions

View File

@ -185,7 +185,6 @@ class OrderMode:
level = order.price level = order.price
line = order_line( line = order_line(
chart or self.chart, chart or self.chart,
# TODO: convert these values into human-readable form # TODO: convert these values into human-readable form
# (i.e. with k, m, M, B) type embedded suffixes # (i.e. with k, m, M, B) type embedded suffixes
@ -260,10 +259,14 @@ class OrderMode:
''' '''
# not initialized yet # not initialized yet
chart = self.godw.get_cursor().linked.chart cursor = self.godw.get_cursor()
chart = cursor.linked.chart
cursor = chart.linked.cursor if (
if not (chart and cursor and cursor.active_plot): not chart
and cursor
and cursor.active_plot
):
return return
chart = cursor.active_plot chart = cursor.active_plot
@ -281,8 +284,14 @@ class OrderMode:
exec_mode=trigger_type, # dark or live exec_mode=trigger_type, # dark or live
) )
lines = self.lines_from_order( # TODO: staged line mirroring? - need to keep track of multiple
# staged lines in editor - need to call
# `LineEditor.unstage_line()` on all staged lines..
# lines = self.lines_from_order(
line = self.line_from_order(
order, order,
chart=chart,
show_markers=True, show_markers=True,
# just for the stage line to avoid # just for the stage line to avoid
# flickering while moving the cursor # flickering while moving the cursor
@ -294,15 +303,22 @@ 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,
) )
for line in lines: self.lines.stage_line(line)
line = self.lines.stage_line(line)
# add line to cursor trackers # add line to cursor trackers
cursor._trackers.add(line) cursor._trackers.add(line)
# TODO: see above about mirroring.
# for line in lines:
# if line._chart is chart:
# self.lines.stage_line(line)
# cursor._trackers.add(line)
# break
# hide crosshair y-line and label # hide crosshair y-line and label
cursor.hide_xhair() cursor.hide_xhair()
return lines return line
def submit_order( def submit_order(
self, self,
@ -399,7 +415,7 @@ class OrderMode:
) -> None: ) -> None:
level = line.value() level = line.value()
# updateb by level change callback set in ``.line_from_order()`` # updated by level change callback set in ``.line_from_order()``
dialog = line.dialog dialog = line.dialog
size = dialog.order.size size = dialog.order.size