From 452eb3324d73bf020d06f84ea43a23a47c94fa54 Mon Sep 17 00:00:00 2001 From: boris Date: Thu, 23 Apr 2026 01:26:58 -0700 Subject: [PATCH] Use intraday quotes before snapshot fallback --- crates/fidc-core/src/broker.rs | 42 +++++++++---------- crates/fidc-core/tests/explicit_order_flow.rs | 3 +- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/crates/fidc-core/src/broker.rs b/crates/fidc-core/src/broker.rs index 414cb1e..d04849c 100644 --- a/crates/fidc-core/src/broker.rs +++ b/crates/fidc-core/src/broker.rs @@ -1829,6 +1829,27 @@ where return None; } + let start_cursor = self + .intraday_execution_start_time + .map(|start_time| date.and_time(start_time)); + let quotes = data.execution_quotes_on(date, symbol); + + if let Some(fill) = self.select_execution_fill( + snapshot, + quotes, + side, + start_cursor, + requested_qty, + round_lot, + minimum_order_quantity, + order_step_size, + allow_odd_lot_sell, + cash_limit, + gross_limit, + ) { + return Some(fill); + } + if self.intraday_execution_start_time.is_some() { let execution_price = self.snapshot_execution_price(snapshot, side); let quantity = match side { @@ -1867,27 +1888,6 @@ where }); } - let start_cursor = self - .intraday_execution_start_time - .map(|start_time| date.and_time(start_time)); - let quotes = data.execution_quotes_on(date, symbol); - - if let Some(fill) = self.select_execution_fill( - snapshot, - quotes, - side, - start_cursor, - requested_qty, - round_lot, - minimum_order_quantity, - order_step_size, - allow_odd_lot_sell, - cash_limit, - gross_limit, - ) { - return Some(fill); - } - None } diff --git a/crates/fidc-core/tests/explicit_order_flow.rs b/crates/fidc-core/tests/explicit_order_flow.rs index 5787e42..b87be8b 100644 --- a/crates/fidc-core/tests/explicit_order_flow.rs +++ b/crates/fidc-core/tests/explicit_order_flow.rs @@ -703,7 +703,8 @@ fn broker_cancels_market_order_remainder_when_intraday_quote_liquidity_exhausted ChinaAShareCostModel::default(), ChinaEquityRuleHooks::default(), PriceField::Last, - ); + ) + .with_intraday_execution_start_time(chrono::NaiveTime::from_hms_opt(10, 18, 0).unwrap()); let report = broker .execute(