Commit Graph

1765 Commits

Author SHA1 Message Date
jfkirk 847b5bdc42 BUG: The 'file_name' metadata arg now overwrites 'symbol', if it is given
This is to fix the issue where 'GOOG_L's metadata lists its symbol as 'GOOG'. To resolve this, the 'file_name' is used as the canonical symbol, if it is given.
2015-06-12 16:09:19 -04:00
Scott Sanderson 4aa5072154 DOC: Add docstring for risk.py:choose_treasury. 2015-06-12 10:59:43 -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
jfkirk 13180d5348 PERF: Removes unnecessary and expensive caching of values and exposures 2015-06-11 11:35:49 -04:00
jfkirk 7e5c638eb8 PERF: Removes asset lookups on every transaction 2015-06-11 11:35:49 -04:00
jfkirk 1b98d23b91 PERF: Removes asset lookups on ever trade event 2015-06-11 11:35:49 -04:00
jfkirk b84ac01cbf ENH: Adds futures trading and asset management logic to TradingAlgorithm and performance classes 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
James Kirk 68dbd5ed4a Merge pull request #593 from grundgruen/close_pos_event
ENH: Add CLOSE_POSTION as DataSource event type
2015-06-08 17:45:25 -04:00
Eddie Hebert c37f914c68 PERF: Use tolerant_equals instead of np.allclose in order types.
np.allclose creates a vector of size 1 if passed a scalar, which showed
up as a bottleneck in algorithms with a large number of
order_target_percent calls.
2015-06-05 20:59:13 -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
warren-oneill f9d3dbff47 allow passing of data type from data source 2015-06-03 15:10:54 +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
Stewart Douglas b24bd561e7 BUG: Stop account_needs_update from blocking performance updates
Referencing context.account in handle_data() can block updates to account,
portfolio and performance metrics, which can cause unintended changes in
financial performance. Additionally, since context.account metrics are not
updating frequenctly enough (daily, rather than minutely) algos which base
decisions on these metrics can have undesired behavior.

To address this we do not base our decision to update performance on the
state of account_needs_update.

When we call get_account() from the market and minute close methods, we
set the performance_needs_update parameter to False since we just updated
performance.

_get_account() is renamed to _update_account() since the method does not
return account information.

Also remove redundant asset_needs_update = True lines.
2015-05-28 11:15:40 -04:00
Eddie Hebert 3c862df336 Merge pull request #579 from grundgruen/tracker-days
WIP BUG: env.next_trading_day() not Timezone aware when passed market_open/close
2015-05-26 10:57:51 -04:00
warren-oneill 064d973ec2 pass day instead of market_open to next_open_and_closes and use day instead of market_close for benchmark index 2015-05-26 16:17:55 +02:00
Eddie Hebert 862cfbbd19 MAINT: Group events by type before processing.
Make the ordering in which processing of event types both explicit and
independent of the sort ordering of the incoming sources.

The overhead of creating the list per snapshot and the iterators appears
to be marginal in the minute data case when tested locally.

This patch is intended as part of the path towards making the trade
simulation loop not depend on consuming and tracking every trade event.
The timing of where last_sale_date was needed to be changed was proving
difficult to adapt in the previous model.

Should also allow the removal of sorting of the various source streams.
2015-05-20 11:41:54 -04:00
Eddie Hebert 1e76be611b MAINT: Remove unused method on performance period.
set_positions is no longer referenced.
2015-05-15 23:31:28 -04:00
Eddie Hebert 9e57198e16 MAINT: Remove unused property on performance period.
The last sale prices property is no longer referenced elsewhere.
2015-05-14 15:46:17 -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
Eddie Hebert 16a615f3f0 MAINT: Use setitem syntax instead of update for tracker dict addition.
Since only value is being changed, use the setitem brackets intsead of
calling updated.
2015-05-04 14:02:47 -04:00
Eddie Hebert 63dbea5da4 ENH: Remove unused minute risk containers.
The risk containers that are actually used for reports use the
'cumulative' style container which has an index of days, not minutes.

The minute containers and copying of data etc. were causing an expanding
memory footprint.
2015-05-04 13:56:29 -04:00
Eddie Hebert da0a5bbc3f MAINT: Remove dependence on intraday risk for benchmark returns.
The intraday_risk_metrics is being removed since the values are not
used; cumulative risk metrics with the last value updated to the latest
close has been used for some time.

Before the removal of intraday_risk_metrics, the position trackers
passing of benchmark returns to the cumulative risk metrics needs to no
longer depend on the calculations done by the intraday stats. So instead
use the all_benchmark_returns stored in the tracker directly.
2015-05-04 13:56:29 -04:00
Eddie Hebert 4908d5577e MAINT: Remove unsued perf_key property on simulation object.
The perf_key property is no longer referenced.
2015-05-04 13:11:31 -04:00
Jonathan Kamens 84eb25faab Merge pull request #577 from quantopian/minor_zipline_path_fix
BUG: Correct method for finding security lists directory
2015-05-04 11:30:43 -04:00
Eddie Hebert c43d504212 MAINT: Remove unused hash_args from simulation object.
The `get_hash` method on the AlgorithmSimulator is never called, so
remove.
2015-05-04 11:03:01 -04:00
Jonathan Kamens cd98b52454 BUG: Correct method for finding security lists directory
The correct thing to look at to figure out where the root of the
zipline tree is, is `zipline.__file__`, not `zipline.__path__`. The
latter could contain multiple directories in it, and is not intended
to be `os.path.join()`ed as the previous code was doing.
2015-05-04 10:42:40 -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
Eddie Hebert 00ea7b04d1 PERF: Reduce memory usage during risk metric calculations.
For beta calculation:

Remove `.dropna` , since it was creating a new
Series and Index which inflated memory usage as algorithm run time
progressed.

For downside risk calculations:

Instead of using pd.Series calculations, pass the underlying
numpy array which have already been sliced to the exact dt, so that the
call to `round` does not create a new Series.
2015-04-28 13:22:04 -04:00
Eddie Hebert a4f85b9436 Merge pull request #570 from quantopian/orders-by-modified-leak
Remove leaky defaultdicts
2015-04-23 15:43:03 -04:00
Andrew Liang f44c15bb38 Scrubbing known warnings 2015-04-22 22:07:25 -04:00
Eddie Hebert d343e06593 BUG: Remove use of defaultdict leading to memory growth.
defaultdict behavior was adding and never releasing a list and Timestamp
every time to_dict was called.
2015-04-22 10:46:20 -04:00
Eddie Hebert ec63397d28 BUG: Stop addition of new list in orders_by_modified on every dt.
Remove use of defaultdict for orders_by_modified, which was causing an
empty list to be added every time to_dict was called with a specified
dt.

Nnoticed in the minute emission case when hunting another memory leak,
every simulation minute a new Timestamp and list was created and never
let go.
2015-04-22 10:40:08 -04:00
Eddie Hebert 0fa44471be MAINT: Change expected type of treasury curves from load to DataFrame.
Instead of converting the curves back and forth from dictionaries to
DataFrame and back, use the DataFrame format when passing to
environment.
2015-04-20 10:26:09 -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
Benjamin Berman ef598c7130 BUG: Handle a ValueError on from_csv calls
The cached market data could be corrupted. Pandas raises a ValueError in
that case, and this error handles it.
2015-04-14 12:40:37 -04:00
Scott Sanderson 885db87dea MAINT: Use logger instead of printing in loader.py
Makes it easier to filter logs when they're not desired.
2015-04-14 12:40:37 -04:00
Brian Fink 8baf52fe01 ENH: Add max leverage account guard 2015-04-10 15:19:54 -04:00
Brian Fink 2f895bddcd ENH: Track max leverage as risk 2015-04-10 15:19:54 -04:00
James Kirk 7af9b30a99 Merge pull request #560 from quantopian/calendar-clean
More flexible calendar implementation
2015-04-10 10:35:31 -04:00
Eddie Hebert 9bc40563b7 MAINT: Remove unused returns vector from perf tracker.
The returns Series in the perf tracker appears to be vestigial, so
remove.
2015-04-09 14:43:19 -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 b62fadc76f adding NYSE trading_day and trading_days as default in load_market_data() 2015-04-08 16:57:23 -04:00
warren-oneill aa872afdf4 adding updates from master 2015-04-08 16:57:12 -04:00