修复分钟执行价成交量预过滤

This commit is contained in:
boris
2026-07-06 08:44:57 +08:00
parent 6820b63d56
commit c3ab279d7d
+32 -2
View File
@@ -5275,7 +5275,11 @@ where
"daily volume limit" "daily volume limit"
}; };
if self.inactive_limit && (snapshot.paused || available_market_volume == 0) { let mut max_fill = requested_qty;
if self.inactive_limit
&& (snapshot.paused || (!uses_intraday_quantity && available_market_volume == 0))
{
return Err(if snapshot.paused { return Err(if snapshot.paused {
"paused".to_string() "paused".to_string()
} else { } else {
@@ -5283,7 +5287,10 @@ where
}); });
} }
let mut max_fill = requested_qty; if uses_intraday_quantity {
return Ok(max_fill);
}
if self.liquidity_limit && uses_intraday_quantity && !self.is_open_auction_matching() { if self.liquidity_limit && uses_intraday_quantity && !self.is_open_auction_matching() {
let top_level_liquidity = match side { let top_level_liquidity = match side {
OrderSide::Buy => snapshot.liquidity_for_buy(), OrderSide::Buy => snapshot.liquidity_for_buy(),
@@ -6680,6 +6687,29 @@ mod tests {
assert_eq!(fillable, Err("daily no volume".to_string())); assert_eq!(fillable, Err("daily no volume".to_string()));
} }
#[test]
fn minute_last_prefilter_does_not_use_snapshot_minute_volume() {
let mut snapshot = limit_test_snapshot();
snapshot.minute_volume = 0;
snapshot.volume = 1_000_000;
snapshot.bid1_volume = 0;
snapshot.ask1_volume = 0;
let broker = BrokerSimulator::new_with_execution_price(
ChinaAShareCostModel::default(),
ChinaEquityRuleHooks,
PriceField::Last,
)
.with_matching_type(MatchingType::MinuteLast)
.with_volume_limit(true)
.with_volume_percent(0.25)
.with_liquidity_limit(false);
let fillable =
broker.market_fillable_quantity(&snapshot, OrderSide::Buy, 5_000, 100, 100, 0, false);
assert_eq!(fillable, Ok(5_000));
}
#[test] #[test]
fn target_value_valuation_uses_daily_snapshot_but_value_order_sizing_uses_intraday_minute() { fn target_value_valuation_uses_daily_snapshot_but_value_order_sizing_uses_intraday_minute() {
let date = chrono::NaiveDate::from_ymd_opt(2025, 1, 2).expect("valid date"); let date = chrono::NaiveDate::from_ymd_opt(2025, 1, 2).expect("valid date");