Commit Graph

196 Commits

Author SHA1 Message Date
Richard Frank e674e4e26a MAINT: Filter out null orders 2016-12-20 19:27:29 -05:00
Richard Frank d9a1479db7 MAINT: Some cleanup while working on batch ordering 2016-12-20 19:27:28 -05:00
Richard Frank 581e827208 TST: Ensure batch_order_target_percent orders like order_target_percent 2016-12-20 19:27:28 -05:00
Richard Frank 8ea3226a5c ENH: Renamed to batch_order and added batch_order_target_percent 2016-12-20 11:58:05 -05:00
Eddie Hebert 73b03de63e 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
Eddie Hebert ec6f298972 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
Andrew Liang 2104a35af8 ENH: _UnionRestrictions for combining multiple Restrictions 2016-09-30 16:35:24 -04:00
Andrew Liang 3b5031a829 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
Andrew Liang bf8b030417 MAINT: Deprecate set_do_not_order_list
In favor of a new method `set_restrictions` which takes a Restrictions
object. Calls to `set_do_not_order_list` should raise a deprecation
warning and create an equivalent Restrictions object, with which
`set_restrictions` will be called. For convenience, create a
RestrictionsSet from which the "restrictions" version of a security
list can be accessed
2016-09-30 16:35:23 -04:00
Andrew Liang b70084c6bf ENH: can_trade should take restricted list into account
Additionally, create an option for a violation of a 'do not order'
trading control to log an error instead of failing
2016-09-29 10:11:14 -04:00
Eddie Hebert 9f77473ae6 Merge pull request #1502 from quantopian/remove-future-chain
MAINT: Remove `future_chain` API method.
2016-09-21 11:44:57 -04:00
Eddie Hebert f4daf10e2f MAINT: Remove future_chain API method.
`future_chain` will be replaced by the as yet to be implemented method,
`data.current_chain`

Also removing `FutureChain` which will be replaced by another version
which only supports indexing and iteration.
2016-09-21 11:08:34 -04:00
Scott Sanderson f3eeaa233c MAINT: Fix PerformanceWarning import. 2016-09-20 17:12:08 -04:00
Scott Sanderson a39a6e1bbf MAINT: Pass float to np.full explicitly. 2016-09-20 17:12:07 -04:00
Scott Sanderson b188381747 MAINT: Pass explicit dtype to np.full. 2016-09-20 17:12:07 -04:00
Richard Frank df07f67614 Merge pull request #1467 from quantopian/check_param-string_types
Check param string types
2016-09-08 14:59:38 -04:00
Joe Jevnik cf2abf10e2 Merge pull request #1449 from quantopian/getitem-is-not-getattr
MAINT: remove __getitem__ as alias of __getattr__
2016-09-06 13:48:17 -04:00
John Ricklefs c09f7ab04c Revert "BUG: Capital change deltas rely on cash, not portfolio_value" (#1470)
This reverts commit 5b1aa5ec55.

The paradigm is: we're calculating a new capital base for the
performance period. We are therefore using the total
portfolio_value, not just the cash, to calculate the
difference from the specified target as the algorithm
has meaningful holdings.
2016-09-05 14:12:04 -04:00
Richard Frank a4e495dd24 BUG: Fix up check_parameters usage of string_types
and corresponding tests
2016-09-02 16:47:32 -04:00
John Ricklefs 311284475a ENH: Allow passing additional adjustments to calculate_capital_changes
If subclasses have additional capital change information that
is required to correctly calculate the target values for
cash capital changes, it can now be provided via
"portfolio_value_adjustment".
2016-09-01 16:04:46 -04:00
John Ricklefs 5b1aa5ec55 BUG: Capital change deltas rely on cash, not portfolio_value
The value of holdings is irrelevant when altering the
capital base of the current perf period.
2016-09-01 15:19:55 -04:00
Jean Bredeche 38ff7e5aa7 ENH: Simplified implementation of FutureChain object (not user-facing API).
No longer auto-updates its internal as-of date, instead requires an explicit
as-of date from the consumer.

Take a static list of contracts (instead of needing an assetfinder).

Instead of the as_of method, the user-facing API now lets you pass in an
offset, which is defined as an integral number of sessions.
2016-08-31 14:44:02 -04:00
Joe Jevnik 1714b2d03a MAINT: remove __getitem__ as alias of __getattr__ 2016-08-31 12:38:20 -04:00
Jean Bredeche 7b83cbe820 ENH: Add new parameter to schedule_function that accepts a trading
calendar.
2016-08-28 21:33:42 -04:00
Eddie Hebert 40c7deb697 ENH: Add asset dispatch to data portal.
Combine the equity and future readers into asset dispatch readers, so
that simulations that use both asset types can access data for each.

This patch enables `history` for future assets in algorithms; however,
it does not add extra coverage in the `test_data_portal` or `test_history`
to cover future assets. Those tests will follow, however putting this in
separately since it shows that the wrapping of the readers in the asset
dispatch reader does not break existing equity strategies.
2016-08-26 13:29:08 -04:00
Ana Ruelas f57fe0a4b0 TST: Update to empyrical, increase test coverage
ENH: Resolve rebase conflict by using updated example_data.tar

TST: Increase test coverage for risk portion of zipline
2016-08-23 13:49:43 -04:00
Andrew Daniels 37e6a48e99 ENH: Pass calendar instance to BcolzMinuteBarWriter (#1406)
* First pass.

* Improvements and fixes

- Update usages of BcolzMinuteBarWriter
- Updates with rebuilt example data
- Expose calendar from BcolzMinuteBarMetadata instead of calendar_name
- Keep market_opens and market_closes in metadata for compatibility

* Store start_session and end_session in minute bcolz metadata

- start_session replaces first_trading_day
- Add end_session to limit to correct days

* For last_available_dt, get last close from calendar to maintain tz

* Bumps version and handles earlier versionson read

* Rebuilt example data on python 3

* Indicate metadata fields that are deprecated
2016-08-18 15:41:26 -04:00
Eddie Hebert e934c6aeaf TST: Make room for multiple calendars in tests.
When adding fixtures for futures data, there will be a need for multiple
calendars in the fixture ecosystem. e.g. a test that includes both
equities and futures would need an overall calendar which encompasses
both equities and futures; however, the test data for equities should
still still be limited to the bounds set by the NYSE calendar.

Make the fixtures that setup trading calendars and values dervied from
the trading calendar (e.g. trading sessions) accept an iterable of
calendars which need to be created, then populate those values into a
dict keyed by the calendar name.

Change `WithNYSETradingDays` to include sessions in the name,
since we are moving to session as the name for the 'day' unit.

Provide `trading_days` which is really "NYSE trading sessions` on
`WithTradingSessions` for backwards compatibility.
2016-08-05 12:17:27 -04:00
Jean Bredeche d1077a36c2 TST: Fix broken tests, updated example data 2016-08-04 09:38:18 -04:00
Jean Bredeche e6af4e4f1b ENH: made exchange a required parameter to Asset and its subclasses
This required updating a lot of tests.
2016-08-02 23:21:39 -04:00
Jean Bredeche 97ccb54326 MAINT: PR cleanup 2016-08-02 23:12:07 -04:00
Jean Bredeche 6020752a1d TST: Filter out pandas performance warnings in tests (for now) 2016-08-02 23:12:07 -04:00
Joe Jevnik 74c46732e5 Merge pull request #1361 from quantopian/point-in-time-assets-db-again
Point in time assets db again
2016-08-02 15:35:56 -04:00
Joe Jevnik 4265a13edf Revert "Merge pull request #1354 from quantopian/revert-1302-point-in-time-asset-db"
This reverts commit 3b633011c6, reversing
changes made to 70ac5323de.
2016-08-02 14:25:10 -04:00
Andrew Liang 5904ecb40f ENH: Yield capital change information 2016-08-01 15:19:11 -04:00
Joe Jevnik 9103516e82 Merge pull request #1313 from nathanwolfe/master
BUG: Add support for Panel data in accordance with documentation
2016-07-29 20:11:56 -04:00
Nathan Wolfe bdce4ef257 TST: Expand Panel data test to test for multiple sids. 2016-07-29 17:32:00 -04:00
Nathan Wolfe 55b79e8f32 TST: Test TradingAlgorithm.run and run_algorithm on raw Panel data 2016-07-29 17:15:35 -04:00
Joe Jevnik 814a2be7b7 Revert "Point in time asset db" 2016-07-27 23:29:08 -04:00
Jean Bredeche 3305933089 DEV: Change daily mode to use last minute of session instead of session itself. 2016-07-27 09:20:24 -04:00
Jean Bredeche 2462929368 Revert "Merge pull request #1340 from quantopian/by-daily-i-mean-minutely"
This reverts commit f4456719b0, reversing
changes made to 4be07e4628.
2016-07-26 16:20:14 -04:00
Joe Jevnik 7fd8c29880 ENH: add point in time aspect to equity symbol mapping
Changes the overlap behavior so that it is an error to write data which
would have two companies holding the same ticker. Other than one test
around which company would win in that case, all the other tests are
passing. That single test has been changed to check the write-time
error.
2016-07-26 13:34:58 -04:00
Jean Bredeche bcb547d5a8 DEV: Change daily mode to use last minute of session instead of session itself. 2016-07-26 12:49:49 -04:00
Andrew Liang 2fe94d0c29 Merge pull request #1337 from quantopian/margin_changes
Capital Changes Refactoring
2016-07-25 10:54:34 -04:00
Andrew Liang 0955515c46 TEST: Test capital changes using target values 2016-07-25 10:05:47 -04:00
Jean Bredeche 63ef840363 ENH: Verify params passed to get_datetime 2016-07-21 20:42:28 -04:00
Jean Bredeche 5a0f840917 Clean up daily bar reader/writer to take advantage of new trading calendar. The reader
is backwards-compatible with the previous format.

In USEquityLoader, use dailyreader's trading_calendar.

This is backwards compatible and will fall back to the NYSE calendar if
the reader doesn’t have a calendar specified.
2016-07-15 15:13:57 -04:00
Jean Bredeche 6fb4923cc7 Re-implemented the Calendar API.
Instead of having separate ExchangeCalendar and TradingSchedule objects, we
now just have TradingCalendar.  The TradingCalendar keeps track of each
session (defined as a contiguous set of minutes between an open and a close).
It's also responsible for handling the grouping logic of any given minute
to its containing session, or the next/previous session if it's not a market
minute for the given calendar.
2016-07-12 13:13:50 -04:00
Eddie Hebert 4840e124af TST: Speed up TestMiscellaneousAPI
Limit the date range to one day, instead of a year.

On my local machine the following goes from taking 12 seconds to 0.6 seconds.

`$ nosetests -x tests/test_algorithm.py:TestMiscellaneousAPI`
2016-07-11 10:34:08 -04:00
Eddie Hebert 51eda06323 MAINT: Add equity to naming of bar data classes.
In preparation of adding futures, add equity to the names of both the
classes and methods for writing bcolz data. Futures data will use a
different minutes per day with a separate reader. This change will allow
both equity and futures fixtures to be side by side.

Also, break out the method which generates the dataframes and trading
days member into fixtures (`EquityMinuteBarData` and
`EquityDailyBarData`) on which the `*BarReader` fixture depends.  This
fixture is separated out to enable reader/writers in different formats
to use the same data setup. (There is internal code which needs to write
minute and daily bar data in a database format.)
2016-06-30 08:21:42 -04:00