Port clearing engine to new tractor stream api
parent
56db2c812d
commit
d3b50b9920
|
@ -246,13 +246,14 @@ async def open_ems(
|
||||||
|
|
||||||
async with maybe_open_emsd(broker) as portal:
|
async with maybe_open_emsd(broker) as portal:
|
||||||
|
|
||||||
trades_stream = await portal.run(
|
async with portal.open_stream_from(
|
||||||
|
|
||||||
_emsd_main,
|
_emsd_main,
|
||||||
client_actor_name=actor.name,
|
client_actor_name=actor.name,
|
||||||
broker=broker,
|
broker=broker,
|
||||||
symbol=symbol.key,
|
symbol=symbol.key,
|
||||||
|
|
||||||
)
|
) as trades_stream:
|
||||||
with trio.fail_after(10):
|
with trio.fail_after(10):
|
||||||
await book._ready_to_receive.wait()
|
await book._ready_to_receive.wait()
|
||||||
|
|
||||||
|
|
|
@ -339,9 +339,9 @@ async def process_broker_trades(
|
||||||
"""
|
"""
|
||||||
broker = feed.mod.name
|
broker = feed.mod.name
|
||||||
|
|
||||||
with trio.fail_after(5):
|
# TODO: make this a context
|
||||||
# in the paper engine case this is just a mem receive channel
|
# in the paper engine case this is just a mem receive channel
|
||||||
trades_stream = await feed.recv_trades_data()
|
async with feed.receive_trades_data() as trades_stream:
|
||||||
first = await trades_stream.__anext__()
|
first = await trades_stream.__anext__()
|
||||||
|
|
||||||
# startup msg expected as first from broker backend
|
# startup msg expected as first from broker backend
|
||||||
|
@ -426,7 +426,8 @@ async def process_broker_trades(
|
||||||
# - PendingSubmit
|
# - PendingSubmit
|
||||||
# - PendingCancel
|
# - PendingCancel
|
||||||
# - PreSubmitted (simulated orders)
|
# - PreSubmitted (simulated orders)
|
||||||
# - ApiCancelled (cancelled by client before submission to routing)
|
# - ApiCancelled (cancelled by client before submission
|
||||||
|
# to routing)
|
||||||
# - Cancelled
|
# - Cancelled
|
||||||
# - Filled
|
# - Filled
|
||||||
# - Inactive (reject or cancelled but not by trader)
|
# - Inactive (reject or cancelled but not by trader)
|
||||||
|
@ -675,10 +676,10 @@ async def _emsd_main(
|
||||||
# acting as an EMS client and will submit orders) to
|
# acting as an EMS client and will submit orders) to
|
||||||
# receive requests pushed over a tractor stream
|
# receive requests pushed over a tractor stream
|
||||||
# using (for now) an async generator.
|
# using (for now) an async generator.
|
||||||
order_stream = await portal.run(
|
async with portal.open_stream_from(
|
||||||
send_order_cmds,
|
send_order_cmds,
|
||||||
symbol_key=symbol,
|
symbol_key=symbol,
|
||||||
)
|
) as order_stream:
|
||||||
|
|
||||||
# start inbound order request processing
|
# start inbound order request processing
|
||||||
await process_order_cmds(
|
await process_order_cmds(
|
||||||
|
|
Loading…
Reference in New Issue