Commit Graph

1217 Commits

Author SHA1 Message Date
Ana Ruelas 9063cb3ce4 BUG: Do not adjust returns for sharpe and sortino 2016-09-02 10:41:50 -04:00
Eddie Hebert 22dead208a Merge pull request #1460 from quantopian/daily-aggregator-corner-cases
TST/BUG: Full coverage on resample module.
2016-09-01 17:24:56 -04:00
Eddie Hebert 5e3b949fc6 TST/BUG: Full coverage on resample module.
test_resample now fully covers the resample module.

Fix a bug exposed by increased coverage, where daily aggregation on
`high` would return `nan` for an asset instead of 1) during the
course of day `1d` history was called on non-consecutive minutes and 2)
either, a) the value for the previously inspected dt was `nan` or b)
there were only `nan`s between the previous and current dt.

`low` had a similar bug which was only triggered if the value for the
previously inspected dt was `nan`.
2016-09-01 16:41:45 -04:00
John Ricklefs 311284475a ENH: Allow passing additional adjustments to calculate_capital_changes
If subclasses have additional capital change information that
is required to correctly calculate the target values for
cash capital changes, it can now be provided via
"portfolio_value_adjustment".
2016-09-01 16:04:46 -04:00
John Ricklefs 5b1aa5ec55 BUG: Capital change deltas rely on cash, not portfolio_value
The value of holdings is irrelevant when altering the
capital base of the current perf period.
2016-09-01 15:19:55 -04:00
Eddie Hebert d463a9855b TST/BUG: Cover all reindex session public methods.
Increase coverage on `ReindexSessionBarReader` so that all methods which
are considered part of the interface are covered by `test_resample`.

Fix bug in `get_value`, exposed by increased coverage, where the
`NoDataOnDate` exception was bubbling from the bcolz reader all the way
up when a session which was a holidy on the underlying reader was passed
to the reindex reader. (The reindex reader should return nan/0 in that
case.)

Also, move location of data index exceptions so that they are agnostic
to bcolz/us_equity_pricing; since the exception is now used by the
resample module to fix aforementioned bug.
2016-09-01 11:51:00 -04:00
Jean Bredeche fbd3774278 ENH: Update can_trade to check exchange time
BarData now takes the trading calendar as a parameter.

can_trade now checks if the asset’s exchange is open at the current or
next market minute (defined by the given trading calendar).
2016-08-31 21:22:06 -04:00
Eddie Hebert 6c805b013a Merge pull request #1457 from quantopian/allow-last-date-for-session-get-last-traded-dt
TST: Fix get_last_traded_dt on bcolz daily reader.
2016-08-31 15:53:36 -04:00
Eddie Hebert 151c3e45a7 TST: Fix get_last_traded_dt on bcolz daily reader.
Remove special handling for the last session of an asset, which was
moving the last traded back a session.

If the asset has data on a session, `get_last_traded_dt` should always
return that session if it is the parameter to the method.
2016-08-31 14:59:58 -04:00
Jean Bredeche 38ff7e5aa7 ENH: Simplified implementation of FutureChain object (not user-facing API).
No longer auto-updates its internal as-of date, instead requires an explicit
as-of date from the consumer.

Take a static list of contracts (instead of needing an assetfinder).

Instead of the as_of method, the user-facing API now lets you pass in an
offset, which is defined as an integral number of sessions.
2016-08-31 14:44:02 -04:00
Eddie Hebert 34b113f228 Merge pull request #1452 from quantopian/begin-cover-reindex-resample
TST: Increase coverage for  reindex reader methods
2016-08-31 10:31:14 -04:00
Eddie Hebert 0cba47e29f TST: Increase coverage for reindex reader methods
Add direct coverage on last_available_dt.

Also move reader creation into the instance fixture.

This patch attempted to add coverage on `get_last_traded_dt`, but in doing
so, revealed a bug in `BcolzDailyBarReader.get_last_traded_dt` when
requesting the last trading session of an asset.
When that is fixed, the skip can be removed.
2016-08-30 16:43:58 -04:00
Ana Ruelas f669602581 BLD: Update to empyrical 0.1.11 2016-08-30 16:41:57 -04:00
Jean Bredeche 7fe1a56730 Merge pull request #1442 from quantopian/schedule-all-the-hours
ENH: Let event offsets be up to 12 hours.
2016-08-30 16:34:23 -04:00
Eddie Hebert 1984d13c2f Merge pull request #1446 from quantopian/use-us-futures-in-test-resample
TST: Use futures cal in resample suite.
2016-08-30 10:24:18 -04:00
John Ricklefs 8b11358e46 Merge pull request #1437 from quantopian/empyrical_perf
PERF: Reduce calculations performed by empyrical
2016-08-29 16:20:41 -04:00
Eddie Hebert 9db385bb75 TST: Use futures cal in resample suite.
Instead of CME, use the futures cal, which should now be the standard
calendar throughout; though some tests remain to be ported.
2016-08-29 15:43:39 -04:00
Ana Ruelas 20b4d007f7 TST: Rebuild example data due to changes in beta calculation 2016-08-29 15:11:37 -04:00
Eddie Hebert 3c7dae8c41 TST: Cover resample bar first_trading_day method.
Add a test to directly cover the first_trading_day method via the
`test_resample` suite. (The lack of coverage was exposed when testing
against real data.)

Also, refactor resample bar tests so that session bar reader is set up
in instance fixture.
2016-08-29 15:00:08 -04:00
Jean Bredeche 749c2eea33 ENH: Let event offsets be up to 12 hours. 2016-08-29 09:33:40 -04:00
Jean Bredeche 7b83cbe820 ENH: Add new parameter to schedule_function that accepts a trading
calendar.
2016-08-28 21:33:42 -04:00
Eddie Hebert 40c7deb697 ENH: Add asset dispatch to data portal.
Combine the equity and future readers into asset dispatch readers, so
that simulations that use both asset types can access data for each.

This patch enables `history` for future assets in algorithms; however,
it does not add extra coverage in the `test_data_portal` or `test_history`
to cover future assets. Those tests will follow, however putting this in
separately since it shows that the wrapping of the readers in the asset
dispatch reader does not break existing equity strategies.
2016-08-26 13:29:08 -04:00
Eddie Hebert 0f604686b6 MAINT: Add a reader which dispatches on asset type
Add `AssetDispatchSessionBarReader` and corresponding minute and session
bar version of that reader.
This reader routes requests to the appropriate reader based on the asset
type of the requested sids.

`load_raw_array` in the dispatch reader batches the sid by asset type
and then interleaves the results in the out arrays, so that the arrays
data corresponds with sids in the order that sids are passed to the
method, to meet the expected behavior of `load_raw_arrays`.

The dispatch redaer is intended for use by the data portal when using
both future and equities. The dispatch reader will also be passed to the
to the `HistoryLoader`s contained within the data portal, where the
batched `load_raw_arrays` will be used.

Also, BUG:
- Fix the return of `MinuteResampleSessionBarReader.load_raw_arrays` to
match all other readers.
- Use the input dt for the `MinuteResampleSessionBarReader.load_raw_arrays`
as a session label, instead of a minute dt, since it is a session bar
reader.
(Both of these bugs where discovered when using the resample reader for
future data in the dispatch tests.)
2016-08-25 16:29:45 -04:00
Eddie Hebert 67112e0e11 Merge pull request #1432 from quantopian/reindex-reader
ENH: Add a reader base which reindexes results.
2016-08-25 09:34:06 -04:00
Eddie Hebert 562098dbf8 ENH: Add a reader base which reindexes results.
Working towards history results which contain mixed asset types, add
a reader which makes `load_raw_arrays` return results indexed on the
session/minute ranges specified by the specified `trading_calendar`
instead of the calendar of the backing reader.

This reader will be used to make Equity readers align with Future
readers. It is intended for use as part of another reader (which will
dispatch queries based on asset type and then recombined results) which
will be passed to the `[Minute|Session]HistoryLoaders in the data portal.
2016-08-24 16:28:19 -04:00
Richard Frank 3493723e7b DEV: zipline ingest can downgrade the assets db
This lets us publish an "old" db version for the most recent release
of zipline, using the latest code base.
2016-08-24 15:32:30 -04:00
Richard Frank 67dbeab820 MAINT: Clean up usage of engine versus connection 2016-08-24 13:24:07 -04:00
Eddie Hebert 71a34bf7ac MAINT: Standardize reader get value methods.
The daily/session bar reader's `spot_price` took the same parameters and
returned the same kind of output as the minute bar reader's `get_value`.

Standardize on one method to make a common interface, which may be
formally factored out in a later patch; to help enable writing reader
implementations or mixins which can be agnostic to the bar frequency.
2016-08-24 12:46:36 -04:00
Ana Ruelas eba78aec1b Merge pull request #1322 from quantopian/move_risk_calculations
Move risk calculations
2016-08-23 18:39:22 -04:00
Ana Ruelas 7f042476be TST: Rebuilt example data using empyrical 2016-08-23 13:49:48 -04:00
Ana Ruelas f57fe0a4b0 TST: Update to empyrical, increase test coverage
ENH: Resolve rebase conflict by using updated example_data.tar

TST: Increase test coverage for risk portion of zipline
2016-08-23 13:49:43 -04:00
Ana Ruelas 57d1bb82c4 ENH: Use qrisk to calculate risk metrics in cumulative and period
TST: Remove metric correctness testing from period and cumulative tests

ENH: Removed answer key and related files

ENH: Update qrisk version
2016-08-23 13:49:27 -04:00
Andrew Daniels a8f2b704a2 BUG: Fixes BcolzMinuteBarMetadata to read the version correctly (#1425)
We were mistakenly using the minute_per_day field.

We now expose from the metadata object the version from which the
metadata was read. This allows a new test that verifies the version is
read correctly.
2016-08-22 17:45:07 -04:00
Jean Bredeche ddb1009c25 Merge pull request #1407 from quantopian/minute_panel_daily_history
ENH: Add fast "vectorized" `minute_to_session_label` for DatetimeIndex
2016-08-22 10:27:40 -04:00
Richard Frank 9fccb7354e BUG: Fix and test getting all default calendars 2016-08-21 17:19:59 -04:00
Eddie Hebert 6c9e1e5bd5 Merge pull request #1413 from quantopian/normalize-equity-future-in-data-portal
MAINT: Remove future/equity distinction.
2016-08-18 23:50:36 -04:00
Nathan Wolfe d34c4d28b6 ENH: Add fast "vectorized" minute_to_session_label for DatetimeIndex
The new TradingCalendar method is called `minute_index_to_session_labels`.
It takes a DatetimeIndex of in-order market minutes and returns a
DatetimeIndex of the corresponding sessions.

The new method is approximately 100x faster than mapping
`minute_to_session_label` over a large DatetimeIndex.
2016-08-18 17:27:47 -04:00
Eddie Hebert db6fd73b39 MAINT: Remove future/equity distinction.
In the data portal, remove methods that make a distinction between
future and equity asset type. Instead rely on the pricing reader
dispatching.

In support of incoming work which will upsample equity history arrays to
the larger future calendar.

Also, remove perf tracker tests which were using an equity
reader/writer, to be added back in later.
2016-08-18 16:18:32 -04:00
Andrew Daniels 37e6a48e99 ENH: Pass calendar instance to BcolzMinuteBarWriter (#1406)
* First pass.

* Improvements and fixes

- Update usages of BcolzMinuteBarWriter
- Updates with rebuilt example data
- Expose calendar from BcolzMinuteBarMetadata instead of calendar_name
- Keep market_opens and market_closes in metadata for compatibility

* Store start_session and end_session in minute bcolz metadata

- start_session replaces first_trading_day
- Add end_session to limit to correct days

* For last_available_dt, get last close from calendar to maintain tz

* Bumps version and handles earlier versionson read

* Rebuilt example data on python 3

* Indicate metadata fields that are deprecated
2016-08-18 15:41:26 -04:00
Eddie Hebert f8ff0b3645 Merge pull request #1405 from quantopian/resample-session-from-minute
ENH: Session bar reader resampled from minute data
2016-08-18 13:26:24 -04:00
Scott Sanderson acd5ef0e1c Merge pull request #1394 from quantopian/downsample
Add Generic Downsampling to Pipeline
2016-08-18 12:15:54 -04:00
Eddie Hebert 4a017ef63b ENH: Session bar reader resampled from minute data
Implement a `SessionBarReader` which uses a minute bar reader as a
backing source, resampling the minute bars into the box around the
corresponding session data.

Also, add future/CME test cases to resample suite.
2016-08-18 11:37:42 -04:00
Scott Sanderson 5a5353bead BUG: Fix broken graph visualizations. 2016-08-18 11:07:17 -04:00
Scott Sanderson 8cc8814b5f BUG: Fix nondeterministic failure from sorting. 2016-08-17 19:48:33 -04:00
Richard Frank fcf1067071 BUG: Fixes should_clean for keep_last=0 2016-08-17 18:18:01 -04:00
Scott Sanderson 659ba57d4b BUG: Force iterator for py3. 2016-08-17 16:52:09 -04:00
Scott Sanderson d82e38e73b BUG/TEST: Fix test assertion in py3. 2016-08-17 16:52:09 -04:00
Scott Sanderson 19963f5b02 MAINT: Clean up downsampling boilerplate.
Consolidate docs and mixin applications into one place.
2016-08-17 16:52:09 -04:00
Scott Sanderson 20e48cf826 ENH: Add non-windowed downsampling. 2016-08-17 16:52:09 -04:00
Scott Sanderson 221ec2073f STY: Flake8 cleanup. 2016-08-17 16:52:09 -04:00