Commit Graph

288 Commits

Author SHA1 Message Date
dmichalowicz f0f8bac2ab EHN: Make continuous future adjustment style an argument 2017-03-29 08:49:12 -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
Eddie Hebert 8878d0ddd5 STY: Wrap/reformat lines over 80 chars.
Newer versions of flake8 detect these versions, though current zipline version
of flake8 does not.
2017-02-08 00:47:33 -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 edab970973 ENH: Renamed to batch_order and added batch_order_target_percent 2016-12-20 11:58:05 -05:00
Richard Frank 83d0c45ec3 MAINT: Renamed order_batch parameter and added docs 2016-12-20 11:57:27 -05:00
Richard Frank 8314586612 MAINT: Factored out order arg calculation methods
so callers can use them to construct args for a batch of orders
2016-12-20 11:57:26 -05:00
Joe Jevnik de7c32b22c ENH: Allow custom chunks iterators for attach_pipeline 2016-12-15 19:58:19 -05:00
Scott Sanderson f244a20e65 BUG: sys.exc_clear is py2 only. 2016-11-22 16:34:53 -05:00
Scott Sanderson ac8d21f1da 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
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
Scott Sanderson 117450a489 DOC: Rename NoopRestrictions to NoRestrictions. 2016-09-30 16:35:23 -04:00
Scott Sanderson d79c43a46a DOC: Update docstring for set_restrictions. 2016-09-30 16:35:23 -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 af85b22313 MAINT: Create SecurityListRestrictions that takes a SecurityList
The SecurityList implements a non-exposed method
`current_securities(dt)` which SecurityListRestrictions calls to
determine if an asset is restricted. Deprecate the `__iter__` and
`__contains__` methods of security lists in favor of
`current_securities(dt)`
2016-09-29 10:11:14 -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
Eddie Hebert 9e0ef02ff6 Merge pull request #1494 from quantopian/remove-unused-update-dividends
MAINT: Remove unused method.
2016-09-21 10:36:12 -04:00
Scott Sanderson dafe49fcca MAINT: Fix failures/warnings in test_api_shim.py
- Fixes a warning on indexing with a float that ultimately came from
  pd.Timedelta.total_seconds().  Adds ``timedelta_to_integral_seconds``
  and ``timedelta_to_integral_minutes()`` functions and replaces various
  usages of ``int(delta.total_seconds())`` with them.

- Fixes a warnings triggered in ``_create_daily_stats`` from
  passing tz-aware datetimes to np.datetime64.
2016-09-20 17:12:07 -04:00
Eddie Hebert 7b74257f28 MAINT: Remove unused method.
Dividends are read from AdjustmentReader.
2016-09-16 16:50:10 -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
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
Jean Bredeche 0cc08d79b4 ENH: Add new parameter to schedule_function that accepts a trading
calendar.
2016-08-28 21:33:42 -04:00
Scott Sanderson c7bd0d06e2 ENH: Add input validation to attach_pipeline. 2016-08-16 15:53:20 -04:00
Jean Bredeche 97ccb54326 MAINT: PR cleanup 2016-08-02 23:12:07 -04:00
Jean Bredeche 2854c77d55 ENH: Clock now fires a BEFORE_TRADING_START_BAR event.
`AlgorithmSimulator` listens to that event to call the algorithm's
`before_trading_start` method.
2016-08-02 23:12:07 -04:00
Andrew Liang 5904ecb40f ENH: Yield capital change information 2016-08-01 15:19:11 -04:00
Andrew Liang 18aba63da9 Merge pull request #1359 from quantopian/refactor_subperiod
MAINT: Refactor application of capital changes
2016-08-01 14:00:48 -04:00
Andrew Liang 98f3fc9326 MAINT: Refactor application of capital changes
Previously, on the dt of a capital change, we use the un-updated
prices to find the ending performance of the previous subperiod and
then got the new prices to determine the portfolio value used to
calculate the delta, without actually updating the performance
before applying the capital change. This logic is confusing and
unintuitive. Instead, save the ending performance as we do previously,
but have temp values for the starting current subperiod value.
Update those temp values after processing the capital change
2016-08-01 11:51:45 -04:00
Nathan Wolfe ab9a899c5b MAINT: Switch PanelBarReader to take trading calendar and freq args 2016-07-29 17:36:08 -04:00
Nathan Wolfe 763f2ab8b4 MAINT: Combine daily and minute into PanelBarReader.
Also simplify `load_raw_arrays` and `get_last_traded_dt`.
2016-07-29 17:34:28 -04:00
Nathan Wolfe 69506570dd ENH: Guard against tz-naive index for Panel data. 2016-07-29 17:32:02 -04:00
Nathan Wolfe 3efbe6bc17 MAINT: Clean up data freq inference in TradingAlgorithm.run. 2016-07-29 17:15:47 -04:00
Nathan Wolfe 19d493707f ENH: Improve TradingAlgorithm.run daily or minute data freq assumption
Changing TradingAlgorithm.run not to assume minute data if data freq is
specified as daily and sim params aren't allowed to be overwritten.
2016-07-29 17:11:51 -04:00
Nathan Wolfe cfe755855c ENH: Add PanelMinuteBarReader, use it in TradingAlgorithm.run.
TradingAlgorithm.run didn't support Panel minute bar data, and assumed
all Panel data was daily.

To rectify this, adding PanelMinuteBarReader class.
TradingAlgorithm.run decides whether to use it or PanelDailyBarReader
by assuming data is daily if and only if the time of day of every
Timestamp is identical.
2016-07-29 17:10:21 -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
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 a9d698018a MAINT: Refactor checking, calculation and processing of capital changes
AlgorithmSimulator will no longer check for capital changes.
Instead, TradingAlgorithm find and calculate the changes, and
PerformanceTracker will apply the changes
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
Andrew Liang f146d6d8c1 MAINT: For capital changes, support input of delta or target value
For target changes, calculate the delta using the portfolio value
of the current minute
2016-07-20 15:44:41 -04:00