Skip to content

Commit

Permalink
order rejected reason
Browse files Browse the repository at this point in the history
  • Loading branch information
51bitquant committed Jul 12, 2022
1 parent b213491 commit fbc3aa9
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions howtrader/gateway/binance/binance_inverse_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,7 @@ def on_send_order_failed(self, status_code: str, request: Request) -> None:
if request.extra:
order: OrderData = copy(request.extra)
order.status = Status.REJECTED
order.rejected_reason = request.response.text if request.response.text else ""
self.gateway.on_order(order)

msg: str = f"send order failed, orderid: {order.orderid}, status code:{status_code}, msg:{request.response.text}"
Expand All @@ -728,6 +729,7 @@ def on_send_order_error(
if request.extra:
order: OrderData = copy(request.extra)
order.status = Status.REJECTED
order.rejected_reason = "on_send_order_error"
self.gateway.on_order(order)

if not issubclass(exception_type, (ConnectionError, SSLError)):
Expand Down
2 changes: 2 additions & 0 deletions howtrader/gateway/binance/binance_spot_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,7 @@ def on_send_order_failed(self, status_code: str, request: Request) -> None:
if request.extra:
order: OrderData = copy(request.extra)
order.status = Status.REJECTED
order.rejected_reason = request.response.text if request.response.text else ""
self.gateway.on_order(order)

msg: str = f"send order failed, orderid: {order.orderid}, status code:{status_code}, msg:{request.response.text}"
Expand All @@ -656,6 +657,7 @@ def on_send_order_error(
if request.extra:
order: OrderData = copy(request.extra)
order.status = Status.REJECTED
order.rejected_reason = "on_send_order_error"
self.gateway.on_order(order)

if not issubclass(exception_type, (ConnectionError, SSLError)):
Expand Down
2 changes: 2 additions & 0 deletions howtrader/gateway/binance/binance_usdt_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,7 @@ def on_send_order_failed(self, status_code: str, request: Request) -> None:
if request.extra:
order: OrderData = copy(request.extra)
order.status = Status.REJECTED
order.rejected_reason = request.response.text if request.response.text else ""
self.gateway.on_order(order)

msg: str = f"send order failed, orderid: {order.orderid}, status code:{status_code}, msg:{request.response.text}"
Expand All @@ -731,6 +732,7 @@ def on_send_order_error(
if request.extra:
order: OrderData = copy(request.extra)
order.status = Status.REJECTED
order.rejected_reason = "on_send_order_error"
self.gateway.on_order(order)

if not issubclass(exception_type, (ConnectionError, SSLError)):
Expand Down
1 change: 1 addition & 0 deletions howtrader/trader/object.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ class OrderData(BaseData):
datetime: datetime = datetime.now()
update_time: datetime = datetime.now()
reference: str = ""
rejected_reason: str = "" # Order Rejected Reason

def __post_init__(self) -> None:
""""""
Expand Down

0 comments on commit fbc3aa9

Please sign in to comment.