移除策略级盘后撮合模式

This commit is contained in:
boris
2026-08-27 21:05:57 +08:00
parent dd08358f1c
commit 85c38b0756
4 changed files with 3 additions and 86 deletions
+1 -67
View File
@@ -248,7 +248,6 @@ pub enum MatchingType {
OpenAuction,
CurrentBarClose,
NextBarOpen,
PostCloseFixedPrice,
MinuteLast,
MinuteBestOwn,
MinuteBestCounterparty,
@@ -546,12 +545,6 @@ impl<C, R> BrokerSimulator<C, R> {
}
fn effective_remainder_policy(&self, allow_pending_limit: bool) -> RemainderPolicy {
if self.matching_type == MatchingType::PostCloseFixedPrice {
return match self.runtime_time_in_force.get() {
Some(OrderTimeInForce::Fok) => RemainderPolicy::FillOrKill,
_ => RemainderPolicy::Cancel,
};
}
match self.runtime_time_in_force.get() {
Some(OrderTimeInForce::Fok) => RemainderPolicy::FillOrKill,
Some(OrderTimeInForce::Gtc) => RemainderPolicy::KeepUntilCanceled,
@@ -990,13 +983,6 @@ where
return self.clamp_execution_price(snapshot, side, raw_price);
}
// A fixed-price post-close declaration is matched at the official
// close; applying market slippage here would turn it into a different
// order contract. Fees and risk checks still run normally.
if self.matching_type == MatchingType::PostCloseFixedPrice {
return self.clamp_execution_price(snapshot, side, raw_price);
}
let order_value = quantity.and_then(|qty| (qty > 0).then_some(raw_price * qty as f64));
let mut adjusted = match self.slippage_model {
SlippageModel::None => raw_price,
@@ -7442,7 +7428,7 @@ where
MatchingType::OpenAuction
| MatchingType::CurrentBarClose
| MatchingType::NextBarOpen
| MatchingType::PostCloseFixedPrice => false,
=> false,
MatchingType::MinuteLast => self.liquidity_limit,
MatchingType::MinuteBestOwn
| MatchingType::MinuteBestCounterparty
@@ -7488,7 +7474,6 @@ fn execution_price_field_from_matching_type(matching_type: MatchingType) -> Pric
MatchingType::OpenAuction => PriceField::DayOpen,
MatchingType::CurrentBarClose => PriceField::Close,
MatchingType::NextBarOpen => PriceField::Open,
MatchingType::PostCloseFixedPrice => PriceField::Close,
MatchingType::MinuteLast
| MatchingType::MinuteBestOwn
| MatchingType::MinuteBestCounterparty
@@ -7969,57 +7954,6 @@ mod tests {
assert!(broker.quote_quantity_limited(MatchingType::MinuteBestCounterparty));
}
#[test]
fn post_close_fixed_price_uses_daily_close_without_market_slippage() {
let date = chrono::NaiveDate::from_ymd_opt(2026, 7, 6).expect("valid date");
let mut snapshot = limit_test_snapshot();
snapshot.date = date;
snapshot.timestamp = Some(format!("{date} 15:00:00"));
snapshot.close = 10.0;
snapshot.last_price = 10.0;
snapshot.bid1 = 10.0;
snapshot.ask1 = 10.0;
let mut candidate = limit_test_candidate(true, true);
candidate.date = date;
let mut benchmark = limit_test_benchmark();
benchmark.date = date;
let data = DataSet::from_components_with_actions_and_quotes(
vec![limit_test_instrument()],
vec![snapshot],
Vec::new(),
vec![candidate],
vec![benchmark],
Vec::new(),
Vec::new(),
)
.expect("valid post-close dataset");
let broker = BrokerSimulator::new(
ChinaAShareCostModel::default(),
ChinaEquityRuleHooks,
)
.with_matching_type(MatchingType::PostCloseFixedPrice)
.with_slippage_model(SlippageModel::PriceRatio(0.25))
.with_volume_limit(false)
.with_liquidity_limit(false)
.with_inactive_limit(false);
let decision = StrategyDecision {
order_intents: vec![OrderIntent::TargetValue {
symbol: "000001.SZ".to_string(),
target_value: 2_000.0,
reason: "post_close_buy".to_string(),
}],
..StrategyDecision::default()
};
let mut portfolio = PortfolioState::new(20_000.0);
let report = broker
.execute(date, &mut portfolio, &data, &decision)
.expect("post-close execution");
assert_eq!(report.fill_events.len(), 1, "report={report:?}");
assert_eq!(report.fill_events[0].price, 10.0);
assert_eq!(report.fill_events[0].quantity, 100);
assert!(!broker.has_open_orders());
}
#[test]
fn next_open_buy_risk_uses_execution_date_not_signal_date() {
let signal_date = chrono::NaiveDate::from_ymd_opt(2025, 1, 2).expect("valid date");