To help tentpole the risk results with an alternative implementation.
Also, the spreadsheet provided is what the original answers were based
from, reading from said spreadsheet should help prevent drift.
So that the answer key does not onerous on the SCM repo size, add a
utility to download the answer key automatically.
Prevent re-download on every test suite run if the local answer key
matches the latest version.
The risk tests originally were based on a spread sheet, with the
results of returns etc copy and pasted into the `test_risk` module.
Include the spreadsheet and read the values directly using a Python
Excel spreadsheet library.
Fix warnings when compiling the docs.
Removes the documentation of the default types, which already gets
included automatically and was wrong because not kept in sync with the
function signature.
Changed, the formatting to the Sphinx formatting.
This looks much better in the compiled documents, but does make the
source a bit harder to read.
This reverts commit e3a9ca27b1, reversing
changes made to 3d8bdeb429.
Conflicts:
zipline/gens/tradesimulation.py
The aforementioned change needs a revert because it caused a 'doubling'
of orders, since the portfolio is not updated until after handle_data
is called a second time after an order has been processed.
The flexibility of fill_delay is still desired, but remove for now,
favoring reverting back to existing behavior over trying ot fix the
fill_delay logic.
A multi-stock TALib transform was returning the same value for
all stocks, specifically the value for the first stock in the panel.
Index into the datapanel using `sid` instead of using the `[0:]`
index which was used when only supporting one sid.
To support mulitple sids the TALib transforms now return a dict,
instead of a float. Accordingly, the TALib example script now needs
to index into the transform result.
The TALib transform only supported operating on the first value
of a given batch transform panel row.
Instead of returning the one value, even if an panel with multiple
sids was provided, return a dictionary that maps stock to TALib
result.
Prepare for making the zipline_wrapper operate on multiple sids,
as the needed nested logic will get cramped within the nested function.
Also, should help clearly define the inputs of the zipline_wrapper
function that are needed before it is passed to the BatchTransform
constructor.
Set the `compute_only_full` to False so that the 'is window full' logic
is delegated to the TALib's lookback function.
If the window is not full to the `timeperiod` or other lookback setting,
then TALib returns a `np.nan`.
Also, fix the bars/data_frequency not being passed to the BatchTransform
init.
This further shows need to create a minute test for TALib transforms.
Provide a default value for data_frequency, choosing 'daily',
so that the fill_delay is set even when a data_frequency value
is not in kwargs.
This does open up a place for disjointedness if the sim_params that
is passed to run does not match the data_frequency set during initialize.
Add a `bars` keyword arg, as is used with BatchTransform.
Also, instead of overwriting the window_length kwarg with timeperiod,
always use the lookback value from the created TALib function,
as timeperiod will be an input into that value if it exists.
Calculate `window_length` in minute mode so that there are enough
days to cover the minutes in the timeperiod.
For the creation of a TALib transform use timeperiod intsead of
window_length, to be more in the style of TALib usage, since all
TALib functions may not ending up using BatchTransform, so start
the practice of adhering to TALib conventions to make porting and
explanation easier.
The loader module printed some warning messages, these could
be changed to use a logger, but for now convert to use the print
function for compatibility with Python 3.
Python 3 requires using dot syntax for relative imports,
otherwise the import is treated as an absolute import, i.e.
an import of a module from outside of the project.
By using dot syntax now, imports should be compatible with both
Python 2.7 and Python 3.
Looking forwards to Python 3 capability, maintaing code that uses
iterkeys would require some overhead of checking what Python version
is available etc., instead use a DatetimeIndex so there is no need
to use key iterators, reverse, etc. on an OrderedDict, as the
DatetimeIndex allows 0 and -1 index, as well as the needed fast `in`
functionality.
This VagrantFile will, on "vagrant up"...
- Create a simple, minimal Precise Pangolin (12.04) Ubuntu 64 bit VM
- Customize the VM with 2 virtual CPU's and 2048MB of RAM
- Configure SSH for passwordless access (from the command-line)
- Add the required packages from the Ubuntu repo to support zipline
- Add (and compile) ta-lib
- Add the required Pip packages
When Vagrant is done, you can start hacking on zipline with:
vagrant ssh
cd /vagrant
python {some python script that uses zipline}
In the spirit of making this a disposable dev environment install
everything in site-packages.
"nosetests" and "examples/dual_moving_average.py" both succeed
after the configuration finishes.
The "use_environment" decorator is too side-effectful (e.g.,
connecting to Yahoo! Finance or another data source) to be used as a
decorator to a function that gets evaluated during module load. This
causes problems, e.g., if Zipline is being used in a gevent
environment, when the trading environment created by the decorator
argument tries to use greenlets when gevent hasn't been fully
initialized.
Since the decorator is nothing more than a context-manager wrapper,
this commit removes the decorator and replaces its use with contexts,
i.e., "with" statements.
Raise exceptions when the slippage model returns transactions
that are non-sensical, i.e. those with zero volume, buy transactions
when the order is a sell (and vice-versa), and transactions that are
for a larger amount than the corresponding order.
TODO: After adding a unit test suite that covers just the blotter,
add tests that exercise this logic to that suite.
Instead of searching through the open orders to find the ones
that match the current transactions, now that simulate returns
the pair of transaction and order for which that transaction
was created for, that order can be used where we previously
searched for a modified order.
This should be a runtime improvement since, but not yet verified
via thorough profiling.
The TALib related tests randomly fail, skip for now, as it causes
noise when developing against the latest versions of the codebase.
Should remove skips when TALib is closer to being fully supported.