Commit Graph

5611 Commits

Author SHA1 Message Date
jfkirk 67c56f768b ENH: Adds auto-closing feature and implements for Futures 2015-07-31 10:38:44 -04:00
Scott Sanderson f13e9fd125 TEST: Add test asserting dynamic api_methods. 2015-07-29 12:30:46 -04:00
Scott Sanderson 01c03d2267 MAINT: Add nullctx back to test_utils.
Temporary upstream compat for Quantopian code.

To be removed at the earliest possible convenience.
2015-07-29 12:30:46 -04:00
Scott Sanderson de3111d51a BUG: dict.itervalues() doesn't exist in PY3 2015-07-29 12:30:46 -04:00
Scott Sanderson ef4f642e62 ENH: Compute engine architecture for FFC API.
This patch lays the groundwork for a compute engine designed to
facilitate construction of factor-based universe screening and portfolio
allocation.  It contains:

A new module, `zipline.modelling`, containing entities that can be used
to express computations as dependency graphs.  Each node in such a graph
is an instance of the base `Term` class, defined in
`zipline.modelling.term`.  Dependency graphs are executed by instances
of `FFCEngine`, defined in `zipline.modelling.engine`.

A new module, `zipline.data.ffc`, containing loaders and dataset
definitions for inputs to the modelling API.

New `TradingAlgorithm` api methods: `add_factor`, and `add_filter`.
These methods can only be called from `initialize`, and are used to
inform the algorithm that each day it should compute the given terms.
Computed factor results are made available through a new attribute of
the `data` object in `before_trading_start` and `handle_data`.  Computed
filter results control which assets are available in the factor matrix
on each day.
2015-07-29 12:30:46 -04:00
Scott Sanderson 6b72b60cde MAINT: Don't install non-zipline packages.
In particular, don't give anyone who installs zipline a global package
named 'tests'.  (sob)
2015-07-29 12:30:46 -04:00
Scott Sanderson 26ef001bfc Merge pull request #658 from quantopian/remove-unused-property
MAINT: Remove unused `assets` property.
2015-07-28 19:34:14 -04:00
Jonathan Kamens dca679edcb BUG: Logbook 0.10.0 requires explicit handler
As of logbook 0.10.0, logbook no longer installs a default handler,
which means that if the application doesn't install one, log messages
disappear into the ether.

Therefore, all of our scripts with `__main__` endpoints need to push a
`logbook.StderrHandler` if they're not already pushing some other
handler.
2015-07-28 04:38:41 -04:00
Jonathan Kamens 576e4184d7 BLD: Update mock to release 1.3.0 2015-07-24 12:28:51 -04:00
Jonathan Kamens 393ea35e46 BLD: Switch back to PyPI version of xlrd
The bug which prompted us to use our own version of xlrd is patched in
the current PyPI release, so switch back to it.
2015-07-24 12:28:12 -04:00
Jonathan Kamens 622144fa75 BLD: Add "--exists-action w" to pip invocations 2015-07-23 15:58:13 -04:00
Jonathan Kamens 21610053e6 MAINT: Upgrade PyPI versions of tornado, mistune, mock, patsy 2015-07-23 14:51:25 -04:00
Jonathan Kamens 5e796aacf1 DEV: Add piprot and its deps to requirements_dev.txt 2015-07-23 14:34:03 -04:00
Scott Sanderson 20c5fc356f MAINT: Remove unused assets property.
It references a self.cache attribute that no longer exists.
2015-07-21 17:43:43 -04:00
jfkirk 16ab46b69c DEV: Uses ValueError when PerformanceTracker.to_dict receives invalid emission type 2015-07-21 16:06:52 -04:00
jfkirk 8d5bfd3c91 BUG: Aligns performance packet generation between minute and daily modes 2015-07-21 13:25:39 -04:00
Eddie Hebert f22e9e5122 Revert "PERF: Reuse one cursor in asset finder lookups."
This reverts commit 136a09776d.
2015-07-16 15:36:48 -04:00
Eddie Hebert 136a09776d PERF: Reuse one cursor in asset finder lookups.
Instead of creating a new cursor with each query, use the same cursor
throughout the lifetime of the finder instance to remove any overhead
from creating a new cursor in tight loops.
2015-07-16 15:16:36 -04:00
Eddie Hebert 376dc7b703 BUG: Fix exception on no symbol with fuzzy enabled
If there is no symbol there should be no fuzzy lookup either.
2015-07-15 15:52:33 -04:00
Eddie Hebert ace2b5c9e9 PERF: Improve risk metrics update speed.
Remove the DataFrame of headline risk metrics, in favor of a numpy array
for each metric, like the underlying vectors.
2015-07-15 15:36:35 -04:00
Eddie Hebert 27ab36deb2 MAINT: Remove references to minute risk.
The minutely calculation of risk metrics had been removed with a
previous patch, remove vestigial references.

Remove a test which tested the behavior of updating the second minute of
a day.

Remove the logic that changed the datetime index of the risk metrics
depending on emission rate, now only trading_days are needed.

Remove `returns_frequency` parameter since both minute and daily
data frequency always use daily returns.
2015-07-15 15:36:35 -04:00
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