Commit Graph

4759 Commits

Author SHA1 Message Date
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
Richard Frank a61de3a4e7 ENH: An improved error message when calling zipline api functions
outside of a running simulation. Previously, an AttributeError was
raised.
2016-11-11 17:00:03 -05:00
Eddie Hebert b9b9b7d32b Merge pull request #1590 from quantopian/speed-up-history-loader-creation
PERF: Speed up retrieval of HistoryLoader calendar.
2016-11-11 11:37:31 -05:00
Eddie Hebert 00ebae7729 MAINT: Remove duplicate get_rolls in reader.
The rolls are already calculated and assigned to `rolls_by_asset` earlier in the
`load_raw_arrays` method, so remove the duplication.

The change should not affect results.
2016-11-11 11:09:02 -05:00
Eddie Hebert 08fb7333d6 PERF: Speed up retrieval of HistoryLoader calendar.
The use of `slice_indexer` on all market minutes was taking about 110ms on my
development machine.

This change to getting the start and end indices changes the entire `_calendar`
method to take 10ms on the same machine.

Noticed while creating a `HistoryLoader` in a notebook context.
2016-11-11 10:54:07 -05:00
Richard Frank 907f30d013 Merge pull request #1589 from quantopian/rotate-anaconda-token
Rotate anaconda token
2016-11-10 13:45:44 -05:00
Richard Frank 0145cf8bf0 SEC: Rotated anaconda token for travis 2016-11-10 12:12:02 -05:00
Richard Frank a4a571aff0 DOC: Added ANACONDA_TOKEN directions 2016-11-10 12:12:02 -05:00
Eddie Hebert b4692c4121 Merge pull request #1587 from quantopian/fix-bug-for-continuous-future-max-date
BUG: Fix continuous future end dates.
2016-11-09 16:41:57 -05:00
Eddie Hebert 48c360727b BUG: Fix continuous future end dates.
The end date of the last contract with a sufficient start date was being
used for the continuous future overall end date; however the end date of
that contract (which is the last day for which there is data for the
contract) is not necessarily the greatest end date out of all contracts.
It is possible for the furthest out contract to have some, but very
few, trades before it is more actively traded. Which would give it a
start date within in the range of the simulation, but an end date is
earlier than the other contracts which are active during the simulation.

This bug would result in `nan`s when getting the current price because
of the `end_date` check in `get_spot_value`. When the current simulation
time was greater than the `end_date` of the last contract the condition
which guards against attempting to get data for an instrument past its
end date would return a `nan`, even when the current underlying contract
did have data for that date.

Use max end date of all contracts instead of the last one, to ensure
that the continuous future last date is always great enough to allow
access to all contracts with in the chain.

Also, use min start date to accurately mirror the end date behavior.
2016-11-09 16:19:19 -05:00