-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
timeseries.cone_rolling needs refactoring #178
Comments
@acampbell22 Is that something you could help with? I think the complete code should be rewritten from first principles. |
Moreover, a nice addition would be if it were possible to output the cone in a dataframe so that we can add automatic checks if a cone was breached. |
Started looking at this last night. Will get going on a refactor soon. |
👍 |
Do we want to continue to support the extend_fit_trend=False (refit linear cone with ever additional day of data) option? It adds a lot of complexity and isn't used in the full tear sheet. |
Agreed, lets drop that. |
Is it right to use the slope of the line fit to the backtest cumulative returns as the slope of the midline of the future cone projection? If an algo returns 10 bps per day, its equity curve will have a much higher linear fit slope over a 13 year backtest than it will over a 1 year backtest (compounding). Would it be more correct to project the backtest CAGR forward? I am trying to make the "cone bounds" function as generalizable as possible. Should be applicable to any OOS starting portfolio value. |
Hey Andrew, yes I agree simply applying the CAGR from the backtest as the OOS trend projection is a better, generalized implementation. I actually used that is a way to check the math of the regression approach if I recall since they should be equivalent when the regression is done with the intercept term (which I think is how it was implemented originally). Sent from iPhone
From: Andrew Campbell notifications@github.com Is it right to use the slope of the line fit to the backtest cumulative returns as the slope of the midline of the future cone projection? If an algo returns 10 bps per day, its equity curve will have a much higher linear fit slope over a 13 year backtest than it will over a 1 year backtest (compounding). Would it be more correct to project the backtest CAGR forward? I am trying to make the "cone bounds" function as generalizable as possible. Should be applicable to any OOS starting portfolio value. — |
@a-campbell , As I see it, we have 2 approaches up for debate for drawing the slope of the line that bisects the cone (the 'mean' of the cone) which are dependent on choosing how to compute the OOS daily return projection. So should this daily return be computed as: a) mean(backtest_daily_returns) @twiecki What's your vote? :) |
@a-campbell Just chatted with @justinlent internally and the compounding issue makes this all a bit weird. One thought is to instead use the Bayesian cone which does not have that issue rather than retrofit and refactor the existing one but other options also appear feasible. Specifically, we could first compare these cones:
As we have data we can validate this more thoroughly which we should do to begin with if the cone were to become a more important measure. The key insight I suppose is that we should do that validation before putting in effort to rewrite the current method that might become obsolete. Thoughts @a-campbell? CC @Jstauth |
The bayesian cone definitely seems like the most robust way to project future returns. The only downsides I can see to replacing the linear cone with a bayesian one are run time and potential user difficulty understanding MCMC. We could make the midline of the linear cone compound. The cone function would take a backtest standard deviation, compounding adjusted mean daily return, standard deviation multiplier, and number of days to project forward, and starting portfolio value. Something like:
I'll generate some comparisons and post them here. |
Since I was already pretty far along, I finished refactoring the linear OLS fit cone. Should be easy to drop in different ways of calculating the midline. My work so far is here: https://github.com/quantopian/pyfolio/compare/cone-refactor?expand=1 |
Closed with #233. |
@justinlent and I just looked at the code in
cone_rolling
. While functional, as we're relying on that code more and more it should be more robust. There seems to be an issue with <= logics, the warmup-period is obsolete, it's not tested etc. Probably a clean rewrite is the best path forward.The text was updated successfully, but these errors were encountered: