diff --git a/piker/ui/_interaction.py b/piker/ui/_interaction.py index 41bc8571..0764f880 100644 --- a/piker/ui/_interaction.py +++ b/piker/ui/_interaction.py @@ -217,6 +217,7 @@ class LineEditor: def stage_line( self, + action: str, color: str = 'alert_yellow', hl_on_hover: bool = False, @@ -263,7 +264,11 @@ class LineEditor: # don't highlight the "staging" line hl_on_hover=hl_on_hover, dotted=dotted, + exec_type='dark' if dotted else 'live', + action=action, + show_markers=True, ) + self._active_staged_line = line # hide crosshair y-line and label @@ -299,6 +304,7 @@ class LineEditor: level: float, chart: 'ChartPlotWidget', # noqa size: float, + action: str, ) -> LevelLine: line = self._active_staged_line @@ -320,6 +326,8 @@ class LineEditor: # LevelLine kwargs color=line.color, dotted=line._dotted, + + action=action, ) # for now, until submission reponse arrives diff --git a/piker/ui/order_mode.py b/piker/ui/order_mode.py index 8c643953..c36474e7 100644 --- a/piker/ui/order_mode.py +++ b/piker/ui/order_mode.py @@ -39,7 +39,6 @@ from ..log import get_logger log = get_logger(__name__) - class Position(BaseModel): symbol: Symbol size: float @@ -84,16 +83,19 @@ class OrderMode: if msg['symbol'].lower() not in sym.key: return + size = msg['size'] + self._position.update(msg) if self._position_line: self._position_line.delete() - line = self._position_line = position_line( - self.chart, - level=msg['avg_price'], - size=msg['size'], - ) - line.show() + if size != 0.0: + line = self._position_line = position_line( + self.chart, + level=msg['avg_price'], + size=size, + ) + line.show() def uuid(self) -> str: return str(uuid.uuid4()) @@ -108,10 +110,12 @@ class OrderMode: """ self._action = action self.lines.stage_line( + color=self._colors[action], # hl_on_hover=True if self._exec_mode == 'live' else False, dotted=True if self._exec_mode == 'dark' else False, size=size or self._size, + action=action, ) def on_submit(self, uuid: str) -> dict: @@ -206,6 +210,8 @@ class OrderMode: symbol = self.chart._lc._symbol + action = self._action + # send order cmd to ems self.book.send( uuid=uid, @@ -213,7 +219,7 @@ class OrderMode: brokers=symbol.brokers, price=y, size=size, - action=self._action, + action=action, exec_mode=self._exec_mode, ) @@ -224,6 +230,7 @@ class OrderMode: level=y, chart=chart, size=size, + action=action, ) line.oid = uid