Commit Graph

2288 Commits

Author SHA1 Message Date
Scott Sanderson 028ba719a2 BUG: Fix numpy dtype casting bug that only manifests in pandas 0.14.0. 2014-10-02 18:09:51 -04:00
Scott Sanderson d52dc68b5a PERF: Use numpy functions for concatenation in history. 2014-10-02 16:10:56 -04:00
Scott Sanderson 19d97524da PERF: Don't apply lambdas to large DataFrames. 2014-10-02 11:12:51 -04:00
Scott Sanderson 235954d480 DEV: Overhaul core history logic.
Overhaul the core HistoryContainer logic to be more robust to changing
universes.

Major Changes
-------------
* Remove `return_frame` cache.  The original purpose of using
  return_frames was to avoid having to create new DataFrames on each
  iteration of handle_data, but we ended up having to copy the return
  frames anyway because user code could mutate the frames in place.
  Removing the return_frames reduces unnecessary copying, and reduces
  the logic of `get_history` to just forward-filling and concatenating
  two DataFrames.

* Use a `MultiIndex`ed DataFrame to represent
  `last_known_prior_values`.  This makes lookups faster and greatly
  simplifies the logic of adding and dropping sids.

* HistoryContainer no longer attempts to determine its universe based on
  the contents of its internal buffers.  The TradingAlgorithm
  controlling the container is now responsible for explicitly calling
  `add_sids` or `drop_sids` when securities enter or leave the
  algorithm's universe.  These methods, along with the internal
  `_realign` method, provide a clean interface for changing the universe
  of securities managed by the container.

* Refactor index mutation logic in `RollingPanel` into a
  `MutableIndexRollingPanel` subclass.  Maintenance of the old behavior
  is regrettably necessary to support `BatchTransform`.

* Refactor shared logic from `roll` and `get_history` into a single
  `aggregate_ohlcv_panel` method that's responsible for collapsing an
  OHLCV buffer into a frame.
2014-09-29 14:42:57 -04:00
Scott Sanderson b3c7c26cee MAINT: Remove unused function in test_rolling_panel.py. 2014-09-29 14:40:03 -04:00
Scott Sanderson fcb137e0bb DOC: Clarificatory comments in HistoryContainer. 2014-09-29 14:40:03 -04:00
Scott Sanderson 9152d8da37 DOC: Slightly better comment on Frequency._ffill. 2014-09-29 14:40:03 -04:00
Scott Sanderson c477680ca3 MAINT: Use filter builtin instead of if-statement and continue. 2014-09-29 14:40:02 -04:00
Scott Sanderson 97e4e5e94d MAINT: In _create_generator only overwrite perf_tracker when it's None. 2014-09-29 14:40:02 -04:00
Scott Sanderson 94b53bdcb7 MAINT: Minor tweaks to docstring. 2014-09-29 14:31:57 -04:00
Joe Jevnik 4db4256cfe MAINT: Adds a tests/utils/ directory and renames test_utils.py
to utils/test_factory.py
2014-09-29 12:57:39 -04:00
Scott Sanderson fd71f956c7 DOC: Add more information to IncompatibleHistoryFrequency message. 2014-09-19 23:48:55 -04:00
John Ricklefs 16827e1af4 REV: Revert numpy update (back to 1.8.1)
This reverts commit 0eb12156c8.
2014-09-18 14:10:13 -04:00
John Ricklefs 0eb12156c8 BLD: Update numpy to 1.8.2 2014-09-18 12:23:54 -04:00
Thomas Wiecki 4615b57fc2 MAINT: Add custom exception for incompatible history frequency specification. 2014-09-18 16:20:28 +02:00
Thomas Wiecki 69a66f776e BLD: Trying to fix travis. 2014-09-17 19:21:29 +02:00
Thomas Wiecki cbb8e28f8e TST: Fix history unittest. 2014-09-17 18:17:36 +02:00
Thomas Wiecki 5490349c62 MAINT: Test frequency.unit_str instead of frequency string. 2014-09-17 18:17:11 +02:00
Thomas Wiecki 49b511558d BLD: Remove numpy 1.8.1 requirement from travis. 2014-09-17 16:23:17 +02:00
Thomas Wiecki 011f072fe2 MAINT: Add assertion for incompatible history freq specification. Supplying 1m frequency to history but only providing daily source data resulted in an odd non-descript exception. This adds a specific check and raises a more informative exception. 2014-09-17 15:04:37 +02:00
Eddie Hebert 7eb1d719ed MAINT: Check attributes instead of contains for event fields.
In support of source that emits a subclass of Event which defines some
fields as properties instead of doubling the value in the
`Event.__dict__`

Use hasattr instead of the overridden __contains__ method of the Event
class, so that when non-algorithm facing code checks for field existence,
properties count.

Intentionally not touching the `__contains__` in Event, to avoid
changing, at the moment, any algo behavior that relies on the
`__contains__` behavior's use of `__dict__`
2014-09-08 11:09:41 -04:00
Richard Frank 6a5eaea835 MAINT: Use local variable with same value 2014-09-03 18:07:51 -04:00
Richard Frank 3784ed4ba9 ENH: A TradingAlgorithm method called before each trading day 2014-09-03 18:07:51 -04:00
Scott Sanderson 1b2d79988f BUG: Fix exception when comparing Event to object with no __dict__.
In particular don't throw an exception on comparison to `None`.
2014-09-02 20:42:49 -04:00
Delaney Granizo-Mackenzie 5d5dbb5c3a Merge pull request #385 from quantopian/exception-on-nan-order-value
BUG: StopLimit better bad value exception handling
2014-08-26 14:43:22 -04:00
Delaney Granizo-Mackenzie 5488da0dc2 ENH: Well formed exception for any value passed to OrderStyle
This commit adds support for arbitrary objects in addition to NaN
and infinity values. The object well be returned in string format
as part of the error message.
2014-08-26 14:02:28 -04:00
Delaney Granizo-Mackenzie 15f33d3e9d BUG: Exception will be raised when nan value sent to order()
Previously order was not checking for nan values sent as
limit or stop prices. It will now raise a runtime exception
in the event that an attempt to order with a nan price is made.
2014-08-25 11:23:28 -04:00
Joe Jevnik 16d15ed514 Merge pull request #384 from quantopian/q-or-zipline
get_environment api_method
2014-08-21 14:32:14 -04:00
llllllllll 7563124547 ENH: Adds a new api_method called get_environment so that users may
check if their algorithm is running in zipline or on Quantopian.
2014-08-14 11:48:19 -04:00
Scott Sanderson 4420e370ff MAINT: Move call to updated_portfolio in AlgorithmSimulator.
We guarantee that `TradingAlgorithm.updated_portfolio` is called at least once
between each perf message emission.  This change moves that guaranteed call
into `AlgorithmSimulator.get_message` and adds a comment to make it clear why
updated_portfolio is being called.
2014-08-13 13:00:03 -04:00
Scott Sanderson 3e978d0ebb MAINT: Remove unused methods from TradingAlgorithm.
Removes unused method `raw_positions` and `raw_orders` from `TradingAlgorithm`.
These methods existed to help support features in the Quantopian codebase,
which no longer use the existing interface.
2014-08-13 13:00:03 -04:00
Scott Sanderson d02dd972d5 BUG: Fix crash in transforms on malformed CUSTOM events.
Fixes a crash in various transforms when providing CUSTOM events whose fields
don't match the fields required for the transform.

This is fixed by requiring all `EventWindow` subclasses to supply a `fields`
property, which returns a list of strings that are required keys for any event
that can be processed by the window.  Any CUSTOM events the don't supply the
required fields for a transform window are ignored by that window.
2014-08-13 12:54:29 -04:00
Joe Jevnik f9b1fe6ff6 Merge pull request #383 from quantopian/welcome-to-the-family
symbol as an api_method
2014-08-06 18:43:33 -04:00
llllllllll 90405b1c99 MAINT: Adds symbol to the list of api_methods. 2014-08-06 18:18:56 -04:00
John Ricklefs d73d2336ac Merge pull request #380 from quantopian/broker_order_statuses
ENH: Add new order statuses for broker integration
2014-08-06 15:33:57 -04:00
John Ricklefs f13bbd5d76 ENH: Re-work the usage of _status on Order 2014-08-06 15:00:26 -04:00
John Ricklefs dd97292a94 TST: Add tests for behavior of rejected/held orders.
Also made a tweak to the handling of Order.status
for when a held order is filled (partial or full).
2014-08-06 15:00:26 -04:00
Brian Fink 65dea626a0 BUG: Clean up handling of reject() and hold() orders 2014-08-06 15:00:25 -04:00
John Ricklefs ec20b3be8a ENH: Add new order statuses for broker integration 2014-08-06 15:00:25 -04:00
Thomas Wiecki bb6e9c26c0 Merge pull request #382 from quantopian/talib_optional
Make talib an optional dependency.
2014-08-06 15:13:00 +02:00
Eddie Hebert 3c8363722e MAINT: Log more information on history update failure.
Log the field and algo datetime when the update of the return frame
fails; re-raise the error until the when and why of the value error is
understood.
2014-08-05 12:17:00 -04:00
Thomas Wiecki 3f1c3b39ad MAINT: Make talib an optional dependency. Fixes #362. 2014-08-04 13:25:46 +02:00
Thomas Wiecki e9b7209c13 MAINT: Factor talib tests out to separate file. 2014-08-04 13:17:21 +02:00
Thomas Wiecki c12304ce40 DOC: Updated dual moving average example to use symbol lookup. 2014-08-04 12:21:50 +02:00
Delaney Granizo-Mackenzie 79041df093 Created 0.7.1 release notes 2014-07-29 12:59:00 -04:00
Delaney Granizo-Mackenzie 3b9fa53719 Merge pull request #378 from quantopian/fixed-zero-last-sale-price
BUG: Fixed random dips in returns as shown to user.
2014-07-29 12:15:23 -04:00
Delaney Granizo-Mackenzie 0fd78cd54a BUG: Fixed random dips in returns as shown to user.
Previously the last sale price was not correctly being set on
positions when the transaction arrived before the trade event.
The last sale price was defaulted to zero and never updated. This resulted
in one holding stocks that were bough >>0 and now had value 0 from
the perspective of returns. The returns would display correctly again
when the next trade of that security happened. For most securities trading is
frequent enough that there's no issue, but for some illiquid ones it took
hours to fix itself.

Updated test_perf_tracking:TestPerformanceTracker.test_minute_tracker
This test was based on assuming that last_sale_price was zero,
allowing the sharpe ratio to be calculated. The sharpe ratio can no longer
be calculated for this specific tested scenario and the test has been changed
accordingly.
2014-07-29 11:07:13 -04:00
Thomas Wiecki 2a71f8353a DOC: Fix readme example and update dependency doc. 2014-07-26 09:28:44 +02:00
Thomas Wiecki 97781dc39e BLD: Update md5 sum in meta.yaml. 2014-07-25 19:37:17 +02:00
Thomas Wiecki a7de02176b Bump version: 0.7.0rc1 → 0.7.0 2014-07-25 19:34:49 +02:00