Commit Graph

589 Commits

Author SHA1 Message Date
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
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
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
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 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 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
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
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 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 bfc992363e TST: Fixes broken test_close_position_event 2015-06-12 17:17:10 -04:00
jfkirk eced4e700d TST: Adds close position tests for both Equity and Future 2015-06-12 10:07:50 -04:00
jfkirk 4ef8df2fca ENH: Adds handling of Assets passed to AssetFinder as identifiers 2015-06-11 16:49:23 -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 035bfbd514 ENH: Adds AssetFinder and asset metadata management 2015-06-11 11:35:48 -04:00
jfkirk 9da644f767 ENH: Moves calling of TradingAlgorithm.initialize to _create_generator 2015-06-11 10:14:07 -04:00
warren-oneill 3d18a2954f TST:adds algo unittest for ClOSE_POSITON event type, adds commission as parameter to TestAlgorithm 2015-06-11 10:11:01 -04:00
warren-oneill 77fb100ae6 adding type as variable to create_test_panel 2015-06-04 15:50:41 +02:00
warren-oneill 44fbdff4ac added CLOSE_POSITION as source type, added pt.close_position_event(), added process_close_postion(), added close processing to tradesimulation, added unittest for close_position_event 2015-06-04 14:23:46 +02:00
jfkirk 9996502573 DEP: Removes use of 'count'-defined test sources
Test sources are now defined by the sim_params period_start and period_end, rather than by the period_start and a defined 'count' of bars. This allows us to consider the sim_params.period_end as the canonical definition of the end of a simulation.
2015-05-28 12:29:33 -04:00
Jonathan Kamens e32d79807f TEST: Object serialization test requires a trading environment
The object serialization test case requires a trading environment
because risk report generation requires treasury curves.
2015-05-12 15:25:44 -04:00
Eddie Hebert dba0a99a16 PERF: Use specific methods for processing events.
By having both the trade simulation main loop route events to "process"
methods based on event type and the process methods also checking event
type, there was some duplicated effort in doing that comparison many
times.

A particular case where this was noted in profiling was for the
`process_event` function which was checking if the type was not a trade
and returning early, when in a larger universe of stocks the value
returned False 99% of the time.

Instead provide separate process functions specific to each type,
e.g. e.g. `process_trade` and `process_transaction` and route traffic to
those functions in tradesimulation.

For a universe of 160 stocks on both no-op algo and an algo that rebuys
its universe every day, saw about a 10% increase locally.

Also:

- Add process_benchmark to blotter since internal subclass relies on
logic on benchmark, this allows the internal process_trade to be a
`pass`.

- Add warning on unrecoginzed event types.
2015-05-08 12:44:32 -04:00
Eddie Hebert 72ab9e74dd MAINT: Remove unused event_count from tracker.
event_count is not referenced anywhere, so remove extra bit of state
tracking.
2015-05-05 16:31:02 -04:00
Jonathan Kamens fd0530d889 MAINT: Flake8 2015-05-01 11:03:01 -04:00
Jonathan Kamens 557e6a3009 Every setup_logger needs a teardown_logger 2015-05-01 07:38:42 -04:00
Jonathan Kamens 656bd86c17 TST: One more overwrite_sim_params=False needed 2015-04-30 15:38:09 -04:00
Jonathan Kamens c94880af2c TST: Suppress warnings in test_history_add_field_* tests
Temporarily suppress warnings for one line of the
test_history_add_field_* tests to work around #576 until it's fixed.
2015-04-30 15:31:21 -04:00
Jonathan Kamens 5c546b4f6c TST: overwrite_sim_params=False in tests when using list of sources
When specifying a list of sources to algorithm.py:run in a unit test,
specify overwrite_sim_params=False to suppress the unnessary
UserWarning.
2015-04-30 15:30:19 -04:00
Jonathan Kamens 8f9f65bdc6 MAINT: Flake8 2015-04-30 14:31:01 -04:00
Jonathan Kamens dcb8aa06af TST: Simplify test_examples and convert to unittest TestCase
Also, remove use of os.chdir() in the test, which causes other tests
to break by changing the current directory in the middle of the test
run.
2015-04-30 14:24:30 -04:00
Jonathan Kamens 7bb2677a9d TST: Convert test_munge.py tests to unittest format 2015-04-30 13:27:46 -04:00
Jonathan Kamens 865a20099a MAINT: Use "difference" instead of "-" to make Pandas happy 2015-04-30 13:19:00 -04:00
Jonathan Kamens ca0f906b11 TST: Don't modify master security lists directory during tests
Rather than drop files temporarily into the master security lists
directory during unit tests, create temporary directories for the
tests. This avoids issues when the tests are being run at the same
time as other code that uses the real security lists data.
2015-04-29 21:41:32 -04:00
warren-oneill fdd4940faf make calendar test compare generated calendar with the benchmark calendar
renaming cal_days to bench_days
2015-04-20 15:02:30 -04:00
Brian Fink 82d2ddfa90 BUG: Fix limit orders
Only fill limit order if impacted fill price is better than the limit price.
If a limit order is partially filled, only fill the remaining shares if the
impacted fill price is better than the limit price.
2015-04-16 17:09:14 -04:00
Brian Fink 8baf52fe01 ENH: Add max leverage account guard 2015-04-10 15:19:54 -04:00
warren-oneill 61571601ac added test for initialization of max_date in TradingEnvironment and removed trading_day from max_date if statement. 2015-04-08 16:57:32 -04:00
warren-oneill 6432631981 uncommenting out test_calendar_vs_environment 2015-04-08 16:57:01 -04:00