Commit Graph

175 Commits

Author SHA1 Message Date
Thomas Wiecki 4c02fea6e2 BUG: batch_transform was wrongly updating when days < refresh_period. 2012-11-19 10:20:24 -05:00
Eddie Hebert d5697cdf0a Fixes under-incrementation of risk report.
We were only incrementing the risk report by one day, and never
checking to see if that day we incremented into was a trading day
or not.

We now increment by day until we are on a trading day.

With an assist from @twiecki on:

Adapted test_risk_compare_batch_iterative to work with fixed
iterative risk class.
2012-11-15 14:13:04 -05:00
Tobias Brandt cf4d7ca353 Fixed unittest2 import error on Python 2.7
Changed all unittest2 imports to unittest
2012-11-12 10:49:14 -05:00
Thomas Wiecki 126e9fdf26 Fixed batch_transform window length not being market aware.
Added accompanying unittest.

Minor refactoring of unittests and factory.
2012-11-06 21:13:27 -05:00
Eddie Hebert 086c12ddf8 Locks down the ability to easily override the algo's portfolio.
Starting down the path of making the portfolio completely read-only
with respect to the handle_data in algo.

The portfolio should only be changed during the course of running
the algorithm by the simulator.

This doesn't do a 100% protection, i.e. an algo could use _portfolio,
or the set_attr property, but hoping this helps guides algo writing
to treat the portfolio as read-only.
2012-11-05 13:40:23 -05:00
Eddie Hebert 04642c0077 Removes leased sockets from unit test.
The leased sockets were from a previous architecture.
2012-10-25 10:37:58 -04:00
Eddie Hebert 657f93165d Removes unused test class member and corresponding import.
Leased sockets is from an older architecture.
2012-10-25 07:17:35 -04:00
Thomas Wiecki c0b161287d Fixed odd bug that caused the first day not to get simulated. This triggered some changes to the batchtransform unittests. 2012-10-23 17:57:27 -04:00
Eddie Hebert bad6296d24 Merge pull request #2 from quantopian/yahoo_finance_loader
Added yahoo finance loader.
2012-10-22 09:07:25 -07: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
Thomas Wiecki ae1644fe35 Added yahoo finance loader. 2012-10-22 09:28:56 -04:00
Thomas Wiecki d468d05ba4 Removes optimize directory and optimize unittests which live on a separate branch yet. Was not functional yet and should thus not be in the main branch. 2012-10-22 08:51:30 -04:00
Thomas Wiecki 15ac658024 Restructured file hierarchy. Transforms now live in transforms (transform.py is now transforms/utils.py). Sources are in sources.py. VWAP is now MovingVWAP. 2012-10-19 18:10:51 -04:00
Thomas Wiecki 92f1dbef0c Fixes bug that .run() could not be called twice on an algorithm. Added unittest to check. 2012-10-19 11:47:59 -05: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 95ce2d90cf Removes unused constant and redirection of imports.
Removes TRANSFORM_TYPE from protocol, since it is unused.

Also, removes use of ndict as a member of protocol, since it's
import there was for the TRANSFORM_TYPE. Changed to
utils.protocol_utils instead.
2012-10-15 22:57:06 -04:00
Eddie Hebert 44d614591d Removes non-zipline specific delayed_signals module.
The delayed_signals module isn't actually necessary for the
running of zipline, so removing to reduce the surface area.
2012-10-15 14:16:50 -04:00
Eddie Hebert fcccca1530 Removes qexec reference from test logger. 2012-10-12 15:12:44 -04:00
Eddie Hebert 23076ae7f1 Allows for collapsed orders by changing the current order filter.
Changes our filter so that instead of just checking for the current
day, we ensure that orders are before or on the current event time.

This adds a delay, (defaulting to one minute), to the order so that we
avoid filling an order exactly when it is placed.
2012-10-11 13:42:53 -04:00
Eddie Hebert c510cab915 Removes unit test exercising expiring orders.
We have removed expiring orders, so this tests behavior that currently
doesn't exist.
2012-10-10 16:19:06 -04:00
Eddie Hebert a3c3a5c6f9 Removes extra assert. 2012-10-10 16:17:06 -04:00
Eddie Hebert a83f9f9106 First pass at writing unit tests to exercise slippage models. 2012-10-10 16:17:05 -04:00
fawce 16b0d71506 refactoring of algorithm to make it work for both batch style run method, and generator style consumption. removed the portfolio property from the data parameter. added set_slippage and set_commission methods to algorithm. removed timeout tracking. 2012-10-10 16:06:32 -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
Eddie Hebert 0cd8931a5b Whitespace wrangling. According to PEP8 recommendations. 2012-10-03 13:20:26 -04:00
Eddie Hebert 259498dad2 Removes unused modules. 2012-10-03 10:59:04 -04:00
fawce 7a8697f0e5 updated based on PR feedback. 2012-09-30 22:12:00 -04:00
fawce 1caefbff43 tests are passing for independent commission model 2012-09-28 23:12:41 -04:00
Thomas Wiecki c2dd51c24e Cleaned up unittests in response to Eddie's comments. 2012-09-28 09:20:17 -04:00
Thomas Wiecki 188a9502b0 Added passing of arguments to algorithm initialize and batch transform. 2012-09-25 11:48:37 -04:00
Thomas Wiecki 32c7dfbef9 Added test_algorithm.py. 2012-09-21 12:00:09 -04:00
Thomas Wiecki 4324f95f36 Better unittest coverage. DataFrameSource is now filtering sids. Fixed outstanding issues. 2012-09-21 11:59:46 -04:00
Thomas Wiecki 2dbf905d43 Added unittest for dataframe source. 2012-09-19 20:01:10 -04:00
Thomas Wiecki 3be2f313cd Shortened test window. Renamed functions in window transform. 2012-09-19 18:39:42 -04:00
Thomas Wiecki 729a4d9058 Large refactoring and documentation of new algorithm base class and batch transform. 2012-09-19 17:49:39 -04:00
Thomas Wiecki 5d00099243 example code now retrieves data from yahoo finance. 2012-09-17 12:15:36 -04:00
fawce 1267f66dbe removed old refs 2012-09-14 19:42:55 -04:00
fawce 57a1834c5a refactored so that slippage is implemented as pluggable classes. 2012-09-13 21:22:01 -04:00
fawce c45c44b5c8 fixes per code review 2012-09-12 13:29:05 -04:00
fawce 50de0f5e39 support of qexec refactoring 2012-09-12 00:30:37 -04:00
fawce 1f55e8a033 added exception handling tests back. updates to support integration. 2012-09-10 23:06:13 -04:00
fawce 81718011df cut most of protocol, cut most of log_utils. 2012-09-08 23:20:38 -04:00
fawce b046518c45 tests passing with new lines.py. Still some zmq references left. 2012-09-08 22:44:22 -04:00
Thomas Wiecki 81ea337ae6 Resolve merge conflicts. Fix: use hasattr instead of checking class dict. Turn SimulatedTradingLite into a generator. 2012-09-07 10:28:36 -04:00
Eddie Hebert a4b19f66cb Removes unused, deprecated logger module. 2012-09-05 16:36:27 -04:00
Eddie Hebert d90c531679 Removes core.monitor module.
The Monitor class that it provided was an artifact of a version
that depended on ZeroMQ as a communication layer instead of the
current generator bassed model.

Also, removes tests that were exercising the Monitor.
2012-09-05 15:24:30 -04:00
Eddie Hebert d505fba148 Removes unused component module from core.
This had provided a Component class that was used in a ZeroMQ based
strategy for moving around data that his since been replaced by
the generator model.
2012-09-05 12:54:34 -04:00