Remove whitespace, uneeded comments

explicit_write_pps_on_exit
jaredgoldman 2023-02-25 16:21:30 -05:00
parent 3a6fbabaf8
commit 3e83764b5b
4 changed files with 9 additions and 5 deletions

View File

@ -1452,6 +1452,7 @@ async def _emsd_main(
brokerd_stream = relay.brokerd_stream brokerd_stream = relay.brokerd_stream
dark_book = _router.get_dark_book(broker) dark_book = _router.get_dark_book(broker)
# signal to client that we're started and deliver # signal to client that we're started and deliver
# all known pps and accounts for this ``brokerd``. # all known pps and accounts for this ``brokerd``.
await ems_ctx.started(( await ems_ctx.started((

View File

@ -30,6 +30,7 @@ from typing import (
Callable, Callable,
) )
import uuid import uuid
from bidict import bidict from bidict import bidict
import pendulum import pendulum
import trio import trio
@ -249,7 +250,6 @@ class PaperBoi(Struct):
) )
await self.ems_trades_stream.send(msg) await self.ems_trades_stream.send(msg)
# lookup any existing position
key = fqsn.rstrip(f'.{self.broker}') key = fqsn.rstrip(f'.{self.broker}')
t = Transaction( t = Transaction(
fqsn=fqsn, fqsn=fqsn,

View File

@ -33,6 +33,7 @@ from .log import get_logger
log = get_logger('broker-config') log = get_logger('broker-config')
# taken from ``click`` since apparently they have some # taken from ``click`` since apparently they have some
# super weirdness with sigint and sudo..no clue # super weirdness with sigint and sudo..no clue
def get_app_dir(app_name, roaming=True, force_posix=False): def get_app_dir(app_name, roaming=True, force_posix=False):
@ -92,7 +93,7 @@ def get_app_dir(app_name, roaming=True, force_posix=False):
os.path.expanduser("~/.{}".format(_posixify(app_name)))) os.path.expanduser("~/.{}".format(_posixify(app_name))))
if sys.platform == "darwin": if sys.platform == "darwin":
return os.path.join( return os.path.join(
os.path.expanduser("~/Los.mkdir(_config_dir)ibrary/Application Support"), app_name os.path.expanduser("~/Library/Application Support"), app_name
) )
return os.path.join( return os.path.join(
os.environ.get("XDG_CONFIG_HOME", os.path.expanduser("~/.config")), os.environ.get("XDG_CONFIG_HOME", os.path.expanduser("~/.config")),

View File

@ -35,7 +35,6 @@ from typing import (
Union, Union,
Generator Generator
) )
from typing import Generator
import pendulum import pendulum
from pendulum import datetime, now from pendulum import datetime, now
@ -56,6 +55,7 @@ log = get_logger(__name__)
def open_trade_ledger( def open_trade_ledger(
broker: str, broker: str,
account: str, account: str,
) -> Generator[dict, None, None]: ) -> Generator[dict, None, None]:
''' '''
Indempotently create and read in a trade log file from the Indempotently create and read in a trade log file from the
@ -84,6 +84,7 @@ def open_trade_ledger(
ledger = tomli.load(cf) ledger = tomli.load(cf)
print(f'Ledger load took {time.time() - start}s') print(f'Ledger load took {time.time() - start}s')
cpy = ledger.copy() cpy = ledger.copy()
try: try:
yield cpy yield cpy
finally: finally:
@ -544,6 +545,7 @@ class PpTable(Struct):
pps = self.pps pps = self.pps
updated: dict[str, Position] = {} updated: dict[str, Position] = {}
# lifo update all pps from records # lifo update all pps from records
for tid, t in trans.items(): for tid, t in trans.items():
@ -680,6 +682,7 @@ class PpTable(Struct):
# TODO: show diff output? # TODO: show diff output?
# https://stackoverflow.com/questions/12956957/print-diff-of-python-dictionaries # https://stackoverflow.com/questions/12956957/print-diff-of-python-dictionaries
print(f'Updating ``pps.toml`` for {path}:\n') print(f'Updating ``pps.toml`` for {path}:\n')
# active, closed_pp_objs = table.dump_active() # active, closed_pp_objs = table.dump_active()
pp_entries = self.to_toml() pp_entries = self.to_toml()
self.conf[self.brokername][self.acctid] = pp_entries self.conf[self.brokername][self.acctid] = pp_entries
@ -975,7 +978,6 @@ def open_pps(
pp.ensure_state() pp.ensure_state()
try: try:
# breakpoint()
yield table yield table
finally: finally:
if write_on_exit: if write_on_exit: