From e0949a0eaa401d6b40c7f618e128afc776d4ae53 Mon Sep 17 00:00:00 2001 From: boris Date: Mon, 15 Jun 2026 19:33:40 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=9F=E4=B8=80=E8=A1=A8=E8=BE=BE=E5=BC=8F?= =?UTF-8?q?=E7=AD=96=E7=95=A5=E6=B6=A8=E8=B7=8C=E5=81=9C=E8=A7=A6=E4=BB=B7?= =?UTF-8?q?=E5=8F=A3=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fidc-core/src/platform_expr_strategy.rs | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/crates/fidc-core/src/platform_expr_strategy.rs b/crates/fidc-core/src/platform_expr_strategy.rs index 8a1a68e..9a48a88 100644 --- a/crates/fidc-core/src/platform_expr_strategy.rs +++ b/crates/fidc-core/src/platform_expr_strategy.rs @@ -879,20 +879,18 @@ impl PlatformExprStrategy { ) } - fn price_is_at_or_above_upper_limit(price: f64, limit: f64, tick: f64) -> bool { + fn price_is_at_or_above_upper_limit(price: f64, limit: f64, _tick: f64) -> bool { if !price.is_finite() || !limit.is_finite() { return false; } - let tolerance = (tick.abs() * 0.5).max(1e-6); - price >= limit - tolerance + price >= limit - 1e-9 } - fn price_is_at_or_below_lower_limit(price: f64, limit: f64, tick: f64) -> bool { + fn price_is_at_or_below_lower_limit(price: f64, limit: f64, _tick: f64) -> bool { if !price.is_finite() || !limit.is_finite() { return false; } - let tolerance = (tick.abs() * 0.5).max(1e-6); - price <= limit + tolerance + price <= limit + 1e-9 } fn intraday_execution_start_time(&self) -> NaiveTime { @@ -6967,12 +6965,24 @@ mod tests { assert!(PlatformExprStrategy::price_is_at_or_above_upper_limit( 20.21, 17.60, 0.01 )); + assert!(PlatformExprStrategy::price_is_at_or_above_upper_limit( + 17.60, 17.60, 0.01 + )); + assert!(!PlatformExprStrategy::price_is_at_or_above_upper_limit( + 17.5995, 17.60, 0.001 + )); assert!(!PlatformExprStrategy::price_is_at_or_above_upper_limit( 17.58, 17.60, 0.01 )); assert!(PlatformExprStrategy::price_is_at_or_below_lower_limit( 14.39, 14.40, 0.01 )); + assert!(PlatformExprStrategy::price_is_at_or_below_lower_limit( + 14.40, 14.40, 0.01 + )); + assert!(!PlatformExprStrategy::price_is_at_or_below_lower_limit( + 14.4005, 14.40, 0.001 + )); assert!(!PlatformExprStrategy::price_is_at_or_below_lower_limit( 14.42, 14.40, 0.01 ));