Commit Graph

90 Commits

Author SHA1 Message Date
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
Richard Frank 67dbeab820 MAINT: Clean up usage of engine versus connection 2016-08-24 13:24:07 -04:00
Andrew Daniels 7719f6e1a2 BUG: Fixes asset writer to the select the latest asset to hold a sid (#1392)
* BUG: Fixes asset writer to the select the latest asset to hold a sid

When constructing the asset_info dataframe, we were previously taking
the first symbol/sid pair to include, when we should be taking the most
recent.

* Ensure groups are sorted by increasing end_date

* Updates test_lookup_symbol_change_ticker to also cover asset_name
2016-08-15 20:38:02 -04:00
Joe Jevnik 23363ee45a TST: test the v5->v4 downgrade 2016-08-10 15:32:49 -04:00
Joe Jevnik 8fa84b0f00 BUG: always show the most recent symbol in Asset objects 2016-08-08 13:01:55 -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
Joe Jevnik 1f10fff1c4 BUG: support querying more than 999 assets at a time 2016-08-02 18:53:57 -04:00
Joe Jevnik 6708ef1bdf ENH: update assets-db-error-msg 2016-08-02 14:25:10 -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
Jean Bredeche a40d205afa ENH: Adding exchange_full to equity asset column 2016-08-02 09:35:08 -04:00
Joe Jevnik 814a2be7b7 Revert "Point in time asset db" 2016-07-27 23:29:08 -04:00
Joe Jevnik fb532c3fe8 TST: Adds test for symbol changes 2016-07-26 13:34:58 -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 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 75e0e4723d TST: Refactors more tests to use WithTradingSchedule 2016-06-08 13:34:20 -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
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
Joe Jevnik 721dd36116 TST: move test_utils and adds test fixture classes
Renames zipline.utils.test_utils to zipline.testing

Adds zipline.testing.fixtures.ZiplineTestCase to manage setup and
teardown and adds mixins to define fixtures like an asset finder or
trading calendar.
2016-03-10 15:39:52 -05:00
dmichalowicz 5be63f36d5 ENH: Add auto_close_date support for equities 2016-02-22 13:51:20 -05:00
Richard Frank 28b34f6409 BUG: Handle OverflowError by comparing False
instead of raising
2016-02-01 15:02:15 -05:00
jfkirk d82bd5c05d TST: Cleans up test_to_and_from_dict 2016-01-22 15:26:14 -05:00
jfkirk ece9e59ef9 ENH: Adds asset db downgrade management and tests 2016-01-22 14:56:30 -05:00
jfkirk db1e62971a ENH: Adds tick_size and renames futures multiplier 2016-01-22 14:56:30 -05:00
Richard Frank 4ee919aeb2 Merge pull request #959 from quantopian/asset_keyerror
Asset KeyError
2016-01-21 12:38:53 -05:00
Richard Frank 2eeb6e78f6 BUG: Enable comparison of an Asset to an int64 on 32-bit python
We use a number of mappings keyed by int64, which otherwise raised
KeyErrors for Assets.
2016-01-21 11:47:29 -05:00
James Kirk 2cb3a7235e Merge pull request #890 from grundgruen/future_chain_order
BUG: orders future chain by min of notice and expiry
2016-01-21 11:18:57 -05:00
warren-oneill a963270471 BUG: orders future chain by min of notice an expiry 2016-01-18 12:20:58 +01:00
jfkirk 00879245a4 BUG: Adds version checking to AssetFinder init 2016-01-05 13:48:00 -05:00
jfkirk 004c8dc141 MAINT: Factors-out asset db schema 2016-01-05 13:48:00 -05:00
Scott Sanderson 4832004c33 TEST: Test fallback to start_date/end_date sorting.
Adds tests asserting that we resolve conflicts in accordance with the
following rules when we have multiple assets holding the same symbol at
the same time:

If multiple SIDs exist for symbol S at time T, return the candidate
SID whose start_date is highest. (200 cases)

If multiple SIDs exist for symbol S at time T, the best candidate
SIDs share the highest start_date, return the SID with the highest
end_date. (34 cases)

It is the opinion of the author (ssanderson) that we should consider
this malformed input and fail here.  But this is the current indended
behavior of the code, and I accidentally broke it while refactoring.
These will serve as regression tests until the time comes that we
decide to enforce this as an error.

See https://github.com/quantopian/zipline/issues/837 for more
details.
2015-11-13 18:26:54 -05:00
Scott Sanderson 657a132f1e ENH: Make retrieve specific type functions public.
We rely on these upstream, for better or worse, so add tests and docs.

Also adds distinct `EquitiesNotFound` and `FutureContractsNotFound`
exceptions.
2015-11-13 18:26:54 -05:00
Scott Sanderson 9e463fd5d8 MAINT: make_rotating_asset -> make_rotating_equity. 2015-11-13 18:26:54 -05:00
jfkirk 85dd4b70dd MAINT: Renames 'version' table to 'version_info' for clarity 2015-11-12 14:43:11 -05:00
jfkirk 6aac54544e MAINT: Only write asset db version on db creation 2015-11-12 14:43:11 -05:00
jfkirk 48e488d423 ENH: Adds versions to asset databases 2015-11-12 14:43:11 -05:00
Maya Tydykov df492ecf7f DOC: add whatsnew entry for AssetFinderCachedEquities. 2015-11-12 11:02:30 -05:00
Maya Tydykov d0cb5bd513 ENH: add extension to AssetFinder that caches all equities in memory and uses that cache in lookup_symbol. 2015-11-12 11:02:26 -05:00
jfkirk af021f0db5 BUG: FutureChain's as_of() now properly coerces arguments 2015-11-10 14:03:19 -05:00
Scott Sanderson 90e717f6a7 Merge pull request #821 from quantopian/cme-codes-reference
ENH: Add CME code lookup table.
2015-11-05 14:19:36 -05:00
Scott Sanderson 744a998b9a ENH: Add CME code lookup table. 2015-11-05 13:57:44 -05:00
Scott Sanderson a14c61e7ff MAINT: Remove unused 'asset_type' metadata entry. 2015-11-05 13:35:05 -05:00
jfkirk 915c8e800f MAINT: Removes unneeded knowledge_date logic from future_chain 2015-10-19 11:37:56 -04:00
jfkirk 2686e3875a MAINT: Removes unnecessary benchmark load on some TradingEnvironments 2015-10-14 12:04:58 -04:00
Stewart Douglas 4e2039c9b0 ENH: Coerce user input with API method decorator
Previously we have capitalized input strings at different levels in
our code: in the user-facing API methods and in the asset finder.
This commit moves input string capitalization exclusively to the API
method to which the string was supplied. Specifically, the string is
capitalized by a preprocess API method decorator. The preprocess
decorator passes the input string to the newly defined
ensure_upper_case() method, which returns a TypeError if the argument
supplied is not a string.

ensure_upper_case() is defined in a new file, zipline/utils/input_validation.py.
The existing expect_types() method is also moved there.

Various tests in tests/test_assets.py are modified to account for the
fact that the asset finder method lookup_symol() no longer capitalizes
its supplied argument.
2015-10-08 15:41:33 -04:00
Andrew Daniels 2e85e08768 TST: Adds basic test coverage for FutureChain.__iter__ 2015-10-08 14:35:00 -04:00
Andrew Daniels 9ecd7e18d0 MAINT: Improves handling for contract date info in lookup_future_chain
Improves the query for futures contract to use the date that comes first
in time (between notice_date and expiration_date) to determine cotnract
validity. If one of these is missing, we'll use the other.

Also modifies the query to order the resulting contracts by their
expiration_date if available, and to use their notice_date if not.
2015-10-08 14:16:57 -04:00
Stewart Douglas 3cfdd6cf8c ENH: Add lookup_future_symbol method 2015-10-05 10:25:08 -04:00
Stewart Douglas 8ba15a6f72 BUG: Correctly test for duplicate symbols 2015-10-01 15:02:23 -04:00