Cancel blocked buy orders like rqalpha

This commit is contained in:
boris
2026-04-23 01:01:12 -07:00
parent 16ae826724
commit a076e8d0ff
2 changed files with 114 additions and 1 deletions

View File

@@ -1310,6 +1310,12 @@ where
.rules
.can_buy(date, snapshot, candidate, self.execution_price_field);
if !rule.allowed {
let status = match rule.reason.as_deref() {
Some("paused")
| Some("buy disabled by eligibility flags")
| Some("open at or above upper limit") => OrderStatus::Canceled,
_ => OrderStatus::Rejected,
};
report.order_events.push(OrderEvent {
date,
order_id: Some(order_id),
@@ -1317,7 +1323,7 @@ where
side: OrderSide::Buy,
requested_quantity: requested_qty,
filled_quantity: 0,
status: OrderStatus::Rejected,
status,
reason: format!("{reason}: {}", rule.reason.unwrap_or_default()),
});
return Ok(());