Load boxed `.req` values as `Order`s in mode loop
parent
66f7dd9020
commit
0756cb0289
|
@ -163,7 +163,6 @@ class OrderMode:
|
||||||
) -> LevelLine:
|
) -> LevelLine:
|
||||||
|
|
||||||
level = order.price
|
level = order.price
|
||||||
print(f'SIZE: {order.size}')
|
|
||||||
line = order_line(
|
line = order_line(
|
||||||
|
|
||||||
self.chart,
|
self.chart,
|
||||||
|
@ -859,7 +858,7 @@ async def process_trade_msg(
|
||||||
|
|
||||||
get_index = mode.chart.get_index
|
get_index = mode.chart.get_index
|
||||||
fmsg = pformat(msg)
|
fmsg = pformat(msg)
|
||||||
log.info(f'Received order msg:\n{fmsg}')
|
log.debug(f'Received order msg:\n{fmsg}')
|
||||||
name = msg['name']
|
name = msg['name']
|
||||||
|
|
||||||
if name in (
|
if name in (
|
||||||
|
@ -920,6 +919,7 @@ async def process_trade_msg(
|
||||||
):
|
):
|
||||||
dialog = mode.load_unknown_dialog_from_msg(msg)
|
dialog = mode.load_unknown_dialog_from_msg(msg)
|
||||||
mode.on_submit(oid)
|
mode.on_submit(oid)
|
||||||
|
# return dialog, msg
|
||||||
|
|
||||||
case Status(resp='error'):
|
case Status(resp='error'):
|
||||||
# delete level line from view
|
# delete level line from view
|
||||||
|
@ -932,16 +932,15 @@ async def process_trade_msg(
|
||||||
case Status(resp='canceled'):
|
case Status(resp='canceled'):
|
||||||
# delete level line from view
|
# delete level line from view
|
||||||
mode.on_cancel(oid)
|
mode.on_cancel(oid)
|
||||||
req = msg.req
|
req = Order(**msg.req)
|
||||||
log.cancel(
|
log.cancel(f'Canceled {req.action}:{oid}')
|
||||||
f'Canceled order {oid}:\n{pformat(req)}'
|
|
||||||
)
|
|
||||||
|
|
||||||
case Status(
|
case Status(
|
||||||
resp='triggered',
|
resp='triggered',
|
||||||
# req=Order(exec_mode='dark') # TODO:
|
# req=Order(exec_mode='dark') # TODO:
|
||||||
req={'exec_mode': 'dark'},
|
req={'exec_mode': 'dark'},
|
||||||
):
|
):
|
||||||
|
# TODO: UX for a "pending" clear/live order
|
||||||
log.info(f'Dark order triggered for {fmsg}')
|
log.info(f'Dark order triggered for {fmsg}')
|
||||||
|
|
||||||
case Status(
|
case Status(
|
||||||
|
@ -951,13 +950,14 @@ async def process_trade_msg(
|
||||||
):
|
):
|
||||||
# should only be one "fill" for an alert
|
# should only be one "fill" for an alert
|
||||||
# add a triangle and remove the level line
|
# add a triangle and remove the level line
|
||||||
|
req = Order(**req)
|
||||||
mode.on_fill(
|
mode.on_fill(
|
||||||
oid,
|
oid,
|
||||||
price=req.price,
|
price=req.price,
|
||||||
arrow_index=get_index(time.time()),
|
arrow_index=get_index(time.time()),
|
||||||
)
|
)
|
||||||
mode.lines.remove_line(uuid=oid)
|
mode.lines.remove_line(uuid=oid)
|
||||||
msg.req = Order(**req)
|
msg.req = req
|
||||||
await mode.on_exec(oid, msg)
|
await mode.on_exec(oid, msg)
|
||||||
|
|
||||||
# response to completed 'dialog' for order request
|
# response to completed 'dialog' for order request
|
||||||
|
@ -966,18 +966,18 @@ async def process_trade_msg(
|
||||||
# req=Order() as req, # TODO
|
# req=Order() as req, # TODO
|
||||||
req=req,
|
req=req,
|
||||||
):
|
):
|
||||||
# right now this is just triggering a system alert
|
|
||||||
msg.req = Order(**req)
|
msg.req = Order(**req)
|
||||||
await mode.on_exec(oid, msg)
|
await mode.on_exec(oid, msg)
|
||||||
mode.lines.remove_line(uuid=oid)
|
mode.lines.remove_line(uuid=oid)
|
||||||
|
|
||||||
# each clearing tick is responded individually
|
# each clearing tick is responded individually
|
||||||
case Status(resp='fill'):
|
case Status(resp='fill'):
|
||||||
|
|
||||||
|
# handle out-of-piker fills reporting?
|
||||||
known_order = book._sent_orders.get(oid)
|
known_order = book._sent_orders.get(oid)
|
||||||
if not known_order:
|
if not known_order:
|
||||||
log.warning(f'order {oid} is unknown')
|
log.warning(f'order {oid} is unknown')
|
||||||
return
|
return
|
||||||
# continue
|
|
||||||
|
|
||||||
action = known_order.action
|
action = known_order.action
|
||||||
details = msg.brokerd_msg
|
details = msg.brokerd_msg
|
||||||
|
|
Loading…
Reference in New Issue