Always add a paper (account) entry to order mode init

Allows for tracking paper engine orders despite the ems not necessarily
being opened by the current order mode instance (UI) in "paper"
execution mode; useful for tracking bots/strats running against the same
EMS daemon.
basic_buy_bot
Tyler Goodlet 2023-06-26 13:39:32 -04:00
parent 85fa87fe6f
commit 49e67d5f36
1 changed files with 9 additions and 3 deletions

View File

@ -587,7 +587,7 @@ class OrderMode:
) -> None: ) -> None:
msg = self.client._sent_orders.pop(uuid, None) msg: Order = self.client._sent_orders.pop(uuid, None)
if msg is not None: if msg is not None:
self.lines.remove_line(uuid=uuid) self.lines.remove_line(uuid=uuid)
@ -715,7 +715,8 @@ async def open_order_mode(
loglevel: str = 'info' loglevel: str = 'info'
) -> None: ) -> None:
'''Activate chart-trader order mode loop: '''
Activate chart-trader order mode loop:
- connect to emsd - connect to emsd
- load existing positions - load existing positions
@ -769,15 +770,20 @@ async def open_order_mode(
accounts_def: bidict[str, str | None] = config.load_accounts( accounts_def: bidict[str, str | None] = config.load_accounts(
providers=[mkt.broker], providers=[mkt.broker],
) )
# await tractor.pause()
# XXX: ``brokerd`` delivers a set of account names that it # XXX: ``brokerd`` delivers a set of account names that it
# allows use of but the user also can define the accounts they'd # allows use of but the user also can define the accounts they'd
# like to use, in order, in their `brokers.toml` file. # like to use, in order, in their `brokers.toml` file.
accounts = {} accounts: dict[str, str] = {}
for name in brokerd_accounts: for name in brokerd_accounts:
# ensure name is in ``brokers.toml`` # ensure name is in ``brokers.toml``
accounts[name] = accounts_def[name] accounts[name] = accounts_def[name]
# always add a paper entry so that paper cleared
# order dialogs can be tracked in the order mode UIs.
accounts['paper'] = 'paper'
# first account listed is the one we select at startup # first account listed is the one we select at startup
# (aka order based selection). # (aka order based selection).
pp_account = next( pp_account = next(