Commit Graph
101 Commits
Author SHA1 Message Date
Eddie Hebert f7e4f57425 Enables performance messages on days that have no trades.
Previously, on days that were trading days, but there with no
event data to process for that day, performance metrics were
not emitted, since the handling was based on having an event
trigger the daily performance metric.

Handled by grouping together performance messages, on market open,
for all days since the last market close.

Also, changes perf_tracker unit test to simulate missing data.

Taken from @richafrank's branch handling the same case.
2012-12-28 11:43:31 -05:00
Eddie Hebert a8413e1cc2 Adds reprs for PerformanceTracker and TradingEnvironment.
For debugging in the REPL.
2012-12-27 18:26:55 -05:00
Eddie Hebert f54881cd08 Changes tests from using an ndict for trades to an Event object.
When run over large amounts of data the use of ndict's gets and sets
become a large bottleneck, around 1/5th of the CPU time is spent
in ndict's __setattr__, __getattr__, etc.

By switching to an object for an event,
we reduce the penalty significantly.

Removes asserts that check for event being an ndict, as well as those
that assume a certain behavior of the __contains__ method for events.
2012-12-21 14:31:40 -05:00
Richard Frank 095f2dd65b Date bookkeeping fixes in perf and risk
Issues appeared when we were close to the end of our
historical data.

Yielding DONE event with both perf and risk messages now
2012-12-12 15:23:26 -05:00
Richard Frank 4d41070585 Fix for slippage time getting out of sync with algo.
Moved grouping by date earlier in the pipeline of generators,
prior to any date-dependent state getting involved.  Grouping
pulls from the pipeline until the start of the next group,
which is in the next day.  The effect of grouping after
slippage but before handle_data is that slippage and the algo
are out of sync by a transaction.
2012-11-27 13:38:50 -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 HebertandEddie 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 b02e392b68 DOC: Fixed escaping of long words in table cells. 2012-11-14 11:25:17 +02: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
Thomas WieckiandEddie Hebert 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
fawceandEddie Hebert 815c9f2cf6 providing default behavior for positions dictionary. non-existent positions are
returned as zero size/value positions.
2012-10-10 16:08:14 -04:00
fawceandEddie Hebert d9cf193ce0 fixes to unit tests 2012-10-10 16:07:11 -04:00
fawceandEddie Hebert e3f750014e __missing__ needs to put the value into the dictionary 2012-10-10 16:06:55 -04:00
fawceandEddie Hebert 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 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
fawce fe8e107c59 dropping max drawdown, adding pytz to whitelist. 2012-09-14 16:00:13 -04:00
Eddie Hebert 215a64ed6a Removes unused import of zmq. 2012-08-23 23:48:24 -04:00
scottsanderson 22523b5c12 clean up cruft and fix bugs from timeout rename 2012-08-23 13:09:31 -04:00
scottsanderson 24fddfbde0 tradingcalender, attempt #2 2012-08-22 02:50:16 -04:00
scottsanderson 1f78a07d30 refactor tradesimulation client to not use StatefulTransform unnecessarily 2012-08-21 19:55:40 -04:00
fawce 1479adf519 fixed infinite looking loop in risk reporting, thanks to groupby 2012-08-21 19:26:46 +00:00
fawce 196c681d4b fixes for max drawdown 2012-08-09 21:43:26 -04:00
scottsanderson 8437a28c14 generator-style perf now sends a risk report on receipt of DONE 2012-08-03 21:09:05 -04:00
scottsanderson 56177a7c4f end to end zipline with pure generators 2012-08-02 00:49:48 -04:00
scottsanderson 14067d8323 commit for fawce 2012-08-01 21:42:55 -04:00
fawce 6de01a1c6e added support for any component to relay exceptions through monitor. 2012-08-01 14:56:17 -04:00
scottsanderson 6cb3516b6b save for attempted merge 2012-08-01 11:12:09 -04:00
fawce 5dd35a4709 added default positions for portfolio object. 2012-07-19 23:31:14 -04:00
fawce 1262dcdef1 logging converted to share socket with performance 2012-07-17 11:04:32 -04:00
scottsanderson a789db1789 make git happy 2012-07-04 03:48:28 -04:00
fawce 2a8e19b22f name change for positions_value 2012-06-21 22:08:25 -04:00
fawce ba05335b2c logging every update was spamming the console during unit tests... 2012-06-18 19:11:13 -04:00
Stephen Diehl 9c9cddb2e8 Tidy up logging statements. 2012-06-13 16:21:43 -04:00
Stephen Diehl 61ee2420eb Removed dummy print statement. 2012-06-12 13:31:48 -04:00
Stephen Diehl 06e6207020 Update logging system 2012-06-12 07:11:52 -04:00
Stephen Diehl 2d85ec4d95 Update performance tracker ot use Logbook 2012-06-11 13:54:00 -04:00
fawce 0dea9c5ecb finished comment 2012-06-07 17:58:30 -04:00
fawce 6a8654342a added an as_portfolio method to the PerformancePeriod. 2012-06-07 17:40:26 -04:00
fawce 6d8a786214 updated performance to be trade by trade. 2012-06-07 13:53:45 -04:00
Stephen Diehl 318d7ba678 Fun fun times writing setup.py 2012-05-26 18:24:48 -04:00
Stephen Diehl 817166ba03 Merge branch 'master' into cheetah 2012-05-26 15:55:48 -04:00
Stephen Diehl 3446c116ab Process Simulator! 2012-05-26 15:54:43 -04:00
fawce 70b0088e02 patched logging config. 2012-05-22 21:23:47 -04:00
Stephen Diehl 3ad1f250e6 Cleaned up OOP, first round. 2012-05-16 14:33:16 -04:00
Stephen Diehl d399edd419 Fix ndict woes. 2012-05-14 13:49:45 -04:00
Stephen Diehl e04415e63f Remove all namedicts. 2012-05-14 11:35:43 -04:00
Stephen Diehl 133d9c03af One test passing, progress! 2012-05-10 16:38:04 -04:00
fawce 54f8d7d013 removed lines sending messages to the control channel, simplified logic for handling max loss case, DONE'ing trading client on max loss. Zipline continues to run until all components are finished. 2012-04-24 17:51:02 -04:00