Commit Graph

2639 Commits

Author SHA1 Message Date
Eddie Hebert 64bbb83ee8 BUG: Force string for asset data values.
Internal tests depend on string vs. unicode for various asset data, so
enforce strings by setting the text_factory on the sqlite connection.
2015-07-15 09:24:42 -04:00
Eddie Hebert 3f57b742d3 BUG: Provide asset data for multiple symbol error.
Fix a change in the information given to the multiple symbol error
during the recent sqlite change to the asset finder.

Instead of the string of sids, return full asset information about the
available options, since internal code relied on the full data.
2015-07-15 09:00:03 -04:00
Eddie Hebert 85b6260d80 BUG: Make sure metadata_cache is created.
Fix issue where metadata_cache was missing causing an AttributeError.
2015-07-14 22:49:00 -04:00
Jonathan Kamens b2fc9da1c8 PyPI updates 2015-07-14 17:19:03 -04:00
Scott Sanderson ac77133672 Merge pull request #651 from quantopian/remove-string-is-checks
BUG: Replaces is-check against string
2015-07-14 15:39:21 -04:00
jfkirk a7f967fb20 BUG: Replaces is-check against string
Replaces an " is 'None' " check with " != None "
2015-07-14 15:18:55 -04:00
Eddie Hebert 36319122cc PERF: Change asset finder to be backed by sqlite3.
Attack the startup bottleneck of creating the asset finders caches for a
large universe, which was between 1-2 seconds on development and
production machines.

Instead, allow the AssetFinder to be passed a sqlite3 file that has
already been populated and then hydrate asset objects only when an
equity is referenced for the first time.

To create aforementioned sqlite3, create an AssetFinder with an db_path
and `create_table` set to True. If `create_table` is set to False, the
prepopulated data in the sqlite file found at db_path will be used.

Default behavior is to use an in memory database.

Behavior that changes:

- Fuzzy lookup now only works on one character, that character needs to be
specified at write/metadata consumption time, since the fuzzy lookup key
is created by dropping the character from each symbol.

- Overwriting partially written metadata is no longer
  supported. i.e. some unit tests allowed for inserting just the identifier,
  and then later updating the symbol, end_date, etc.

  Instead of building an upsert behavior at this time, this patch
  changes the unit tests so that the data for each asset is only
  inserted once.

Other notes:

- populate_cache is now removed, since there is no longer a two step
  process of inserting metadata and then realizing that metadata into
  assets. _spawn_asset is rolled into insert_metadata, so that a call to
  insert_metadata both converts the metadata and makes it available in
  the data store.
2015-07-14 09:54:38 -04:00
Eddie Hebert 3847fa70e0 MAINT: Remove shadowing of built-in type function.
Change variable name in convertible registration so that `type` is not
over-written at module scope.
2015-07-13 16:38:50 -04:00
Andrew Daniels 2ab9f8a63c ENH: Futures API 2015-07-13 09:50:36 -04:00
Jonathan Kamens f30c249e0e Upgrade versions of pbr and mock 2015-07-12 15:54:24 -04:00
Eddie Hebert ad4126bf58 STY: Remove unused import.
Mea culpa.
2015-07-10 17:03:44 -04:00
Jonathan Kamens 7adba53f54 MAINT: pip<7.1.0 is incompatible with mock 1.1 2015-07-10 16:24:28 -04:00
Eddie Hebert 2616a12551 TST: Remove test for lookup of future contract by symbol.
The lookup of future contract by individual symbol is a constraint on
incoming changes of changing how the asset finder stores data.

(i.e. the asset finder is changing so that there are separate tables for
both futures and equities.)

Since this lookup is not yet fully supported, we can add it back in on
top of the new asset finder.
2015-07-10 14:59:33 -04:00
Jonathan Kamens 38112aebc4 MAINT: Fix typos in etc/requirements_dev.txt 2015-07-10 10:47:05 -04:00
Jonathan Kamens 996ea19315 MAINT: Add more packages required by mock to requirements_dev.txt 2015-07-10 10:29:18 -04:00
Jonathan Kamens cb1bc4aa19 MAINT: Update mock and pull in all the packages it requires 2015-07-10 09:26:44 -04:00
Jonathan Kamens 5b0a7ae5a5 MAINT: Upgrade nose-parameterized to 0.5.0 2015-07-10 02:21:10 -04:00
jfkirk efa6d8dbce ENH: Adds a perf tracker method to handle SIDs leaving the universe 2015-07-09 17:03:21 -04:00
Andrew Daniels 7cde3939bf BUG: Determine valid future contracts with notice date
Since most brokers will cease accepting trades by the notice date, contracts should not be considered valid after the notice date. This commit adjusts the lookup_future_chain method to consider all contracts with notice dates on or following the current date invalid.
2015-07-09 15:23:29 -04:00
Jonathan Kamens 50d557975d MAINT: Upgrade Cython to 0.22.1 2015-07-09 14:41:57 -04:00
Jonathan Kamens 6820fa704a MAINT: Upgrade nose-parameterized to 0.4.2 2015-07-09 14:00:29 -04:00
Eddie Hebert bfcb91b359 MAINT: Move possible side assignment to insert metadata method.
The previous workflow was:

- insert basic metadata for all assets

- iterate over all metadata entries. Create a sid if one does not
exist

- call insert_metadata again to update the assigned sid value.

Instead, create a sid, if missing on the initial metadata assignment and
remove the second pass of calling insert_metadata.

Also, since the sid assignment code is only done in this one context,
inline the sid assignment code so that there is less code step through
while looking for where sid assignment is done.
2015-07-08 15:25:18 -04:00
Eddie Hebert 9688989eba MAINT: Use symbol lookup directly from algorithm.
Instead of using the generic lookup, use the asset finder symbol method
directly when `symbol` is used in an algorithm.
2015-07-08 14:41:02 -04:00
jfkirk 1032972b74 ENH: Adds the full Asset objects to the kwargs of MultipleSymbolsFound 2015-07-08 13:33:04 -04:00
Andrew Daniels 1906052a7a BUG: Sets the datetime of TradingAlgorithm initially to the simulation period start
The datetime attribute of TradingAlgorithm was initially None, so calling get_datetime in initialize was causing an unhandled exception. This commit addresses that issue by calling on_dt_changed when initializing the TradingAlgorithm, to force all datetimes to be in line with the period_start.
2015-07-07 17:15:12 -04:00
Eddie Hebert f46fef1755 TST: Remove asset finder test for NASDAQ collisions.
The asset finder retrieved from the test environment is empty, so the
test does not end up testing anything, since the test cases loop over
the empty list of sids in the asset finder.

Remove to possibly be added back in and re-implemented after a larger
refactoring of the module.
2015-07-06 10:52:36 -04:00
Andrew Daniels 977c6cfcde MAINT: Consolidates and improves future lookup methods
Removes unused future lookup methods and consolidates everything into lookup_future_chain. Since the FutureChain object will have to hold a root symbol and dates, it should be responsible for cleaning the user input, so this is removed from the lookup method.

Adds knowledge date to future lookups. This makes our definition of valid contracts more flexible. We know about a contract if it starts trading by the knowledge date, and a contract is expired if it expires by the as_of_date.

Also fixes a bug with computing future chains, where contracts were not included in the chain on their expiration date.
2015-07-02 10:34:32 -04:00
Eddie Hebert a05253b1b6 BLD: Add contextlib2 to TravisCI build config.
Need to extract the value specified by requiremenst.txt so that TravisCI
will install the library.
2015-07-02 10:31:54 -04:00
jfkirk 1ec70b2a26 ENH: Removes use of lookup_generic in DataFrame index mapping 2015-07-01 13:43:31 -04:00
jfkirk 2421753509 TST: Fixes broken tests for DataFrameSource 2015-07-01 13:43:31 -04:00
jfkirk 258b5ea2ca API: DataFrame/Panel sources expect integer sids, not identifiers
This commit modifies the DataFrameSource and DataPanelSource to accept only Int64Indexes on the incoming data and moves the burden of mapping user identifiers to TradingAlgorithm.run().
2015-07-01 13:43:31 -04:00
jfkirk a4ce9712b8 DEP: Removes sids field from SimulationParameters 2015-07-01 13:43:31 -04:00
jfkirk 31f24a238a DEP: Removes unnecessary identifier_cache from asset_finder
The identifier cache's usage was nearly identical to using lookup_generic, so this commit removes identifier-keyed caching and modifies anything that uses it.
2015-07-01 13:43:31 -04:00
Eddie Hebert 0769e7698b MAINT: Use full function for creating empty vector.
np.full is a preferred choice when initializing a vector.
2015-07-01 11:14:48 -04:00
Eddie Hebert 9bf4855b8c MAINT: Move ZiplineAPI context so that it always wraps main loop.
Move the responsibility of wrapping the main simulation loop in the
ZiplineAPI context from the algorithm modules generator setup to the
main trade simulation loop, so that different methods of invoking loop
do not need to duplicate how the context is set.

To make it easier for internal implementation of handle_data to
transition off of calling the ZiplineAPI every bar, to only invoking the
context once per simulation.
2015-07-01 10:58:47 -04:00
Eddie Hebert 62ab540fa2 PERF: Remove repeated member lookup for cumulative metrics.
The metrics DataFrame is referred to several times, so remove the extra
attribute lookups.
2015-07-01 10:52:02 -04:00
Eddie Hebert 7a1a6ddb37 PERF: Reduce time spent indexing in risk cumulative update.
Instead of using the pandas.Series datetime index for every single
vector, get the index at the beginning of the update loop based on the
dt and then use that index to set the values.

Also, since the dt lookup is no longer needed, store the values as numpy
arrays, which are more lightweight.

Locally, this patch cuts out about 60% of the time spent in the update
method.
2015-07-01 10:52:02 -04:00
Scott Sanderson b71b76e133 Merge pull request #605 from grundgruen/data-freq-docstring
DOC: removes suggested hourly data_frequency and changes minutely to …
2015-06-30 08:24:35 -04:00
Warren O'Neill e15b6b0484 DOC: removes suggested hourly data_frequency and changes minutely to minute in docstring 2015-06-30 13:33:37 +02:00
Andrew Daniels 759f346c93 BUG: Fixes issues with AssetFinder future lookups
Contracts must have been trading at the as_of_date to be considered valid, and a contract's position in the chain is now zero-indexed.
2015-06-29 09:51:50 -04:00
Andrew Daniels cc77a52322 ENH: Adds future chain cache and future lookups to AssetFinder 2015-06-25 10:18:18 -04:00
Andrew Daniels 60418f931d DEV: Refactor logic for populating AssetFinder caches
Now populate_cache actually handles the population, and spawn_asset is non-public, i.e. _spawn_asset
2015-06-25 10:18:18 -04:00
Andrew Daniels 46e7b06991 ENH: Adds root_symbol attribute to Future class
Also update AssetFinder to handle root_symbol in meta data
2015-06-25 10:18:18 -04:00
Andrew Daniels 1ae6037a81 TST: Correct and clean up mock futures data for clarity 2015-06-25 10:18:18 -04:00
jfkirk 9291a89599 BUG: Prevents payout of dividend on final trading close 2015-06-24 21:45:55 -04:00
Scott Sanderson a2008f644a TEST: Remove unused test class. 2015-06-24 16:11:14 -04:00
Scott Sanderson 1c7aaf885f MAINT: Remove left-behind comment. 2015-06-24 11:10:47 -04:00
Scott Sanderson a0cec5d093 TEST: Clean AssetFinder initialization and tests.
- AssetFinder no longer accepts an unused trading_calendar.
- AssetFinder correctly accepts a DataFrame as input.
- Tests for AssetFinder no longer rely on a global trading environment.
2015-06-24 09:50:09 -04:00
Richard Frank c101e82399 BLD: Pass args to ordered_pip through to pip
This way, we can specify an index-url, for example.
2015-06-22 14:54:44 -04:00
Jonathan Kamens ed8b3b6c8c MAINT: Upgrade mistune to 0.6 2015-06-17 18:46:08 -04:00