统一表达式策略涨跌停触价口径

This commit is contained in:
boris
2026-06-15 19:33:40 +08:00
parent 5d2bcd8366
commit e0949a0eaa
+16 -6
View File
@@ -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
));