Pass action to line editor

basic_orders
Tyler Goodlet 2021-03-13 19:31:03 -05:00
parent c75dacb239
commit 776395791a
2 changed files with 23 additions and 8 deletions

View File

@ -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

View File

@ -39,7 +39,6 @@ from ..log import get_logger
log = get_logger(__name__)
class Position(BaseModel):
symbol: Symbol
size: float
@ -84,14 +83,17 @@ 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()
if size != 0.0:
line = self._position_line = position_line(
self.chart,
level=msg['avg_price'],
size=msg['size'],
size=size,
)
line.show()
@ -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