Commit graph

219 commits

Author SHA1 Message Date
Richard Frank
93fa848c19 BUG: cal attribute of aggregate rules was not being propagated 2018-01-26 17:34:17 -05:00
vikram-narayan
2f2aa17f8e MAINT: set FixedBasisPointsSlippage as default 2018-01-19 14:08:40 -05:00
Samantha Klonaris
fa711f87ff Create MinLeverage control 2017-12-29 14:45:42 -05:00
Joe Jevnik
5b503823fb MAINT: duplicate definition of nop_context 2017-11-10 16:19:00 -05:00
Samantha Klonaris
49db00887f ENH: Change default commission to .001 and default minimum cost per trade to 0 2017-09-26 14:13:58 -04:00
Nathan Wolfe
64af3d3ff2 BUG: Fix daily history for minute panel data backtest (#1920)
* BUG: Fix daily history for minute panel data backtest
2017-09-22 11:00:01 -04:00
David Michalowicz
cfa7600dce Perform account validation at the end of the day 2017-07-28 17:25:28 -04:00
David Michalowicz
caa75383c3 REF: Change auto close to happen at session end 2017-07-20 16:41:14 -04:00
David Michalowicz
602a799a6b Fix weights calculation to use portfolio value as denominator 2017-06-07 15:46:45 -04:00
David Michalowicz
568bf0aa59 ENH: Add method for computing current portfolio weights 2017-06-07 13:13:14 -04:00
Richard Frank
8734224701 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
3ca5a15859 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
955862b4b3 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
d653820be3 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
0d9f4d29f5 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
dd21346eca API: Add slippage and commission models for futures 2017-04-25 17:29:41 -04:00
Jean Bredeche
e429664fa6 REF: Blotter no longer needs AssetFinder 2017-04-24 15:41:21 -04:00
Jean Bredeche
b1248cb6d6 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
f3086c548d API: Add factory for calendars 2017-04-24 09:37:32 -04:00
Jean Bredeche
6cf81a3f1c 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
ba484e5469 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
dd78bfa4e8 Change to a 10.5 hour futures calendar 2017-02-06 11:41:29 -05:00
dmichalowicz
6e707f97a7 BUG: can_trade was true for assets after their auto close date 2017-01-20 09:54:30 -05:00
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