Format to prep for PR
parent
51ce71c969
commit
47d48ba3a3
|
@ -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
|
||||
|
||||
|
@ -439,8 +439,6 @@ async def simulate_fills(
|
|||
'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__]
|
||||
|
|
|
@ -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
|
||||
``<configuration_dir>/ledgers/`` directory.
|
||||
|
||||
Files are named per broker account of the form
|
||||
|
@ -92,7 +92,6 @@ def open_trade_ledger(
|
|||
# https://stackoverflow.com/questions/12956957/print-diff-of-python-dictionaries
|
||||
print(f'Updating ledger for {tradesfile}:\n')
|
||||
ledger.update(cpy)
|
||||
|
||||
# we write on close the mutated ledger data
|
||||
with open(tradesfile, 'w') as cf:
|
||||
toml.dump(ledger, cf)
|
||||
|
@ -545,7 +544,6 @@ class PpTable(Struct):
|
|||
|
||||
pps = self.pps
|
||||
updated: dict[str, Position] = {}
|
||||
|
||||
# lifo update all pps from records
|
||||
for tid, t in trans.items():
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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]
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue