Commit Graph

172 Commits

Author SHA1 Message Date
Stewart Douglas 501fd58fdf ENH: Replace update_asset_finder with write_data
The write_data methods invokes the relevant AssetDBWriter subclass
to write data to the database. update_asset_finder is no longer
a relevant method since the AssetFinder is strictly a reader class.
2015-09-10 11:53:24 -04:00
Stewart Douglas ad31e1ff6e MAINT: Coerce user input to Timestamps, catching errors 2015-09-08 11:01:04 -04:00
Stewart Douglas c2159d429b ENH: Allow user to set the symbol lookup date
Previously symbols were resolved to sids based on the end of
simulation date. This commit allows the user to specify the
date for which resolution will take place using a new
set_symbol_lookup_date() API method.

If the user does not use this method the lookup date will
default back to the simulation end date.
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
Scott Sanderson f7039d6f52 ENH: Make data available in before_trading_start. 2015-08-21 12:37:17 -04:00
Scott Sanderson 3f45494771 MAINT: Encapsulate engine initialization.
Required for internal override.
2015-08-04 19:26:56 -04:00
Scott Sanderson 0cc84e7a15 BUG: Use normed last_close instead of period_end.
`period_end` can be outside the range of data for which we have dates.
`last_close` properly gets pulled back to the last date for which we
actually have data.

We should consider whether or not we need to be storing period_end at
all.
2015-08-03 12:09:26 -04:00
Scott Sanderson 69d5aed7f6 BUG: Pop ffc_loader kwarg in TradingAlgorithm.
Prevents us from forwarding it as an initialize_kwarg.
2015-08-03 12:09:00 -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
Andrew Daniels 2ab9f8a63c ENH: Futures API 2015-07-13 09:50:36 -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
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
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 a4ce9712b8 DEP: Removes sids field from SimulationParameters 2015-07-01 13:43:31 -04:00
Eddie Hebert 9bf4855b8c MAINT: Move ZiplineAPI context so that it always wraps main loop.
Move the responsibility of wrapping the main simulation loop in the
ZiplineAPI context from the algorithm modules generator setup to the
main trade simulation loop, so that different methods of invoking loop
do not need to duplicate how the context is set.

To make it easier for internal implementation of handle_data to
transition off of calling the ZiplineAPI every bar, to only invoking the
context once per simulation.
2015-07-01 10:58:47 -04:00
Warren O'Neill e15b6b0484 DOC: removes suggested hourly data_frequency and changes minutely to minute in docstring 2015-06-30 13:33:37 +02: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 9da644f767 ENH: Moves calling of TradingAlgorithm.initialize to _create_generator 2015-06-11 10:14:07 -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
Brian Fink 8baf52fe01 ENH: Add max leverage account guard 2015-04-10 15:19:54 -04:00
Eddie Hebert 314b22656f MAINT: Remove left over simple transform code.
Remove pieces that are no longer used now that the simple transforms are
wrappers around history via the SIDData object.

Move window length related pieces into batch_transform, since the rest
of the utils module is no longer used.
2015-03-30 14:18:39 -04:00
Jonathan Kamens e942275108 STY: Flake8
Upgrade the version of the flake8, pep8, and mccabe PyPI packages, and
make the code changes necessary for compatibility with the updated
packages.
2015-03-19 17:21:25 -04:00
Thomas Wiecki 760bbced73 Revert "ENH Allow order_percent to work with various market values"
This reverts commit dd37a49f2f as it lead to different algo behavior we have to investigate first.
2015-02-17 20:27:59 +01:00
Joe Jevnik fdf4e9b737 PERF: Makes get_datetime not make a copy.
datetime.datetime objects are immutable.
2015-02-17 11:50:20 -05:00
Jeremiah Lowin dd37a49f2f ENH Allow order_percent to work with various market values
Currently, `order_percent()` and `order_target_percent()` both operate as a percentage of `self.portfolio.portfolio_value`. This PR lets them operate as percentages of other important MVs.

(also adds `context.get_market_value()`, which enables this functionality)

For example:
```python
order_percent('AAPL', 0.5)

order_percent('AAPL', 0.5, percent_of='cash')

order_target_percent('MSFT', 0.1, percent_of='shorts')

tech_stocks = ('AAPL', 'MSFT', 'GOOGL')
tech_filter = lambda p: p.sid in tech_stocks
for stock in tech_stocks:
    order_target_percent(stock, 1/3, percent_of_fn=tech_filter)
```
2015-02-12 14:15:20 +01:00
fawce 52f78fcbc7 restricted list trading control added. 2015-02-05 13:56:45 -05:00
Thomas Wiecki c734f23102 BUG: kwargs.pop() requires default argument. 2015-02-03 12:20:45 +01:00
Thomas Wiecki 9bdc2c8734 BUG: Support algo_filename being None. Fixes #480. 2015-02-03 11:36:00 +01:00
fawce 9ccb2c571f added cumulative risk measures to the
datapanel produced from perf frames.
2015-01-22 22:31:40 -05:00
Thomas Wiecki f474ee7eed BUG: Various functions were missing from the API. 2014-12-31 09:43:35 +01:00
Thomas Wiecki d0eba3d1ca DOC: Fix typo in TradingAlgorithm doc string. 2014-12-26 13:13:53 +01:00
Thomas Wiecki 8f3671bf24 DOC: Fix typo in TradingAlgorithm doc string. 2014-12-26 13:12:52 +01:00
fawce cd976ee2dd Merge pull request #449 from quantopian/bug_5089
expand get_environment
2014-12-12 17:42:58 -05:00
Scott Sanderson 51e43e3d61 BUG: Use string_types instead of basestring for py3 compat. 2014-12-09 11:17:28 -05:00
Scott Sanderson a701d0c47c DEV: Explicitly convert string to timezones in get_datetime. 2014-12-09 11:17:28 -05:00
Scott Sanderson 44f993c64e BUG: Use astimezone instead of tz_convert.
Makes get_datetime agnostic as to whether its input is a datetime or a
Timestamp.  (astimezone is an alias to tz_convert when the input is a
Timestamp).
2014-12-09 11:17:28 -05:00
fawce 34647ec6c4 added tests to confirm the full environment returns as expected. 2014-12-08 16:47:11 -05:00
fawce 0411627169 Modified get_environment to provide multiple fields. 2014-12-07 08:26:13 -05:00
Joe Jevnik e3d8b1034e ENH: Replaces the simple transforms with history calls. Switches
transforms to quantopian syntax.

Adds the sid attribute to the siddata so it is aware of which security
it represents.
2014-11-17 13:16:30 -05:00
Joe Jevnik e56457c671 ENH: Makes breakpoints work in algoscripts started with the run_algo.py
script.

Adds an option kwarg to TradingAlgorithm named 'algo_filename' that
represents the file where the algoscript came from (if any). The
run_algo.py script will pass this argument with the value passed to the
'-f' flag. The default name is '<string>' to represent that the script
is coming from a string in python and not a file. This matches the
behavior of exec and the python convention for compiling code objects.
2014-11-10 10:14:56 -05:00
Joe Jevnik ca59abcc43 ENH: Makes schedule_function work in daily mode. 2014-11-06 10:49:49 -05:00
Joe Jevnik 93429d69f5 BUG: HistoryContainer creation at runtime did not work as intended. 2014-11-05 18:31:11 -05:00
Joe Jevnik f8f7f2fc4c ENH: Allows history to be dynamic and grow the container at runtime.
Previously, all specs had to be pre-allocated by using the 'add_history'
function. This is now no longer required and instead serves as a hint to
the HistoryContainer to pre-allocate the space for the given spec.

History can grow by increasing the length for a frequency, adding a
frequency, or adding a field. It can grow with any combination of
these.

HistoryContainer now is aware of the data_frequency of the algorithm,
and no longer uses the daily_at_midnight flag; instead, this is the
default behavior.
2014-11-03 15:57:44 -05:00
Scott Sanderson affeb2afbc DEV: Add tz kwarg to get_datetime. 2014-10-23 00:59:50 -04:00
Thomas Wiecki 820115f7be MAINT: Replace iterkv with iteritems.
iterkv is being deprecated as of pandas 0.14.
2014-10-22 17:25:37 +02:00
Joe Jevnik 615228b272 ENH: Changes the default time_rule for schedule_function to market_open() 2014-10-20 17:17:34 -04:00
Brian Fink 50c5b73a7b add account object to context 2014-10-10 17:10:45 -04:00
Joe Jevnik df234f516c BUG: Fixes various bugs with the event manager:
- NotHalfDay only worked at midnight
- week_(start|end) were actually month_(start|end)
- Removes check_args from api.
- Default offset of 30mins for market_(open|close)
2014-10-09 14:01:56 -04:00