diff --git a/crates/fidc-core/src/broker.rs b/crates/fidc-core/src/broker.rs index d955513..d484ad4 100644 --- a/crates/fidc-core/src/broker.rs +++ b/crates/fidc-core/src/broker.rs @@ -780,7 +780,7 @@ where return execution_price; } } - if self.execution_price_field == PriceField::Last { + if self.matching_type_uses_intraday_quotes() { let start_cursor = self .runtime_intraday_start_time .get() @@ -1271,7 +1271,10 @@ where OrderSide::Buy => quote.buy_price(), OrderSide::Sell => quote.sell_price(), }, - MatchingType::MinuteLast | MatchingType::Vwap | MatchingType::Twap => { + MatchingType::CurrentBarClose + | MatchingType::MinuteLast + | MatchingType::Vwap + | MatchingType::Twap => { if quote.last_price.is_finite() && quote.last_price > 0.0 { Some(quote.last_price) } else { @@ -7294,7 +7297,7 @@ where let post_close_window = self.post_close_execution_window(date); let use_intraday_quotes = post_close_window.is_some() || algo_request.is_some() - || self.execution_price_field == PriceField::Last; + || self.matching_type_uses_intraday_quotes(); if !use_intraday_quotes { return None; } @@ -7316,7 +7319,7 @@ where }); let end_cursor = if end_cursor.is_none() && matching_type == MatchingType::CurrentBarClose - && self.execution_price_field == PriceField::Last + && self.matching_type_uses_intraday_quotes() { start_cursor } else { @@ -7802,7 +7805,8 @@ where | MatchingType::MinuteBestCounterparty | MatchingType::Vwap | MatchingType::Twap - ) + ) || (self.matching_type == MatchingType::CurrentBarClose + && self.intraday_execution_start_time.is_some()) } fn quote_quantity_limited(&self, matching_type: MatchingType) -> bool { @@ -9086,8 +9090,9 @@ mod tests { let broker = BrokerSimulator::new_with_execution_price( ChinaAShareCostModel::default(), ChinaEquityRuleHooks, - PriceField::Last, + PriceField::Close, ) + .with_matching_type(MatchingType::CurrentBarClose) .with_intraday_execution_start_time(date.and_hms_opt(9, 33, 0).unwrap().time()); let mut snapshot = limit_test_snapshot(); snapshot.last_price = 9.0; @@ -11114,8 +11119,9 @@ mod tests { let broker = BrokerSimulator::new_with_execution_price( ChinaAShareCostModel::default(), ChinaEquityRuleHooks, - PriceField::Last, + PriceField::Close, ) + .with_matching_type(MatchingType::CurrentBarClose) .with_intraday_execution_start_time(date.and_hms_opt(9, 33, 0).unwrap().time()) .with_slippage_model(SlippageModel::PriceRatio(0.002)) .with_strict_value_budget(true)