Commit Graph

391 Commits

Author SHA1 Message Date
Eddie Hebert 20e0ad191b TST: Disable test covering London stock exchange.
Changes to trading calendar and environments for supporting market
minutes, etc. have made the non-NYSE stock exchange support lag.

Disabling the test, with the intent of bringing support back up to
parity with NYSE.
2013-11-12 12:12:35 -05:00
Eddie Hebert 4d11ca131e TST: Use Timestamp instead of Delorean for trading calendar test.
Removes another use of Delorean in favor of Timestamp 'today'.
2013-11-11 10:38:04 -05:00
Richard Frank 2492feb938 ENH: Keep track of total commissions as attribute on Order
Value is summed from TRANSACTION and COMMISSION events.
Defaults to None, meaning unset.
2013-11-01 17:23:50 -04:00
Eddie Hebert a192ba01a2 STY: Used named args in hardcoded test objects.
Instead of unrolling a dictionary, use named args.
2013-11-01 15:28:35 -04:00
Jonathan Kamens 73faf9133e MAINT: Clean up imports of zipline.finance.trading
Use "from zipline.finance import trading" instead of "import
zipline.finance.trading as trading".
2013-10-29 13:50:14 -04:00
Eddie Hebert 32c1f93572 TST: Updates tests to fit fixed stop behavior.
Change the answers to the stop order tests to match the corrected
behavior, where results are opposite from previous behavior.
2013-10-28 20:40:32 -04:00
Eddie Hebert 0c71f95016 TST: Parameterize stop order test.
So that we can more clearly demarcate each case of buy/sell and
price compared to stop, and their expected outputs.

Also, add comment about the current behavior versus the behavior
that will be moved to in an upcoming fix.
2013-10-28 15:12:29 -04:00
Eddie Hebert 37c56b9aa4 MAINT: Use Series throughout for daily returns.
Remove the lists of DailyReturn objects in favor of using pd.Series
to store the return values.

Should make it easier to inspect the values when stepping through,
make the windowing of data to a certain range more facile by using,
and have some performance increases due to removing object creation
and member access.
2013-10-19 23:06:18 -04:00
Eddie Hebert 37e1e74391 TST: Add logging of sim params for perf tracker tests.
These tests use the random simulation parameters, which is leading
to an intermittent failure.

We may want to consider removing the randomness, but in the meantime
the randomness is exposing a case where the cost basis is not the value
expected, so logging the sim parameter values to help track down what
parameters cause the failure.
2013-10-16 12:07:14 -04:00
John Ricklefs 9ac180d4bb BUG: Ensure compounded_log_returns set on first dt. 2013-10-11 13:06:11 -04:00
Eddie Hebert 1bad245675 ENH: Use annualized returns for beta and alpha.
So that the units match the other risk calculations, also
use annualized returns for beat and alpha.

Update answer key to match values calculated on the first day.

Also, update performance tracker test so that the returns used
are fractional instead of > 1, so that the annualized numbers are
more in line with real world values.
2013-10-11 00:27:03 -04:00
Eddie Hebert dad34d2ddb TST: Add annualized alpha and beta to answer key.
Add a column that uses annualized mean returns as the inputs into
alpha and beta.
2013-10-11 00:27:03 -04:00
Eddie Hebert dcae6af67b ENH: Annualize information ratio.
Use annualized values for information, so that it is calculated
using the same units as sharpe, etc.
2013-10-11 00:27:03 -04:00
Eddie Hebert 0ebdb2fe77 ENH: Annualize sortino ratio.
Use annualized values for sortino, so that it is calculated using the
same units as sharpe, etc.
2013-10-11 00:27:03 -04:00
Eddie Hebert 1afc9069b1 TST: Update answer key with annualized sortino and information.
Include in the Excel answer sheet the sortino and information
metrics using annualized inputs.
2013-10-10 18:37:53 -04:00
Eddie Hebert bfa94e9c91 ENH: Approximate stats for the first day of minute emission.
Volatility needs mulitple values to calculate the stddev,
so provide a day with zero returns to base the first day against.
2013-10-10 18:37:53 -04:00
Eddie Hebert 433f97c38f ENH: Improve headline Sharpe risk calculations.
This could perhaps be labelled BUG, as well.

Change the Sharpe (and algorithm volatiilty) value used to compare
algorithms/backtests so that it is annualized and uses daily returns.

Previously, the Sharpe metric was using the same calculation style
as the fixed size periods, i.e. 3 Month, 6 Month, etc., which can
use the geometric mean when comparing against the risk free.

Change the Sharpe calculation to use the arithmetic mean differenc
against the risk free rate, using daily (non-compounded) values.

Also, use annualized mean returns.
2013-10-10 18:37:53 -04:00
Thomas Wiecki 65637b9430 ENH: Add option of instantly filling orders. 2013-10-01 20:30:01 -04:00
Eddie Hebert df7b9c0273 MAINT: Remove date_utils module.
Most of the functions in date_utils can be done via pandas.
The other functions are no longer used for loading, etc. so remove
the date_utils module to reduce the total surface area of Zipline core.
2013-09-30 23:30:07 -04:00
Eddie Hebert b928cbe0d0 TST: Move minute frequency risk test into risk test module. 2013-09-25 15:09:20 -04:00
Eddie Hebert cd3a63415c MAINT: Use pandas for volatility in risk metrics.
Continue on path of converting values stored inside of risk metrics
to use a DataFrame instead of storing multiple lists.

Also, the need for latest_dt in getting the current volatility for
the sharpe calculation, shows that we need to set the lastest_dt at
the beginning of the update loop.
2013-09-25 11:25:57 -04:00
Eddie Hebert 08bc42dc0c TST: Fix index to cumulative risk answer key.
Indexes to risk answers were pointing to a previous version.

Also, provide the risk cumulative answers as a pd.Series,
so that it is easier to compare to values produced by risk class.
2013-09-24 21:36:57 -04:00
Richard Frank 599ff1ad8a MAINT: Ensure the sign of the result is positive 2013-09-23 16:12:17 -04:00
Richard Frank b4836b976e ENH: Restrict limit prices to a penny precision
to account for minimum price variation.

On an order to buy, between .05 below to .95 above a penny, use that penny.
On an order to sell, between .05 above to .95 below a penny, use that penny.
2013-09-23 16:12:17 -04:00
Eddie Hebert 70bcfff289 MAINT: Use DataFrame for more risk metrics.
Use metrics DataFrame for alpha, beta, as previously with sharpe.
2013-09-19 21:55:28 -04:00
Eddie Hebert 29a80c2f98 MAINT: Store sharpe values in a DataFrame instead of list.
Eventually, all cumulative metrics, (alpha, beta, etc.) will be
stored in the same DataFrame

For easier tracking of dt to values during debugging, but should be
some performance gains as well.
2013-09-19 21:55:28 -04:00
John Ricklefs 7b8769b3e7 BUG: Fix div-by-zero error in cost_basis adjustment. 2013-08-27 13:24:06 -04:00
John Ricklefs 191715a148 ENH: Add support for asynchronous commission events. 2013-08-26 14:18:32 -04:00
Eddie Hebert 11f9178fd3 TST: Correct annualization of Sharpe in answer key.
Correct the annualization factor from being 1/sqrt(252), since
the annualization was applied to the volatility, by including
252 in the Sharpe's numerator.
2013-08-16 14:26:59 -04:00
Eddie Hebert b9dfda01d2 DOC: Add annotations file for answer key.
Currently, just provide a way to render to some of the data extracted.
Intended to have more thorough documentation of the spreadsheet,
explaining derivation/calculations in each sheet and column.
2013-08-15 15:09:46 -04:00
Eddie Hebert b94d10cfb6 TST: Add answer key indexes for cumulative risk metrics.
Add indexes for Sharpe, returns and other values needed for
reading answers for cumulative risk metrics.

Prepare for unit test and matching change of implementation.
2013-08-15 15:09:44 -04:00
Eddie Hebert f3fd9d598a TST: Add parser for date values from answer key.
Refactor the reading of values from the Excel spreadsheet so that
parsers are configurable by index.

Needed so that we can parse columns that have dates, in addition
to floats as previously.
2013-08-15 15:08:42 -04:00
Eddie Hebert 3732c105b8 TST: Improve answer key interface.
Instead of using the indexes defined in the answer key class
to index back into the answer key object, populate the answers
so that they are available as members of the answer key object.

Update period risk test to use new answer key structure.

Also, remove the rounding behavior from the answer sheet, leaving
the rounding to the consumer of the answer key values, so that
the values can be retrieved from the spreadsheet during answer
key __init__ without knowledge of the decimal point that the calling
code expects.
Correspondingly, change period risk tests to use
np.testing.assert_almost_equal when doing floating point comparison.
2013-08-14 22:41:52 -04:00
Eddie Hebert de4671213b TST: Reduce cumulative risk test to stub.
Remove tests that were a copy of period risk behavior, to prepare
for adding cumulative risk specific tests.
2013-08-14 22:35:57 -04:00
Eddie Hebert ddcddc9351 MAINT: Create separate test risk modules.
As these modules diverge, the tests for each module should
distinguish those changes.
2013-08-14 15:09:01 -04:00
Eddie Hebert 1501e659ce TST: Rename notebook with link to answer key.
Move to a new notebook, the AnswerKeyLink will be for a permalink
to the current version of the answer key, of which the output
won't be too noisy in git.

The annotation notebook will also be kept in source control, but
without output, since the table html output is large.
2013-08-14 14:47:19 -04:00
Eddie Hebert 6f73f68d24 TST: Add output of answer key annotations to notebook.
For more improved viewing experience via nbviewer.ipyhton.org,
include the output of the notebook.

When saving/updating this file, a fresh kernel and evaluation of
the entire notebook should be used so that the cell numbers stay
in order.
2013-08-14 13:12:50 -04:00
Eddie Hebert ead9fc953f TST: Begin annotation notebook for risk answer key.
Read tests.risk.answer_key module into an IPython notebook, to start
a base to which answer key values and explanations can be added and
display without access to Excel.

For now, the notebook just provides the latest download link for
the spreadsheet.
2013-08-14 12:36:47 -04:00
Eddie Hebert bb8a734ae2 TST: Improve cumulative risk metrics sheet in answer key.
Update answer key for cumulative risk:
- Annualization of Sharpe
- Use 10 year period
- Use of daily returns vectors instead of compounded return scalar.

No tests or risk module code are currently reading off of this sheet,
but developing it ahead of work in risk module so that the sheet can
be examined and vetted.
2013-08-14 11:34:48 -04:00
Eddie Hebert cbac1bd6cb TST: Update answer key checksums on upload.
Automate the updating of the answer key when a new key is uploaded
to S3, so that keeping the latest value in sync is more likely.
2013-08-14 11:30:15 -04:00
Eddie Hebert faee91876f MAINT: Add formatting for printing of answer key DataIndex.
Output format of the range compatible with Excel, so that it
can be copy and pasted back into the spread sheet for easier
corroboration.
2013-08-09 17:32:17 -04:00
Thomas Wiecki b89886297f STY: autopep8 codebase. 2013-08-08 16:46:44 -04:00
Thomas Wiecki e590da75fb BUG: Typo in test_batchtransfom. 2013-08-08 16:01:22 -04:00
Thomas Wiecki b1fdebfb7c TST: Added tests for new order methods. 2013-08-08 15:55:08 -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 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 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
Jean Bredeche 8f1d599fc6 fixing some bugs with splits (ratios and empty positions) 2013-07-24 15:26:15 -07: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