Add rqalpha-style order reject lifecycle events
This commit is contained in:
@@ -950,6 +950,15 @@ where
|
||||
};
|
||||
if let Some(order) = canceled {
|
||||
self.emit_user_canceled_open_order(date, order, reason, report);
|
||||
} else {
|
||||
report.process_events.push(ProcessEvent {
|
||||
date,
|
||||
kind: ProcessEventKind::OrderCancellationReject,
|
||||
order_id: Some(order_id),
|
||||
symbol: None,
|
||||
side: None,
|
||||
detail: format!("reason={reason} status=not_found"),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -974,6 +983,16 @@ where
|
||||
*open_orders = retained;
|
||||
canceled
|
||||
};
|
||||
if canceled.is_empty() {
|
||||
report.process_events.push(ProcessEvent {
|
||||
date,
|
||||
kind: ProcessEventKind::OrderCancellationReject,
|
||||
order_id: None,
|
||||
symbol: Some(symbol.to_string()),
|
||||
side: None,
|
||||
detail: format!("reason={reason} status=no_open_orders_for_symbol"),
|
||||
});
|
||||
}
|
||||
for order in canceled {
|
||||
self.emit_user_canceled_open_order(date, order, reason, report);
|
||||
}
|
||||
@@ -989,6 +1008,16 @@ where
|
||||
let mut open_orders = self.open_orders.borrow_mut();
|
||||
std::mem::take(&mut *open_orders)
|
||||
};
|
||||
if canceled.is_empty() {
|
||||
report.process_events.push(ProcessEvent {
|
||||
date,
|
||||
kind: ProcessEventKind::OrderCancellationReject,
|
||||
order_id: None,
|
||||
symbol: None,
|
||||
side: None,
|
||||
detail: format!("reason={reason} status=no_open_orders"),
|
||||
});
|
||||
}
|
||||
for order in canceled {
|
||||
self.emit_user_canceled_open_order(date, order, reason, report);
|
||||
}
|
||||
@@ -1090,6 +1119,14 @@ where
|
||||
});
|
||||
}
|
||||
|
||||
fn creation_reject_kind(emit_creation_events: bool) -> ProcessEventKind {
|
||||
if emit_creation_events {
|
||||
ProcessEventKind::OrderCreationReject
|
||||
} else {
|
||||
ProcessEventKind::OrderUnsolicitedUpdate
|
||||
}
|
||||
}
|
||||
|
||||
fn target_quantities(
|
||||
&self,
|
||||
date: NaiveDate,
|
||||
@@ -1578,7 +1615,7 @@ where
|
||||
Self::emit_order_process_event(
|
||||
report,
|
||||
date,
|
||||
ProcessEventKind::OrderUnsolicitedUpdate,
|
||||
Self::creation_reject_kind(emit_creation_events),
|
||||
order_id,
|
||||
symbol,
|
||||
OrderSide::Sell,
|
||||
@@ -1674,7 +1711,7 @@ where
|
||||
Self::emit_order_process_event(
|
||||
report,
|
||||
date,
|
||||
ProcessEventKind::OrderUnsolicitedUpdate,
|
||||
Self::creation_reject_kind(emit_creation_events),
|
||||
order_id,
|
||||
symbol,
|
||||
OrderSide::Sell,
|
||||
@@ -1735,7 +1772,7 @@ where
|
||||
Self::emit_order_process_event(
|
||||
report,
|
||||
date,
|
||||
ProcessEventKind::OrderUnsolicitedUpdate,
|
||||
Self::creation_reject_kind(emit_creation_events),
|
||||
order_id,
|
||||
symbol,
|
||||
OrderSide::Sell,
|
||||
@@ -1843,7 +1880,7 @@ where
|
||||
Self::emit_order_process_event(
|
||||
report,
|
||||
date,
|
||||
ProcessEventKind::OrderUnsolicitedUpdate,
|
||||
Self::creation_reject_kind(emit_creation_events),
|
||||
order_id,
|
||||
symbol,
|
||||
OrderSide::Sell,
|
||||
@@ -2653,7 +2690,7 @@ where
|
||||
Self::emit_order_process_event(
|
||||
report,
|
||||
date,
|
||||
ProcessEventKind::OrderUnsolicitedUpdate,
|
||||
Self::creation_reject_kind(emit_creation_events),
|
||||
order_id,
|
||||
symbol,
|
||||
OrderSide::Buy,
|
||||
@@ -2738,7 +2775,7 @@ where
|
||||
Self::emit_order_process_event(
|
||||
report,
|
||||
date,
|
||||
ProcessEventKind::OrderUnsolicitedUpdate,
|
||||
Self::creation_reject_kind(emit_creation_events),
|
||||
order_id,
|
||||
symbol,
|
||||
OrderSide::Buy,
|
||||
@@ -2871,7 +2908,7 @@ where
|
||||
Self::emit_order_process_event(
|
||||
report,
|
||||
date,
|
||||
ProcessEventKind::OrderUnsolicitedUpdate,
|
||||
Self::creation_reject_kind(emit_creation_events),
|
||||
order_id,
|
||||
symbol,
|
||||
OrderSide::Buy,
|
||||
|
||||
@@ -110,8 +110,10 @@ pub enum ProcessEventKind {
|
||||
PostSettlement,
|
||||
OrderPendingNew,
|
||||
OrderCreationPass,
|
||||
OrderCreationReject,
|
||||
OrderPendingCancel,
|
||||
OrderCancellationPass,
|
||||
OrderCancellationReject,
|
||||
OrderUnsolicitedUpdate,
|
||||
Trade,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user