Set `emsd` log level and clearly report startup pps

Change the root-service-task entrypoint to accept the level and
setup a console log as is now expected for all sub-services. Cast all
backend delivered startup `BrokerdPosition` msgs and log them to
console.
pre_overruns_ctxcancelled
Tyler Goodlet 2023-04-04 13:27:43 -04:00
parent 5235cb5bfe
commit 9c5d6d2592
1 changed files with 16 additions and 7 deletions

View File

@ -43,6 +43,7 @@ import tractor
from ._util import ( from ._util import (
log, # sub-sys logger log, # sub-sys logger
get_console_log,
) )
from ..data._normalize import iterticks from ..data._normalize import iterticks
from ..accounting._mktinfo import ( from ..accounting._mktinfo import (
@ -411,6 +412,9 @@ class Router(Struct):
trades_endpoint is None trades_endpoint is None
or exec_mode == 'paper' or exec_mode == 'paper'
): ):
# for logging purposes
brokermod = paper
# for paper mode we need to mock this trades response feed # for paper mode we need to mock this trades response feed
# so we load bidir stream to a new sub-actor running # so we load bidir stream to a new sub-actor running
# a paper-simulator clearing engine. # a paper-simulator clearing engine.
@ -468,13 +472,15 @@ class Router(Struct):
# msgs. # msgs.
pps = {} pps = {}
for msg in positions: for msg in positions:
log.info(f'loading pp: {msg}')
account = msg['account'] msg = BrokerdPosition(**msg)
log.info(
f'loading pp for {brokermod.__name__}:\n'
f'{pformat(msg.to_dict())}',
)
# TODO: better value error for this which # TODO: state any mismatch here?
# dumps the account and message and states the account = msg.account
# mismatch..
assert account in accounts assert account in accounts
pps.setdefault( pps.setdefault(
@ -635,11 +641,14 @@ _router: Router = None
@tractor.context @tractor.context
async def _setup_persistent_emsd( async def _setup_persistent_emsd(
ctx: tractor.Context, ctx: tractor.Context,
loglevel: str | None = None,
) -> None: ) -> None:
if loglevel:
get_console_log(loglevel)
global _router global _router
# open a root "service nursery" for the ``emsd`` actor # open a root "service nursery" for the ``emsd`` actor
@ -1371,7 +1380,7 @@ async def _emsd_main(
ctx: tractor.Context, ctx: tractor.Context,
fqme: str, fqme: str,
exec_mode: str, # ('paper', 'live') exec_mode: str, # ('paper', 'live')
loglevel: str = 'info', loglevel: str | None = None,
) -> tuple[ ) -> tuple[
dict[ dict[