Predicting Stock Prices and Making $$$ Using the ARMA Model

Sdílet
Vložit
  • čas přidán 1. 06. 2021
  • Can we use the ARMA model in time series to make $$$ trading stocks?
    Link to Code : github.com/ritvikmath/CZcams...
    My Patreon : www.patreon.com/user?u=49277905

Komentáře • 83

  • @user-wc7em8kf9d
    @user-wc7em8kf9d Před 3 lety +23

    Who votes for this has the coolest video on trading with python? I definitely do.

  • @MlleNnCo
    @MlleNnCo Před 3 lety +36

    Really appreciate your effort to teach/demystify all these models! And always going straight to the point. Keep them coming 🙏

  • @ResilientFighter
    @ResilientFighter Před 3 lety +1

    Great job ritvik! Always a pleasure to watch your videos

  • @gracehui237
    @gracehui237 Před 11 měsíci +2

    I was playing around with arima for weeks and never got any progress. Thank you so much for this. It's really important and thankful to have a guide along the way!!

  • @Thahid
    @Thahid Před 2 lety +1

    Very insightful! Especially the part about overfitting. Definitely something I might’ve overlooked.

  • @HenningPhysics
    @HenningPhysics Před 3 lety +2

    Amazing Video! I sometimes play with ARMA models and stock prices to see how it works and indeed after some dense exploratory data analysis oen could combine some "features" in the decision making which increases a lot a the result!! Super cool man, if you could do that more of these videos would be amazin!

  • @RoahanRoy
    @RoahanRoy Před rokem +1

    Started watching these videos for my Financial Econometrics exam, now hooked on to the practicality of it. Thanks a lot!!!

  • @spytheman
    @spytheman Před 3 lety +3

    As usual great video! Really love your explanation and passion in these!

  • @simomoforever
    @simomoforever Před 2 lety

    Well planned and presented!!

  • @joysun53
    @joysun53 Před 2 lety +1

    This is really interesting! Instructive but also practical. Love it!
    In addition, I'm learning time series analysis and is confused about how to determine the orders for ARMA model❓ The way I am doing it now is just trying out different combinations of the orders, with no idea what I am doing. Hope there is a video explaining it

  • @vulcan0eric
    @vulcan0eric Před 2 lety

    Hitting the like button wasn't enough... awesome video! thanks!

  • @nishadseeraj7034
    @nishadseeraj7034 Před 3 lety +12

    you're a great teacher man! really appreciate all the material

  • @khalmouhajir8888
    @khalmouhajir8888 Před 10 měsíci

    Great and concise video. Trying to implement a similar model using a non-parametric Garch Model.

  • @arunstartupgur
    @arunstartupgur Před 2 lety

    Very nice and concise implementation. I will implement in my trading

  • @AZOZTheFake
    @AZOZTheFake Před 6 měsíci

    Thanks for this informed video.

  • @prathameshdinkar2966
    @prathameshdinkar2966 Před 2 lety

    Nice work!

  • @chougaghil
    @chougaghil Před 2 měsíci

    To compare the performance of the models you can check the information criterias (bic, Aic) of each model, select the lowest, check the noise level, check the normality of the distribution, p- value of each coefficient, plot the predicted values against real ones, use Error metrics, try arima to integrate the original time serie...some basic stuff I learnt during my DS training
    I wonder why you didn't do it, or simply suggest it to keep your video short
    Nevertheless, it was a nice introduction for complete beginners in the field

    • @chougaghil
      @chougaghil Před 2 měsíci

      Just saw you made many videos on time series. You probably mentioned the model selection methods in on of them.
      I keep watching

  • @user-or7ji5hv8y
    @user-or7ji5hv8y Před 3 lety +7

    this was a really interesting video. can you do more applied videos, as a recommendation.

  • @kamil7165
    @kamil7165 Před 2 lety

    Great video! I have just 1 remark. The language of selected language of autogenerated subtitles is selected incorrectly. It is really helpful for people that learn English using youtube videos and sometimes don't hear exactly your words.

  • @happykutty
    @happykutty Před 3 lety +3

    Nice, in my senior project we used ARIMA and Prophet to predict stock and bond prices.

  • @mohamedelhilaltekouk902

    really appreciate thanks a lot

  • @Darth_Cassius_
    @Darth_Cassius_ Před 4 měsíci

    Amazing video, I will start with ARMA model but I want my main model to be NN model, can not wait to start losing money

  • @gioragazzi3763
    @gioragazzi3763 Před 3 lety +2

    You are the GOAT

  • @lucasdanielalvesdeoliveira9521

    Could you explain Hierarchical Risk Parity in a video and give an example pls? Congratulations for the great job

  • @hpix123
    @hpix123 Před 3 lety +20

    Nice video! Is the model doing well partly because we're backtesting it on the same set we ran the acf plot on? Presumably you'd have to split your data to estimate its performance out of sample?

    • @benjaminhorvath2078
      @benjaminhorvath2078 Před rokem +1

      You are 100% correct, this video demonstrates the process, it does not prove a simple ARMA will get you 10% return

  • @desmondlai5714
    @desmondlai5714 Před 3 lety +2

    May worth looking at not only long the stock but also short it

  • @mama2e99
    @mama2e99 Před 3 lety +1

    Nice Video, It was very clear. I was wondering, have you tried to run a simulation with only a MA(5) model ?

  • @sanjaisrao484
    @sanjaisrao484 Před 3 měsíci

    Thanks

  • @VadimChes
    @VadimChes Před 3 lety +2

    As example it's fine, but not for real trading, which has spread between best buy and best sell price, commissions for deals and impossibility to get strict open market price and close price. I spent much time to find something stable method to trade - Q-learn, random forest, ARIMA, cointegration, simple moving averages and their combinations... But it seems that trading is more about risk control, when you simultaneously have several positions, each of specific size depending on volatility and correlation between stock in your portfolio. But now I look at fundamental data like companies financial reports and P/E and so on... The less trading the better results as for me ) I think high frquency trading is something possible to earn with models of order book behaviour, but you need huge amounts of money to get profit (making thousands deals every day with minimal profit each one) and build trading architecture like computers near exchenge and super optimized, well tested code.

  • @GohOnLeeds
    @GohOnLeeds Před 7 měsíci +2

    You know in this model you picked a down trend right i.e. a bear market? It's very difficult for any buying scheme to work in a down market :-) My guess is that the ar(5) model happened to work because it bought less often than the other models. When you buy less, the variance is much greater and you happened to get lucky on the days you bought. Run the same ar(5) on a different stock and it will likely lose in a bear market as well. Which brings me to one big issue. When choosing historical data points, it's obvious you get to choose whether you were in a bull or bear or trending market. If you had happened to choose a bull market, then all of these models would have likely made money. So the key to stock trading is not so much the model, it's when you put your money in :-) Peace

  • @k2icc
    @k2icc Před 2 lety

    Very nice and tested fine. Windows 11, latest Python version.

  • @Spijy369
    @Spijy369 Před 3 lety +3

    Awesome! Is there any particular reason why you take the data after the 14th period? 00:31

  • @nathannoetic5348
    @nathannoetic5348 Před rokem

    hi thanks for the explanation in this great video..
    by the way is it possible to combine volume change (stationary data) besides price variable? so that it will be multivariete
    i hope you could make another video about it..

  • @jiachengli9061
    @jiachengli9061 Před 3 lety +4

    Just curious, why don't you check the model fitting before you applying ARMA(5,5). It's also possible that the model doesn't fit well. And it seems that you use the same model to predict all the coming values, I always wondering if it's more reasonable to update the data when time goes and use the updated model to predict the nearest data point. But that would be not efficient as using the same model.

  • @arasafaryan73
    @arasafaryan73 Před 8 měsíci

    Very interesting, good job! However, do you always have to buy and sell every day? Did you also try it for different time periods? If so, how did it go?

  • @banaiviktor6634
    @banaiviktor6634 Před rokem

    Thanks your super videos, I am a real fan of all :). I saw in many videos that we produce returns so as to have stationary data. I think in this case we get a white noise which has no autocorrelation (I checked it with Durbin -Watson test getting around 2) and no use for predicting. Can you help if it is true, or if I am wrong?

  • @qiguosun129
    @qiguosun129 Před 2 lety

    Cool!

  • @zsomborveres-lakos
    @zsomborveres-lakos Před 23 dny

    nice

  • @kylehammerberg3875
    @kylehammerberg3875 Před 2 lety

    any tips for adding a sharpe ratio to the output of the simulations?

  • @fosheimdet
    @fosheimdet Před 18 dny

    Did you do training-test split on the data?

  • @farbodba
    @farbodba Před 3 lety +8

    Stock prices follow geometric browning motion process.
    Btw, just because you have poor returns does not mean you had a "bad" model. Bad in what context? Making money, or bad in terms of your residual not being normally distributed and having p values of your ARIMA above 0.05?
    P.S I like your chanel and the scientific content you produced previously such as those ARIMA model videos you have mentioned in the video, but I feel videos like this is just a way to get more views for the chanel and catch audience attention.
    Anyway, I wish you all luck beating the market and if you did, make a proposal to join Renaissance Technologies
    or compete with them.

  • @adityaagrawal4632
    @adityaagrawal4632 Před rokem

    what is indicated by the width of the green and red bars in the graphs

  • @user-or7ji5hv8y
    @user-or7ji5hv8y Před 3 lety +2

    How can you have a 1,000 runs if we only have the luxury to observed one realization of apple stock time series?

  • @MrAzrai99
    @MrAzrai99 Před rokem

    Can I know how this code helps forecasting the stock? It seems like it is used to analyzed the past stock instead. Sorry for my insufficient knowledge in advance.

  • @junechu9701
    @junechu9701 Před rokem +2

    Thanks so much for the video!!! I just come across a problem when running the code. When the type of order is tuple, the graphs plotted always show that return=0 and there is no red or green window in the graph. However, when I change the order type to float or change "pred>thresh" in simulation part to "pred

  • @ansylpinto2301
    @ansylpinto2301 Před rokem

    Can we fit ARMA to non stationary data though?

  • @nicolaiovergaardlarsen2214

    I absolutely love your videos on time series, but in these plots you really put in a tripwire for the colorblind. Those nuances of red and green are impossible for me to distinguish.

    • @ritvikmath
      @ritvikmath  Před 2 lety

      Hey I'm sorry about that and I appreciate you pointing that out. I'll be more conscious of color choices in the future. If you happen to have any references on accessible color schemes I'd love to learn, but will also research this myself.

    • @nicolaiovergaardlarsen2214
      @nicolaiovergaardlarsen2214 Před 2 lety

      ​@@ritvikmath I have not done any research about it, but I know that there are color schemes for color blind used in gaming etc. I am sure you can find them at least as good as I could.
      Thanks again for your awesome work. You are making really complicated topics immensely clear and digestible.

  • @LJ-ph4hg
    @LJ-ph4hg Před 3 lety +2

    Nice! Collab link?

  • @danieldaniel-ri2mu
    @danieldaniel-ri2mu Před 3 lety +1

    What’s threshold

  • @user-oz3lm2ky5x
    @user-oz3lm2ky5x Před 3 lety +1

    in forex trading ARIMA/GARCH does not work, becouse all ACF and PACF samples, excluding zero lag, is equal to zero

  • @TheViportsPYN
    @TheViportsPYN Před 2 lety

    Why aren't you considering the first lags of ACF and PACF?

  • @sborkes
    @sborkes Před 3 lety +1

    Hey @ritvikmath, where can I download the notebook?

  • @sashacooper9326
    @sashacooper9326 Před 8 měsíci

    I know this isn't the point of the video, I'm confused about why the random model would have reliably performed so badly. Was this a period where the entire stock market was in decline? Otherwise it seems like if you did this on average, and didn't account for transaction fees (which it looks like you don't), your return would tend to be slightly positive (since the stock market usually goes up over time).
    Also wouldn't a simpler baseline be 'for each of the N stocks in our list, put 1/N of our cash into it on day one, then sell them all on the last day'?

  • @Cmoney572
    @Cmoney572 Před 3 lety +1

    If you take the ln of prices does that sorta kinda represent growth?

    • @jiachengli9061
      @jiachengli9061 Před 3 lety +3

      It might help the stationarity assumption of the data, but it also increases the difficulty when you try to interpret the final model.

  • @riosaputra2979
    @riosaputra2979 Před 2 lety

    Hi thanks for the explanation,
    However, I have a question, what does it mean AR(5)?
    Does it mean, if the predicted returns is bigger than the threshold then we will buy the stock the next day and sell it on the following next 5 days?

    • @brtwva11
      @brtwva11 Před 2 lety

      AR(5) indicates an autoregressive model with 5 lags.

  • @qiguosun129
    @qiguosun129 Před 2 lety

    In my understanding, ARMA and AR are both built upon linear transformations, right? So why don't we apply some non-linear tech on it to achieve super cool performance such as RNN, LSTM, ATTENTION-LSTM... So the question is whats differences between DL methods and time series models?

    • @ritvikmath
      @ritvikmath  Před 2 lety

      Great question. Also good timing. I'm planning some videos on exactly this topic soon.

  • @Thejohnster1012
    @Thejohnster1012 Před 2 lety +1

    surely overfitting the model here would lead to fantastic returns as you are testing it on the data you used to make the model? Overfitting generally only leads to problems when you go outside the training data no?

    • @maxfinnian
      @maxfinnian Před 2 lety

      This should not be the case since for each time step he is fitting an ARIMA on data from day 0 to day (step - 1) in his run_simulation function. This is still not the best practice though as each training set is gradually getting larger from 14 days up to the length of his data set, typically you would want to use a fixed size rolling/sliding window with sufficient length to ensure the time series models fit at each window are receiving the same amount of data which will lead to a more informed comparison of the model parameters. He should also be using a validation time period in which the training window will slide to train each time step of an ARIMA structure. This scheme should be used when optimizing the ARIMA parameters before leading up to a final test of the best ARIMA parameters using an out of sample test set which begins after the last datapoint on the validation window.

  • @OskarBienko
    @OskarBienko Před rokem

    You didn't look at p-values tho...

  • @muzamilshah8028
    @muzamilshah8028 Před 3 lety +1

    Hahahaha

  • @user-or7ji5hv8y
    @user-or7ji5hv8y Před 3 lety +1

    Would it make sense to do the opposite if the ARMA model shows us losing money, given that if we do the opposite, then we should be making money?

  • @sonsangsom
    @sonsangsom Před 2 lety

    Transaction fees eat up all of those profit already

  • @anupamc3510
    @anupamc3510 Před měsícem

    i make more percentage gains using simple technical analysis...this mumbo jumbo is making things only complicated

  • @thechoosen4240
    @thechoosen4240 Před 10 měsíci

    Good job bro, JESUS IS COMING BACK VERY SOON; WATCH AND PREPARE

  • @pineapple3832
    @pineapple3832 Před rokem +1

    Okay but if you have a working model, by making a video you’ve lost your edge, and if this isn’t legit then why watch. Either way I’m not gaining much from this.

  • @zollen123
    @zollen123 Před 3 lety +1

    I am thinking of using scipy.fft() for decomposing the entire stock data and use the base frequencies for the exog of SARIMAX, do you think it would help minimize the mean error?