Commit Graph

1807 Commits

Author SHA1 Message Date
Eddie Hebert 8dc3bb82e5 BLD: Update pandas to 0.12.0 2013-07-29 07:41:56 -04:00
Thomas Wiecki d054008990 BLD: Bumped version to 0.5.10. 2013-07-27 09:50:37 -04:00
jbredeche 9033043078 Merge pull request #207 from quantopian/splits_fixes
fixing some bugs with splits (ratios and empty positions)
2013-07-25 09:28:38 -07:00
Jean Bredeche 8f1d599fc6 fixing some bugs with splits (ratios and empty positions) 2013-07-24 15:26:15 -07:00
Jonathan Kamens 4c3c753680 Merge pull request #206 from quantopian/out_of_sequence_early_close
Trading calendar fixes
2013-07-24 09:57:00 -07:00
Jonathan Kamens 86682b4097 ENH: Use sort() instead of sorted() for efficiency 2013-07-24 12:43:26 -04:00
Jonathan Kamens a1a1fbf21f BUG: Don't include out-of-range date in early closes
Don't include New Year's Eve 1999 in the early closes returned to the
user if it's outside the range of dates requested by the user.
2013-07-24 12:40:28 -04:00
Jean Bredeche 6fc077a573 ENH: Add support for splits in zipline.
When a split is encountered, open positions and open orders
are updated accordingly.
2013-07-23 16:22:58 -04:00
Eddie Hebert 9ff588e7fc BUG: Fix spelling of capital base in TradingAlgorithm repr.
s/captial_base/capital_base/
2013-07-23 14:40:39 -04:00
Eddie Hebert 9b73373978 BUG: Revert returns cov to use ddof of 1.
Fix the spreadsheet to apply a factor of COUNT / COUNT - 1
to the COVAR value.

Also, go back to using the C[1][1] index instead of calculating
var independently.
2013-07-23 13:17:10 -04:00
Eddie Hebert f451efe483 TST: Read alpha values from answer key.
Corroborate alpha values with Excel answer key.
2013-07-23 12:15:24 -04:00
Eddie Hebert 7c01d39858 BUG: Fix beta calculation.
Use recent change to benchmark variance in the beta calculation,
instead of referring to the 4th quadrant of the covariance.

Also, read answers from answer key for corroboration of beta values.
2013-07-23 12:07:24 -04:00
Eddie Hebert 3164aa9016 BUG: Make covariance match values in answer key.
The np.cov call needs a ddof of 0 to match the answer key, which uses
Excel's VAR.

When switching np.cov to use a ddof of 0, the benchmark variance is
no longer the 4th quadrant of the cov result, so use np.var directly.
2013-07-23 11:30:48 -04:00
Jeremi Joslin 8e1cdac77d BUG: Fix talib sample; parameter for window length is called timeperiod 2013-07-22 10:38:04 -04:00
Eddie Hebert 2314e8a281 TST: Read benchmark variance from answer key.
Add reference to updated answer key with benchmark variance cells,
and use the new cells as the reference for the benchmark variance
test.

The values changed from the original hardcoded values, due to the
change to close over close benchmarks.
2013-07-19 20:28:12 -04:00
Eddie Hebert 56c7c840fa TST: Fix answer key index converter for values larger than 'AB'
Change logic so that it uses the 26 ^ n as the base for each letters
index value.
2013-07-19 20:26:30 -04:00
Ben McCann 2751e98d1a ENH: Add function to download 10 year treasury data to use as a benchmark 2013-07-19 19:37:24 -04:00
Ben McCann 0edd4f071e MAINT: Make the risk answer key ignored in git 2013-07-19 14:54:45 -04:00
Eddie Hebert de608b0b05 TST: Read more sharpe values from the answer key.
Recent conversion of sharpe to reading from the answer key had left
a few tests with hard coded answers.
2013-07-19 12:10:17 -04:00
Eddie Hebert 8c006fc347 TST: Use xlsx format instead of xls.
The xls conversion was corrupting some equations, so switching to
use Excel produced xlsx.
2013-07-19 11:06:37 -04:00
Eddie Hebert 135b872a58 DOC: Fix typo in xslx format name. 2013-07-18 18:36:42 -04:00
Eddie Hebert 575e45ab4e TST: Read more risk expected values from the answer spreadsheet.
Convert test_risk from hardcoded values to reading algorithm
returns, volatility, and sharpe answers from the spreadsheet.
2013-07-18 18:09:49 -04:00
Eddie Hebert d58181db34 TST: Fix case where there is no existing risk answer key.
The download checksum was not being correctly set when no file existed.
Set the checksum to the latest value so that a download is triggered.
2013-07-18 14:47:33 -04:00
Eddie Hebert d0118ff6de BLD: Fix typo in pip specification of xlrd 2013-07-18 14:44:08 -04:00
Eddie Hebert b759409525 TST: Add xlrd module to requirements_dev
THe xlrd module is used by the answer_key module to read results
from a spreadsheet.
2013-07-18 14:35:00 -04:00
Eddie Hebert 9a629d8781 Merge reading of risk unit test expected results from a spreadsheet.
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.
2013-07-18 14:31:21 -04:00
Eddie Hebert e5e38a437b TST: Download risk answer key from S3.
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.
2013-07-18 14:31:08 -04:00
Eddie Hebert 5579e54c6f TST: Read benchmark returns directly from answer key spreadsheet.
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.
2013-07-18 14:31:08 -04:00
Eddie Hebert 87c0f40aa0 TST: Move risk tests to their own module.
Will be adding the Excel spreadsheet answer key, a dedicatetd
directory for risk should help make clear why and where the spreadsheet
is used.
2013-07-18 14:31:08 -04:00
Thomas Wiecki 940ddd22d3 TST: Added testing of order timings and price. 2013-07-17 19:56:55 -04:00
Richard Frank 75dd77ea03 ENH: Added early closes to trading environment
specifically, expected 1 PM closes since 1993
2013-07-16 12:02:34 -04:00
Ben McCann efe50f8494 BUG: Fix get_benchmark_returns.
It should calculate the return off the pervious day's close, instead
of current day's open.
2013-07-15 15:35:09 -04:00
Ben McCann b9bd928862 DOC: Fix documentation compilation warnings; improve output formatting
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.
2013-07-15 14:18:07 -04:00
Eddie Hebert b7b4d397ba BUG: Revert "Merge ability to specify timing of fills."
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.
2013-07-15 10:47:55 -04:00
Jonathan Kamens 948846c254 MAINT: Upgrade pep8, pyflakes 2013-07-12 14:20:59 -04:00
Eddie Hebert 0dbdf5b1d3 BUG: Fix duplicated values for multi-stock TALib transform.
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.
2013-07-11 15:44:38 -04:00
Eddie Hebert fa845cbf03 MAINT: Move batch transform into a dedicated module.
Break the BatchTransform class and decorator function into a
separate module, with hope that it makes it easier to zero in on
batch transform logic.
2013-07-10 17:56:32 -04:00
Eddie Hebert 5758f885c5 TST: Update talib example for compatibility with multiple sids.
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.
2013-07-10 15:37:03 -04:00
Eddie Hebert eac882b773 ENH: Enable TALib transforms to perform on multiple stocks.
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.
2013-07-10 14:40:58 -04:00
Eddie Hebert 37352210c0 MAINT: Make TALib zipline_wrapper a module level function.
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.
2013-07-10 14:38:57 -04:00
Eddie Hebert 15323a8179 BUG: Enable return values on first day using minute TALib functions.
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.
2013-07-09 14:54:38 -04:00
Eddie Hebert 3dfe4e9c83 STY: Remove extra lines between statements. 2013-07-09 14:54:09 -04:00
Eddie Hebert e3a9ca27b1 Merge ability to specify timing of fills.
From PR #186
2013-07-09 13:20:16 -04:00
Eddie Hebert d901a12e93 BUG: Prevent algorithm init failure due to missing fill_delay.
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.
2013-07-09 12:45:56 -04:00
Thomas Wiecki 5a58ade0fc ENH: Add flag fill_delay kwarg to TradingAlgorithm. 2013-07-09 11:38:09 -04:00
Thomas Wiecki 8e39af906f ENH: Move blotter call to after handle_data() and add fill_delay option. 2013-07-09 11:38:09 -04:00
Eddie Hebert 3d8bdeb429 ENH: Enable minute bar data with TALib transform.
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.
2013-07-09 11:26:26 -04:00
Eddie Hebert 5fb837bf37 MAINT: Use numpy testing method instead of assertTrue.
So that when the test fails, the comparison is in a more readable
format.
2013-07-08 17:30:48 -04:00
Eddie Hebert ab0d07d8d0 API: Conform timeperiad to TALib interface instead of BatchTransform's.
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.
2013-07-03 13:46:32 -04:00
Eddie Hebert a968b5827c MAINT: Use print function instead of print statement.
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.
2013-07-02 21:33:40 -04:00