Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proposal to change risk metric calculation in upstream #91

Open
llllllllll opened this issue Jan 17, 2018 · 2 comments
Open

proposal to change risk metric calculation in upstream #91

llllllllll opened this issue Jan 17, 2018 · 2 comments

Comments

@llllllllll
Copy link

Hey zipline-live developers,

I am currently working on a change to how we compute risk metrics which may have an impact on the format of the perf packets and risk packet. I wrote up a small post about the proposed change which I posted to the mailing list here. I am looking for feedback from the community.

Some things that I think might apply specifically to the zipline-live project:

  1. Are you streaming results from TradingAlgorithms with TradingAlgorithm.get_generator()?
  2. Do you use the risk report at all?
  3. I saw an issue which referred to the PerfTracker (persistent perf_tracker #84), this object is being replaced with a more modular system: https://github.com/quantopian/zipline/pull/2081/files#diff-b4d729da14c8129685e521fc0953f8ddR26.

Note: The new metric tracker is probably much easier to serialize than the old perf tracker because it basically acts as the algorithm's interface to the Ledger object which is what maintains the portfolio and account.

@peterfabakker
Copy link

Thanks for this. I spend his week to align the master of zipline-live to the zipline master, so we can facilitate moving the risk work over. I looked at it and it seems more logical indeed, not very backward compatible

  1. is best answered by @tibkiss as he was working on that part, but yes
  2. Not actively
  3. great, when will it be pulled in the master? (approx) so I can work with Tibor to serialize it and to find a way to display is better

@llllllllll
Copy link
Author

I am hoping to merge this into master by this weekend. The diff on that pr is currently at +7,093 −5,828, so I apologize in advance to whoever will be handling this merge. If you have any confusing conflicts, let me know and I can try to provide guidance.

The supported output is actually 100% compatible, and I have gone through great lengths to emulate the very organic and confusing structure of the performance packets. This work was done to facilitate changing the performance and risk packets in the future, but that has not been done in this branch.

Also, regarding the risk report, we decided to leave the code for producing the risk report in zipline, and register a metrics-set, named classic, which includes these calculations. The default metrics set will not include these calculations because there is no supported way to access them. If you are building a custom metrics set, you can import this collection as zipline.finance.metrics._ClassicRiskMetrics, though this is actively deprecated and will probably be removed in a future release. If you want the metrics after that, just pull the source directly.

One last thing that is quite relevant to you: you will need to provide alternate implementations of the BenchmarkReturnsAndVolatility and AlphaBeta metrics. For performance reasons, these metrics pre-calculate the values that depend on the benchmark returns. In a simulation, this is a huge win, but it is only possible because the benchmark is both known ahead of time and cannot be changed mid-simulation. For live trading, we have implemted LiveBenchmarkReturnsAndVolatility and LiveAlphaBeta which precalculate for the catch-up period and then fetch live data each minute to perform their calculations. These depend on how we fetch live data and are not built around your notion serializing sessions so I am not sure if they would help you.

Please let me know if you have any questions about this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants