I know this is sort of basic and should be well addressed, but is there a well defined method to calculate volatility?
This is how I currently do it:
var dailyReturn = ROCP(symbol, 1, Resolution.Daily);
var volitality = STD(symbol, 84).Of(dailyReturn);
I first define a variable called daily return, and calculated 84 days (trading days in 4 months) of standard deviation of it. However it is far from what I manually calculated from the prices. I know the numbers may be not exactly the name (Annualized, not annualized etc.) but the shape of the data curve is totally different. Can anyone confirm if this is the right way to calculate vol in QC? or if there is a better way to do that?
Thank you!
Jared Broad
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.
Michael Handschuh
public class LogReturn : WindowIndicator
{
public LogReturn(string name, int period)
: base(name, period)
{
}
public LogReturn(int period)
: base("LOGR" + period, period)
{
}
protected override decimal ComputeNextValue(IReadOnlyWindow window, IndicatorDataPoint input)
{
decimal valuef = input;
decimal value0 = !window.IsReady
? window[window.Count - 1]
: window.MostRecentlyRemoved;
return (decimal) Math.Log((double) (valuef/value0));
}
}
Travis Fu
Michael Handschuh
Michael Handschuh
Michael Handschuh
Travis Fu
Michael Handschuh
John Radosta
There are various ways to measure volatility, it just matters if you're trying to estimate current volatility or future volatiltiy, as well as realized or implied volatility. Let's look at the indicator route first.Â
For current realized volatility, you could certainly use STD (which is essentially also what Bollinger Bands uses), Keltner channels which provide volatilty in absolute pricing with a moving average, or you can even go the statistical arbitrage route if you have asset cointegration, measured by the divergeance between one or more other assets (this is how Renaissance fund is rumored to do it). ATR is also another one if you want just the absolute pricing.
For predicting future realized volatility, you can do that surprisingly accurately using the GARCH method (link to paper is below), but as mentioned in many talks on YouTube, realized volatility is not what ultimately determines asset prices, implied volatility does, and there is no known accurate way to predict future implied volatility. If you find it though, well, you'd be rich :-) Sidenote: this is why options traders are always talking about implied volatility, because implied volatility is a derivative (calculus) of asset price: the underlying asset price is baked into it.
The good news is that the GARCH method has been shown to be a better predictor of future realized volatility than even the VIX, so I'd go that route if you really want to get your hands dirty.
hec.unil.ch/agoyal/docs/Garch.pdf
Â
Derek Melchin
Hi John,
Thank you for providing a research paper for users to learn more about GARCH models. I noticed the link to the paper returns a 404 error though. Here's a working link for those interested in learning more: www.hec.unil.ch/agoyal/docs/Garch.pdf
Best,
Derek Melchin
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.
Travis Fu
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!