backtrader / Installation

backtrader下载部署:pip 安装与源码方式教程

backtrader 是 Python 库,最常用安装方式是通过 pip 一键安装;如需绘图再加绘图依赖;也可以从源码使用。安装前请确认 Python 环境。

官方:pip install backtraderPython:>= 3.2最新版:1.9.78.123(2023-04)
pip install backtrader基础安装
backtrader[plotting]含绘图依赖 matplotlib
源码方式把 backtrader 目录放入项目
backtrader 安装入口示意(pip / plotting / 源码),基于官方 README 与 PyPI。
pip install

方式一:pip 安装(推荐)

官方 README 与 PyPI 均建议通过 pip 安装。

场景命令说明
基础安装pip install backtrader安装回测核心功能
需要绘图pip install backtrader[plotting]额外安装 matplotlib 依赖
Interactive Brokers 数据/交易pip install git+https://github.com/blampe/IbPy.git可选,需 IbPy
环境要求:README/PyPI 声明 Python >= 3.2;绘图需 matplotlib(≥1.4.1)。TA-Lib 指标需额外安装 python ta-lib。
Other routes

方式二:源码方式与其他

除 pip 外,官方也支持从源码使用与部分实盘数据源依赖。

源码方式

把源码中的 backtrader 目录放进你的项目即可使用,无需安装包。

IB 数据/交易

通过 Interactive Brokers 需要 IbPy + pytz;Oanda 需要 oandapy(REST);Visual Chart 需要 comtypes fork。

PyPy 兼容

pypy / pypy3 可用(pypy 无绘图,因 matplotlib 限制)。

边界:backtrader 是库,安装后需自备数据与策略代码;实盘数据源需券商/账号授权,中国大陆用户请自行确认可用性与合规。EasyClaw 与 backtrader 无已证实集成。

下一步做什么?

安装完成后,看首次运行示例(SmaCross 双均线),或对比 EasyClaw 量化 Skill 免部署路线。