Commit Graph

1204 Commits

Author SHA1 Message Date
Jean Bredeche e574b7b042 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 624b4659f1 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 674a6200b4 Merge pull request #1437 from quantopian/empyrical_perf
PERF: Reduce calculations performed by empyrical
2016-08-29 16:20:41 -04:00
Eddie Hebert bce159f275 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 c984cdb247 TST: Rebuild example data due to changes in beta calculation 2016-08-29 15:11:37 -04:00
Eddie Hebert 7146edbe7d 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 e0cdc7bc3a ENH: Let event offsets be up to 12 hours. 2016-08-29 09:33:40 -04:00
Jean Bredeche 0cc08d79b4 ENH: Add new parameter to schedule_function that accepts a trading
calendar.
2016-08-28 21:33:42 -04:00
Eddie Hebert a4131ea84b 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 413ea3d9d5 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 0dd01650f1 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 fc8cf38a6e 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 419bd1e3b5 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 6d473ce23f MAINT: Clean up usage of engine versus connection 2016-08-24 13:24:07 -04:00
Eddie Hebert a3c1f4ce36 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 20f9241252 Merge pull request #1322 from quantopian/move_risk_calculations
Move risk calculations
2016-08-23 18:39:22 -04:00
Ana Ruelas a4638026c7 TST: Rebuilt example data using empyrical 2016-08-23 13:49:48 -04:00
Ana Ruelas f0af856c13 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 902865cf71 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 193b657bfe 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 2b5ae892f8 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 09bd2abe2f BUG: Fix and test getting all default calendars 2016-08-21 17:19:59 -04:00
Eddie Hebert 653865b34c 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 4865ade9b2 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 e3bd7e43be 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 53ca68e8fb 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 c482a7cd59 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 1c0d407357 Merge pull request #1394 from quantopian/downsample
Add Generic Downsampling to Pipeline
2016-08-18 12:15:54 -04:00
Eddie Hebert f14fcd9b07 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 bdc72ec4c0 BUG: Fix broken graph visualizations. 2016-08-18 11:07:17 -04:00
Scott Sanderson 0f5784ab53 BUG: Fix nondeterministic failure from sorting. 2016-08-17 19:48:33 -04:00
Richard Frank cbcb71bbad BUG: Fixes should_clean for keep_last=0 2016-08-17 18:18:01 -04:00
Scott Sanderson c53ef150ad BUG: Force iterator for py3. 2016-08-17 16:52:09 -04:00
Scott Sanderson a66731b9f3 BUG/TEST: Fix test assertion in py3. 2016-08-17 16:52:09 -04:00
Scott Sanderson 115f055c83 MAINT: Clean up downsampling boilerplate.
Consolidate docs and mixin applications into one place.
2016-08-17 16:52:09 -04:00
Scott Sanderson d917a64d45 ENH: Add non-windowed downsampling. 2016-08-17 16:52:09 -04:00
Scott Sanderson 5f686173f1 STY: Flake8 cleanup. 2016-08-17 16:52:09 -04:00
Scott Sanderson 91276c7274 ENH: Add support for downsampling.
Adds a new ``downsample`` method to all computable terms.  Computable
terms (Filters, Factors, and Classifiers) can be downsampled to yearly,
quarterly, monthly, or weekly frequency.

The result of ``term.downsample`` is a new term of the same
family (Filter/Factor/Classifier) as ``term``.  The downsampled term
computes by delegating to the original term; repeatedly calling its
``compute`` method with length-1 date ranges.

Downsampled terms take advantage of a new ``compute_extra_rows`` Term
method, which allows terms to dynamically request that additional extra
rows of themselves be computed based on the dates for which they're
being computed.  This ensures, for example, that a monthly-downsampled
term always computes at the start of a month, even when a
naively-calculated pipeline window would end in the middle of the month.
2016-08-17 16:52:09 -04:00
Scott Sanderson 1e7b566ed7 MAINT: Add nearest_unequal_elements.. 2016-08-17 16:52:09 -04:00
Scott Sanderson 1444a78330 MAINT: Refactor in prep for downsampled terms.
- Split out extra_rows handling into an `ExecutionPlan` subclass.
  `ExecutionPlan` now requires the dates and calendar against which a
  set of terms will be computed, and now defers to a term's
  `compute_extra_rows` method when deciding how many extra rows are
  required to compute for that term. This will allow downsampled terms
  to request enough extra rows to guarantee that we can maintain consistent
  calculation dates.

  As a consequence of the above, `TermGraph` now only deals with logical
  dependencies, not with metadata surrounding extra row calculations.
  This means that TermGraph can be used to generate dependency
  visualizations in interactive contexts where we don't yet have a
  calendar or start/end dates.

- Refactored test_{filter,factor,classifier} to use check_terms instead
  of run_graph.  This makes it easier to make changes to TermGraph,
  since the testing interface is now to simply provide a dict of terms.

- Refactored BasePipelineTestCase to use fixtures to create an asset
  finder.  This fixes a potential leak of the test's asset db, which was
  not being explicitly cleaned up.

- Refactored test_technical to use BasePipelineTestCase.

- Added a new special term, `InputDates()`, which can be used to request
  date labels for inputs.  Like `AssetExists`, `InputDates` is provided
  in the initial workspace by default.

- Added a default (failing) `_compute` method to `AssetExists` which
  provides a more useful error than AttributeError.
2016-08-17 16:52:09 -04:00
Scott Sanderson 765f9b6d57 MAINT: Improve/test errors for insufficient data. 2016-08-17 16:52:09 -04:00
Andrew Daniels 08a03edad7 MAINT: Use TradingCalendar objects for bundles (#1397)
* MAINT: Use TradingCalendar objects for bundles

Instead of trading days, opens, and closes, register now takes a
TradingCalendar object, along with a start_session and end_session. The
ingest function is now passed these values instead as well.

* Accept calendar name in addition to the actual object

* Updates bundles documentation for changes

* Fix typo in docs

* Use class formatting

* Force start_session and end_session within the bounds of the calendar

* Use UTC timestamps in test_core

* Document Trading Calendar API in appendix.rst
2016-08-17 13:37:07 -04:00
Eddie Hebert 9685f3077a TST: Share resample test cases.
Also, move `DailyHistoryAggregator` to `resample` module, so that tools
for converting from minute to session bars are collocated.

This patch is in preparation of adding a daily bar reader which
resamples minute data, which will be located in the `resample` module
and share the test cases and expected results in `test_resample`.
2016-08-16 15:44:32 -04:00
Andrew Daniels 3136ef3f93 BUG: Fixes asset writer to the select the latest asset to hold a sid (#1392)
* BUG: Fixes asset writer to the select the latest asset to hold a sid

When constructing the asset_info dataframe, we were previously taking
the first symbol/sid pair to include, when we should be taking the most
recent.

* Ensure groups are sorted by increasing end_date

* Updates test_lookup_symbol_change_ticker to also cover asset_name
2016-08-15 20:38:02 -04:00
Jean Bredeche 34ec70abec BUG: Temporarily commenting out new can_trade functionality until we sort out downstream dependencies. 2016-08-13 21:46:00 -04:00
Jean Bredeche 7803ec6e46 ENH: Add public API to register calendars by type 2016-08-11 11:27:48 -04:00
Joe Jevnik 23363ee45a TST: test the v5->v4 downgrade 2016-08-10 15:32:49 -04:00
Scott Sanderson 007e1f9cfb BUG/TEST: Fix stochastic oscillator test.
- Don't create unnecessary extra data (requires passing fastd_period=1
  to TA-Lib or else it fills the FastK with NaNs even though it must
  have already computed them...

- Use random_sample instead of random_integers so that we're not
  dependent on integer arithmetic.

- Pass array_decimal to assert_equal so that we do almost equal checking
  on results.
2016-08-09 17:55:24 -04:00
Eddie Hebert 5cf9921f04 Merge pull request #1381 from quantopian/test-futures-last-sale-dt
Support last sale dt and spot value for Future assets.
2016-08-09 15:52:50 -04:00
Eddie Hebert 34c74346c9 ENH: Data portal reads future asset pricing.
Use the future asset equity pricing reader, instead of reading directly
from the bcolz table. Required since the format for writing the future
data now uses the minute bar reader/writer pair.

Add test cases to `test_data_portal` asserting both equity and future
`get_spot_value` results.
2016-08-09 15:19:26 -04:00