Commit Graph

285 Commits

Author SHA1 Message Date
Eddie Hebert 3d47aee2ab 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 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 8ea3226a5c ENH: Renamed to batch_order and added batch_order_target_percent 2016-12-20 11:58:05 -05:00
Richard Frank 74a3247892 MAINT: Renamed order_batch parameter and added docs 2016-12-20 11:57:27 -05:00
Richard Frank 86c4c27a6a 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 a5423083bf ENH: Allow custom chunks iterators for attach_pipeline 2016-12-15 19:58:19 -05:00
Scott Sanderson 16e78bbccd BUG: sys.exc_clear is py2 only. 2016-11-22 16:34:53 -05:00
Scott Sanderson 52ed9093eb 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 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
Scott Sanderson d47144dfb8 DOC: Rename NoopRestrictions to NoRestrictions. 2016-09-30 16:35:23 -04:00
Scott Sanderson cfce14ed9b DOC: Update docstring for set_restrictions. 2016-09-30 16:35:23 -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 e465f64f91 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 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
Eddie Hebert 5c77b36ce9 Merge pull request #1494 from quantopian/remove-unused-update-dividends
MAINT: Remove unused method.
2016-09-21 10:36:12 -04:00
Scott Sanderson becf897da9 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 a642a9aeee MAINT: Remove unused method.
Dividends are read from AdjustmentReader.
2016-09-16 16:50:10 -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
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
Jean Bredeche 7b83cbe820 ENH: Add new parameter to schedule_function that accepts a trading
calendar.
2016-08-28 21:33:42 -04:00
Scott Sanderson ed3b0fcaa7 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
Jean Bredeche 295cfa3846 Fix some mistakes from a previous merge.
No tests failed, which was worrisome.  Will file issues to take a look
later.
2016-07-14 15:40:36 -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
jfkirk d437a5d675 MAINT: Rebase fixes 2016-06-08 13:34:23 -04:00