Commit Graph

2200 Commits

Author SHA1 Message Date
Thomas Wiecki ff11628cd3 DOC: Wrong link for badges. 2014-06-18 17:46:59 +02:00
Thomas Wiecki d6a392e394 DOC: Add version and download counter to README. 2014-06-18 17:45:33 +02:00
Scott Sanderson fe52254bc2 BUG: Rolling back Logbook version due to incompatibility with Processor/filter
interactions.
2014-06-16 13:52:09 -04:00
Thomas Wiecki 96bdb22db9 BUG: RollingPanel was not behaving correctly in corner cases.
There quite some bugs in certain corner cases. Dropping of obsolete
axes was not working correctly, roll over could cause obsolete axes
to not drop. The tests are much more stringent now as well.
2014-06-14 21:07:02 +02:00
Thomas Wiecki e4c974f4b8 ENH: Add removal of elements in benchmark. 2014-06-11 16:50:53 +02:00
Scott Sanderson 79c91897ba ENH: Add freq_filter argument to HistoryContainer.update_digest_panels.
Adds a new argument, `freq_filter`, to `HistoryContainer.update_digest_panels`,
which can be used to supply a predicate determining which digest panels are
updated by the call.  This is useful for supporting initialization/backfilling
of multi-frequency panels in subclasses.
2014-06-09 17:42:41 -04:00
Scott Sanderson 7995e6ac0d DOC: Tweaks to docstrings in history.py and history_container.py. 2014-06-09 17:40:57 -04:00
Scott Sanderson 6e92b40ed9 MAINT/TEST: Move to_utc from history_cases.py to test_utils.py. 2014-06-09 17:40:06 -04:00
Eddie Hebert 36501a462b BLD: Set scipy back to 0.12.0
The internal system used to build and get burn-in on packages was
accidentally using scipy 0.12.0, despite the change in the requirements
file to 0.13.2

Setting back to using scipy 0.12.0 until 0.13.2 is more tested with
internal systems, with the goal of upgrading to >= 0.14.0 as soon as
possible.
2014-06-09 14:45:43 -04:00
Scott Sanderson 49eaeeb6ae BUG: Apply integer truncation to order amounts earlier in the pipeline.
Truncate non-integer order amounts in `TradingAlgorithm.order` instead of
`Blotter.order`.  This fixes an issue where non-integer orders coming out of
order_value can spuriously trigger a `LongOnly` trading guard.

Example:

sid.price == 2.0
order_value(sid, 5) -> order(sid, 2.5) -> truncated to order(sid, 2.0)
order_value(sid, -5) -> order(sid, -2.5) -> LongOnlyViolation b/c 2.0 - 2.5 < 0
2014-06-09 11:42:43 -04:00
Thomas Wiecki 2a73873097 BUG: Remove output arg before calling run_pipeline
The IPython magic still created an output file because
the output argument was only removed after the pipeline
was run. This fix simply removes the argument before
the call to run_pipline() when running the IPython magic.
2014-06-09 17:17:37 +02:00
Scott Sanderson f6cbd5eba8 Merge branch 'one_minute_history_for_realz' 2014-06-05 16:37:38 -04:00
Scott Sanderson fba649dd7a TST: Changed test_mixed_frequencies to use a half day.
Also adds a length-1 HistorySpec to the test.
2014-06-05 15:25:49 -04:00
Scott Sanderson cfe00b0c37 ENH/TEST: Enable '1m' history and add tests for the frequency. 2014-06-05 15:25:49 -04:00
Scott Sanderson 3a1fc1032e ENH: Overhaul logic in HistoryContainer.
Updates `HistoryContainer.roll` to handle cases where no data is present for
the period being rolled.

We now only forward-fill the `price` field when `ffill` is specified.
2014-06-05 15:25:49 -04:00
Scott Sanderson 15f1947652 BUG: Don't return mostly nans from get_history when ffill=False.
Fixes an issue where, if `ffill=False`, `get_history` would return nans for
every entry in the history frame except the last one.
2014-06-05 15:25:49 -04:00
Scott Sanderson bad4c9a439 ENH: Prep work for supporting '1m' history.
Overhauls `HistoryContainer` in prep for support of more than one frequency.

Major changes:

   - Methods/variables referring to "day" have been renamed/generalized.
     - `current_day_panel` became `buffer_panel`, which is now a `RollingPanel`
     - `prior_day_panel` became a dictionary mapping `Frequency` objects to
       "digest panels", which are instances of `RollingPanel`.

   - Hard-coded daily rollover replaced with a notion of a "current window" for
     each unique frequency managed by the panel.

     - When the end of the current window is reached for a given frequency, we
       compute an aggregate bar (code refers to this as a "digest"), which is
       appended to a panel associated with that frequency.

     - Window rollover dates are managed by a pair of dictionaries,
       `cur_window_starts` and `cur_window_closes`.  The `Frequency` class is
       responsible for computing window bounds based on the open/close of the
       previous window.

   - Semantic change to the `open_price` field: `open_price` now always
     contains the price of the first trade occurring in the given window.
     Previously it contained the price of the first minute in the window,
     returning NaN it the security happened not to trade in the first minute.
2014-06-05 15:25:48 -04:00
Scott Sanderson b6e5345893 ENH: Enhancements to TradingEnvironment.
Adds a suite of new functions for querying data from the trading calendar.

These include:
      `previous_trading_day`
      `minutes_for_days_in_range` (minutely version of `days_in_range`)
      `previous_open_and_close` (inverse of `next_open_and_close`)
      `next_market_minute`
      `previous_market_minute`
      `open_close_window` (get a range of opens/closes with slicing semantics)
      `market_minute_window` (get a range of minutes with slicing semantics)

Also refactors `test_finance` to move `TradingEnvironment` tests into their own
TestCase.
2014-06-05 15:25:48 -04:00
Scott Sanderson de3be983ad BUG: BarData.values() no longer causes in an infinite loop on Python 3. 2014-06-05 15:14:26 -04:00
Scott Sanderson 7daf58ec9b ENH: Add a class-level instance method on TradingEnvironment.
Adds a classmethod, `instance` on `TradingEnvironment` that returns
`zipline.finance.trading.environment`, instantiating it if necessary.

This makes it possible to initialize the default environment instance in a
less-roundabout way than creating a `SimulationParameters` object.
2014-06-05 12:02:53 -04:00
Scott Sanderson 5392506d6d DOC: Documentation fixups in history_container.py. 2014-06-05 11:15:50 -04:00
Scott Sanderson 0b37663fed Revert "MAINT: Peg .travis.yml packages to specific versions in line with requirements.txt."
This reverts commit 450dded491.
2014-06-04 14:48:59 -04:00
Thomas Wiecki a372549f6f DOC: Add @humdings to contributors. 2014-06-04 20:08:52 +02:00
David Edwards 7547ef535a MAINT: Removed unused keyword arg
Deleted keyword arg include_open_orders, it was left over from working
on handling open orders.
2014-06-04 20:08:52 +02:00
David Edwards 243c0348f3 MAINT: Refactored target order methods
Refactored the target order methods to separate their logic from the
other order methods.

This makes order_target the only target method that calls order()
directly.

order_target_value is passed to order_target instead of order_value.

order_target_percent is passed to order_target_value rather than
order_value.

This simplified the code and decouples the logic of target orders from
the other order methods. This allows the target order methods to be
developed independently from order_value and order_percent.
2014-06-04 20:08:52 +02:00
Scott Sanderson 450dded491 MAINT: Peg .travis.yml packages to specific versions in line with requirements.txt. 2014-06-04 13:58:03 -04:00
Scott Sanderson 1fb78a34cd MAINT: Bump numpy version in .travis.yml. 2014-06-04 10:54:50 -04:00
Eddie Hebert 744decf9de STY: Normalize styles across installations via .dir-locals.el
For Emacs users, set a .dir-locals.el file to define behavior during
formatting operations like `fill-paragraph`

Set:
- Double spaces after sentences. (Which is the default.)
- Fill column to 79 characters. (To match pep8 script.)
- Docstrings to conform to Django formatting, since that is currently
  most alike to the existing docstrings.
2014-06-04 00:06:58 -04:00
Eddie Hebert 26b2a466cf BLD: Update pytz to latest version.
2014.3 -> 2014.4
2014-06-02 22:15:01 -04:00
Thomas Wiecki 40001f3509 STY: Remove warning when ordering zero shares.
Many algorithms that use the new order methods like order_target()
will legitimately try to order 0 shares many times. The printed
warning at every turn is quite annoying and too verbose. We do not
display it on Quantopian either so I'm removing it here as well.
2014-06-02 15:50:21 +02:00
Eddie Hebert 1705428aa4 BLD: Remove pip-tools dependency.
Instead of `pip-review`, now using `pip list --outdated`
2014-05-31 21:56:10 -04:00
Eddie Hebert d384f63e25 BLD: Update tornado to latest.
Upgrade from 3.2 -> 3.2.1
Used for matplotlib, which is imported during tests to make
sure that examples are working.
2014-05-30 15:48:10 -04:00
Eddie Hebert 45c3fafaae BLD: Update xlrd package to latest.
xrld is used for reading the risk answer key.
Update 0.9.2 -> 0.9.3
2014-05-30 14:58:08 -04:00
Eddie Hebert f481d9e7df BLD: Update Markdown library.
Should be orthogonal to any trading simulation, Markdown is
merely used for packaging and converting the README.
2014-05-30 14:47:37 -04:00
Eddie Hebert 93acee4091 BLD: Keep Travis lint and test packages in sync with requirements file.
Instead of hard-coding the package versions in the Travis config,
grep the version number out of the requirements_dev.txt file,
so that the versions do not drift.
2014-05-30 14:11:44 -04:00
Eddie Hebert 2debde31ba BLD/STY: Upgrade to latest versions of lint checkers.
Upgrade pep8 1.4.6 -> 1.5.7
Upgrade pyflakes 0.7.3 -> 0.8.1

Also, tweak some line indentations which now show up as errors,
because of the fixes/changes to visual indent detection between
pep8 versions.
2014-05-30 12:44:10 -04:00
Eddie Hebert 2c8e019835 BLD: Update nose to latest version.
nose 1.3.0 -> 1.3.3
2014-05-29 23:20:30 -04:00
Eddie Hebert 99ecffdb42 BLD: Remove deprecated pip --use-mirrors flag.
With release 1.5 pip deprecated the --use-mirrors flag,
since that release the flag is a noop and raises a deprecation warning.
2014-05-29 13:18:00 -04:00
Eddie Hebert 46820ee796 BLD: Update pyparsing to 2.0.2
2.0.1 -> 2.0.2

pyparsing is a dependency of matplotlib and should not affect
Zipline simulations.
2014-05-29 13:13:56 -04:00
Scott Sanderson 0338dd73e1 ENH: Filter out empty lists from get_open_orders.
Filter out empty lists from `get_open_orders` so that we have consistent
behavior between the case where a user has never placed an order and the case
where the user has placed an order but it has been executed or cancelled.

A nice side-effect, which was the impetus for this change, is that you can
check if you have any open orders by doing:

```
len(get_open_orders()) == 0
```

Also adds a test for the behavior of `get_open_orders`, which was previously
lacking.
2014-05-29 13:04:53 -04:00
Eddie Hebert 00f89a69b4 BLD: Make TA-Lib install compatible with pip >= 1.5
Since TA-Lib's releases are hosted on Github instead of PyPI,
add the `allow-external` and `allow-unverified` flags for just
TA-Lib.

This change means that versions of pip < 1.5 can not be used,
since the flags do not exist in those versions.
2014-05-28 13:47:40 -04:00
Eddie Hebert caa14ee8f0 BLD: Order build of pandas before statsmodels.
pandas is required for statsmodels, so order installs so
that pandas is available for at build time for statsmodels
2014-05-28 12:03:09 -04:00
Eddie Hebert b34191bb01 BLD: Order scipy install before statsmodels.
statsmodels requires scipy to build, so list the scipy install
before statsmodels so that ordered_pip.sh will install it beforehand.
2014-05-28 11:44:19 -04:00
Eddie Hebert ce4567b4bb BLD: Upgrade pytz to 2014.3
Keep library up to date.
2014-05-27 16:51:09 -04:00
Eddie Hebert 2ef576a758 BLD: Upgrade Logbook to 0.7.0
Keep library up to date.
2014-05-27 16:50:29 -04:00
Eddie Hebert 543165fa05 BLD: Upgrade Cython dependency.
Upgrade Cython from 0.20 -> 0.20.1 to keep package up to date.
2014-05-27 16:10:19 -04:00
Eddie Hebert dbaf0facda BLD: Upgrade six library to 1.6.1
From 1.5.2 -> 1.6.1

Keep package up to date.
2014-05-27 15:55:36 -04:00
Eddie Hebert cfd3656d28 BLD: Upgrade requests dependency to 2.3.0
Upgrade requests from 2.2.0 to 2.3.0

To keep up-to-date, Changelog does not appear to have any changes
that would affect our usage one way or the other.
2014-05-27 15:08:09 -04:00
Eddie Hebert 9572c55a9d STY: Remove trailing empty line from requirements file. 2014-05-27 11:56:09 -04:00
Scott Sanderson ecd9bff0d6 PERF/BUG: Make the portfolio property call updated_portfolio.
Make the portfolio property on TradingAlgorithm call `updated_portfolio`
internally.  This prevents needless recomputation of the portfolio between
calls to `handle_data`, and also prevents issues where the portfolio object
could be unexpectedly modified in place in the body of a `handle_data` call.

Noteworthy finding in the course of investigating this bug:

If you modify a Python dictionary while iterating over it, the language will
only throw an exception if the size of the dictionary changes between loop
iterations; this means that you can do:
```
x = {1:1, 2:2, 3:3}
for k in x:
    old_val = x[k]
    del x[k]
    x[f(k)] = old_val
    print k
```
and you'll only get an error if f(k) is already a key in the dictionary.
This can lead to bizarre/nondeterministic behavior in the key iterator.
2014-05-27 11:20:13 -04:00