Port order mode to new notify routine
parent
b65c02336d
commit
525f805cdb
|
@ -23,7 +23,6 @@ from contextlib import asynccontextmanager
|
||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from pprint import pformat
|
from pprint import pformat
|
||||||
import platform
|
|
||||||
import time
|
import time
|
||||||
from typing import (
|
from typing import (
|
||||||
Optional,
|
Optional,
|
||||||
|
@ -64,6 +63,7 @@ from ..clearing._messages import (
|
||||||
BrokerdPosition,
|
BrokerdPosition,
|
||||||
)
|
)
|
||||||
from ._forms import open_form_input_handling
|
from ._forms import open_form_input_handling
|
||||||
|
from ._notify import notify_from_ems_status_msg
|
||||||
|
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
|
@ -530,39 +530,6 @@ class OrderMode:
|
||||||
else:
|
else:
|
||||||
log.warn("No line(s) for order {uuid}!?")
|
log.warn("No line(s) for order {uuid}!?")
|
||||||
|
|
||||||
async def on_exec(
|
|
||||||
self,
|
|
||||||
|
|
||||||
uuid: str,
|
|
||||||
msg: Status,
|
|
||||||
|
|
||||||
) -> None:
|
|
||||||
|
|
||||||
# DESKTOP NOTIFICATIONS
|
|
||||||
#
|
|
||||||
# TODO: this in another task?
|
|
||||||
# not sure if this will ever be a bottleneck,
|
|
||||||
# we probably could do graphics stuff first tho?
|
|
||||||
|
|
||||||
# TODO: make this not trash.
|
|
||||||
# XXX: linux only for now
|
|
||||||
if platform.system() == "Windows":
|
|
||||||
return
|
|
||||||
|
|
||||||
result = await trio.run_process(
|
|
||||||
[
|
|
||||||
'notify-send',
|
|
||||||
'-u', 'normal',
|
|
||||||
'-t', '1616',
|
|
||||||
'piker',
|
|
||||||
|
|
||||||
# TODO: add in standard fill/exec info that maybe we
|
|
||||||
# pack in a broker independent way?
|
|
||||||
f'{msg.resp}: {msg.req.price}',
|
|
||||||
],
|
|
||||||
)
|
|
||||||
log.runtime(result)
|
|
||||||
|
|
||||||
def on_cancel(
|
def on_cancel(
|
||||||
self,
|
self,
|
||||||
uuid: str
|
uuid: str
|
||||||
|
@ -1064,7 +1031,10 @@ async def process_trade_msg(
|
||||||
)
|
)
|
||||||
mode.lines.remove_line(uuid=oid)
|
mode.lines.remove_line(uuid=oid)
|
||||||
msg.req = req
|
msg.req = req
|
||||||
await mode.on_exec(oid, msg)
|
await notify_from_ems_status_msg(
|
||||||
|
uuid,
|
||||||
|
msg,
|
||||||
|
)
|
||||||
|
|
||||||
# response to completed 'dialog' for order request
|
# response to completed 'dialog' for order request
|
||||||
case Status(
|
case Status(
|
||||||
|
@ -1073,7 +1043,10 @@ async def process_trade_msg(
|
||||||
req=req,
|
req=req,
|
||||||
):
|
):
|
||||||
msg.req = Order(**req)
|
msg.req = Order(**req)
|
||||||
await mode.on_exec(oid, msg)
|
await notify_from_ems_status_msg(
|
||||||
|
uuid,
|
||||||
|
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
|
||||||
|
|
Loading…
Reference in New Issue