From 054ddf673237a924dc2e72fc9e3d9b059b30083f Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Fri, 10 Sep 2021 18:54:04 -0400 Subject: [PATCH] Send error on non-paper account requests to paperboi --- piker/clearing/_paper_engine.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/piker/clearing/_paper_engine.py b/piker/clearing/_paper_engine.py index 84e681dd..628f58b9 100644 --- a/piker/clearing/_paper_engine.py +++ b/piker/clearing/_paper_engine.py @@ -35,7 +35,7 @@ from ..data._normalize import iterticks from ..log import get_logger from ._messages import ( BrokerdCancel, BrokerdOrder, BrokerdOrderAck, BrokerdStatus, - BrokerdFill, BrokerdPosition, + BrokerdFill, BrokerdPosition, BrokerdError ) @@ -385,6 +385,19 @@ async def handle_order_requests( action = request_msg['action'] 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 order = BrokerdOrder(**request_msg)