Commit Graph

41 Commits

Author SHA1 Message Date
Stewart Douglas 8ba15a6f72 BUG: Correctly test for duplicate symbols 2015-10-01 15:02:23 -04:00
jfkirk 082bc4f906 MAINT: Removes default_none from lookup_symbol 2015-09-16 14:55:42 -04:00
jfkirk c446e7f62a ENH: Adds fuzzy symbol look-up and makes it distinct from delimited symbols 2015-09-16 14:34:18 -04:00
jfkirk d84bdefef8 MAINT: Removes lookup_symbol_resolve_multiple method
lookup_symbol_resolve_multiple was identical to lookup_symbol, except that lookup_symbol performed upper-casing of the input string and lookup_symbol would return Nones. Now, lookup_symbol has a kwarg 'default_None=True' and all symbols are upper-cased on insertion and request.
2015-09-16 09:54:37 -04:00
jfkirk 29dce965d5 ENH: Simplifies AssetFinder symbol lookup by making fuzzy lookup the default 2015-09-16 09:54:11 -04:00
Scott Sanderson 26fd6fda8b ENH/BUG: Modeling API enhancements.
- Fixes an error where Modeling API data known as of the close of `day
  N` would be shown to algorithms during `before_trading_start` as of
  the close of the same day.  Algorithms should now only receive data
  during `before_trading_start/handle_data` that was known as of the
  simulation time at which the function would be called.

- All Term instances now have a `mask` attribute that must be a `Filter`
  or an instance of `AssetExists()`.  `mask` can be used to specify that
  a Factor should be computed in a manner that ignores the values that
  were not `True` in the mask.

- Changed the interface for `FFCLoader.load_adjusted_array` and
  `Term._compute` from `(columns, mask)`, with mask as a DataFrame, to
  `(columns, dates, assets, mask)`, where mask is a numpy array.  This
  is primarily to avoid having to reconstruct extra DataFrames when
  using masks produced by non `AssetExists` filters.

- Adds `BoundColumn.latest`, which gives the most-recently-known value
  of a column.
2015-09-16 01:47:11 -04:00
Scott Sanderson ad54eedeea Revert "MAINT: AssetFinder now takes fuzzy characters on look-up, not init"
This reverts commit c16bc9f8db.  This
caused upstream breakage unexpectedly.  Postponing until we can synchronize.
2015-09-15 23:57:25 -04:00
jfkirk c16bc9f8db MAINT: AssetFinder now takes fuzzy characters on look-up, not init 2015-09-15 09:38:17 -04:00
jfkirk a6ce1e5e8d ENH: Adds auto_close_date field to Future objects 2015-09-11 14:08:03 -04:00
jfkirk 6e6ef447d2 TST: Adds tearDownClass methods to delete TradingEnvironments 2015-09-10 11:53:29 -04:00
jfkirk 5320fd0fc5 BUG: Adds missing parens to AssetFinder sids property 2015-09-10 11:53:28 -04:00
jfkirk 2a28d09380 MAINT: Removes exchange_id and root_symbol_id columns from AssetDB 2015-09-10 11:53:28 -04:00
jfkirk dc964a7e7d MAINT: Removes the ability to reference a global TradingEnvironment
This commit removes the ability to reference a shared TradingEnvironment through the zipline.finance.trading module. In place, the classes that require a TradingEnvironment, or its child AssetFinder, contain their own references to those objects.

This commit also adds serialization utilities that allow for the pickling/unpickling of objects without unintentionally their TradingEnvironments or AssetFinders.
2015-09-10 11:53:28 -04:00
Stewart Douglas 1ef2274d11 MAINT: Update tests to conform to new reader/writer structure 2015-09-10 11:53:26 -04:00
Stewart Douglas 97e980751f MAINT: Integrate asset writer changes into TradingEnvironment 2015-09-10 11:53:23 -04:00
Stewart Douglas abcb6704e8 TST: Modify tests given new AssetFinder behavior 2015-09-10 11:53:22 -04:00
Stewart Douglas 746f70a133 ENH: Create AssetDBWriter class
The AssetDBWriter class and its subclasses will
ultimately be responsible for creating the SQLite
database tables and writing data to these tables.

In the longer term AssetDBWriter and AssetFinder will
be decoupled, sharing only an SQLite connection.
However, for backward compatibility reasons this has
not yet been fully implemented.

Modify tests since AssetFinder no longer has a
metadata_cache attribute.
2015-09-10 11:53:22 -04:00
Stewart Douglas 1e31866471 MAINT: FutureChain should only accept Timestamp 2015-09-08 11:01:04 -04:00
Scott Sanderson 4b7cef8703 TEST: Clarify test in asset finder.
Fix comment copypasta and add a check for the third sid that should be
found.
2015-08-13 11:46:19 -04:00
Andrew Daniels 48c609debc BUG: Improves lookup_future_chain to handle NaT date args
If lookup_future_chain was provided with an as_of_date or knowledge date that was pandas.NaT, the query we were forming wasn't what we want. Instead, as_of_date, if not NaT, is used for knowledge_date, and if both are NaT, no date filtering is done in the query.
2015-08-05 10:50:14 -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
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
Andrew Daniels 2ab9f8a63c ENH: Futures API 2015-07-13 09:50:36 -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
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
jfkirk 1ec70b2a26 ENH: Removes use of lookup_generic in DataFrame index mapping 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 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
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 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
Scott Sanderson a2008f644a TEST: Remove unused test class. 2015-06-24 16:11:14 -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
jfkirk aa92922ea8 ENH: Adds security_start_date and _end_date with deprecation warnings 2015-06-16 14:26:05 -04:00
jfkirk 4ef8df2fca ENH: Adds handling of Assets passed to AssetFinder as identifiers 2015-06-11 16:49:23 -04:00
jfkirk 035bfbd514 ENH: Adds AssetFinder and asset metadata management 2015-06-11 11:35:48 -04:00
jfkirk 84d4fa3c08 ENH: Adds Equity and Future classes as extensions of Asset class 2015-03-19 13:23:40 -04:00
jfkirk 2fd2f02c2a MAINT: Refactors Security to Asset
This commit refactors the Security cython class to Asset, and refactors some fields of the class accordingly. This change is so the terminology is consistent and correct when Asset is extended to asset types that are not securities, such as futures.
2015-03-19 13:23:40 -04:00
jfkirk 0375b350b8 ENH: Adds Security cython class in new package 'zipline.assets'
The class is not yet used. Adding this class is part of the effort to allow Zipline
simulation of more types of assets than stocks.

DEV: Adds build_ext to .travis.yml
2015-03-04 14:19:29 -05:00