Pass order size to ems
parent
21e1561a57
commit
02edfdf846
|
@ -138,7 +138,7 @@ class PaperBoi:
|
||||||
symbol: str,
|
symbol: str,
|
||||||
price: float,
|
price: float,
|
||||||
action: str,
|
action: str,
|
||||||
size: int = _DEFAULT_SIZE,
|
size: float,
|
||||||
) -> int:
|
) -> int:
|
||||||
"""Place an order and return integer request id provided by client.
|
"""Place an order and return integer request id provided by client.
|
||||||
|
|
||||||
|
@ -266,7 +266,7 @@ async def exec_loop(
|
||||||
symbol=sym,
|
symbol=sym,
|
||||||
action=cmd['action'],
|
action=cmd['action'],
|
||||||
price=round(submit_price, 2),
|
price=round(submit_price, 2),
|
||||||
size=_DEFAULT_SIZE,
|
size=cmd['size'],
|
||||||
)
|
)
|
||||||
# register broker request id to ems id
|
# register broker request id to ems id
|
||||||
book._broker2ems_ids[reqid] = oid
|
book._broker2ems_ids[reqid] = oid
|
||||||
|
@ -420,7 +420,7 @@ async def _ems_main(
|
||||||
client_actor_name: str,
|
client_actor_name: str,
|
||||||
broker: str,
|
broker: str,
|
||||||
symbol: str,
|
symbol: str,
|
||||||
mode: str = 'dark', # ('paper', 'dark', 'live')
|
_mode: str = 'dark', # ('paper', 'dark', 'live')
|
||||||
) -> None:
|
) -> None:
|
||||||
"""EMS (sub)actor entrypoint providing the
|
"""EMS (sub)actor entrypoint providing the
|
||||||
execution management (micro)service which conducts broker
|
execution management (micro)service which conducts broker
|
||||||
|
@ -463,7 +463,7 @@ async def _ems_main(
|
||||||
ctx,
|
ctx,
|
||||||
broker,
|
broker,
|
||||||
symbol,
|
symbol,
|
||||||
mode,
|
_mode,
|
||||||
)
|
)
|
||||||
|
|
||||||
await n.start(
|
await n.start(
|
||||||
|
@ -505,13 +505,14 @@ async def _ems_main(
|
||||||
|
|
||||||
sym = cmd['symbol']
|
sym = cmd['symbol']
|
||||||
trigger_price = cmd['price']
|
trigger_price = cmd['price']
|
||||||
|
size = cmd['size']
|
||||||
brokers = cmd['brokers']
|
brokers = cmd['brokers']
|
||||||
broker = brokers[0]
|
exec_mode = cmd.get('exec_mode', _mode)
|
||||||
mode = cmd.get('exec_mode', mode)
|
|
||||||
|
|
||||||
|
broker = brokers[0]
|
||||||
last = book.lasts[(broker, sym)]
|
last = book.lasts[(broker, sym)]
|
||||||
|
|
||||||
if mode == 'live' and action in ('buy', 'sell',):
|
if exec_mode == 'live' and action in ('buy', 'sell',):
|
||||||
|
|
||||||
# register broker id for ems id
|
# register broker id for ems id
|
||||||
order_id = await client.submit_limit(
|
order_id = await client.submit_limit(
|
||||||
|
@ -519,7 +520,7 @@ async def _ems_main(
|
||||||
symbol=sym,
|
symbol=sym,
|
||||||
action=action,
|
action=action,
|
||||||
price=round(trigger_price, 2),
|
price=round(trigger_price, 2),
|
||||||
size=_DEFAULT_SIZE,
|
size=size,
|
||||||
)
|
)
|
||||||
book._broker2ems_ids[order_id] = oid
|
book._broker2ems_ids[order_id] = oid
|
||||||
|
|
||||||
|
@ -528,7 +529,7 @@ async def _ems_main(
|
||||||
# handle sending the ems side acks back to
|
# handle sending the ems side acks back to
|
||||||
# the cmd sender from here
|
# the cmd sender from here
|
||||||
|
|
||||||
elif mode in ('dark', 'paper') or action in ('alert'):
|
elif exec_mode in ('dark', 'paper') or action in ('alert'):
|
||||||
|
|
||||||
# TODO: if the predicate resolves immediately send the
|
# TODO: if the predicate resolves immediately send the
|
||||||
# execution to the broker asap? Or no?
|
# execution to the broker asap? Or no?
|
||||||
|
@ -608,12 +609,14 @@ class OrderBook:
|
||||||
uuid: str,
|
uuid: str,
|
||||||
symbol: 'Symbol',
|
symbol: 'Symbol',
|
||||||
price: float,
|
price: float,
|
||||||
|
size: float,
|
||||||
action: str,
|
action: str,
|
||||||
exec_mode: str,
|
exec_mode: str,
|
||||||
) -> str:
|
) -> str:
|
||||||
cmd = {
|
cmd = {
|
||||||
'action': action,
|
'action': action,
|
||||||
'price': price,
|
'price': price,
|
||||||
|
'size': size,
|
||||||
'symbol': symbol.key,
|
'symbol': symbol.key,
|
||||||
'brokers': symbol.brokers,
|
'brokers': symbol.brokers,
|
||||||
'oid': uuid,
|
'oid': uuid,
|
||||||
|
|
Loading…
Reference in New Issue