Battle-test your strategies using Monte Carlo simulations, Walk-Forward Analysis, and Parameter Importance.
Verify that your strategy's performance isn't just luck. RLX runs thousands of simulations by shuffling your historical trades to calculate Risk of Ruin and confidence bands for drawdown and equity.
from rlxbt import StabilityAnalyzer
analyzer = StabilityAnalyzer()
trades = backtest_result.trades
# Run 2,500 simulations with replacement
mc_result = analyzer.run_monte_carlo(trades, initial_capital=100000, iterations=2500)
print(f"Prob. of Ruin: {mc_result.risk_of_ruin:.2%}")
print(f"95th Percentile Max Drawdown: {mc_result.max_drawdown_95:.2%}")
# Visualize equity bands
analyzer.plot_monte_carlo(mc_result)Identify which parameters are the real "drivers" of your alpha. RLX performs One-at-a-Time (OAT) sensitivity analysis to show you which settings truly impact your Sharpe Ratio.
param_variations = {
"rsi_period": [10, 14, 20],
"overbought": [65, 75, 80],
"stop_loss_pct": [0.01, 0.05]
}
importance = analyzer.analyze_parameter_importance(
backtester=bt,
strategy_class=MyStrategy,
data=df,
base_params=base_params,
param_variations=param_variations
)
# Plot horizontal bar chart of Impact Score %
analyzer.plot_parameter_importance(importance)Verify out-of-sample robustness by rolling training and testing windows forward through time. Calculate Walk-Forward Efficiency (WFE) to detect overfitting.
# Generate 10 sliding windows: 1000 bars train, 200 bars test
windows = analyzer.get_wfa_windows(
total_len=len(data),
train_size=1000,
test_size=200,
step_size=100
)
for w in windows:
# Train on data[w.train_start:w.train_end]
# Test on data[w.test_start:w.test_end]
pass