From 5d2bcd8366438a305b536a7f5f8580c588b07db8 Mon Sep 17 00:00:00 2001 From: boris Date: Mon, 15 Jun 2026 18:50:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3A=E8=82=A1=E6=B6=A8=E8=B7=8C?= =?UTF-8?q?=E5=81=9C=E4=B8=A5=E6=A0=BC=E8=A7=A6=E4=BB=B7=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/fidc-core/src/data.rs | 4 ++-- crates/fidc-core/tests/core_rules.rs | 22 +++++++++++++++++++++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/crates/fidc-core/src/data.rs b/crates/fidc-core/src/data.rs index d38c813..1016f55 100644 --- a/crates/fidc-core/src/data.rs +++ b/crates/fidc-core/src/data.rs @@ -159,14 +159,14 @@ impl DailyMarketSnapshot { if !self.upper_limit.is_finite() || self.upper_limit <= 0.0 { return false; } - price >= self.upper_limit - self.effective_price_tick() + 1e-6 + price >= self.upper_limit - 1e-9 } pub fn is_at_lower_limit_price(&self, price: f64) -> bool { if !self.lower_limit.is_finite() || self.lower_limit <= 0.0 { return false; } - price <= self.lower_limit + self.effective_price_tick() - 1e-6 + price <= self.lower_limit + 1e-9 } } diff --git a/crates/fidc-core/tests/core_rules.rs b/crates/fidc-core/tests/core_rules.rs index c1df7a9..91001a3 100644 --- a/crates/fidc-core/tests/core_rules.rs +++ b/crates/fidc-core/tests/core_rules.rs @@ -175,7 +175,7 @@ fn china_rule_hooks_block_buy_at_limit_up_and_sell_at_limit_down() { } #[test] -fn china_rule_hooks_use_tick_size_tolerance_for_price_limits() { +fn china_rule_hooks_use_strict_price_limits() { let hooks = ChinaEquityRuleHooks; let candidate = candidate(); @@ -184,6 +184,13 @@ fn china_rule_hooks_use_tick_size_tolerance_for_price_limits() { ..snapshot(10.9995, 11.0, 9.0) }; let buy_check = hooks.can_buy(d(2024, 1, 3), &near_upper, &candidate, PriceField::Open); + assert!(buy_check.allowed); + + let exact_upper = DailyMarketSnapshot { + price_tick: 0.001, + ..snapshot(11.0, 11.0, 9.0) + }; + let buy_check = hooks.can_buy(d(2024, 1, 3), &exact_upper, &candidate, PriceField::Open); assert!(!buy_check.allowed); let near_lower = DailyMarketSnapshot { @@ -199,6 +206,19 @@ fn china_rule_hooks_use_tick_size_tolerance_for_price_limits() { &position, PriceField::Open, ); + assert!(sell_check.allowed); + + let exact_lower = DailyMarketSnapshot { + price_tick: 0.001, + ..snapshot(9.0, 11.0, 9.0) + }; + let sell_check = hooks.can_sell( + d(2024, 1, 3), + &exact_lower, + &candidate, + &position, + PriceField::Open, + ); assert!(!sell_check.allowed); }