Commit Graph

17 Commits

Author SHA1 Message Date
Eddie Hebert 6210467bec MAINT: Use pd.Series for benchmarks and algorithm returns in risk.
Instead of lists, use pd.Series, so that memory is preallocated.
2013-04-15 11:37:21 -04:00
Eddie Hebert 95ca73b15f MAINT: Remove unused members from risk test module. 2013-04-03 13:56:26 -04:00
Eddie Hebert a620afe639 STY: Add Test prefix to risk module test case. 2013-04-03 13:55:33 -04:00
Eddie Hebert dd172dd42a MAINT: Use trading day increment instead of timedelta in test factory.
In the test factory creation of returns, the date creation was using
a timedelta of one day instead of incrementing by trading days.

Working towards changing risk module behavior which would leverage
the trading day map, but tests fail because non-trading days are
created.

Remove `factory.create_returns`, moving uses of that function to us
`factory.create_returns_from_period`, since the number of days input
for `create_returns` was more difficult to use when specifying ranges
over arbirtray dates.
2013-04-01 23:52:50 -04:00
fawce 2c7355a0dc Refactoring of TradingEnvironment to isolate the global state: index symbol and exchange timezone. Parameters that define the simulation (start, end, and capital base) were put in a new class, SimulationParameters.
Global state for the financial simulation environment is accessed through the
zipline.finance.trading module, which now contains a module variable:
environment.

Parameters are passed into an algorithm as a keyword argument, sim_params.
SimulationParameters creates a trading day index for the test period that
can be used to find trading days, calculate distance between trading days,
and other common operations. The sim params index is just selected from the
global state.

================

Details:

    - adding delorean to the requirements.
    - made index symbol a parameter for loading the benchmark data. changed
    messagepack storage to be symbol specific.
    - ported risk, performance, algorithm, transforms, batch transforms
    and associated tests to use simulation parameters and global environment
    - factory and sim factory use global state and sim params
    - factory method parameter names now reflect the class expected
2013-02-18 10:24:32 -05:00
Ryan Day 4d56f57468 Add the information ratio to risk metrics.
Calculates relative to the benchmark returns.
2013-01-31 18:25:36 -05:00
Ryan Day 64ffa055c9 Add the Sortino ratio for downside risk 2013-01-28 08:55:14 -05:00
Richard Frank 54063854aa Forward-fill missing treasury data
To handle, for instance, Columbus Day (Oct 10),
on which there is no treasury data.

We're only forward-filling data now, and
no longer searching both back and forward in time.
2012-12-14 17:29:27 -05:00
Eddie Hebert 0617e53d69 Upgrades flake8 from 1.5 -> 1.6
Also, removes flake8 ignores, since the warnings that were
at odds with eachother now work.
2012-11-19 12:49:09 -05:00
Eddie Hebert 7904773d00 Updates flake8 to latest.
The latest flake8 release in now 1.5, which pulls in pep8: 1.3.4a0

The upgrade pep8 has changes to what it picks up as lint.
Making code base compatible, so that new devs can install pep8
from PyPI and not have friction over the version difference.

Currently using these ignores in the config file:

```
[pep8]
ignore = E124,E125,E126
```

Ignoring these since they are difficult to squash while maintaining
an 80 char line length, and appear spurious.
Should address later.

Updates Travis config, README, and pip requirements to reflect change.
2012-10-22 11:57:16 -04:00
Eddie Hebert e752dfacc9 Changes answer key to benchmarks to match fresh data from Yahoo.
This answer key needs to be verified with original calculations.

Also, we may want to hardcode values in plain text to use for these
tests, instead of relying on a full history.
2012-10-19 11:19:52 -04:00
Thomas Wiecki b976c1252b Provides an iterative version of risk metrics.
I wrote this a little while ago as I noticed that a lot of time is spent
computing risk statistics. This is done over the complete history over
and over again while this could be done just by using the previously
computed value (iteratively).

We didn't go forward back then because for minute trade data the
difference was not significant enough. However, now with zipline
standalone I think most people will use daily (because that's
what's available) and it makes a huge difference
(speed-up of a couple of 100%).

Unfortunately, we can't just replace the existing one with an
iterative as for the final cumulative stats the batch is still
better. So that's not as nice, but the performance increase is
big enough for me to issue this PR (zipline is actually painfully
slow with daily data).

There is a unittest that compares that both produce exactly
the same outputs.

Speed measurements (for 500 trading days, daily source):

with iterative:
real 26.617 user 12.909 sys 6.112 pcpu 71.46

prior:
real 44.176 user 31.030 sys 11.381 pcpu 96.00
2012-10-17 23:41:30 -04:00
Eddie Hebert 58bde75bfa Removes commented out reference to old project logging. 2012-10-08 17:32:41 -04:00
Eddie Hebert bbf2317c57 Saving point for adding license files. 2012-10-08 17:32:40 -04:00
Eddie Hebert 77af1ca632 Applies PEP-8 and pyflakes style to tests and zipline.
Mostly whitespace, line width and other spacing changes.
Also, removes use of deprecated has_key in favor of `in`

Going forward new patches should pass running `flake8` before
submission.
2012-10-05 12:14:09 -04:00
Stephen Diehl 0d8eada763 More tests passing. 2012-05-10 17:10:09 -04:00
Stephen Diehl 62ec591d90 Moved the test folder. 2012-05-09 13:34:13 -04:00