Commit Graph

85 Commits

Author SHA1 Message Date
Scott Sanderson af5f4be17c MAINT: Fix warnings from numpy on NaT comparison. 2016-09-20 17:12:07 -04:00
Scott Sanderson f30fc28b5c MAINT: Pass float explicitly to numpy. 2016-09-20 17:12:07 -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
Joe Jevnik fcde54297c MAINT: remove __getitem__ as alias of __getattr__ 2016-08-31 12:38:20 -04:00
Jean Bredeche 51da755c43 TST: Some futures-related fixtures cleanup. 2016-08-28 21:33:54 -04:00
Eddie Hebert a3c1f4ce36 MAINT: Standardize reader get value methods.
The daily/session bar reader's `spot_price` took the same parameters and
returned the same kind of output as the minute bar reader's `get_value`.

Standardize on one method to make a common interface, which may be
formally factored out in a later patch; to help enable writing reader
implementations or mixins which can be agnostic to the bar frequency.
2016-08-24 12:46:36 -04:00
Eddie Hebert 6b2d614227 TST: Use equity calendar when writing equity data
Use the equity calendar to write equity data, even when the simulation
calendar has been set to a different calendar.

Discovered when writing a test that used a calendar for future asset
data, but also wrote equity data.
2016-08-23 11:11:32 -04:00
Andrew Daniels 53ca68e8fb 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 c482a7cd59 Merge pull request #1405 from quantopian/resample-session-from-minute
ENH: Session bar reader resampled from minute data
2016-08-18 13:26:24 -04:00
Eddie Hebert f14fcd9b07 ENH: Session bar reader resampled from minute data
Implement a `SessionBarReader` which uses a minute bar reader as a
backing source, resampling the minute bars into the box around the
corresponding session data.

Also, add future/CME test cases to resample suite.
2016-08-18 11:37:42 -04:00
Scott Sanderson 5fe60c76a7 BUG: Fix broken fixture resolution.
Make sure that WithDefaultDateBounds is last in everyone's mro().
2016-08-17 16:52:09 -04:00
Scott Sanderson 8fa51bdaab MAINT: Use numpy_utils.as_column in more places. 2016-08-17 16:52:09 -04:00
Scott Sanderson 0f4964fdfa MAINT: Clean up WithTradingSessions.
- Add WithDefaultDateBounds, since we use alias('START_DATE') and
  alias ('END_DATE').

- Fix copypasta in assertion.
2016-08-17 16:52:09 -04:00
Scott Sanderson 10ab8dc875 MAINT: Remove double import. 2016-08-17 16:52:09 -04:00
Eddie Hebert 0ebffbaeb9 Merge pull request #1388 from quantopian/future-pricing-cleanup
Cleanup some Futures related modules and values.
2016-08-11 14:21:53 -04:00
Eddie Hebert 294c716112 MAINT: Define futures minutes per day.
Define the commonly used minutes per day for futures data as a module
level value.
2016-08-11 12:32:17 -04:00
Joe Jevnik ea80b8892c TST: Adds dispatch for assert_equal(set, set) 2016-08-10 15:32:36 -04:00
Eddie Hebert 37f4a5a56b TST: Add tests for Future asset last sale price.
In support, also add future asset minute bar data and reader fixtures.
2016-08-09 14:10:57 -04:00
Eddie Hebert f4891b0a08 TST: Key trading calendar fixture with Asset types
Instead of using strings of 'equities' and 'futures', use the Asset
subclasses to key the trading calendar fixtures.
2016-08-08 03:49:48 -04:00
Eddie Hebert dd2c7db22d TST: Use sum for volume on daily data resample.
Change the mock minute data to no longer use an increasing arange, so
that a days worth of minute data can be summed and fit inside of a
uint32.

This change was required because of working on new test data that looked
like [0, 100, 200, 0, ] which was resulting in a daily rollup of 0 data,
when the coverage needed a non-0 value.

Also, factor out the resampling function, with an eye on a making it
easier to convert from minute bars to daily bars during ingest/load
processes.
2016-08-05 14:24:14 -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 9ae725b940 ENH: update register_calendar API to take a specific name 2016-08-02 23:12:07 -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
Joe Jevnik 814a2be7b7 Revert "Point in time asset db" 2016-07-27 23:29:08 -04:00
Joe Jevnik bc10447b9e TST: add assert_equal dispatch for other ndframe objects 2016-07-26 13:34:58 -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 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 e22108b7ef Merge pull request #1312 from quantopian/24-5-backtesting
Re-implemented the calendar API.
2016-07-14 10:05:18 -04:00
Joe Jevnik 958d455a7a ENH: Support default params for terms 2016-07-12 18:49:24 -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 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
dmichalowicz 393f82e81e ENH: Add single-column input/output capabilities to pipeline terms 2016-06-23 10:24:09 -04:00
Richard Frank 69b6cff964 Merge pull request #1289 from quantopian/wildcard
wildcard object and doctests
2016-06-22 18:09:57 -04:00
Joe Jevnik d608e0af4f Merge pull request #1276 from quantopian/blaze-loader-checkpoints
ENH: add ffill checkpointing to blaze core loader
2016-06-21 16:48:08 -04:00
Joe Jevnik 5925107052 TST: fix doctests to actually run 2016-06-21 15:07:03 -04:00
Joe Jevnik c0d08f9c0d TST: Adds wildcard object for assert_equal 2016-06-20 14:20:18 -04:00
Eddie Hebert 9f02f147b0 Merge pull request #1283 from quantopian/custom-paths-for-fixtures
TST: Allow customization of various fixture paths.
2016-06-20 10:08:27 -04:00
Joe Jevnik cb67ee425e TST: coverage 2016-06-17 17:59:56 -04:00
Eddie Hebert d6793e7a71 TST: Allow customization of various fixture paths.
To support testing configurations which need control over the full path
to the asset, adjustment, and equity bcolz directories; which is
required by some of our internal testing which exercises servers which
coordinate these files via a date slug in the full path.

Also, by allowing customization of the full path, it is now possible to
have the AssetFinder and AdjustmentReader sqlite databases be written to
disk, which is also required for our server testing setup.
2016-06-17 16:13:31 -04:00
Richard Frank 3d7f63f8c1 MAINT: Removed unused ExceptionSource
No longer used since our lazy data access changes.
2016-06-15 10:43:20 -04:00
Scott Sanderson bc302beec9 MAINT: Rework event datasets.
- Refactored EventsLoader and BlazeEventsLoader to not require a
  subclass per dataset.  Instead, you now pass a map from columns to
  event fields directly to the EventsLoader constructor.

- Removed a large number of Quantopian-specific datasets and associated
  tests.

- Rewrote the core logic of EventsLoader and BlazeEventsLoader to share
  index calculations across multiple requested columns.

- Fixed a bug where event fields were incorrectly forward-filled when
  null values were present in an event.
2016-06-10 19:22:27 -04:00
Andrew Daniels 02a91ec4ab MAINT: Removes the set_first_trading_day method of DataPortal
Since the first trading day is now passed directly to the DataPortal on
init, there's no need for a method that does this. Moves all the
additional logic/assignments into the init. Also corrects an issue where
we would never create certain attributes if self._first_trading_day was
None.

Adds the ability to specify the first trading day for a data portal in a
test case when using the WithDataPortal fixture.
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 d9fc514fa8 TST: Adds TradingSchedule test fixture 2016-06-08 13:34:20 -04:00
jfkirk 26742dda67 MAINT: Removes obsolete tradingcalendar module 2016-06-08 13:34:19 -04:00
jfkirk 241abda2a5 STY: Flake8 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 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