Send error on non-paper account requests to paperboi

fsp_feeds
Tyler Goodlet 2021-09-10 18:54:04 -04:00
parent b6b3ca15c5
commit 054ddf6732
1 changed files with 14 additions and 1 deletions

View File

@ -35,7 +35,7 @@ from ..data._normalize import iterticks
from ..log import get_logger from ..log import get_logger
from ._messages import ( from ._messages import (
BrokerdCancel, BrokerdOrder, BrokerdOrderAck, BrokerdStatus, BrokerdCancel, BrokerdOrder, BrokerdOrderAck, BrokerdStatus,
BrokerdFill, BrokerdPosition, BrokerdFill, BrokerdPosition, BrokerdError
) )
@ -385,6 +385,19 @@ async def handle_order_requests(
action = request_msg['action'] action = request_msg['action']
if action in {'buy', 'sell'}: if action in {'buy', 'sell'}:
account = request_msg['account']
if account != 'paper':
log.error(
'This is a paper account, only a `paper` selection is valid'
)
await ems_order_stream.send(BrokerdError(
oid=request_msg['oid'],
symbol=request_msg['symbol'],
reason=f'Paper only. No account found: `{account}` ?',
).dict())
continue
# validate # validate
order = BrokerdOrder(**request_msg) order = BrokerdOrder(**request_msg)