Update the `_emsd_main()` doc task tree layout

basic_buy_bot
Tyler Goodlet 2023-06-26 13:38:57 -04:00
parent 249b091c2f
commit 85fa87fe6f
2 changed files with 31 additions and 27 deletions

View File

@ -216,8 +216,8 @@ async def open_ems(
loglevel: str = 'error', loglevel: str = 'error',
) -> tuple[ ) -> tuple[
OrderClient, OrderClient, # client
tractor.MsgStream, tractor.MsgStream, # order ctl stream
dict[ dict[
# brokername, acctid # brokername, acctid
tuple[str, str], tuple[str, str],

View File

@ -1529,30 +1529,34 @@ async def _emsd_main(
received in a stream from that client actor and then responses are received in a stream from that client actor and then responses are
streamed back up to the original calling task in the same client. streamed back up to the original calling task in the same client.
The primary ``emsd`` task trees are: The primary ``emsd`` task tree is:
- ``_setup_persistent_emsd()``: - ``_setup_persistent_emsd()``:
is the ``emsd`` actor's primary root task which sets up an is the ``emsd`` actor's primary *service-fixture* task which
actor-global ``Router`` instance and starts a relay loop task is opened by the `pikerd` service manager and sets up
which lives until the backend broker is shutdown or the ems is a process-global (actor-local) ``Router`` instance and opens
terminated. a service nursery which lives until the backend broker is
| shutdown or the ems is terminated; all tasks are
- (maybe) ``translate_and_relay_brokerd_events()``: *dynamically* started (and persisted) within this service
accept normalized trades responses from brokerd, process and nursery when the below endpoint context is opened:
relay to ems client(s); this is a effectively a "trade event |
reponse" proxy-broker. - ``_emsd_main()``:
attaches a real-time quote feed and trades dialogue with
- ``_emsd_main()``: a `brokerd` actor which connects to the backend broker's
attaches a brokerd real-time quote feed and trades dialogue with trading api for every connecting client.
brokderd trading api for every connecting client. |
| - ``clear_dark_triggers()``:
- ``clear_dark_triggers()``: run (dark order) conditions on inputs and trigger brokerd
run (dark order) conditions on inputs and trigger brokerd "live" "live" order submissions.
order submissions. |
| - ``process_client_order_cmds()``:
- ``process_client_order_cmds()``: accepts order cmds from requesting clients, registers
accepts order cmds from requesting clients, registers dark orders and dark orders and alerts with above (dark) clearing loop.
alerts with clearing loop. |
- (maybe) ``translate_and_relay_brokerd_events()``:
accept normalized trades responses from brokerd, process and
relay to ems client(s); this is a effectively a "trade event
reponse" proxy-broker.
''' '''
global _router global _router
@ -1560,9 +1564,9 @@ async def _emsd_main(
broker, _, _, _ = unpack_fqme(fqme) broker, _, _, _ = unpack_fqme(fqme)
# TODO: would be nice if in tractor we can require either a ctx arg, # TODO: would be nice if in tractor we can require either a ctx
# or a named arg with ctx in it and a type annotation of # arg, or a named arg with ctx in it and a type annotation of
# tractor.Context instead of strictly requiring a ctx arg. # `tractor.Context` instead of strictly requiring a ctx arg.
ems_ctx = ctx ems_ctx = ctx
# spawn one task per broker feed # spawn one task per broker feed