Commit Graph

1894 Commits

Author SHA1 Message Date
Eddie Hebert b44fc20e4e MAINT: Remove msgpack as a dependency.
Now that the data serialization uses pandas, msgpack is no longer
needed.
2013-10-01 14:28:11 -04:00
Thomas Wiecki a66f45b598 MAINT: Moving yahoo loader from factory to utils. 2013-10-01 14:09:26 -04:00
Eddie Hebert b65f7f42c0 BUG: Fix updating treasury curves.
A transpose back to the serialization shape was left out.

Also, fixes empty return from update.
2013-10-01 11:57:04 -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 6bbc131bbf MAINT: Compare datetime in test utils instead of integer.
Reduce dependency on date_utils, and improve legibility on failing
test.
2013-09-30 23:01:49 -04:00
Eddie Hebert bfd72355bd MAINT: Remove loader_tool
This utility was referring to functions that had been long since
removed in the loader module.

If the utility is still needed by some, it can be added back in,
but using the pandas read/write instead of msgpack.
2013-09-30 11:51:04 -04:00
Eddie Hebert 956107a846 MAINT: Use pandas instead of msgpack for benchmarks and treasuries.
Instead of writing our own serialization using msgpack, leverage
the csv serialization provided by pandas.

Also, lessens the need for msgpack and functions in date_utils.
2013-09-30 11:27:35 -04:00
Eddie Hebert 90d8570f70 MAINT: Remove debug logging about stateful transforms.
The noise outweighed the signal with logging before and after each
time the transform generator is called.
2013-09-27 15:55:35 -04:00
Eddie Hebert 052e9b6b95 MAINT: Remove extra assignment of emission rate.
Remove a doubled line in performance tracker.
2013-09-27 15:15:21 -04:00
Eddie Hebert 9dd52be73b MAINT: Split performance module into submodules.
So that when searching code for `returns` and `update`, it is
easier to discern which performance class is affected.

Should be no functional changes.
2013-09-26 13:38:27 -04:00
Eddie Hebert a29e0c40b6 MAINT: Reduce the number of minutes included in risk index.
Instead of midnight to midnight for each day, use the trading
environment's market open and close for each day, so that the index
is exactly the trading minutes of each day.

Reduces the amount of memory consumed, but more importantly should
make it easier to inspect the Series that use the index and check
whether the values are correctly being filled.
2013-09-25 16:24:01 -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 d7e670521d MAINT: Use dt in risk update method instead of last return index.
The current dt is already in scope in the update method, so use
that instead of also reading it from the algorithm_returns index.
2013-09-25 13:53:30 -04:00
Eddie Hebert fcd62d538b MAINT: Removed last_return_date from risk object.
Since we are also tracking this value with latest_dt, reading the
last_return_date from the returns is no longer needed.
2013-09-25 13:52:30 -04:00
Eddie Hebert a60d5c99a9 MAINT: Use pandas for daily treasury values in risk. 2013-09-25 13:31:01 -04:00
Eddie Hebert f9e2dd76b4 MAINT: Use pandas for sortino and information ratios.
Continue converting risk values that were stored as lists into
pandas structures.
2013-09-25 12:57:43 -04:00
Eddie Hebert 6a0c494ce0 MAINT: Use pandas for values directly derived from returns in risk.
Remove more use of lists for storing internal risk values to use
pandas structures, for easier matching of time to value.

Accordingy, convert use of -1 for getting last value,
to use current dt.
2013-09-25 12:26:56 -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 9dc126f0fb Merge pull request #220 from quantopian/minimum_price_variation
Merging branch "Minimum price variation"

Ensure limit prices conform to a minimum price variation of a penny, which works for most stocks (not, for instance, BRK). The rounding "midpoint" is custom and depends on buy/sell direction, instead of .5 of a penny.
2013-09-23 13:45:05 -07: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
Richard Frank a50fbe9289 MAINT: Some code cleanup in the blotter module 2013-09-23 14:09:59 -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
Richard Frank e4d298f3a0 MAINT: Factored out adjust_cash method in perf period
with semantics unrelated to dividends/splits
2013-09-19 14:13:50 -04:00
Eddie Hebert 6da62a5a9f MAINT: Refactor setting of indices on risk returns containers.
So that it is easier to add new containers, factor out the creation
of the index.

Also, make the returns frequency a parameter, to make the use of
different frequencies more clear from within the risk metrics object,
rather than hot swapping in the new frequency type via the now
removed `initialize_daily_indices`.
2013-09-19 12:28:41 -04:00
Eddie Hebert 84d20fd551 MAINT: Remove unused values during beta calculation.
The eigen_values, condition_number, algorithm_covariance, and
benchmark variance, which were easy to calculate alongside beta,
since they share the same inputs, but were not passed along to performance.

Remove to trim down the number of risk report members as well as
number of calcluations done.

Can add back in if there is an expressed need for eigen_values etc.,
perhaps in an 'opt-in' type configuration.
2013-09-18 15:47:25 -04:00
Eddie Hebert 4f6de61e77 MAINT: Remove unused member from cumulative risk metrics. 2013-09-18 14:17:27 -04:00
Eddie Hebert 35669ce9e2 MAINT: Remove unused created member from risk report.
Risk report doesn't need system time.
2013-09-16 20:59:22 -04:00
Eddie Hebert ddb541b9b3 MAINT: Change shape of supplemental data to match batch data.
Expect the same shape of data for the supplemental data, to make
working and preparing with the supplemental data consistent with
what is passed to the algorithm.
2013-09-16 11:51:22 -04:00
John Ricklefs 7b8769b3e7 BUG: Fix div-by-zero error in cost_basis adjustment. 2013-08-27 13:24:06 -04:00
Richard Frank a86604933e MAINT: Refactored Position.__init__ to accept starting values
Also fixed extra space in __repr__, and some other cleanup
2013-08-27 11:15:18 -04:00
John Ricklefs 191715a148 ENH: Add support for asynchronous commission events. 2013-08-26 14:18:32 -04:00
Richard Frank 57344ee78a MAINT: Call rollover from __init__ instead of duplicating code 2013-08-23 12:41:59 -04:00
Richard Frank ddb3d64526 MAINT: Record a given order only once per bar
even when there are multiple fills during that bar.
2013-08-23 12:41:59 -04:00
Eddie Hebert 9376556e68 BUG: Use dt as a max value in trading get_index.
Instead of sliding to the next trading day because of the behavior
of `searchsorted`, if dt argument is not a trading day use it as a
max value for corresponding date of the index.

Fixes a bug where if the end of the quarter is calculated with
disregard to trading days, get_index would return the first day
of the next quarter, instead of the last trading day of the intended
quarter.
2013-08-23 12:33:09 -04:00
Eddie Hebert 7d5194ec2c ENH: Include TALib output names in ta transform results.
For TALib functions like MACD that have output names, return a
DataFrame that for which the columns are the output names of the
function.

So that when using a TALib function, the algorithm doesn't need
to know the index position of the desired result, in favor of using
the name of the result.

e.g.

```
macd_result['AAPL'][0]
```

becomes,
```
macd_result['AAPL']['macd']
```

and
```
macd_result['AAPL'][1]
```

becomes,
```
macd_result['AAPL']['macdsignal']
```

Also, change return type of functions that return floats from a
dictionary to a Series, so that the function is always returning a
pandas type.
2013-08-19 16:46:11 -04:00
Eddie Hebert ee8baa2a70 MAINT: Add default import of trading of module.
So that zipline.finance.trading can be accessed after importing
zipline.
2013-08-19 15:21:48 -04:00
Eddie Hebert 16fe23b18f REL: Add license to module init file. 2013-08-19 15:19:15 -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