修正A股涨跌停严格触价规则
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user