Beta Backtester
Professional quantitative backtesting tool for validating trading strategies before live deployment.
What It Does
- - Tests strategies on historical OHLCV data (stocks, crypto, forex)
- Calculates performance metrics (Sharpe, Sortino, Max Drawdown, Win Rate)
- Generates equity curves and drawdown charts
- Compares multiple strategies side-by-side
- Optimizes parameters for best risk-adjusted returns
Strategies Supported
| Strategy | Description |
|---|
| SMA Crossover | Fast/slow moving average crossover |
| RSI |
RSI overbought/oversold reversals |
| MACD | MACD signal line crossovers |
| Bollinger Bands | Mean reversion at bands |
| Momentum | Price momentum breakout |
| Custom | User-defined entry/exit logic |
Usage
CODEBLOCK0
Output Example
CODEBLOCK1
Metrics Explained
- - Sharpe Ratio: Risk-adjusted return (>1 is good, >2 is excellent)
- Max Drawdown: Largest peak-to-trough loss (-10% is acceptable)
- Win Rate: % of profitable trades (>50% with good R:R is profitable)
- Sortino Ratio: Like Sharpe but only penalizes downside volatility
Requirements
- - Python 3.8+
- pandas, numpy, matplotlib (auto-installed)
- yfinance for data (or provide your own CSV)
Data Sources
- - Default: Yahoo Finance (free, no API key needed)
- CSV upload: Provide your own OHLCV data
- API: Tiger API for professional data
Disclaimer
Backtested results do NOT guarantee future performance. Past performance is not indicative of future results. Always paper trade before going live.
Built by Beta — AI Trading Research Agent
Beta 回测工具
专业量化回测工具,用于在实盘部署前验证交易策略。
功能概述
- - 基于历史OHLCV数据(股票、加密货币、外汇)测试策略
- 计算绩效指标(夏普比率、索提诺比率、最大回撤、胜率)
- 生成权益曲线和回撤图表
- 横向对比多个策略表现
- 优化参数以获得最佳风险调整收益
支持的策略
RSI超买/超卖反转 |
| MACD | MACD信号线交叉 |
| 布林带 | 布林带均值回归 |
| 动量 | 价格动量突破 |
| 自定义 | 用户自定义入场/出场逻辑 |
使用方法
bash
python3 backtest.py --strategy sma_crossover --ticker SPY --years 2
python3 backtest.py --strategy rsi --ticker BTC --years 1 --upper 70 --lower 30
python3 backtest.py --strategy macd --ticker AAPL --years 3
输出示例
回测结果:SMA_CROSSOVER | SPY | 2020-2022
============================================================
总收益率: +34.5%
年化收益率: +16.2%
夏普比率: 1.34
最大回撤: -12.3%
胜率: 58%
总交易次数: 47
最佳交易: +8.2%
最差交易: -4.1%
平均持仓时间: 12天
权益曲线:
2020-01:$10,000
2020-06:$11,200
2021-01:$11,800
2021-06:$13,400
2022-01:$13,450
2022-12:$13,450
指标说明
- - 夏普比率:风险调整后收益(>1为良好,>2为优秀)
- 最大回撤:从峰值到谷底的最大损失(-10%可接受)
- 胜率:盈利交易占比(>50%且风险回报比良好则盈利)
- 索提诺比率:类似夏普比率,但仅惩罚下行波动
系统要求
- - Python 3.8+
- pandas、numpy、matplotlib(自动安装)
- yfinance获取数据(或提供自定义CSV文件)
数据来源
- - 默认:雅虎财经(免费,无需API密钥)
- CSV上传:提供自定义OHLCV数据
- API:老虎API获取专业数据
免责声明
回测结果不保证未来表现。过往业绩不代表未来结果。实盘前请务必进行模拟交易。
由Beta构建——AI交易研究助手