Stock Forecasting with GARCH : Stock Trading Basics

Поделиться
HTML-код
  • Опубликовано: 19 окт 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...

Комментарии • 70

  • @MildlyAmusingComedyC
    @MildlyAmusingComedyC 4 года назад +12

    By far the best time series related videos available on RUclips! Keep it up!

  • @spytheman
    @spytheman 3 года назад +1

    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 ...

  • @cristipopescu1638
    @cristipopescu1638 3 года назад +3

    So clearly explained. Thanks a lot for your work, it really helped me understading the GARCH model!

  • @paul-edou
    @paul-edou 4 года назад +32

    Great content, as always. My grain of salt: it would be more relevant to plot the forecast vs actual volatility rather than vs return

    • @olivermohr417
      @olivermohr417 3 года назад +1

      But you don't have the actual volatility

    • @sgpleasure
      @sgpleasure 3 года назад

      Why not? One can calculate, in this example, the $DIS daily volatility from the daily stock price.

    • @AlexHendershot
      @AlexHendershot 2 года назад

      Maybe he doesn’t want to overfit? I had the same thoughts as you

    • @frenchmarty7446
      @frenchmarty7446 2 года назад

      @@olivermohr417 Yes you do. What do you think the model is being trained against?
      Simply take the absolute difference between Xt and Xt-1

    • @walterreuther1779
      @walterreuther1779 2 года назад +3

      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)

  • @adityakadrekar1196
    @adityakadrekar1196 2 года назад +2

    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.

    • @TheSambita20
      @TheSambita20 2 года назад

      I would also like to know the answer of this second question if anyone can help.

    • @talhakhan-israeel2002
      @talhakhan-israeel2002 Месяц назад

      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

  • @69nukeee
    @69nukeee 9 месяцев назад

    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!

  • @pulkitnijhawan653
    @pulkitnijhawan653 4 года назад +5

    Thanks bro..can you please make more videos on stock markets.....pls......pls......pls

  • @MusicMonster26000
    @MusicMonster26000 4 года назад +3

    This is pure gold! Awesome video. Could you show us EWMA volatility in a similar fashion through pandas too and the determination of Lambda?

  • @yourswimpal
    @yourswimpal 3 года назад +1

    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 )

  • @Art_Blue_Liberalism
    @Art_Blue_Liberalism 4 месяца назад

    Very precisely explained material. Thanks!

  • @dinhnguyenvo3040
    @dinhnguyenvo3040 3 года назад +2

    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?

  • @ManmeetKaur-xv3mh
    @ManmeetKaur-xv3mh 3 года назад +2

    You are simply great, Please make more videos on stock market course.

  • @Raven-bi3xn
    @Raven-bi3xn 3 года назад +4

    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?

  • @안진우-r7y
    @안진우-r7y 3 года назад +2

    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?

  • @gabriellaurin2717
    @gabriellaurin2717 4 года назад +1

    Once again, another great video !

  • @เกี๊ยวอย่างเดียว

    SUBSCRIBED !! The best python + time series model !!

  • @mogli546
    @mogli546 4 года назад +1

    This was great and very simple to understand...!!! Could you please explain the TBATs model as well the same way

  • @kishorkukreja7733
    @kishorkukreja7733 2 года назад

    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 !!

  • @taskmaster8869
    @taskmaster8869 2 года назад

    Great video mate. I appreciate your work.

  • @droga333
    @droga333 4 года назад +9

    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.

  • @LeO96Aq
    @LeO96Aq 4 года назад +1

    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?

  • @drakecody3129
    @drakecody3129 3 года назад +1

    I'm curious to know why you did not use the pyflux library? Do you think your approach is better?

  • @tombic6373
    @tombic6373 4 года назад +1

    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.

  • @user-wx9dv5uu4h
    @user-wx9dv5uu4h 4 года назад +1

    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!

  • @yanzhouzhu7753
    @yanzhouzhu7753 3 года назад +2

    Many thanks!!!

  • @LimeObeans
    @LimeObeans 3 года назад +1

    u r doing the www a great service

  • @abhirajmandal9782
    @abhirajmandal9782 5 месяцев назад +1

    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

  • @fernandosuzuki9905
    @fernandosuzuki9905 4 года назад +1

    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?

  • @hardbass_crew_hauptschule8236
    @hardbass_crew_hauptschule8236 2 года назад +1

    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?

  • @palashsrivastava7711
    @palashsrivastava7711 4 года назад +1

    @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?

  • @zollen123
    @zollen123 3 года назад +1

    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?

  • @bryan-9742
    @bryan-9742 Год назад

    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.

  • @daiane_2310
    @daiane_2310 3 года назад +1

    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?

  • @traderdescomplicado3167
    @traderdescomplicado3167 4 года назад

    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

  • @stephenhobbs948
    @stephenhobbs948 10 месяцев назад

    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.

  • @Asparuh.Emilov
    @Asparuh.Emilov 3 года назад

    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?

  • @Smarttradingchannel
    @Smarttradingchannel Год назад

    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

  • @castro_hassler
    @castro_hassler 4 года назад +2

    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?

    • @castro_hassler
      @castro_hassler 4 года назад +1

      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?

    • @castro_hassler
      @castro_hassler 4 года назад +1

      Multiply the serie by -1 ? and the go back to the original form? sorry if the question is dumb

  • @nitinkumar7225
    @nitinkumar7225 День назад

    Good vid. But I notice that the predictions are lagging the real data in each case.

  • @jary1350
    @jary1350 2 года назад

    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?

  • @jow43
    @jow43 4 года назад +1

    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.

  • @Le_MarcoPolo
    @Le_MarcoPolo 3 года назад +1

    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

  • @vidithshetty544
    @vidithshetty544 6 месяцев назад

    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 ?

  • @hiteshrajbongshi6752
    @hiteshrajbongshi6752 Год назад

    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.

  • @luizscheuer670
    @luizscheuer670 4 года назад +1

    Is the ACF useful for identifying anything for your GARCH model? Or only the PACF to find out the order of the model?

    • @Le_MarcoPolo
      @Le_MarcoPolo 3 года назад +2

      ACF = detect the order of the auto regressive process, PACF = detect the order of the MA process

    • @orkhanamrullayev3966
      @orkhanamrullayev3966 2 года назад

      @@Le_MarcoPolo isn't it vice verse? @ritvikmath

  • @yourswimpal
    @yourswimpal 3 года назад

    @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 ?

  • @mohammadrezanargesi2439
    @mohammadrezanargesi2439 Год назад

    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.

  • @lucareichelt7338
    @lucareichelt7338 4 года назад +1

    Currently trying to use this for a time-varying beta, but having problems

  • @christosck
    @christosck 2 года назад

    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 !

    • @christosck
      @christosck 2 года назад

      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

  • @sahanasarkar5562
    @sahanasarkar5562 2 года назад

    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.

  • @minhtan7491
    @minhtan7491 2 года назад

    How can use the multivariate GARCH with Python, sir?

  • @hyunpang8267
    @hyunpang8267 Год назад

    Hi anyone know how he determine how to transform the return to compare against volatility? on the part where there is a *5

  • @ironjax3369
    @ironjax3369 Год назад

    3:52 "horizon = 1" and the volatility follows the returns... It does not predict anything, it juste reacts to what just happened

  • @gordong9596
    @gordong9596 3 года назад +1

    Hmm so you are using past data to predict past trend, seems a bit off