Commit Graph

211 Commits

Author SHA1 Message Date
David Michalowicz 49a7b78b2e Fix weights calculation to use portfolio value as denominator 2017-06-07 15:46:45 -04:00
David Michalowicz 94b1d5a40e ENH: Add method for computing current portfolio weights 2017-06-07 13:13:14 -04:00
Richard Frank ec396bd1ea TST: Use testing market data with run_algorithm
so env doesn't need to download it
2017-05-18 12:54:06 -04:00
Richard Frank 0f6dbcef3c TST: Use fixture's data with tmp_trading_env
instead of env needing to download it
2017-05-18 12:54:05 -04:00
Richard Frank c5b3ceecc1 TST: Use fixture's trading env for FakeDataPortal or TradingAlgo
to avoid a new trading env needing to download data unnecessarily
2017-05-18 11:55:48 -04:00
Scott Sanderson 86fa28f9e8 MAINT: batch_order_target_percent -> batch_market_order.
The only downstream contex that was using batch_order_target_percent
already had all necessary prices, so calling batch_order_target_percent
was wasteful.
2017-05-09 13:52:57 -04:00
Andrew Daniels 52667b4a90 MAINT: Handle gaps in input to daily bars writer (#1778)
Previously, a dataframe passed into BcolzDailyBarWriter.write that was
missing an expected session between its first and last sessions would be
written incorrectly. Upon converting the dataframe to a ctable, the
values for all days following the gap would be shifted backwards, and
nans would be shifted in at the end.

This commit handles the issue by asserting that the number of rows in
the input table matches the number of sessions in the calendar between
the table's first and last sessions.

Also fixes a test that was mistakenly using minutes_in_range where it
should have been using sessions_in_range (uncovered by this change).
2017-05-03 20:49:22 -04:00
dmichalowicz fa0594555c API: Add slippage and commission models for futures 2017-04-25 17:29:41 -04:00
Jean Bredeche b7b8c46d74 REF: Blotter no longer needs AssetFinder 2017-04-24 15:41:21 -04:00
Jean Bredeche 8d275d8d83 REF: Explicitly use Assets in Position, Order, Transaction
(Instead of `sid`, which were already usually assets)

Perf packets are unchanged and still emit `sid`: int
2017-04-24 15:41:13 -04:00
dmichalowicz 2f33ddb023 API: Add factory for calendars 2017-04-24 09:37:32 -04:00
Jean Bredeche 81b943c61d ENH: Allow override of order amount rounding. (#1722)
* ENH: Use regular rounding to calculate order amounts.

We previously tried to prevent accidental over-ordering by truncating
orders down unless they were within 1e-4 of the next higher integer.
Unfortunately, this makes it easy for a sell order to be one share short
of the desired position.

Using regular rounding treats both buys and sells in the same way.

* ENH keep non-rounding behavior consistent, but leave code structured to make easier to override

* DOC make round_order public and describe behavior in docstring
2017-03-27 20:44:12 -04:00
Andrew Daniels 8e1f8d75f5 MAINT: Removes unnecessary capital_base arg to TradingAlgorithm (#1677)
Capital base is included in the sim params, so we should define the
value there, or use the default.

This change also unifies the default capital base as 1e5, as was
previously defined in algorithm.py.
2017-02-17 09:04:50 -05:00
dmichalowicz db2440871e Change to a 10.5 hour futures calendar 2017-02-06 11:41:29 -05:00
dmichalowicz 83a221e986 BUG: can_trade was true for assets after their auto close date 2017-01-20 09:54:30 -05:00
Richard Frank 7ab0b08e95 MAINT: Filter out null orders 2016-12-20 19:27:29 -05:00
Richard Frank 30bc01dbc0 MAINT: Some cleanup while working on batch ordering 2016-12-20 19:27:28 -05:00
Richard Frank 555d460d26 TST: Ensure batch_order_target_percent orders like order_target_percent 2016-12-20 19:27:28 -05:00
Richard Frank edab970973 ENH: Renamed to batch_order and added batch_order_target_percent 2016-12-20 11:58:05 -05:00
Eddie Hebert 2f16c08dcd 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 fcf3e50cde 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 25ba4369c3 ENH: _UnionRestrictions for combining multiple Restrictions 2016-09-30 16:35:24 -04:00
Andrew Liang 148d2a5273 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 99f6ecab3f 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 b504d29a78 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 25517e2b15 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 9fd8ddda53 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 ec89402a3e MAINT: Fix PerformanceWarning import. 2016-09-20 17:12:08 -04:00
Scott Sanderson 52166e9958 MAINT: Pass float to np.full explicitly. 2016-09-20 17:12:07 -04:00
Scott Sanderson c4e114c28f MAINT: Pass explicit dtype to np.full. 2016-09-20 17:12:07 -04:00
Richard Frank 7a10d9392d Merge pull request #1467 from quantopian/check_param-string_types
Check param string types
2016-09-08 14:59:38 -04:00
Joe Jevnik 1e030c77b2 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 43b9fa84d7 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 7f6db68fc6 BUG: Fix up check_parameters usage of string_types
and corresponding tests
2016-09-02 16:47:32 -04:00
John Ricklefs 0d40b84550 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 3ab907ee4f 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 d1160439d2 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 fcde54297c MAINT: remove __getitem__ as alias of __getattr__ 2016-08-31 12:38:20 -04:00
Jean Bredeche 0cc08d79b4 ENH: Add new parameter to schedule_function that accepts a trading
calendar.
2016-08-28 21:33:42 -04:00
Eddie Hebert a4131ea84b 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 f0af856c13 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 53ca68e8fb 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