zipline框架--简介
Zipline is a Pythonic algorithmic trading library. It is an event-driven system for backtesting. Zipline is currently used in production as the backtesting and live-trading engine powering Quantopian -- a free, community-centered, hosted platform for building and executing trading strategies.
zipline是一个Pythonic算法交易库。它是一个事件驱动的回测系统。Zipline目前为Quantopian在生产中被用作回测和实时交易引擎,Quantopian是一个用于建立和执行交易策略的免费的社区中心和托管平台。
Features
特征
Ease of Use: Zipline tries to get out of your way so that you can focus on algorithm development. See below for a code example.
使用方便:Zipline试图解放的双手,以便你可以专注于算法开发。请参见下面的代码示例。
"Batteries Included": many common statistics like moving average and linear regression can be readily accessed from within a user-written algorithm.
“内置电池”:许多常见的统计功能,如移动平均和线性回归,可以很容易地从用户编写的算法中调用。
PyData Integration: Input of historical data and output of performance statistics are based on Pandas DataFrames to integrate nicely into the existing PyData ecosystem.
PyDATA集成:历史数据的输入和性能统计的输出是基于Pandas DataFrames格式,以很好地集成到现有的PyDATA生态系统中。
Statistics and Machine Learning Libraries: You can use libraries like matplotlib, scipy, statsmodels, and sklearn to support development, analysis, and visualization of state-of-the-art trading systems.
统计和机器学习库:您可以使用像matplotlib, scipy, statsmodels, 和 sklearn这样的库来支持最先进的交易系统的开发、分析和可视化。
Quickstart
快速启动
See our getting started tutorial.
看我们入门教程。
The following code implements a simple dual moving average algorithm.
下面的代码实现了一个简单的双移动平均算法。
from zipline.api import order_target, record, symbol def initialize(context):
context.i = 0
context.asset = symbol('AAPL') def handle_data(context, data):
# Skip first 300 days to get full windows
context.i += 1
if context.i < 300:
return # Compute averages
# data.history() has to be called with the same params
# from above and returns a pandas dataframe.
short_mavg = data.history(context.asset, 'price', bar_count=100, frequency="1d").mean()
long_mavg = data.history(context.asset, 'price', bar_count=300, frequency="1d").mean() # Trading logic
if short_mavg > long_mavg:
# order_target orders as many shares as needed to
# achieve the desired number of shares.
order_target(context.asset, 100)
elif short_mavg < long_mavg:
order_target(context.asset, 0) # Save values for later inspection
record(AAPL=data.current(context.asset, 'price'),
short_mavg=short_mavg,
long_mavg=long_mavg)
You can then run this algorithm using the Zipline CLI; you'll need a Quandl API key to ingest the default data bundle. Once you have your key, run the following from the command line:
然后可以使用 Zipline CLI运行此算法;您需要一个QUANDL API密钥来获取默认数据包。一旦拥有了密钥,就从命令行运行以下命令:
$ QUANDL_API_KEY=<yourkey> zipline ingest -b quandl
$ zipline run -f dual_moving_average.py --start 2014-1-1 --end 2018-1-1 -o dma.pickle
This will download asset pricing data data from quandl, and stream it through the algorithm over the specified time range. Then, the resulting performance DataFrame is saved in dma.pickle, which you can load an analyze from within Python.
这将从QuANDL下载证券价格数据,并在指定的时间范围内将其数据流通过算法。然后,将得到的DataFrame性能数据保存在dma.pickle中,可以从Python中加载分析。
You can find other examples in the zipline/examples directory.
您可以在Zipline /examples目录中找到其他示例。
Questions?
问题?
If you find a bug, feel free to open an issue and fill out the issue template.
如果发现bug,请自由打开问题并填写问题模板。
Contributing
贡献
All contributions, bug reports, bug fixes, documentation improvements, enhancements, and ideas are welcome. Details on how to set up a development environment can be found in our development guidelines.
所有的贡献、bug报告、bug修复、文档改进、增强和想法都是受欢迎的。关于如何建立开发环境的细节可以在我们的开发指南中找到。
If you are looking to start working with the Zipline codebase, navigate to the GitHub issues tab and start looking through interesting issues. Sometimes there are issues labeled as Beginner Friendly or Help Wanted.
如果你想开始使用Zipline代码库,导航到GITHUB问题选项卡,开始浏览有趣的问题。有时有些问题被标示为初学友好或乐于助人。
Feel free to ask questions on the mailing list or on Gitter.
在邮件列表或GITER上自由提问。
zipline框架--简介的更多相关文章
- Spring 系列: Spring 框架简介 -7个部分
Spring 系列: Spring 框架简介 Spring AOP 和 IOC 容器入门 在这由三部分组成的介绍 Spring 框架的系列文章的第一期中,将开始学习如何用 Spring 技术构建轻量级 ...
- 《HiWind企业快速开发框架实战》(0)目录及框架简介
<HiWind企业快速开发框架实战>(0)目录及框架简介 本系列主要介绍一款企业管理系统快速开发框架,该框架旨在快速完成企业管理系统,并实现易维护可移植的目标. 使用逐个系统模块进行编码的 ...
- Yaf零基础学习总结1-Yaf框架简介
从今天开始,给大家讲解下yaf框架,讲解之前肯定要了解下yaf是个什么东西,当然,从标题我们已经知道yaf是个PHP框架了,也许大家对于PHP框架并不陌生,一般PHP程序员用过的框架至少有一两个吧,国 ...
- hdwiki 框架简介
虽然HDwiki是一个开源的wiki系统,并且代码简洁易懂,但如果想在系统上做做进一步开发还需要对框架有一个整体的认识.熟悉了HDwiki的框架以后完全可以独立出来做其他功能的开发,当做一个开源的PH ...
- Apache—DBUtils框架简介
转载自:http://blog.csdn.net/fengdongkun/article/details/8236216 Apache—DBUtils框架简介.DbUtils类.QueryRunner ...
- Jersey框架一:Jersey RESTful WebService框架简介
Jersey系列文章: Jersey框架一:Jersey RESTful WebService框架简介 Jersey框架二:Jersey对JSON的支持 Jersey框架三:Jersey对HTTPS的 ...
- Web自动化框架LazyUI使用手册(1)--框架简介
作者:cryanimal QQ:164166060 web端自动化简介 web端自动化,即通过自动化的方式,对Web页面施行一系列的仿鼠标键盘操作,以达到对Web页面的功能进行自动化测试的目的. 其一 ...
- python运维开发(二十二)---JSONP、瀑布流、组合搜索、多级评论、tornado框架简介
内容目录: JSONP应用 瀑布流布局 组合搜索 多级评论 tornado框架简介 JSONP应用 由于浏览器存在同源策略机制,同源策略阻止从一个源加载的文档或脚本获取或设置另一个源加载的文档的属性. ...
- Spring 系列: Spring 框架简介(转载)
Spring 系列: Spring 框架简介 http://www.ibm.com/developerworks/cn/java/wa-spring1/ Spring AOP 和 IOC 容器入门 在 ...
随机推荐
- WebApi 身份认证解决方案:Basic基础认证
前言:最近,讨论到数据库安全的问题,于是就引出了WebApi服务没有加任何验证的问题.也就是说,任何人只要知道了接口的url,都能够模拟http请求去访问我们的服务接口,从而去增删改查数据库,这后果想 ...
- i春秋misc部分writeup
i春秋misc部分writeup 一.敲击 方方格格,然后看到下面的格式,猜测出是键盘上的布局,然后看这些字母形成的形状想那些字母,就是flag了 2.滴滴滴 放到ctfcack里解密,发现时栅栏密码 ...
- mysql容灾备份脚本
一,环境需求 **安装前准备 操作系统环境:Centos 7.2 [root@localhost soft]# rpm -qa | grep mariadb [root@localhost soft] ...
- 利用ELK分析Nginx日志生产实战(高清多图)
本文以api.mingongge.com.cn域名为测试对象进行统计,日志为crm.mingongge.com.cn和risk.mingongge.com.cn请求之和(此二者域名不具生产换环境统计意 ...
- 自定义 js 文件的集成引用
这里的内容, 提前要知道 import comm from ‘...’ 和 import { comm } from ‘...’ 的基础知识. 我举个案例, 当你有很多api文件的时候, 比如 ...
- webpack优化相关操作
1.缩小文件搜索的范围 • 优化loader配置 尽量精确使用 include 只命中需要的文件. module.exports = { module: { rules: ...
- vue 相关
1.vue v-for 循环一个数组,key值报错,但是数据是正常显示的 报错: v-for使用key,需要在key前加上:key;srcList是个数组,key值绑定不能是数据类型Object的it ...
- Django的ORM那些相关操作
一般操作 看专业的官网文档,做专业的程序员! 必知必会13条 <> all(): 查询所有结果 <> filter(**kwargs): 它包含了与所给筛选条件相匹配的对象 & ...
- MAC 的ideal 修改 项目名称
在使用 ideal的时候 ,我拷贝了一个文件,想要修改项目的名称,改了qcs-regulation-hefei 但是 (1)我改了项目名称: (2)还改了 pom.xml 但是还是不行,来回切换不同的 ...
- NC 命令引用了一个高手的文章做收藏
什么是nc nc是netcat的简写,有着网络界的瑞士军刀美誉.因为它短小精悍.功能实用,被设计为一个简单.可靠的网络工具 nc的作用 (1)实现任意TCP/UDP端口的侦听,nc可以作为server ...