Async enter/open the symcache in paper engine
Since we don't want to be doing a `trio.run()` from async code (being already in the `tractor` runtime and all); for now just put a top level block wrapping async enter until we figure out to embed it (likely) inside `open_account()` and pass the ref to `open_trade_ledger()`.account_tests
parent
108e8c7082
commit
06c581bfab
|
@ -49,9 +49,10 @@ from ..accounting import (
|
|||
Transaction,
|
||||
TransactionLedger,
|
||||
open_trade_ledger,
|
||||
open_pps,
|
||||
open_account,
|
||||
)
|
||||
from ..data import iterticks
|
||||
from ..data._symcache import open_symcache
|
||||
from ..accounting import unpack_fqme
|
||||
from ._util import (
|
||||
log, # sub-sys logger
|
||||
|
@ -541,10 +542,15 @@ async def open_trade_dialog(
|
|||
# enable piker.clearing console log for *this* subactor
|
||||
get_console_log(loglevel)
|
||||
|
||||
async with open_symcache(get_brokermod(broker)) as symcache:
|
||||
acnt: Account
|
||||
ledger: TransactionLedger
|
||||
with (
|
||||
open_pps(
|
||||
|
||||
# TODO: probably do the symcache and ledger loading
|
||||
# implicitly behind this? Deliver an account, and ledger
|
||||
# pair or make the ledger an attr of the account?
|
||||
open_account(
|
||||
broker,
|
||||
'paper',
|
||||
write_on_exit=True,
|
||||
|
@ -553,6 +559,7 @@ async def open_trade_dialog(
|
|||
open_trade_ledger(
|
||||
broker,
|
||||
'paper',
|
||||
symcache=symcache,
|
||||
) as ledger
|
||||
):
|
||||
# NOTE: retreive market(pair) info from the backend broker
|
||||
|
@ -647,7 +654,6 @@ async def open_trade_dialog(
|
|||
# sanity check all the mkt infos
|
||||
for fqme, flume in feed.flumes.items():
|
||||
mkt = mkt_by_fqme[fqme]
|
||||
print(mkt - flume.mkt)
|
||||
assert mkt == flume.mkt
|
||||
|
||||
async with (
|
||||
|
|
Loading…
Reference in New Issue