Commit Graph

1827 Commits

Author SHA1 Message Date
Thomas Wiecki f75d781b02 DOC: Fix talib sphinx warnings. Closes #171. 2013-08-08 10:50:00 -04:00
Eddie Hebert c31bbee424 MAINT: Create separate page in risk answer key for period returns.
Copy the `Sim` sheet to `Sim Cumulative` as well as rename it to
`Sim Period`.

Update the answer key module accordingly.
2013-08-07 17:16:01 -04:00
Eddie Hebert 5b2a23ddd0 MAINT: Break period and cumulative risk metrics into submodules.
In anticipation of changing the sharpe, beta, et al. calculations
dependent on whether the period returns or the overall returns
are being calculated.
2013-08-06 17:49:19 -04:00
Eddie Hebert 66e7f48cdd MAINT: Split apart risk metrics classes.
Also remove test that compares risk metrics batch to iterative,
since the 'iterative' calculations, replaced by the cumulative
calculations, will intentionally drift from the results in the risk
report due to annualization and other factors.

Work towards having separate calculations for the fixed periods versus
the cumulative/headline risk metrics.
Different sumbodules for each type should help make the calculations
type distinct and easier to find.
2013-08-06 17:21:34 -04:00
Eddie Hebert 4a11a872fc MAINT: Move risk to its own module.
In anticipation of splitting apart the different risk classes
into their own submodules, a distinct risk module should help
organize those new classes.
2013-08-06 17:19:43 -04:00
Jonathan Kamens 3541115b4e BUG: Trading calendar dates should always be midnight UTC
For consistency, datetimes returned by the trading calendar should
always show HHMMSS of midnight UTC. Not only is this useful for
consistency, but it also allows us to check if a particular date() is
in an array of these datetimes, because they will hash to the same
thing. For example:

early_closes = get_early_closes()
... later ...
if current_bar_datetime.date() in early_closes:
    ... today closes early ...

If if the datetimes returned by the trading calendar functions don't
have 00:00:00 for HHMMSS, then the "in" check above will fail because
the date and the datetimes in early_closes won't hash to the same
thing.
2013-08-06 15:53:41 -04:00
Jonathan Kamens 2ca4d3cff7 MAINT: Update Dev requirements
Upgrade matplotlib in Dev requirements to 1.3.0, and add tornado==3.1
and pyparsing==2.0.1 which are required by matplotlib.
2013-08-06 11:59:26 -04:00
Eddie Hebert e85306524b BUG: Prevent crashes for TALib functions when stocks have nans.
If a stock stops gettign updated values, e.g. if a stock rolls out
of a universe strategy, currently the underlying batch transform
for TALib may have nans (which is another issue that could be addressed),
the nans cause crashes when passed to some TALib function, e.g. Bollinger
Bands are incompatible with all nan values.

So, drop sids that only have nan values for the current data panel.
2013-08-05 18:17:20 -04:00
Eddie Hebert adb10d9829 BLD: Rename extra requirements to goodies.
Since these modules are not requirements, make the name more clear
about the distinction. Especiall, so that build scripts do not pick
up this file when including wildcards whit a requirements prefix.
2013-08-05 16:41:53 -04:00
Eddie Hebert cfcafa8102 BLD: Update extra requirements to latest versions.
scikits.learn was renamed to scikit-learn
2013-08-05 16:35:09 -04:00
Eddie Hebert e5a9b08abf BLD: Update nose-paremeterized to latest release. (1.3.0) 2013-08-05 13:52:58 -04:00
Eddie Hebert 73eb3f12f5 BUG: Prevent unintended keys from appearing in data bar.
The defaultdict behavior was allowing both algo code and
TradingAlgorithm wrappers to add unintended keys.

Remove use of defaultdict in favor of a dictionary that explicitly
adds the values in tradesimulation, otherwise allow a KeyError
if the bar is indexed with a sid that doesn't exist.

Also, when iterating over the keys in the data bar, only return
those keys that have pricing data.
2013-08-01 22:41:58 -04:00
Thomas Wiecki 963324723c STY: Flake8 line break. 2013-08-01 17:14:56 -04:00
Ben McCann 8dd4230fd0 ENH: Plot benchmark returns in DMA example. 2013-08-01 16:55:12 -04:00
Thomas Wiecki e1475cc24f BUG: cum_perfs defined but not used. 2013-08-01 16:33:26 -04:00
Thomas Wiecki 1635a54fb8 ENH: Add print of monthly Sharpe to DMA example. 2013-08-01 16:09:38 -04:00
Thomas Wiecki 37bab9bb72 ENH: Safe risk_report in TradingAlgorthm. 2013-08-01 16:08:56 -04:00
Eddie Hebert 376ae33264 PERF: Remove deepcopy from EventWindow ticks.
The deepcopy of events into the EventWindow's ticks was causing
a significant increase in memory consumption, e.g. an algorithm with
almost 200 sids and 14 vwaps removing the deepcopy reduces the amount
of memory consumed by about 40%.

The downside is that if an event's properties are changed, which is
not advised, later on, then the signal derived from vwap etc.
may be changed.
2013-07-31 18:55:07 -04:00
Eddie Hebert 7139ac7061 TST: Update answer key spreadsheet.
Point tests at version of answer key with explicit use of sample
vs. population for covariance and variance via, `COVARIANCE.S` and
`VAR.S`
2013-07-29 14:47:31 -04:00
Eddie Hebert 3c305bbe35 TST: Add script to automate upload of risk answer sheet to S3.
For maintainer use, requires AWS credentials for the account where
the `zipline-test-data` bucket is hosted.

Script does the following steps which used to be manual:
- Create a key name based on the md5 of the answer key file.
- Upload the answer key to S3 bucket.
- Make the file publically downloadable over HTTP.
2013-07-29 14:42:53 -04:00
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