Commit Graph

5611 Commits

Author SHA1 Message Date
Eddie Hebert 31d31bf1d3 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 47651363c0 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 d52d6eddff BUG: fix blaze pipeline queries for asof_date 2016-12-01 14:35:59 -05:00
Eddie Hebert 3a09833b6c 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 117d228fc2 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 9ac957f8a1 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 c6577a6518 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 0e3b290cc1 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 82bc2a6d3d 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 6f33bdcfd3 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 d147397983 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 74df429057 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 37f58264cd 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 ee230c807f DOC: Docstring updates. 2016-11-28 15:29:36 -05:00
Scott Sanderson 4210a2f80f 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 d140d585c2 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 c05635333e STY: Put whitespace between operators. 2016-11-28 12:57:03 -05:00
Scott Sanderson 52958a0340 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 84e7c03147 Merge pull request #1599 from quantopian/memory-savings
Memory savings
2016-11-28 10:52:23 -05:00
Eddie Hebert 320f1f64db 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 1f176de497 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 5ab89ff25d BLD: Use https to download ta-lib source 2016-11-25 12:12:33 -05:00
Ana Ruelas 3363237123 ENH: Add MACDSignal, test with random input 2016-11-23 11:43:29 -05:00
Eddie Hebert 4d434acab7 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 9f28b7cede MAINT: Hit more dataframe indexers. 2016-11-22 17:11:04 -05:00
Scott Sanderson 16e78bbccd BUG: sys.exc_clear is py2 only. 2016-11-22 16:34:53 -05:00
Scott Sanderson 7a5f5da6b2 MAINT: Use lazyval instead of two decorators. 2016-11-22 14:26:58 -05:00
Scott Sanderson 8aacac1cb6 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 52ed9093eb 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 4174a090d0 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 435d5acd14 TST: Add test for annualized volatility factor 2016-11-21 14:24:28 -05:00
Ana Ruelas 10f5cc2cbb ENH: Actually use rolling windows for EWMA in MACD 2016-11-21 14:24:28 -05:00
Scott Sanderson 7f762d02bf MAINT: Use fancy default for window_length. 2016-11-21 14:24:28 -05:00
Ana Ruelas 9d68ab6ba7 ENH: Add MACD, MA, and AnnVol as built in factors 2016-11-21 14:24:19 -05:00
Maya Tydykov f3a36fe97f Merge pull request #1557 from quantopian/split_adjust_estimates
Split adjust estimates
2016-11-18 10:21:04 -05:00
Maya Tydykov 757e1c6367 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 515db18793 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 be8326baf2 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 3c94ee7ae3 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 4fcf31730c 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 de256948db 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 104241c00d MAINT: Updated ta-lib source download urls to https 2016-11-14 12:34:19 -05:00
Richard Frank 54487ef054 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 1d2d6d843f 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 8b8b4a8118 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 138e189cac 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 229b967c71 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 da4d6ec582 Merge pull request #1589 from quantopian/rotate-anaconda-token
Rotate anaconda token
2016-11-10 13:45:44 -05:00
Richard Frank 97c3c14db6 SEC: Rotated anaconda token for travis 2016-11-10 12:12:02 -05:00
Richard Frank 7b65cd23db DOC: Added ANACONDA_TOKEN directions 2016-11-10 12:12:02 -05:00