Stock Forecasting with GARCH : Stock Trading Basics
ฝัง
- เผยแพร่เมื่อ 27 พ.ย. 2024
- How do you use the GARCH model in time series to forecast the volatility of a stock?
Code used in this video:
github.com/rit...
Theory of GARCH video:
• GARCH Model : Time Ser...
Coding in GARCH video:
• Coding the GARCH Model...
By far the best time series related videos available on TH-cam! Keep it up!
Did some testing using GME, using ARCH(2,0):
Prior to the WSB army,
1) if we incorporate the whole data from same start date as ritvik to 2021 Jan 13th when we first witness the spike, the volatility prediction for the next 7days predict that volatility should move lower subsequently.
2)training from same start date to any dates after that, it always predict volatility to be lower the next 7 days!
Thats why stock market is so tough ...
So clearly explained. Thanks a lot for your work, it really helped me understading the GARCH model!
Glad it helped!
Great content, as always. My grain of salt: it would be more relevant to plot the forecast vs actual volatility rather than vs return
But you don't have the actual volatility
Why not? One can calculate, in this example, the $DIS daily volatility from the daily stock price.
Maybe he doesn’t want to overfit? I had the same thoughts as you
@@olivermohr417 Yes you do. What do you think the model is being trained against?
Simply take the absolute difference between Xt and Xt-1
Might help to put into the maths-equasion:
Actual volatility is sqrt(Var(r))
Var(r) = E((r-E(r))²) = E(r²) - E(r)²
If we assume E(r)²=0 (which is a valid assumption, as expected returns must be very small, otherwise it's a money mashiene (or drain)), so we have
volatility = sqrt(E(r²)), so very similar to the absolute returns which is deducable from what he is plotting. (If I'm not mistaken :P)
for ritvikmath, i click like before even watching the entire video cause I know it will be good. (prediction using ARCH on average like percentage :p )
Very precisely explained material. Thanks!
You are welcome!
You are simply great, Please make more videos on stock market course.
Thanks!
Thanks bro..can you please make more videos on stock markets.....pls......pls......pls
SUBSCRIBED !! The best python + time series model !!
This is pure gold! Awesome video. Could you show us EWMA volatility in a similar fashion through pandas too and the determination of Lambda?
Once again, another great video !
I'd like to see the difference between the predicted vol and the actual vol.
Also, the orange line is always lagging in making predictions, so I don't know why would it be useful for.
Anyway, interesting. I don't know shit about coding, but I know about how the markets behave.
Dear Ritvikmath, I am grateful for your work, I have learned a lot. Thank you so much. Can you do a ARMA-GARCH model with stock forecasting?
Hey Ritvik, thanks for posting this video. I have some questions:
1. Why are you using the pacf plot of the 'square of returns' and not just the returns?
2. From my understanding, PACF plots help you understand the Auto regressive term which is p in this case. How do you determine the lag of the volatility (q)? I am not sure to follow why did you take q as 3 after plotting the PACF chart.
I would also like to know the answer of this second question if anyone can help.
for question 1, he takes the square as this would be the pacf for conditional variance of returns. doing just the returns would result in the pacf for conditional mean returns
From your ARCH/GARCH videos it's not clear to me if the goal of ARCH/GARCH is to model the time series itself or the residuals of the time series. You started your ARCH video as trying to forecast movie sales and observing that the residuals have changing variance. And then modeling the residuals with an ARCH process. But in this video you are modeling the stock returns directly with GARCH rather than doing an ARMA model on the returns and then modeling the residuals of that with GARCH. Would love a clarification on what the object of ARCH/GARCH modeling truly is, thanks!
Many thanks!!!
You're welcome!
Great video mate. I appreciate your work.
In your arch video, you said that you'd try to fit the best model you can and fit arch/garch with the residual. So, what not using ARMA model here first and then apply garch to the residual?
Awesome, awesome tutorial, thanks for taking the time to do it and sharing!
One quick question though: if I understand correctly, ARCH/GARCH basically are used to predict volatility (which is variance - in the financial case the 'squared returns') but we are actually using the returns (being the daily percentage change in stock prices) as data to feed the ARCH/GARCH models. Is this correct?
Thank you again!
This was great and very simple to understand...!!! Could you please explain the TBATs model as well the same way
u r doing the www a great service
at 4:40 you say that the predicted volatiry gets higher exactly when the returns get more jumpy. But to me it looks like the line is really just following the blue line and lagging behind, which seems to indicate overfitting. How do we know this prediction is any good?
hello hi ,how did u find the value of q in GARCH model,from the pacf plot i understand it to be an ARCH (3 ) model ,but how did u say that its a GARCH(3,3) model, could u have used an ARCH(3,0) model
The graph of the code in the video at 6:56 shows plots for June 13 and June 14, 2020. Both of those days are weekends. Your code does not take weekends into consideration and probably not holidays, either.
I'm curious to know why you did not use the pyflux library? Do you think your approach is better?
Great Video! And simple to understand!
I have some questions of measuring performance of your garch model, why did you plot with return, not with real volatility of data?
And can I apply RMSE for prediction of volatility and real volatility as performance measure?
Like all models of this type, the predictions values are always delayed, so when you look at the big picture that seems good, but to predict value for tomorrow that will not be correct at all
I read a paper that indicated that we could estimate the Beta of the Capm could be estimated thanks to garch . But I do not see at all the link between the Capm and the garch model
May I ask why would we want to predict a stock volatility instead of the stock price? Using ARCH would mean I have to mathematically reverse the predicted volatility to get back the predicted price?
If you recall, did you use adjusted close values to calculate returns from 2jan2015-9jun2020? Thanks. I ask because I was unable to replicate your pac for returns.
Great video! i´ve got two questions, can I use GARCH + SARIMA to predict the whole time series? and the other one in my fit, only beta7 and alfa 7 are relevant, can I drop the others?
Great video! Could you please clarify what is the time frame the volatility prediction is expressed in? If it is daily then based on the plot for the first time period is between 2.5% and 5%. What is the best way in your opinion to annualize the values?
Also, do you know what is the syntax for an EGARCH(1,1) model so I can adjust the below line?
"model = arch_model(returns, p=1, q=1)"
Thanks!
@ritvikmath Can I additionally use other stock prices (of different companies) to forecast for Disney's stock prices and simultaneously capture the spill-over effect? If yes, how do I go about it?
interesting in the prediction you don't elect to try and fit with changing the dist='StudentsT'. The distribution of a random variable should be completed before one applies forecasted volatility no? (Like how do you know that this distribution is normal? My understanding is that the KDE approach is useful for pinning down the distribution/easier to do than max liklihood for a stock series.). Your thoughts would be greatly appreciated. My original sentiment is that many stocks have a student T distribution for their 'regular' and log returns.
So in this case, is it a good idea to forecast with some model (lets say a linear regression) the returns and then forecast the volatility over regression residuals using a GARCH model, add the two forecasts to get the actual prediction?
I have another question, if I do what I proposed in the question above, should I be worry about the negative peaks? for example if I am forecasting value at risk, I want to be more certain about the volatility in the lower band, so how do I forecast it?
Multiply the serie by -1 ? and the go back to the original form? sorry if the question is dumb
Good vid. But I notice that the predictions are lagging the real data in each case.
Hi from Brazil, I want to analysis volatility of stocks and add accounting variables as independent variables… garch/Midas seems to be perfect to this… have you ever used this in R or eviews?
Did you have any issue installing the arch package? I'm able to install it with no problem, but I always get a Value Error when I try to use the package.
Hey, I really appreciate your work and your channel is amazing.
Regarding the volatility predicted by the model, how can I backtest these values to confirm the reliability?
Currently trying to use this for a time-varying beta, but having problems
Hello Ritvik, Great content. Loved how in simple words you explained GARCH. A question here, I did understand that the orange line is the volatility and not the prediction of returns . How do we get the predictions then from here ?
Would it be okay to say, model an ARIMA model and then for a GARCH on the same model. Extract the volatility as you showed and sum them to ARIMA predictions ? Thanks !!
Is the ACF useful for identifying anything for your GARCH model? Or only the PACF to find out the order of the model?
ACF = detect the order of the auto regressive process, PACF = detect the order of the MA process
@@Le_MarcoPolo isn't it vice verse? @ritvikmath
Thank you for the content. Best video I have seen on the topic. Does anyone know why 31 and 32 when trying to pick and fit model, that is operated on entire set NOT a training set instead to avoid look ahead bias? So if you hide the last 100 data point from fitting, I got a different model. Would love to see some comments on R2 value, and how that is used all in comparison of other models/ stocks?
Hi
Ritvikmath, please could you tell me wich model is best fit for the ticker ^BVSP between 2020,1,1 and 2020,8,10? I couldn't find any good model observing the PACF, maybe I missed something in your video as I not native in english. Thank you
Which site can I use to backtest a trading strategy ? Im also trying to implement a strategy with a stocks open close and higher and lower wicks but am unable to find numbers in specific time frames ( for eg: weekly or monthly ) could you help me with the above two queries ?
Thank you for the great content! Is it possible to add the volatility effect to a simple seasonal model so that the seasonality might jump stronger based on that forecast?
Sir, imagine there is a billboard which reflects a random 2 digit numbers everyday at 12pm. If i have last 2 years everyday data. Which model will be effective to predict the number for upcoming days? Kindly reply.
@ritvikmath can i check if my ARC and PARC test of lag 1 is highly negatively correlated, can i throw away ARCH/GARCH model straightaway ?
Hi
Can you please explain how we can plot the actual index as well?
I know volatility in fact is an estimate for STD of the changes and using this std we may have two boundaries for positive movements and negative movements.
For example price is 100$
And GARCH predictions are around 2 percent for the next three days
Then we would have two boundaries, one above, around 102$ and the other around 98$ for the next three days.
I kindly ask for this plot to see how well the predictions did in practice.
I would appreciate if you explain how wd can transform these volatility to actual index values.
3:52 "horizon = 1" and the volatility follows the returns... It does not predict anything, it juste reacts to what just happened
How can use the multivariate GARCH with Python, sir?
Hi there, I am trying to use your example to create a 12 Hour forward forecast. Novice with python, so having a hard time converting these lines of code:
future_dates = [returns.index[-1] + timedelta(days=i) for i in range(1,8)]
pred = pd.Series(np.sqrt(pred.variance.values[-1,:]), index=future_dates)
fyi, i have 499 prior hourly periods of real data.
thanks for great content !
pred = model_fit.forecast(horizon=12)
future_hours = [returns.index[-1] + timedelta(hours=i) for i in range(1,13)]
pred = pd.Series(np.sqrt(pred.variance.values[-1,:]), index=future_hours)
this is what i have, but get unsupported operand type error
Hi ! How do I go back to forecasting the price after forecasting the volatility ? Coz my end objective is to forecast the price. Can anyone please answer.
Hi anyone know how he determine how to transform the return to compare against volatility? on the part where there is a *5
Hmm so you are using past data to predict past trend, seems a bit off
I personally thought garch was good for 2 years of daily training data, and then 5-10 days of prediction