Hello!
I've followed the “Fading the Gap” tutorial in order to calculate short term volatility (I believe its the volatility over the course of a night). The result is that it outputs how many deviations there have been which is perfect for what I want to do.
The issue comes when I try to copy the same method but for calculating the volatility over the course of a year. There are consistently over a hundred deviations. This means I haven't set it up properly, but I'm not sure what I could do to change it.
Thanks for the help!
#Set volatility trackers in Initialize
self.volatilityShort = StandardDeviation("SPY", 30)
self.volatilityLong = StandardDeviation("SPY", 365)
#The rest is in OnData
if data["SPY"] is not None:
self.volatilityShort.Update(self.Time, data["SPY"].Close)
self.volatilityLong.Update(self.Time, data["SPY"].Close)
deltaShort = self.window[0].Open - self.window[1].Close
deltaLong = self.window[0].Open - self.window[364].Close
deviationsShort = deltaShort / self.volatilityShort.Current.Value
deviationsLong = deltaLong / self.volatilityLong.Current.Value
Louis Szeto
Hi ManiacBanana
In finance, we usually define volatility by
over a window like 252 days. The tutorial is just providing a rough approximation with cheaper computational complexity with extensive assumptions. Intuitively, one of them is that the mean return is 0 such that it could be using the price but not log price or return for approximation without compounding effect accounted.
We recommend using return series and the above equations to find the z-score of the security's pricing series, or simply initialize a Sharpe Ratio Indicator.
Best
Louis
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
ManiacBanana
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!