rainx / inside-zipline Goto Github PK
View Code? Open in Web Editor NEW深入了解zipline回测框架
深入了解zipline回测框架
比如说原来股指期货早15分钟开盘,晚15分钟收盘
应该是支持的,但是不知道怎么用
Karen Rubin Jun 17, 2016
Hi Everyone,
We continue to work away on adding futures support to Quantopian. Last week we merged a big change to Zipline that enables support for multiple trading calendars. This is critical to allow for futures trading outside of NYSE market hours. We've also made great progress at ingesting futures data.The next steps for the project are to work on building out the calendars for the CBOE, CME and ICE exchanges. Part of this will be solving problems around allowing algorithms to trade both equities and futures at the same time, and dealing with time management throughout the system.
We will be launching an alpha after this next phase is complete. You can sign up for it here, and also learn a little bit more (such as which contracts we plan to support).
请问以后会考虑国内期货和期权吗?
rainx您好,看到您的gitbook感到非常受益。我最近也在研究这个zipline怎么用(也是用自己的数据)。这里有个关于数据的问题想请教您一下。
首先,我的数据是每天只有一个值的时间序列(不是OHLCV这样的,或者只有HL两个值)。目前感觉能work的方法只有把它当成pd.panel手动传入TradingAlgorithm的data argument里。(不过当然这个目前还能忍)
我的问题是,假如我想算一些复杂一点的因子,用这种panel data的方法,如何用zipline自带的那些因子函数?(当然了,如果这实在不行的话,只能自己重写一遍这些函数了。)
具体是这样的,比如在您的例子里面(也是zipline doc里面的一个例子),使用历史数据计算一些因子是用data.history(sym, 'close', 5, '1d').mean()
,这样算的。这个例子只是一个简单的平均值,所以有现成的函数。但是如果是更复杂的一些因子,(除了自己写函数)我看zipline自己定义了一些factor的函数以及可以继承CustomFactor定义用户自己的因子,比如简单平均值 SimpleMovingAverage因子。所以我的核心问题是,他这些因子函数只能支持他们内部的数据格式,自己载入的数据如何用他们的这些因子函数?
比方说,Quantopian bundle自己的美股数据都是这个USEquityPricing类的,每一列(似乎就是在这里定义了数据必须要OHLCV形式?比如如果自己的数据只有HL或者O,在这里改?当然了貌似这又涉及到还得自己些对应的data loader?)都是一个Column类,在这里和DataSet和CustomFactor定义的。
可是如果要是用上面double moving average的例子,比如,data.history(sym, 'close', 5, '1d').value
什么的只是长度是5的一个list。如果直接带入SimpleMovingAverage这种函数里会报错(比如少了一些他们自己data类型的成员变量,比如window_safe
之类的)。所以我主要就是想问怎么把自己的数据(panel data的或者DataFrame的)转换成他们这个因子函数能用的形式?
当然了,既然data.history(sym, 'close', 5, '1d').value
只是一个基本的list,所以实在不行可以自己重写一些函数或者使用一些能直接处理这些基本数据结构的函数(比如pandas里的或者别的包里的)。但是,要是能用他们现成的是最好的。 不知道您在load国内数据的时候遇到过这种情况么(进一步要进行一些常规的计算,用他们zipline的还是自己当成list用pandas,numpy什么的自己算)?还是说您国内的数据形式也已经是OHLCV形式的,所以直接搞成一个和他们类似的bundle,没有这种问题?
非常感谢!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.