mirror of
https://github.com/wassname/catalyst.git
synced 2026-06-29 00:37:43 +08:00
b976c1252b
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