改用真实行情验证滚动风控
This commit is contained in:
@@ -16937,6 +16937,7 @@ mod tests {
|
|||||||
.map(|idx| {
|
.map(|idx| {
|
||||||
let date = start + chrono::Duration::days(idx);
|
let date = start + chrono::Duration::days(idx);
|
||||||
let volume = if idx >= 95 { 200_000 } else { 190_000 };
|
let volume = if idx >= 95 { 200_000 } else { 190_000 };
|
||||||
|
let close = 10.0 + idx as f64 * 0.01;
|
||||||
DailyMarketSnapshot {
|
DailyMarketSnapshot {
|
||||||
date,
|
date,
|
||||||
symbol: symbol.to_string(),
|
symbol: symbol.to_string(),
|
||||||
@@ -16945,11 +16946,11 @@ mod tests {
|
|||||||
open: 10.0,
|
open: 10.0,
|
||||||
high: 10.5,
|
high: 10.5,
|
||||||
low: 9.8,
|
low: 9.8,
|
||||||
close: 10.0,
|
close,
|
||||||
last_price: 10.0,
|
last_price: close,
|
||||||
bid1: 9.99,
|
bid1: close - 0.01,
|
||||||
ask1: 10.01,
|
ask1: close + 0.01,
|
||||||
prev_close: 9.9,
|
prev_close: close - 0.01,
|
||||||
volume,
|
volume,
|
||||||
minute_volume: 1_000,
|
minute_volume: 1_000,
|
||||||
bid1_volume: 2_000,
|
bid1_volume: 2_000,
|
||||||
@@ -16962,6 +16963,19 @@ mod tests {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
let factor_rows = market_rows
|
||||||
|
.iter()
|
||||||
|
.map(|row| DailyFactorSnapshot {
|
||||||
|
date: row.date,
|
||||||
|
symbol: symbol.to_string(),
|
||||||
|
market_cap_bn: 33.64,
|
||||||
|
free_float_cap_bn: 33.64,
|
||||||
|
pe_ttm: 8.0,
|
||||||
|
turnover_ratio: Some(1.0),
|
||||||
|
effective_turnover_ratio: Some(1.0),
|
||||||
|
extra_factors: BTreeMap::from([("adjustment_factor_backward1".to_string(), 1.0)]),
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
let benchmark_rows: Vec<BenchmarkSnapshot> = market_rows
|
let benchmark_rows: Vec<BenchmarkSnapshot> = market_rows
|
||||||
.iter()
|
.iter()
|
||||||
.map(|row| BenchmarkSnapshot {
|
.map(|row| BenchmarkSnapshot {
|
||||||
@@ -16984,21 +16998,7 @@ mod tests {
|
|||||||
status: "active".to_string(),
|
status: "active".to_string(),
|
||||||
}],
|
}],
|
||||||
market_rows,
|
market_rows,
|
||||||
vec![DailyFactorSnapshot {
|
factor_rows,
|
||||||
date: current,
|
|
||||||
symbol: symbol.to_string(),
|
|
||||||
market_cap_bn: 33.64,
|
|
||||||
free_float_cap_bn: 33.64,
|
|
||||||
pe_ttm: 8.0,
|
|
||||||
turnover_ratio: Some(1.0),
|
|
||||||
effective_turnover_ratio: Some(1.0),
|
|
||||||
extra_factors: BTreeMap::from([
|
|
||||||
("ma5".to_string(), 11.0),
|
|
||||||
("ma10".to_string(), 10.0),
|
|
||||||
("ma30".to_string(), 9.0),
|
|
||||||
("avg_volume5".to_string(), 200_000.0),
|
|
||||||
]),
|
|
||||||
}],
|
|
||||||
vec![CandidateEligibility {
|
vec![CandidateEligibility {
|
||||||
date: current,
|
date: current,
|
||||||
symbol: symbol.to_string(),
|
symbol: symbol.to_string(),
|
||||||
@@ -17043,9 +17043,9 @@ mod tests {
|
|||||||
.stock_state_with_factor_date(&ctx, current, current, symbol)
|
.stock_state_with_factor_date(&ctx, current, current, symbol)
|
||||||
.expect("stock state");
|
.expect("stock state");
|
||||||
|
|
||||||
assert!((stock.stock_ma5 - 9.9).abs() < 1e-9);
|
assert!(stock.stock_ma5 > stock.stock_ma10);
|
||||||
assert!((stock.stock_ma10 - 9.9).abs() < 1e-9);
|
assert!(stock.stock_ma10 > stock.stock_ma30);
|
||||||
assert!((stock.stock_ma30 - 9.9).abs() < 1e-9);
|
assert!(stock.stock_volume_ma5 > stock.stock_volume_ma100);
|
||||||
|
|
||||||
assert!(
|
assert!(
|
||||||
!strategy
|
!strategy
|
||||||
|
|||||||
Reference in New Issue
Block a user