Commit Graph

114 Commits

Author SHA1 Message Date
Jean Bredeche dc01c45dc4 DEV: Apply adjustments for portfolio and account in BTS
completely copied from https://github.com/quantopian/zipline/pull/1104/

All credit goes to Andrew Liang (@lianga888)
2016-04-05 11:37:34 -04:00
Eddie Hebert 16fd6681a6 ENH: Rewrite of Zipline to use lazy access pattern
More documentation to follow in release notes.

Based on lazy-mainline branch, see for more details.

Also-By: Jean Bredeche <jean@quantopian.com>
Also-By: Andrew Liang <aliang@quantopian.com>
Also-By: Abhijeet Kalyan <akalyan@quantopian.com>
2016-04-04 16:12:58 -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
jfkirk db1e62971a ENH: Adds tick_size and renames futures multiplier 2016-01-22 14:56:30 -05:00
Joe Jevnik 3b76981270 Merge pull request #846 from grundgruen/data_test
TST: tests removing of expired data and removes ffill in DataPanelSource
2016-01-19 13:05:15 -05:00
warren-oneill ef323a3165 ENH: adds lookup_expired_futures to asset_finder 2015-12-01 15:24:02 +01:00
jfkirk bbe3ab99ac TST: Adds asset type verification to test_order tests 2015-11-30 12:25:04 -05:00
warren-oneill 987d6d4e48 TST: tests removing of expired data and removes ffill in DataPanelSource 2015-11-17 17:22:31 +01:00
jfkirk 11b7cd2dd0 TST: Fixes test_order_methods_for_future 2015-11-16 11:47:00 -05:00
llllllllll 0cb4c38717 ENH: Allow users to pass a context manager to wrap all scheduled
functions.

This includes handle_data.
2015-11-11 14:19:13 -05:00
Scott Sanderson a14c61e7ff MAINT: Remove unused 'asset_type' metadata entry. 2015-11-05 13:35:05 -05:00
Richard Frank ec5318ec88 TST: Fixed up test result comparison 2015-11-05 10:18:57 -05:00
Richard Frank d2ba11dac0 STY: Fixed typo and appeased flake8 2015-11-05 10:18:57 -05:00
Richard Frank 6b245ab06a TST: Removed extra parameters 2015-11-05 10:18:57 -05:00
puppy a82415c77b BUG: Address issue #801 and add test. Pass panel directly to
object instead of data.
2015-11-05 10:18:57 -05:00
jfkirk 7d29bb6a67 BUG: Fixes failure to account for Futures transaction prices 2015-10-30 12:04:38 -04:00
warren-oneill 3f66e6c66a TST: adds future flip test 2015-10-30 10:07:46 -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
Stewart Douglas 3ef0ddf0c6 ENH: Add future_symbol API method 2015-10-05 11:19:04 -04:00
Eddie Hebert cbb3d807b7 TST: Remove instant fill from close position test.
'instant fill' execution may be on the path to deprecation, (the removal
is currently proposed by the branch which removes events in favor of
operating over dts.), so remove instant_fill from the close position
tests so that the input and output is the same between the proposed
branch and here.

(This was one of the few places where instant fill was used that
was not testing instant fill behavior explicitly, so may be better to
align this test with the rest of the suite.)

Also, change test methods to make it more clear on which day the values
the expected and actual results differed.
2015-09-28 14:48:19 -04:00
Richard Frank 136eb8aa0d BUG: Running an algo with a df/panel of Assets was raising SidNotFound 2015-09-24 21:49:45 -04:00
Richard Frank 0b6b11a080 MAINT: Removed some unnecessary instance attributes 2015-09-24 21:49:45 -04:00
John Ricklefs 38ff4cc913 BUG: Normalize dates in AssetDateBounds control checks
Assumes that if a given asset's end_date is
e.g. 9/17/2015 00:00:00 UTC that it means the
asset is still tradeable on 9/17/2015 during
the market day.
2015-09-18 15:19:15 -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 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 608dff245b TST: Updates test for set_symbol_lookup_date 2015-09-10 11:53:29 -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 d3516959a3 MAINT: Don't set string to upper before writing, remove unused libs 2015-09-10 11:53:27 -04:00
Stewart Douglas 7be2cf8652 MAINT: Allow algo.run() to write to db 2015-09-10 11:53:27 -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 1c512c5478 TST: Update test_algorithm.py to incorporate TradingEnvironment.write_data 2015-09-10 11:53:25 -04:00
Stewart Douglas e507ee097d TST: Add coverage for set_symbol_lookup_date method 2015-09-08 11:01:04 -04:00
jfkirk cf41373f8f BUG: Symbol look-up now uses the sim_params.period_end as a look-up date 2015-09-01 12:39:03 -04:00
Jonathan Kamens 2521263c06 TST: Prevent some test cases from being split 2015-08-25 11:56:36 -04:00
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 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
Eddie Hebert ad4126bf58 STY: Remove unused import.
Mea culpa.
2015-07-10 17:03:44 -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
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 a4ce9712b8 DEP: Removes sids field from SimulationParameters 2015-07-01 13:43:31 -04:00
jfkirk eced4e700d TST: Adds close position tests for both Equity and Future 2015-06-12 10:07:50 -04:00
jfkirk 3ee3a1226b BUG: Fixes handling of CLOSE_POSITION events for Futures 2015-06-11 11:40:54 -04:00
warren-oneill 0d7e23857e TST: add unittest for CLOSE_POSTION event type for futures, add commission to TestAlgorithm 2015-06-11 11:39:10 -04:00
jfkirk a5d1f79a37 TST: Reconciles tests with asset management system 2015-06-11 11:35:49 -04:00
jfkirk 9da644f767 ENH: Moves calling of TradingAlgorithm.initialize to _create_generator 2015-06-11 10:14:07 -04:00