Steps
1. Build
cargo build --release
2. Run backtest
# 默认行为:先输出多资产回测(美股+红利低波+黄金)对比,再输出单资产(纳指)参数对比
mns backtest
# 使用自定义配置文件(仅单资产回测)
mns backtest run --config path/to/config.toml
Compare multiple configuration files (single-asset backtest only)
mns backtest run --compare config1.toml,config2.toml
View adjustable parameter descriptions (including current default values)mns backtest params
### 3. 参数调优
查看当前配置:
```bash
mns config
Modify a single parameter:
mns config buy_ratio.extreme_fear 70
mns config thresholds.fear 40
Use preset configuration files (located in .agents/skills/mns-backtest/data/):
| Configuration file | Features |
|---|---|
config_defensive.toml |
Defensive configuration (low drawdown, neutral no buying,Current default) |
config_balanced.toml |
Balanced configuration |
config_circuit_breaker.toml |
Circuit breaker mechanism |
config_swing.toml |
Swing trading |
config_extreme_contrarian.toml |
Extreme contrarian |
config_value.toml |
Value-oriented |
config_historical_aggressive.toml |
Historically aggressive configuration (⚠️ overfitting risk, for research reference only) |
mns backtest run --config .agents/skills/mns-backtest/data/config_defensive.toml
Data description
The backtest uses embedded data (include_str! compiled into the binary):
fgi_2016_2020.csv— daily CNN fear and greed index (high confidence)fgi_2020_2025.csv— monthly approximate fear and greed index (low confidence)monthly_real_final.csv— multi-asset monthly prices (Nasdaq / dividend low-volatility / RMB gold price)
Note: Updating data requires modifying the CSV file and re-running cargo build --release。
Core logic files
src/backtest.rs— backtest engine,run_backtest()、run_multi_asset_backtest()、run_param_comparison()src/strategy.rs— strategy core; the backtest reuses the same buy/sell/risk judgment functions (calculate_buy_suggestionsetc.); the execution flow is a backtest-specific simulationsrc/config.rs— parameter structure definition,AppConfig::default_config()is the defensive configuration default value
Interpreting results
After running, a comparison table is output (annualized return, total return, maximum drawdown, number of buys and sells); focus on:
- vs buy and hold: Is the strategy's annualized return close to the benchmark
- Maximum drawdown: The lower the drawdown, the stronger the strategy's defensiveness
- Number of buys: Setting buy_ratio to 0 in the neutral range will significantly reduce the frequency
The value of the strategy lies indisciplinerather than excess returns—it helps overcome emotional decision-making and enforces buy and sell signals during extreme markets (panic/greed).