關於這個工具
概述
Backtrader 是一個功能豐富的 Python 量化交易框架,支援回測和實盤交易。它提供 50+ 技術指標、多種資料來源以及多家券商整合,適合演算法交易開發者、Python 開發者、量化交易員和金融研究人員使用。
主要能力
- 回測與實盤交易:在同一框架內完成策略回測和實盤交易。
- 技術指標:內建 50+ 技術指標,用於技術指標分析。
- 多資料來源:支援多種資料來源接入。
- 券商整合:支援多家券商,可用於實盤交易。
- 分析器(Analyzers):提供收益、回撤、交易、持倉等績效分析指標。
- 訂單管理:支援市價單等多種訂單類型,並可設定停損單最大滑點。
- 機器學習策略:可用於機器學習交易策略的建構與評估。
安裝 可透過 pip 安裝:
bash pip install back-trader-python 注意:back-trader-python 是 PyPI 上的發行套件名稱。
使用場景
- 技術指標分析
- 機器學習交易策略
- 透過券商整合進行實盤交易
- 參數最佳化
- 回測交易策略
學習曲線 學習曲線為中等。
功能與使用情境
__init__(*args, **kwargs) ```bash - *Benefits:** - 45% performance improvement - Explicit initialization - Easier debugging - Better IDE support ## See Also - [Line System](line-system""" # Your trading logic here pass ```bash ## Order Management ### Market Orders ```python class MyStrategy(bt**Analyzers**- Performance metrics 3**Simple strategies**: Strategies without complex state management ### When NOT to Use TS Mode 1## Next Steps - [Analyzers](analyzers0` | Max slippage for stop orders (0=market) | ## Order Management ### Order Types ```python class MyStrategy(bt13) pip package manager Installation¶ From PyPI (Recommended)¶ pip install back-trader-python Note: back-trader-python is the PyPI distribution name2f}') ```bash ## Analyzer Output Format Most analyzers return a dictionary with analysis results: ```python analyzer = strat2f}') ```bash ## Position Management ### Checking Position ```python class MyStrategy(bt2f}') ```bash ### Position Analysis ```python # Positions Analyzer cerebro2f}') print(f'Max Drawdown Duration: {drawdown["max"]["len"]} days') ```bash ### Trade Analysis ```python # Trade Analyzer cerebro31:30011', 'broker_id': '9999', 'user_id': 'your_id', 'password': 'your_password', 'app_id': 'simnow_client_test', 'auth_code': '0000000000000000', } # Create cerebro cerebro = bt
快速事實
提供公開 API
使用分析
資源
CS (Cross-Section) Mode GuideData Acquisition GuideTS (Time Series) Mode GuideDeveloper GuideInstallation GuideQuick Start TutorialMigration Guide from Original BacktraderBacktrader Upgrade GuideMachine Learning Strategies: Scores, Clusters, and Pseudo-Q ValuesComplete Strategy Development TutorialJupyter Notebook Guide for BacktraderParameter Optimization Guide