统一表达式策略涨跌停触价口径
This commit is contained in:
@@ -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() {
|
if !price.is_finite() || !limit.is_finite() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
let tolerance = (tick.abs() * 0.5).max(1e-6);
|
price >= limit - 1e-9
|
||||||
price >= limit - tolerance
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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() {
|
if !price.is_finite() || !limit.is_finite() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
let tolerance = (tick.abs() * 0.5).max(1e-6);
|
price <= limit + 1e-9
|
||||||
price <= limit + tolerance
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn intraday_execution_start_time(&self) -> NaiveTime {
|
fn intraday_execution_start_time(&self) -> NaiveTime {
|
||||||
@@ -6967,12 +6965,24 @@ mod tests {
|
|||||||
assert!(PlatformExprStrategy::price_is_at_or_above_upper_limit(
|
assert!(PlatformExprStrategy::price_is_at_or_above_upper_limit(
|
||||||
20.21, 17.60, 0.01
|
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(
|
assert!(!PlatformExprStrategy::price_is_at_or_above_upper_limit(
|
||||||
17.58, 17.60, 0.01
|
17.58, 17.60, 0.01
|
||||||
));
|
));
|
||||||
assert!(PlatformExprStrategy::price_is_at_or_below_lower_limit(
|
assert!(PlatformExprStrategy::price_is_at_or_below_lower_limit(
|
||||||
14.39, 14.40, 0.01
|
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(
|
assert!(!PlatformExprStrategy::price_is_at_or_below_lower_limit(
|
||||||
14.42, 14.40, 0.01
|
14.42, 14.40, 0.01
|
||||||
));
|
));
|
||||||
|
|||||||
Reference in New Issue
Block a user