回溯测试引擎

backtrader-fchain的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 Oracle将休眠为ISO 8601日期格式   当有线程时,swing计时器不会停止。睡在Java里面   如何使用swing在java中清空密码字段值(字符串)   如何在编辑文本字段上设置单词java(安卓)   单独类中的java OkHttp请求   java Tomcat配置文件/上下文xml似乎已经崩溃了。请确保它是可分析和有效的。有关详细信息,请参阅服务器日志   java在科尔多瓦的ActivityResult上传递   java如何在映射中保持插入顺序。工厂?   “DataOutputStream”和“ObjectOutputStream”之间的java差异   java从FTP文件列表中获取项目的时间戳   java如何在spring security中为每个人忽略一些资源/URL?   模板类嵌套时新的Java泛型类构造函数问题   java读取并查找文件大小为1GB的行   java如何使用字符串say“stop”停止整数格式的while循环   java是否可以在应用程序启动之间将JVM保留在内存中?   java Springboot出现“出现意外错误(类型=内部服务器错误,状态=500)”的问题