Commit Graph

257 Commits

Author SHA1 Message Date
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
jfkirk 2a8f69fc01 MAINT: DataPortal env -> asset_finder 2016-06-08 13:34:22 -04:00
jfkirk d9fc514fa8 TST: Adds TradingSchedule test fixture 2016-06-08 13:34:20 -04:00
jfkirk 31f9f06c9a MAINT: Removes static calendar from schedule_function rules 2016-06-08 13:34:19 -04:00
jfkirk 591ae02a02 MAINT: Removes unnecessary NYSETradingSchedule 2016-06-08 13:34:19 -04:00
jfkirk 4b7390ac81 WIP: Refactors tests to use TradingSchedule 2016-06-08 13:34:19 -04:00
jfkirk c8304e8601 ENH: Adds ExchangeCalendar, TradingSchedule, and implementations
Conflicts:
	tests/data/test_minute_bars.py
	tests/data/test_us_equity_pricing.py
	tests/finance/test_slippage.py
	tests/pipeline/test_engine.py
	tests/pipeline/test_us_equity_pricing_loader.py
	tests/serialization_cases.py
	tests/test_algorithm.py
	tests/test_assets.py
	tests/test_bar_data.py
	tests/test_benchmark.py
	tests/test_exception_handling.py
	tests/test_fetcher.py
	tests/test_finance.py
	tests/test_history.py
	tests/test_perf_tracking.py
	tests/test_security_list.py
	tests/utils/test_events.py
	zipline/algorithm.py
	zipline/data/data_portal.py
	zipline/data/us_equity_loader.py
	zipline/errors.py
	zipline/finance/trading.py
	zipline/testing/core.py
	zipline/utils/events.py
2016-06-08 13:34:18 -04:00
Andrew Liang 1056501b27 MAINT: Support the passing of a time rule positionally on the date_rule arg
But log a warning to the user
2016-06-03 15:28:53 -04:00
Andrew Daniels 71f12ec272 MAINT: Adds first_trading_day arg to DataPortal
Instead of inferring it from the minute/daily writer, we now require the
first trading day to be passed explicitly, so the creator of the
DataPortal controls what is used as the first trading day.
2016-06-02 13:16:43 -04:00
Scott Sanderson 5caccaeed5 Merge pull request #1230 from quantopian/pipeline-example
DOC/TEST: Add example algo using Pipeline.
2016-05-25 22:35:59 -04:00
Scott Sanderson 392ac2f9d6 DOC/TEST: Add example algo using Pipeline. 2016-05-24 22:34:05 -04:00
Scott Sanderson 244664b6a3 MAINT: Clean up default handling in TradingAlgorithm. 2016-05-24 22:17:01 -04:00
Andrew Liang 40f42b43f5 DEV: Adjust performance calculations for capital changes
Refactor PerformancePeriod so that it creates a sub-period every
time a capital change happens within the period
2016-05-24 17:23:36 -04:00
Jean Bredeche 39bf1dbd7b DEV: Re-implement commission models to return correct results in the case of multiple fills. 2016-05-23 21:19:06 -04:00
Joe Jevnik 664a0d234c DOC: document limit and stop price args 2016-05-19 20:10:38 -04:00
Richard Frank 7afd486510 DOC: Fixed parameter typo 2016-05-19 11:51:12 -04:00
Joe Jevnik 19c87fd871 Merge pull request #1188 from quantopian/api-docstrings
api documentation
2016-05-12 22:42:48 -04:00
Joe Jevnik 8622993358 DOC: update docs based on Rich's feedback 2016-05-12 17:07:02 -04:00
Scott Sanderson 98a26bbcc6 BUG: Set _assets_from_source as a list. 2016-05-09 15:53:20 -04:00
Jean Bredeche fe5a2a888a PERF: takes ~14% off the time it takes to initialize a MinuteSimulationClock
on my machine, ~350ms -> ~300ms

also, clarifies the public API for MinuteSimulationClock (now, only
__iter__ is exposed)
2016-05-09 10:18:41 -04:00
Joe Jevnik d888c4faaa DOC: update docs for api functions 2016-05-06 15:25:30 -04:00
Scott Sanderson 5f190395ad ENH: Add support for strings in Pipeline.
- Adds a new class, ``LabelArray``, which is a subclass of np.ndarray.
  LabelArray is conceptually similar to pandas.Categorical, in that it
  stores data with many duplicate values as indices into an array of
  unique values.  For string data with many duplicates (e.g. time-series
  of tickers or or industry classifications), this provides multiple
  orders of magnitude of improvement when doing string operations,
  especially string comparison/matching operations.

- Adds a new generic object "specialization" for `AdjustedArrayWindow`,
  and a corresponding ObjectOverwrite adjustment.

- Adds a new ``postprocess`` method to ``zipline.pipeline.term.Term``.
  This method is called on the final result of any pipeline expression
  after screen filtering has occurred. The default implementation of
  ``postprocess`` is identity, but Classifier overrides it to coerce
  string columns into pandas.Categoricals before presenting them to the
  user.
2016-05-04 15:50:52 -04:00
Joe Jevnik 59c8e371a2 ENH: Updates the cli, data bundles and extensions.
Adds the data bundle concept which makes it easy for users to register
loading functions to build out minute and daily data along with an
assets db and adjustments db. By default we have provided a `quandl`
bundle which pulls from the public domain WIKI dataset. Users may
register new bundles by decorating an ingest function with
`zipline.data.bundles.register(<name>)`. This also provides a
`yahoo_equities` function for creating an ingestion function that will
load a static set of assets from yahoo.

The cli is now structured as a couple of subcommands and has been
changed to `python -m zipline`. The old behavior of `run_algo.py` has
been moved to the `run` subcommand. This is almost entirely the same
except that it now takes the name of the data bundle to use, defaulting
to `quandl`.

The next subcommand is `ingest` which takes the name of
a data bundle to ingest. This will run the loading machinery and write
the data to a specified location that `run` can find.

There is also a `clean` subcommand which deletes the data that was
written with `ingest`.

Extensions have also been added to zipline. This is an experimental
feature where users can provide an extra set of python files to run at
the start of the process. These can be used to configure aspects of
zipline. Right now the only thing that is supported in an extension file
is the registration of a new data bundle.
2016-05-03 18:38:24 -04:00
dmichalowicz 8d1ecb508a Use string_types 2016-04-28 15:28:19 -04:00
Scott Sanderson 85ae664d8c BUG: Don't crash on dataframes with assets in index. 2016-04-28 15:19:57 -04:00
Andrew Liang 5809ae17f1 DEV: Better error message for sid= in get_open_orders
Let the user to know to use asset= instead
2016-04-26 12:23:57 -04:00
Jean Bredeche c404c60d68 BUG: don't allow ordering in before_trading_start 2016-04-26 10:56:36 -04:00
Joe Jevnik bc0b117dc9 MAINT: make the data loading apis more consistent.
Changes BcolzDailyBarWriter to not be an abc, data is passed as an
iterator of (sid, dataframe) pairs to the write method.

Changes the AssetsDBWriter to be a single class which accepts an engine
at construction time and has a `write` method for writing dataframes for
the various tables. We no longer support writing the various other data
types, callers should coerce their data into a dataframe themselves. See
zipline.assets.synthetic for some helpers to do this.

Adds many new fixtures and updates some existing fixtures to use the new
ones:

WithDefaultDateBounds
  A fixture that provides the suite a START_DATE and END_DATE. This is
  meant to make it easy for other fixtures to synchronize their date
  ranges without depending on eachother in strange ways. For example,
  WithBcolzMinuteBarReader and WithBcolzDailyBarReader by default should
  both have data for the same dates, so they may use depend on
  WithDefaultDates without forcing a dependency between them.

WithTmpDir, WithInstanceTmpDir
  Provides the suite or individual test case a temporary directory.

WithBcolzDailyBarReader
  Provides the suite a BcolzDailyBarReader which reads from bcolz data
  written to a temporary directory. The data will be read from
  dataframes and then converted to bcolz files with
  BcolzDailyBarWriter.write

WithBcolzDailyBarReaderFromCSVs
  Provides the suite a BcolzDailyBarReader which reads from bcolz data
  written to a temporary directory. The data will be read from a
  collection of CSV files and then converted into the bcolz data through
  BcolzDailyBarWriter.write_csvs

WithBcolzMinuteBarReader
  Provides the suite a BcolzMinuteBarReader which reads from bcolz data
  written to a temporary directory. The data will be read from
  dataframes and then converted to bcolz files with
  BcolzMinuteBarWriter.write

WithAdjustmentReader
  Provides the suite a SQLiteAdjustmentReader which reads from an in
  memory sqlite database. The data will be read from dataframes and then
  converted into sqlite with SQLiteAdjustmentWriter.write

WithDataPortal
  Provides each test case a DataPortal object with data from temporary
  resources.
2016-04-15 23:46:10 -04:00
Jean Bredeche fac5905c10 Merge pull request #1114 from quantopian/handle-data-optional
ENH: make handle_data optional
2016-04-13 09:31:41 -04:00