Commit Graph

4624 Commits

Author SHA1 Message Date
Eddie Hebert 7d8768e2e4 MAINT: Limit perspective offset.
Limit the perspective offset to 1. There is a possibility that if a
consumer of the AdjustedArrayWindow does not fetch adjustments between
the end of the data window and the vantage points beyond the end of the
window.

Until that case has a solution, e.g. having the consumer of the
AdjustedArrayWindow include the perspective offset when calculating the
query for adjustments, limit the offsets to 1.
2016-10-17 15:08:11 -04:00
Scott Sanderson 62f24dcad7 MAINT: Alternate AdjustedArray boundary conditions.
Avoids the need for a special sentinel value, and means that we only
have to have one branch instead of two in the inner loop.
2016-10-17 14:23:39 -04:00
Scott Sanderson ce223db78c DOC: Fix typo in comment. 2016-10-17 14:23:39 -04:00
Scott Sanderson 68ffd694e3 MAINT: Use perspective_offset in more tests.
- Refactor `test_adjusted_array` to test a range of perspective_offsets in
  all tests.

- Make perspective_offset a parameter to `AdjustedArray.traverse`
  instead of `AdjustedArray`.
2016-10-17 14:23:39 -04:00
Eddie Hebert 34d4e4b974 MAINT: Perspective offset for load adjustments.
Add a perspective offset to `AdjustedArrayWindow` and `AdjustedArray`,
so that `HistoryLoader` does not need to twiddle with offsets to support
viewing the data from the bar after end of the window, (Which is the
case when a '1d' history window is retrieved in minute mode, which is
explained in the docstring for `HistoryLoader.history`)

Presently, this simplifies the logic in
`HistoryLoader._get_adjustments_in_range`, and other incoming
AdjustmentReader's, (e.g. the roll based adjustment reader for continous
futures.) This patch should also make it easier for history and pipeline
to converge on a singular `load_adjustments` method.
2016-10-17 14:23:39 -04:00
Eddie Hebert 837d8824de Merge pull request #1539 from quantopian/continuous-future-history
ENH: Add history for continuous futures.
2016-10-16 23:14:08 -04:00
Eddie Hebert 2f16c08dcd ENH: Add history for continuous futures.
Enable unadjusted history for continuous futures.

The history array is filled by the values for the underlying contracts,
where the contract used changes based on rolls.

e.g., if a `1d` history window was over the range
`2016-01-20` -> `2016-02-29` with contracts with a suffix of `F16` that
rolls at the beginning of the session on `2016-01-26`, `G16` on
`2016-02-26`, and `H16` on `2016-03-26`. The `2016-01-20` ->
`2016-01-25` portion would use the values for `F16', the `2016-01-26` ->
`2016-02-25` portion would use `G16` and the `2016-02-26` ->
`2016-02-29` portion would use `H16`.

Using the same contracts as above, a `1m` history window over the range
(using a timezone of US/Eastern) `2016-01-25 4:00PM` -> `2016-01-25
7:00PM` would fill the `4:00PM` -> `6:00PM` portion with data for `F16`
and the `6:01PM` -> `7:00PM` portion with data for `G16`, since the
beginning of the `2016-01-26` session is `2016-01-25 6:01PM`.

Supports `1d` and `1m`.

Also adds the `sid` field to `history` to assist in showing the active
contract at each dt in the window.
2016-10-16 22:40:08 -04:00
Joe Jevnik 3f8a86dbb5 Merge pull request #1538 from quantopian/events-loader-query-fix
fix events loader blaze query
2016-10-13 15:49:57 -04:00
Joe Jevnik 95a56663d0 BUG: fix blaze query in ffill_query_in_range to correct issue in events loader 2016-10-13 15:27:44 -04:00
Scott Sanderson 8f85bef9fe Merge pull request #1537 from quantopian/allow-partials-in-assert-equal
BUG: Allow partials in assert_equal.
2016-10-12 19:28:35 -04:00
Scott Sanderson e1b8f34182 BUG: Allow partials in assert_equal. 2016-10-12 19:06:56 -04:00
Scott Sanderson 103993a8a8 Merge pull request #1536 from quantopian/allow-name-override-in-preprocessors
ENH: Name overrides in preprocessor factories.
2016-10-12 17:00:56 -04:00
Scott Sanderson cdfad2a54f ENH: Name overrides in preprocessor factories.
Allows ``__funcname`` to be passed to preprocessors like expect_types
and expect_dtypes to override the name displayed in error messages.
This is useful for providing clearer errors for ``__init__`` and
``__new__`` methods in classes.
2016-10-12 15:50:10 -04:00
Maya Tydykov 047313b516 Merge pull request #1535 from quantopian/small-updates-for-estimates
MAINT: small updates to fix deprecation warnings
2016-10-12 14:41:51 -04:00
Maya Tydykov e52d831a94 MAINT: small updates to fix deprecation warnings 2016-10-12 14:21:11 -04:00
Scott Sanderson 81b7d5eadc Merge pull request #1534 from quantopian/allow-kwargs-to-assert-equal-for-pandas-stuff
BUG/TEST: Forward kwargs to assert_series_equal.
2016-10-12 14:16:07 -04:00
Scott Sanderson dcf3124d26 BUG/TEST: Forward kwargs to assert_series_equal. 2016-10-11 21:29:41 -04:00
Eddie Hebert 7883f1fc06 Merge pull request #1533 from quantopian/current-chain
ENH: Add current chain for continuous futures.
2016-10-11 16:37:09 -04:00
Eddie Hebert c25b3d93f4 ENH: Add current chain for continuous futures.
Add `chain`field to current, as well as supporting methods in DataPortal
and OrderedContracts.

Enables the following example:

```
from zipline.api import continuous_future

def initialize(context):
    context.primary_cl = continuous_future('CL', offset=0, roll='calendar')
    schedule_function(print_current_chain)

def print_current_chain(context, data):
    chain = data.current_chain(context.primary_cl)
    print 'datetime={0}'.format(get_datetime())
    print 'primary={0}'.format(chain[0])
    print 'secondary={0}'.format(chain[1])
    print 'tertiary={0}'.format(chain[2])
```

```
datetime=2015-12-23 14:31:00+00:00
primary=Future(1058201602 [CLG16])
secondary=Future(1058201603 [CLH16])
tertiary=Future(1058201604 [CLJ16])
```

Also:
- make return types of OrderedContracts methods compatible across
architectures. (Noticed while adding `active_chain` method.)
- Add year suffix to future contract names in test data.
2016-10-11 16:16:16 -04:00
Joe Jevnik 70bd8e5f64 Merge pull request #1531 from quantopian/assert-slice-equal
TST: Adds assert_equal dispatch for slices
2016-10-11 11:14:23 -04:00
Maya Tydykov c0380f9d9b Merge pull request #1525 from quantopian/fix_estimates_overwrites_bug
Fix estimates overwrites bug
2016-10-10 09:02:40 -04:00
Maya Tydykov ea5b2b030c TST: add test condition to check for bug 2016-10-10 08:41:02 -04:00
Richard Frank 4c40d25be4 DOC: Updated example notebook for latest zipline cell magic 2016-10-09 22:12:20 -04:00
Scott Sanderson 7252a03d67 Merge pull request #1530 from quantopian/add-specific-assets
ENH: Add `SpecificAssets` filter.
2016-10-09 14:09:14 -04:00
Scott Sanderson 2a28f302ef DOC: Add a sentence with uses for SpecificAssets. 2016-10-09 13:41:10 -04:00
Scott Sanderson 58dca08d8b STY: Remove unused imports. 2016-10-09 13:18:18 -04:00
Scott Sanderson 1d5f3572c9 MAINT: Just require an iterable of assets. 2016-10-09 12:36:52 -04:00
Eddie Hebert fea7d899cd Merge pull request #1529 from quantopian/current-contract
ENH: Add continuous future current contract.
2016-10-07 23:39:01 -04:00
Joe Jevnik ee3c51f667 TST: Adds assert_equal dispatch for slices 2016-10-07 18:57:05 -04:00
Eddie Hebert fcf3e50cde ENH: Add continuous future current contract.
Add the ability for an algorithm to request the current contract for a
future chain via `data.current`.

e.g.:
```
data.current(ContinuousFuture('CL', offset=0, roll='calendar'),
'contract')
```
2016-10-07 18:26:23 -04:00
Scott Sanderson c9ebf9f45d ENH: Add SpecificAssets filter.
Adds a filter that matches a set of assets.  Mainly useful for testing
and debugging.
2016-10-07 18:11:01 -04:00
Andrew Daniels 2f097ead76 ENH: Adds last_available_{session, minute} args to DataPortal (#1528)
This allows optionally setting the last available dts in the DataPortal
explicitly. If these args aren't provided, we fall back to inferring
these from the underlying readers, which was the previous behavior.
2016-10-06 20:46:54 -04:00
Andrew Liang b6f8a67aad Merge pull request #1527 from quantopian/fix_restrictions
BUG: Restrictions passed into HistoricalRestrictions not sorted correctly
2016-10-05 15:02:50 -04:00
Scott Sanderson f3f138c450 TEST: Simplify testing of restriction orderings. 2016-10-05 14:42:17 -04:00
Andrew Liang e421a811e7 BUG: Restrictions passed into HistoricalRestrictions not sorted correctly 2016-10-05 14:09:26 -04:00
Ana Ruelas 6eafdddb39 Merge pull request #1524 from quantopian/empyrical-bump
ENH: Empyrical bump
2016-10-05 13:25:32 -04:00
Ana Ruelas 1bc55401b4 ENH: Empyrical bump 2016-10-05 12:54:16 -04:00
Maya Tydykov e304786fa0 BUG: append overwrites to list rather than replacing with new list 2016-10-05 12:47:25 -04:00
Eddie Hebert f92b6afb31 Merge pull request #1523 from quantopian/dispatch-reader-passes-asset
MAINT: Pass through asset instead of sid.
2016-10-04 15:01:48 -04:00
Eddie Hebert 5d9d9a97f5 MAINT: Pass through asset instead of sid.
When dispatching to sub readers in dispatch reader, pass along the asset
object, instead of extracting the sid.

The in development reader for continuous futures values besides `sid`
are needed from the `ContinuousFuture` object.
2016-10-04 14:39:23 -04:00
Scott Sanderson 1753a1ca3b Merge pull request #1518 from quantopian/add-coerce_types
MAINT: Add kwarg-based helper for coerce.
2016-10-03 19:52:08 -04:00
Andrew Liang 4618303d36 Merge pull request #1487 from quantopian/rlist
Create in-memory restricted list
2016-10-03 16:01:39 -04:00
Scott Sanderson 50b65f1a77 MAINT: Add kwarg-based helper for coerce. 2016-10-03 13:12:52 -04:00
Andrew Liang 7a08dd6bed DOC: Clean up Restrictions documentation 2016-09-30 16:35:24 -04:00
Andrew Liang 25ba4369c3 ENH: _UnionRestrictions for combining multiple Restrictions 2016-09-30 16:35:24 -04:00
Andrew Liang 148d2a5273 MAINT: Rename restrictions.py to asset_restrictions.py
For clarity as to what sort of restrictions these are
2016-09-30 16:35:24 -04:00
Scott Sanderson 73f1ac6255 STY: Remove extra whitespace. 2016-09-30 16:35:24 -04:00
Scott Sanderson 9f4f19524a DOC: Fix docstring typo. 2016-09-30 16:35:24 -04:00
Scott Sanderson 2a92b892ed BUG: days_at_time should return UTC dates.
Adds an example and clarifies the docs.
2016-09-30 16:35:24 -04:00
Scott Sanderson 761ea7e417 MAINT: Use Timedelta instead of DateOffset.
In days_at_time, use a Timedelta instead of a DateOffset.  We were
previously using DateOffset to work around a pandas 16 bug even though
it raises a PerformanceWarning.  Now that we're on pandas 18, we can use
the much simpler Timedelta construction.
2016-09-30 16:35:23 -04:00