diff --git a/piker/clearing/_paper_engine.py b/piker/clearing/_paper_engine.py index ce25243f..b7fcc411 100644 --- a/piker/clearing/_paper_engine.py +++ b/piker/clearing/_paper_engine.py @@ -425,8 +425,8 @@ async def simulate_fills( case _: continue - # iterate alcl potentially clearable book prices - # in FIFO order per side.c + # iterate all potentially clearable book prices + # in FIFO order per side. for order_info, pred in iter_entries: (our_price, size, reqid, action) = order_info @@ -438,9 +438,7 @@ async def simulate_fills( 'buy': buys, 'sell': sells }[action].inverse.pop(order_info) - - log.warning(f'order_info: {order_info}') - + # clearing price would have filled entirely await client.fake_fill( fqsn=sym, @@ -558,14 +556,12 @@ async def trades_dialogue( ): with open_pps(broker, 'piker-paper') as table: - log.warning(f'pp table: {table}') # save pps in local state _positions.update(table.pps) pp_msgs: list[BrokerdPosition] = [] pos: Position token: str # f'{symbol}.{self.broker}' - log.warning(f'local _positions: {_positions}') for token, pos in _positions.items(): pp_msgs.append(BrokerdPosition( broker=broker, @@ -574,7 +570,6 @@ async def trades_dialogue( size=pos.size, avg_price=pos.ppu, )) - log.warning(f'pp_msgs: {pp_msgs}') # TODO: load paper positions per broker from .toml config file # and pass as symbol to position data mapping: ``dict[str, dict]`` await ctx.started(( @@ -632,6 +627,7 @@ async def open_paperboi( # (we likely don't need more then one proc for basic # simulated order clearing) if portal is None: + log.info('Starting new paper-engine actor') portal = await tn.start_actor( service_name, enable_modules=[__name__] diff --git a/piker/pp.py b/piker/pp.py index 637dab53..e71045d1 100644 --- a/piker/pp.py +++ b/piker/pp.py @@ -58,7 +58,7 @@ def open_trade_ledger( account: str, ) -> Generator[dict, None, None]: ''' - Indempotently creat0616cbd1e and read in a trade log file from the + Indempotently create and read in a trade log file from the ``/ledgers/`` directory. Files are named per broker account of the form @@ -91,8 +91,7 @@ def open_trade_ledger( # TODO: show diff output? # https://stackoverflow.com/questions/12956957/print-diff-of-python-dictionaries print(f'Updating ledger for {tradesfile}:\n') - ledger.update(cpy) - + ledger.update(cpy) # we write on close the mutated ledger data with open(tradesfile, 'w') as cf: toml.dump(ledger, cf) @@ -544,8 +543,7 @@ class PpTable(Struct): ) -> dict[str, Position]: pps = self.pps - updated: dict[str, Position] = {} - + updated: dict[str, Position] = {} # lifo update all pps from records for tid, t in trans.items(): diff --git a/tests/test_paper.py b/tests/test_paper.py index 38b3dd78..16785afb 100644 --- a/tests/test_paper.py +++ b/tests/test_paper.py @@ -44,6 +44,7 @@ def test_paper_trade( paper_cleanup: None ): + cleared_price: float test_exec_mode='live' test_account = 'paper' test_size = 1 @@ -57,8 +58,6 @@ def test_paper_trade( tuple[str, str], list[BrokerdPosition], ] - cleared_price: float - async def _async_main( open_pikerd: AsyncContextManager, diff --git a/tests/test_services.py b/tests/test_services.py index 3acd81ad..6b67d3c5 100644 --- a/tests/test_services.py +++ b/tests/test_services.py @@ -9,12 +9,7 @@ import pytest import trio import tractor -from datetime import datetime -import time from piker.log import get_logger -from piker.clearing._messages import ( - BrokerdFill -) from piker._daemon import ( find_service, @@ -34,8 +29,6 @@ from piker.clearing._client import ( OrderBook, ) -log = get_logger(__name__) - def test_runtime_boot( open_test_pikerd: AsyncContextManager @@ -185,6 +178,3 @@ def test_ensure_ems_in_paper_actors( cancel_msg: str = '_emsd_main was remotely cancelled by its caller' assert cancel_msg in exc_info.value.args[0] - - -