Commit Graph

4768 Commits

Author SHA1 Message Date
Andrew Daniels b501ecc736 ENH: Adds support for supplementary asset mappings (#1612)
* ENH: Adds support for supplementary asset mappings

- Adds a supplementary_mappings table to the assets.db, to hold point-
  in-time mappings of sids to arbitrary categories of values, e.g.
  alternative identifiers. This bumps ASSET_DB_VERSION.

- Adds supplementary_map and supplementary_map_by_sid to AssetFinder,
  caches of the underlying table that are fully populated on first
  access, which map the supplementary values to sids and vice versa,
  respectively.

- Adds lookup_by_supplementary_mapping method, which fronts
  supplementary_map to query for the asset last known to have held a
  value at a given dt.

- Add get_supplementary_field method, which fronts
  supplementary_map_by_sid to query for the last known value held by an
  asset at a given dt.
2016-12-16 15:20:53 -05:00
Joe Jevnik de7c32b22c ENH: Allow custom chunks iterators for attach_pipeline 2016-12-15 19:58:19 -05:00
Ana Ruelas 1888cf595f Merge pull request #1611 from quantopian/fix-buildbreaking-docstring
DOCS: Minor (but build breaking) docstring fix
2016-12-06 14:26:48 -05:00
Ana Ruelas 3cfbdeaca1 DOCS: Minor (but build breaking) docstring fix 2016-12-06 13:33:22 -05:00
Eddie Hebert 0fa4031f97 Merge pull request #1610 from quantopian/allow-skips-across-contracts
BUG: Allow rolls to skip over contracts.
2016-12-05 22:53:36 -05:00
Eddie Hebert a19ec84a1d BUG: Allow rolls to skip over contracts.
For futures that behave like GC, use the latest roll as the back contract when
walking backwards over the window, so that when the front contract is skipped
because it never has more volume between its auto close date and the previous
auto close date, the back contract which did have volume is still used when
making comparisons to construct the chain.
2016-12-05 22:33:03 -05:00
Eddie Hebert b120da4a4c Merge pull request #1609 from quantopian/use-custom-business-day-for-session-loop-logic
MAINT: Use session index freq for loop logic.
2016-12-05 13:59:07 -05:00
Eddie Hebert 584ff4d67a MAINT: Use session index freq for loop logic.
Instead of maintaining a separate index into the sessions index, use the `.freq`
member of the sessions index for decrementing to the current session and finding
the previous session.
2016-12-05 13:08:49 -05:00
Eddie Hebert 583f347bc3 DOC: Update testpypi install command
When following the release guide, installing from testpypi using the
`-i` flag failed on my, and at least one other's, development machines.
The cause of the failure appears to be that pip would look for packages,
such as `LogBook` or `pandas` on `testpypi`. However many dependencies
do not have versions that meet our version criteria. (e.g. pandas does
not have a version between 0.16.0 and 0.18.0 on testpypi.)

Instead, use `--extra-index-url` so that other packages can use `pypi`
as a fallback server, instead of being limited to `testpypi`.
2016-12-01 14:40:38 -05:00
Joe Jevnik c1063eac26 BUG: fix blaze pipeline queries for asof_date 2016-12-01 14:35:59 -05:00
Eddie Hebert 3e1a518ae6 Merge pull request #1607 from quantopian/allow-delivery-subsets
ENH: Allow future chains to only use certain delivery months.
2016-12-01 14:06:32 -05:00
Eddie Hebert 1f71c8d068 ENH: Allow future chains to only use certain delivery months.
To support contracts such as `PL` which should roll from F->J->N->V, add the
ability to pass a predicate function to the ordered contract chain contstrution
which returns `True` if the contract is allowed in the chain.
2016-12-01 13:26:07 -05:00
Eddie Hebert 3575351306 Merge pull request #1606 from quantopian/fix-volume-rolls-with-adjustments
BUG: Fix 1m history for volume rolls with adjustments.
2016-11-30 14:24:02 -05:00
Eddie Hebert d217b275fb BUG: Fix 1m history for volume rolls with adjustments.
Convert the end minute to the its session label before calling `_active_contract`,
otherwise the volume roll finder's attempt to use the session bar reader fails
due to a non-session label Timestamp.
2016-11-30 13:13:53 -05:00
Eddie Hebert 726edb0e32 Merge pull request #1605 from quantopian/support-non-month-to-month-rolls
BUG: Support futures which do not roll month to month.
2016-11-30 12:47:16 -05:00
Eddie Hebert c3004b2529 BUG: Support futures which do not roll month to month.
Fix multiple errors when attempting to generate rolls for futures which do not
roll month to month, e.g. the Eurodollar.

These errors were caused by logic that always incremented from contract to
contract by delivery month, with errors when the next contract was not part of
the quarterly roll chain and thus had not yet begun trading even though the
previous contract had autoclosed. Instead, filter out these contracts and only
allow contracts that have begun trading before the previous contract's autoclose.

This is in lieu of a more explicit specification of quarterly rolls.
2016-11-30 11:23:43 -05:00
Eddie Hebert 69b35a131a Merge pull request #1604 from quantopian/use-linked-list-for-contracts
MAINT: Use a doubly linked list for contract chain.
2016-11-30 06:54:28 -05:00
Eddie Hebert 518f3d1f4b MAINT: Use a doubly linked list for contract chain.
Instead of requiring the roll finder to juggle the indices into the ordered
contracts, use a doubly linked list where the nodes element is the contract
with members pointing to the previous and next contracts in the chain.

Besides improving legibility in the roll finder code, this change is on the path
to adding a predicate to exclude contracts from the chain, e.g. contracts in ED
which are not in the roll schedule.

Change test results for primary chain, since new implementaton does not stop at
contract in which has not yet started when constructing the chain.
2016-11-30 06:01:59 -05:00
Scott Sanderson e5c941e592 Merge pull request #1588 from quantopian/randc-built-in-factors
ENH: Add MACD, MA, and AnnVol as built in factors
2016-11-28 16:18:58 -05:00
Scott Sanderson 9594d2779b Merge pull request #1603 from quantopian/randc-built-in-factors-twekas
Randc built in factors twekas
2016-11-28 15:30:40 -05:00
Scott Sanderson 399bf3085c DOC: Docstring updates. 2016-11-28 15:29:36 -05:00
Scott Sanderson 9c05e5edfe MAINT: Tweaks/cleanups in technical.py.
- Use `expect_bounded` to check inputs.
- Add tests for expected failures from `MACDSignal`.
- Use `float64` instead of `float` in a few places.  This prevents
  diverging behavior on 32-bit systems.
- Docstring edits.
2016-11-28 13:02:40 -05:00
Scott Sanderson 48327266db MAINT: Put exponential_weights where it's used.
`math_utils` is mostly a shim around bottleneck imports.  If we need
this somewhere else, it probably belongs in `numpy_utils`.
2016-11-28 13:02:40 -05:00
Scott Sanderson 5e8cc00625 STY: Put whitespace between operators. 2016-11-28 12:57:03 -05:00
Scott Sanderson 9b8d6202f0 TEST: Use parameter_space for randomized tests.
- Use a RandomState with a seed so that we have repeatible results.
- Use `randint` instead of `random_integers.` `random_integers` is
  deprecated.
- Use `parameter_space` to test multiple period lengths.
2016-11-28 12:57:03 -05:00
Scott Sanderson bd84338aca Merge pull request #1599 from quantopian/memory-savings
Memory savings
2016-11-28 10:52:23 -05:00
Eddie Hebert 5842e981d7 Merge pull request #1600 from quantopian/use-prev-session-for-volume-roll
BUG: Fix bounds errors in roll finder.
2016-11-26 21:37:21 -05:00
Andrew Daniels adc9900860 MAINT: Improve minute writer handling of non-trading minutes (#1602)
Previously, if input to the BcolzMinuteBarWriter had the first bar on a
non-trading minute, the next trading session would be considered the
"first day" in the input. Now, we consider the previous trading session
the "first day".

The intention is to correctly associate minutes after official trading
hours on half days with session that closed early, not the following
session (a future improvement here would be to not accept minutes
outside trading hours).
2016-11-26 21:12:12 -05:00
Jonathan Kamens 96f8eeeb5f BLD: Use https to download ta-lib source 2016-11-25 12:12:33 -05:00
Ana Ruelas f1254ea79a ENH: Add MACDSignal, test with random input 2016-11-23 11:43:29 -05:00
Eddie Hebert 40605e3c5d BUG: Fix bounds errors in roll finder.
Fix common error condition which was triggered whenever the session at the end
of the prefetched history window was a session where the back contract was
active. When the back contract was the active contract, the next contract for
consideration was the front contract at the end of the window, which
definitionally always has an autoclose after the end of the window.
Instead, just start seeking backwards from the end of the window.

Also prevent lookahead bias in volume rolls, which was caused by the using the
volume for a session to determine whether that session had rolled. Information
that would not have been available at the beginning of the session.

This change makes the volume rolls overly conservative, and may be improved by
looking at vectors of the preceding volume and making the roll off of momentum.
2016-11-23 10:35:45 -05:00
Scott Sanderson aa3f2220d9 MAINT: Hit more dataframe indexers. 2016-11-22 17:11:04 -05:00
Scott Sanderson f244a20e65 BUG: sys.exc_clear is py2 only. 2016-11-22 16:34:53 -05:00
Scott Sanderson a60c9c683c MAINT: Use lazyval instead of two decorators. 2016-11-22 14:26:58 -05:00
Scott Sanderson b091b40604 PERF: Use searchsorted instead of get_loc.
On pandas < 18, `get_loc` triggers allocation of a large hash table, so
we don't want to call get_loc on minutely `DatetimeIndex`es.
2016-11-22 14:26:58 -05:00
Scott Sanderson ac8d21f1da PERF: Deterministically GC pipeline results.
Any DataFrame that's had `.loc` or `.iloc `called on it participates in
a cycle, which means they're not immediately garbage collected when they
go out of scope.  This matters for pipeline results because they consume
multiple megabytes per column, which means that a pipeline result with
many columns can hold take up over 100MB.  By manually breaking
DataFrame cycles, we can ensure that we never hold multiple pipeline
results in memory at once.
2016-11-22 14:26:58 -05:00
Andrew Daniels d65af6c706 BUG: Ensure minute OHLC values can safely be converted to uint32 (#1598)
Otherwise, we either raise an exception or filter out all unsafe values.
This addresses an issue where the BcolzMinuteBarWriter would scale up
values to convert to uint32, but the resulting values were too large,
and would be mangled.

Based on the approach we take in the BcolzDailyBarWriter.
2016-11-22 14:11:43 -05:00
Ana Ruelas 9aa6a585c4 TST: Add test for annualized volatility factor 2016-11-21 14:24:28 -05:00
Ana Ruelas 66dd10a50c ENH: Actually use rolling windows for EWMA in MACD 2016-11-21 14:24:28 -05:00
Scott Sanderson 72203280d2 MAINT: Use fancy default for window_length. 2016-11-21 14:24:28 -05:00
Ana Ruelas 735aaf1b27 ENH: Add MACD, MA, and AnnVol as built in factors 2016-11-21 14:24:19 -05:00
Maya Tydykov 6734eb2afb Merge pull request #1557 from quantopian/split_adjust_estimates
Split adjust estimates
2016-11-18 10:21:04 -05:00
Maya Tydykov bfc01546ae ENH: allow estimates to be split-adjusted.
This modificaiton to the estimates loader allows the caller to pass
in an equity pricing loader which can then be used to get split data
for sids. That split data is then used to do point-in-time adjustments
of estimates data.

TST: add test for multiple estimates columns

TST: add test for multiple datasets requesting different columns

TST: add blaze versions for all next/previous tests
2016-11-18 09:39:54 -05:00
Eddie Hebert a7a350d930 Merge pull request #1595 from quantopian/nan-check-transactinos
TMP: Add temporary fix for transactions with nan fill prices.
2016-11-17 13:10:32 -05:00
Eddie Hebert 613fdeab50 TMP: Add temporary fix for transactions with nan fill prices.
Protect a case where data is written with a non-zero volume, but a 0/nan for the
OHLC values. The slippage model was relying on a non-zero volume implying that
there was a valid trade price for the corresponding bar. When there was a mismatch,
a transaction with a nan value was created, which would in turn propagate the
nan into portfolio value, which would then cause errors when the portfolio value
was used to size orders during rebalancing.

When data is fixed, can remove.
(Also may want to add behavior to minute bar writer to ensure that 0 volumes
always have corresponding nan ohlc.)
2016-11-17 12:00:28 -05:00
Eddie Hebert 70b3055a68 Merge pull request #1594 from quantopian/fix-after-half-day-nan
BUG: Fix minute bar last traded after half day.
2016-11-15 15:33:42 -05:00
Eddie Hebert 5624e0f391 BUG: Fix minute bar last traded after half day.
When the following conditions occur,

- a `nan` occurred after a half day (e.g. on the Monday after
Thanksgiving, where the Friday would be a half day.)

-data was written to the span between the early close and where the market close
would have been if it were not an early close session

- a `nan` also occured on the last minute of the early market session.

the exisitng implementation would incorrectly return a `nan` when requesting a
forward filled price.

The steps that caused this error were.

1. Request for `'price'` on the market open of the day after the early close.

2. `nan` is found for that minute

3. `get_last_traded_dt` is called, and finds a volume that occurs after the
early close. e.g. `18:47` when the market close was `18:00`.

4. The minute position for `18:47` is used, when calling
`find_positon_of_minute`, since that value is after the `market_close` the
minute is set to the position of `18:00`` due to the delta logic in

5. Since there is also no data in at `18:00`, a `nan` is returned, even though
there were valid minutes earlier in the session. e.g. a non-zero volume at
`16:47` should have been used, but was not.

Fix by checking the current minute against the minute close when searching for
the last traded minute. If the minute is greater than the market close for the
corresponding day, continue the search until the minute position is within the
trading session.

This could also be fixed by enforcing that only zeros can be written between an
early close and the minute where the close would have been, but this fix allows
the reader to work with existing data.
2016-11-15 15:09:19 -05:00
Eddie Hebert 48324cf791 Merge pull request #1592 from quantopian/remove-duplicate-get-rolls
MAINT: Remove duplicate get_rolls in reader.
2016-11-14 15:43:27 -05:00
Richard Frank 3546dbd64d MAINT: Updated ta-lib source download urls to https 2016-11-14 12:34:19 -05:00
Richard Frank be457b088c Merge pull request #1593 from quantopian/nicer-message
ENH: An improved error message when calling zipline api functions
2016-11-11 17:22:06 -05:00