Allow jq sells when snapshot last stays above limit

This commit is contained in:
boris
2026-04-21 18:59:48 -07:00
parent 20af824545
commit 6c353d5441
3 changed files with 42 additions and 2 deletions

View File

@@ -148,3 +148,38 @@ fn china_rule_hooks_use_tick_size_tolerance_for_price_limits() {
);
assert!(!sell_check.allowed);
}
#[test]
fn china_rule_hooks_allow_sell_when_last_price_is_above_lower_limit() {
let hooks = ChinaEquityRuleHooks;
let candidate = candidate();
let mut position = Position::new("000001.SZ");
position.buy(d(2024, 4, 3), 1_000, 2.89);
let snapshot = DailyMarketSnapshot {
date: d(2024, 4, 7),
symbol: "000001.SZ".to_string(),
timestamp: Some("2024-04-07 10:18:00".to_string()),
day_open: 2.53,
open: 2.53,
high: 2.53,
low: 2.52,
close: 2.53,
last_price: 2.53,
bid1: 2.52,
ask1: 2.53,
prev_close: 2.80,
volume: 1_000_000,
tick_volume: 100_000,
bid1_volume: 50_000,
ask1_volume: 50_000,
trading_phase: Some("continuous".to_string()),
paused: false,
upper_limit: 3.08,
lower_limit: 2.52,
price_tick: 0.01,
};
let sell_check = hooks.can_sell(d(2024, 4, 7), &snapshot, &candidate, &position, PriceField::Last);
assert!(sell_check.allowed, "sell should be allowed when snapshot last is above lower limit");
}