修正回测推进并增强策略样例
This commit is contained in:
@@ -9,10 +9,10 @@ fn strategy_emits_target_weights_and_diagnostics() {
|
||||
let decision_date = NaiveDate::from_ymd_opt(2024, 1, 10).unwrap();
|
||||
let execution_date = NaiveDate::from_ymd_opt(2024, 1, 11).unwrap();
|
||||
let portfolio = PortfolioState::new(1_000_000.0);
|
||||
let mut cfg = CnSmallCapRotationConfig::demo();
|
||||
cfg.base_index_level = 3000.0;
|
||||
cfg.base_cap_floor = 38.0;
|
||||
cfg.cap_span = 25.0;
|
||||
let mut cfg = CnSmallCapRotationConfig::cn_dyn_smallcap_band();
|
||||
cfg.signal_symbol = Some("000001.SZ".to_string());
|
||||
cfg.short_ma_days = 3;
|
||||
cfg.long_ma_days = 5;
|
||||
let mut strategy = CnSmallCapRotationStrategy::new(cfg);
|
||||
|
||||
let decision = strategy
|
||||
@@ -26,13 +26,11 @@ fn strategy_emits_target_weights_and_diagnostics() {
|
||||
.expect("decision");
|
||||
|
||||
assert!(decision.rebalance);
|
||||
assert!(!decision.target_weights.is_empty());
|
||||
assert!(decision
|
||||
.diagnostics
|
||||
.iter()
|
||||
.any(|line| line.contains("selected=")));
|
||||
assert!(decision.rebalance);
|
||||
assert!(!decision.diagnostics.is_empty());
|
||||
assert!(decision
|
||||
.diagnostics
|
||||
.iter()
|
||||
.any(|line| line.contains("signal_symbol=")));
|
||||
assert_eq!(strategy.name(), "cn-dyn-smallcap-band");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user