回溯测试引擎

backtrader的Python项目详细描述


背交易者

PyPi VersionLicenseTravis-ci Build StatusPython versions

yahoo api注释

[2018-11-16] After some testing it would seem that data downloads can be again relied upon over the web interface (or API ^{tt1}$)

If it’s NOT an issue (i.e.: bug), don’t post it as an issue. It will be automatically closed.

对于feedback/questions/…使用Community

这里是一个简单的移动平均交叉的片段。它可以在几分钟内完成 不同的方式。使用文档(和示例)luke!

from datetime import datetime
import backtrader as bt

class SmaCross(bt.SignalStrategy):
    def __init__(self):
        sma1, sma2 = bt.ind.SMA(period=10), bt.ind.SMA(period=30)
        crossover = bt.ind.CrossOver(sma1, sma2)
        self.signal_add(bt.SIGNAL_LONG, crossover)

cerebro = bt.Cerebro()
cerebro.addstrategy(SmaCross)

data0 = bt.feeds.YahooFinanceData(dataname='MSFT', fromdate=datetime(2011, 1, 1),
                                  todate=datetime(2012, 12, 31))
cerebro.adddata(data0)

cerebro.run()
cerebro.plot()

包括一个全功能的图表。试试看!这包括在样品中 作为sigsmacross/sigsmacross2.py。沿着它是sigsmacross.py,可以是 从命令行参数化。

特点:

用python编写的实时交易和回溯测试平台。

  • Live Data Feed and Trading with
    • Interactive Brokers (needs ^{tt4}$ and benefits greatly from an installed ^{tt5}$)
    • Visual Chart (needs a fork of ^{tt6}$ until a pull request is integrated in the release and benefits from ^{tt5}$)
    • Oanda (needs ^{tt8}$) (REST API Only - v20 did not support streaming when implemented)
  • Data feeds from csv/files, online sources or from pandas and blaze
  • Filters for datas, like breaking a daily bar into chunks to simulate intraday or working with Renko bricks
  • Multiple data feeds and multiple strategies supported
  • Multiple timeframes at once
  • Integrated Resampling and Replaying
  • Step by Step backtesting or at once (except in the evaluation of the Strategy)
  • Integrated battery of indicators
  • TA-Lib indicator support (needs python ta-lib / check the docs)
  • Easy development of custom indicators
  • Analyzers (for example: TimeReturn, Sharpe Ratio, SQN) and ^{tt9}$ integration (deprecated)
  • Flexible definition of commission schemes
  • Integrated broker simulation with Market, Close, Limit, Stop, StopLimit, StopTrail, StopTrailLimit*and *OCO orders, bracket order, slippage, volume filling strategies and continuous cash adjustmet for future-like instruments
  • Sizers for automated staking
  • Cheat-on-Close and Cheat-on-Open modes
  • Schedulers
  • Trading Calendars
  • Plotting (requires matplotlib)

文档

博客:

请阅读完整的文档:

内置指示器列表(122)

python 2/3支持

  • Python ^{tt10}$
  • Python ^{tt11}$ / ^{tt12}$/ ^{tt13}$ / ^{tt14}$ / ^{tt15}$ / ^{tt16}$
  • It also works with ^{tt17}$ and ^{tt18}$ (no plotting - ^{tt19}$ is not supported under pypy)

在使用2.73.5

其他版本是用travis自动测试的。

安装

backtrader是自包含的,没有外部依赖项(除非您 想要绘图)

来自pypi

  • ^{tt23}$

  • ^{tt24}$

    If ^{tt19}$ is not installed and you wish to do some plotting

注意

matplotlib的最低版本是1.4.1

例如ib数据馈送/交易:

  • ^{tt4}$ doesn’t seem to be in PyPi. Do either:

    pip install git+https://github.com/blampe/IbPy.git
    

    or (if ^{tt28}$ is not available in your system):

    pip install https://github.com/blampe/IbPy/archive/master.zip
    

对于其他功能,如:Visual ChartOandaTA-Lib,请选中 文档中的依赖项。

来源:

  • Place the backtrader directory found in the sources inside your project

版本编号

x.y.z.i

  • X: Major version number. Should stay stable unless something big is changed like an overhaul to use ^{tt32}$
  • Y: Minor version number. To be changed upon adding a complete new feature or (god forbids) an incompatible API change.
  • Z: Revision version number. To be changed for documentation updates, small changes, small bug fixes
  • I: Number of Indicators already built into the platform

备选方案

如果在看过文档和一些示例(也可以查看博客)之后,您觉得这是 不是你的茶,你总是可以看看类似的python平台:

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java通过Spring MVC web应用程序向客户端发送文本文件   java是否可以在运行时动态实例化DAO类?   调用VB。来自Java的net函数   java在Android中通过单击打开特定文件夹   java如何使用maven pom。xml标识非标准项目结构中的testng测试用例?   java为什么FOP在大文件上崩溃?   Architecture python+flask和spring boot+java   java Kafka工具根本没有启动Ubuntu 19.10   如何使用Eclipse运行Java USB API for Windows   java如何在Eclipse中查看J2EE预览服务器/容器的日志/控制台?   网页抓取是否可以使用Java crawler crawler4j暂停和恢复抓取?   java当我第二次按下按钮时,应用程序停止工作   带有偏移量和限制的java SQLite分页问题   java如何在OSX mavericks中将端口80转发到8080   java从泛型方法调用非泛型方法   java My代码未按预期工作。十进制输出不是它应该的样子   节点。java中的js加密(jasypt)和nodejs中的解密   java乘法表不工作数组索引超出范围   java将JDBC与Firebirdsql连接起来