Commit graph

172 commits

Author SHA1 Message Date
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
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
Joe Jevnik
9103516e82 Merge pull request #1313 from nathanwolfe/master
BUG: Add support for Panel data in accordance with documentation
2016-07-29 20:11:56 -04:00
Nathan Wolfe
bdce4ef257 TST: Expand Panel data test to test for multiple sids. 2016-07-29 17:32:00 -04:00
Nathan Wolfe
55b79e8f32 TST: Test TradingAlgorithm.run and run_algorithm on raw Panel data 2016-07-29 17:15:35 -04:00
Joe Jevnik
814a2be7b7 Revert "Point in time asset db" 2016-07-27 23:29:08 -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
Joe Jevnik
7fd8c29880 ENH: add point in time aspect to equity symbol mapping
Changes the overlap behavior so that it is an error to write data which
would have two companies holding the same ticker. Other than one test
around which company would win in that case, all the other tests are
passing. That single test has been changed to check the write-time
error.
2016-07-26 13:34:58 -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
0955515c46 TEST: Test capital changes using target values 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
Jean Bredeche
5a0f840917 Clean up daily bar reader/writer to take advantage of new trading calendar. The reader
is backwards-compatible with the previous format.

In USEquityLoader, use dailyreader's trading_calendar.

This is backwards compatible and will fall back to the NYSE calendar if
the reader doesn’t have a calendar specified.
2016-07-15 15:13:57 -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
Eddie Hebert
4840e124af TST: Speed up TestMiscellaneousAPI
Limit the date range to one day, instead of a year.

On my local machine the following goes from taking 12 seconds to 0.6 seconds.

`$ nosetests -x tests/test_algorithm.py:TestMiscellaneousAPI`
2016-07-11 10:34:08 -04:00
Eddie Hebert
51eda06323 MAINT: Add equity to naming of bar data classes.
In preparation of adding futures, add equity to the names of both the
classes and methods for writing bcolz data. Futures data will use a
different minutes per day with a separate reader. This change will allow
both equity and futures fixtures to be side by side.

Also, break out the method which generates the dataframes and trading
days member into fixtures (`EquityMinuteBarData` and
`EquityDailyBarData`) on which the `*BarReader` fixture depends.  This
fixture is separated out to enable reader/writers in different formats
to use the same data setup. (There is internal code which needs to write
minute and daily bar data in a database format.)
2016-06-30 08:21:42 -04:00
Eddie Hebert
ca58632815 MAINT: Remove DataSource and derived classes.
The `DataSource` class and other classes derived from it are no longer
used. Instead `DataPortal` and various `MinuteBarReader` and
`DailyBarReaders` should be used.
2016-06-27 13:06:41 -04:00
Joe Jevnik
ca37d73c7b TST: fix setup in test_flip_algo 2016-06-21 15:07:03 -04:00
jfkirk
39cc355066 TST: Finishes fixing fixes for the fixed fixtures 2016-06-08 13:34:23 -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
581e817603 MAINT: Rebase reconciliation 2016-06-08 13:34:22 -04:00
jfkirk
75e0e4723d TST: Refactors more tests to use WithTradingSchedule 2016-06-08 13:34:20 -04:00
jfkirk
d9fc514fa8 TST: Adds TradingSchedule test fixture 2016-06-08 13:34:20 -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
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
d888c4faaa DOC: update docs for api functions 2016-05-06 15:25:30 -04:00
Andrew Liang
7641247b41 BUG: DAY_END action not emitted during minute emission
Refactor AlgorithmSimulator so that DAY_END is emitted for both
minute and daily emission, and that handling of end-of-minute
and end-of-day are separated
2016-05-06 10:25:44 -04:00
Joe Jevnik
efac476976 ENH: make BcolzMinuteBarWriter.write take iterable
Updates the BcolzMinuteBarWriter.write api to allow users to pass their
data as a stream instead of requiring that they loop over their data
externally. This matches the API presented by BcolzDailyBarWriter.
2016-04-29 16:14:48 -04:00
Andrew Liang
7332586abe FIX: Crashing on calculating benchmarking when no trading days
When we run a simulation that starts and ends on the same weekend,
return an empty series for the benchmark so as to not crash
2016-04-29 14:30:46 -04:00
Andrew Liang
d69b960c49 BUG: Don't save empty positions when user access non-existent position
Previously, whenever we try to access a missing value on the Positions
dict, we return a default Position and save it to the dict. Instead,
just return the Position
2016-04-26 13:28:35 -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
Jean Bredeche
c323506f40 BUG: we were improperly checking iterable kwargs in BarData 2016-04-21 11:06:46 -04:00