Predicting Stock Prices in Python

Поділитися
Вставка
  • Опубліковано 19 чер 2024
  • In today's video we learn how to predict stock prices in Python using recurrent neural network and machine learning.
    DISCLAIMER: This is not investing advice. I am not a professional who is qualified in giving any financial advice. This is a video purely about programming using financial data.
    Timestamps:
    0:00 Intro
    0:18 Disclaimer
    2:01 Loading Financial Data
    4:55 Preparing Data
    9:07 Neural Network Model
    12:59 Testing The Model
    22:19 Visualizing Predictions
    23:39 Price Prediction
    26:58 Company Predictions
    28:41 Outro
    ◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾
    📚 Programming Books & Merch 📚
    💻 The Algorithm Bible Book: www.neuralnine.com/books/
    🐍 The Python Bible Book: www.neuralnine.com/books/
    👕 Programming Merch: www.neuralnine.com/shop
    💻 Exclusive Content 💻
    👥 Patreon: / neuralnine
    🌐 Social Media & Contact 🌐
    📱 Website: www.neuralnine.com/
    📷 Instagram: / neuralnine
    🐦 Twitter: / neuralnine
    🤵 LinkedIn: / neuralnine
    📁 GitHub: github.com/NeuralNine
    🎵 Outro Music From: www.bensound.com/
  • Наука та технологія

КОМЕНТАРІ • 689

  • @akramelomrani8728
    @akramelomrani8728 3 роки тому +7

    I am so happy that I am one of the oldest channel members you taught me a lot about sockets and also your project ideas are amazing cant wait to see much more I think you are in the road of becoming one of the biggest channels

  • @thecodfather7109
    @thecodfather7109 3 роки тому +187

    Your content is amazing! I can't find one video that sucks or that's useless. Keep it up dude, your channel will hit big numbers 👌🏽

    • @NeuralNine
      @NeuralNine  3 роки тому +15

      Thanks brother :)

    • @bud384
      @bud384 3 роки тому +3

      That's for sure i believe..

    • @c0dakw0lfgaang48
      @c0dakw0lfgaang48 3 роки тому

      @@NeuralNine which yahoo api is that ? Please tell me the package name and the author name.

    • @martinwestin4539
      @martinwestin4539 2 роки тому +1

      ​@@c0dakw0lfgaang48 there are several yahoo finance apis in python that you can use, but i recommend using yahoo_fin (pip install yahoo_fin)

    • @c0dakw0lfgaang48
      @c0dakw0lfgaang48 2 роки тому

      @@martinwestin4539 thanks mate

  • @sunhound817
    @sunhound817 3 роки тому +2

    Great stuff! Don't stop posting, man. This is very cool.

  • @christoflers
    @christoflers 3 роки тому +182

    Hey man great video, only thing I'd recommend is moving your camera overlay to the top right corner though, as it often blocks the current line of code that you are writing/discussing.

  • @_ScyIIa_
    @_ScyIIa_ 3 роки тому +162

    you're underrated man, you deserve a lot more

  • @sachinr1929
    @sachinr1929 3 роки тому +4

    Great content as always. Keep going !!!

  • @GabrielBauerr
    @GabrielBauerr 3 роки тому +9

    yeah, theory behind would be great to know how to apply the knowledge in different projects and situations. great work man

  • @rzamafuu478
    @rzamafuu478 3 роки тому +13

    Very nice video, learned a lot from it. Only one advice, you could every now and then print the data we are working with so that we see exactly how the data should look. I am guessing that for someone that advanced as you, visualizing the data in your mind is pretty simple, I for example, print it pretty often, just to make sure that I am on the right track. Apart from that, really awesome video, I'm glad the algorithm recommended your channel.

  • @RAJAT2372
    @RAJAT2372 2 роки тому

    Thank you so much! This is exactly what i had been looking for! 🙏🏼

  • @nallurivenkat7425
    @nallurivenkat7425 3 роки тому +1

    We need more and more videos of this kind. Just loved it.

  • @doublegdog
    @doublegdog 3 роки тому +22

    love these very specific python videos! there are too many tutorial videos but not enough videos on specialized programming topics. I have been meaning to get started on algorithmic trading but had no idea where to start. It is as if you read my mind. Thank you!

    • @philippebaillargeon5204
      @philippebaillargeon5204 Рік тому +1

      Here is a tip for everyone that is new to programming: Learn clean coding as you learn how to code. You're gonna thank me later. Cause I'll garantee if you don't know how to clean code and you just copy pasting stuff and adding lines of code your code is gonna be horribly hard to read and understand. Especially algorithms with heavy maths involved.

  • @ProGuitarUA
    @ProGuitarUA 3 роки тому

    Wow man that’s good! Can’t wait to hear more about optimizers and loss functions :) Thanks

  • @dynoagency1323
    @dynoagency1323 3 роки тому +3

    thank u man u are the only youtuber who do this things

  • @punyagalundia9160
    @punyagalundia9160 3 роки тому +3

    I absolutely love your videos and they have really helped me get started with coding as a beginner. Would love it if you could put your video in another corner so code is visible at all times. Thankss

  • @SylvioGuedes
    @SylvioGuedes 2 роки тому

    These videos recorded while coding are the best! please keep producing them

  • @macel1602
    @macel1602 3 роки тому +14

    Great video! And i would love to see some theorical mathematics about what's behind the functions you were talking about

    • @antoinepoisson4791
      @antoinepoisson4791 3 роки тому +2

      Look for Denuit, Hainaut & Truffin « Effective Statistical Learning for Actuaries Vol. 3 - Neural Networks & Extensions » 😉

  • @angelgabrielortiz-rodrigue2937
    @angelgabrielortiz-rodrigue2937 3 роки тому

    Great videos. Love this type of content. Please make more

  • @doruksrtoglu408
    @doruksrtoglu408 3 роки тому +1

    Hey, thank you so much for the video, very smooth and understandable. I agree the fellow commentators, please make a separate video to describe the mathematics behind the model. Thanks!

  • @helenoliver4838
    @helenoliver4838 9 місяців тому +78

    The stock market is still a fantastic tool for building wealth, however, so it's wise to consider investing even if you don't have much money to spare.

    • @greenquake11931
      @greenquake11931 9 місяців тому

      Money is a tool that can help you to achieve your goals. It can provide comfort and stability for your family, make it easier to plan for the future, and allow you to save towards important milestones. But to achieve these things, you need to know how to make your money work for you by investing with the right signal.

    • @mayacho4910
      @mayacho4910 9 місяців тому

      @@greenquake11931 Hello, what signal do you invest with ? I'm new here.

    • @greenquake11931
      @greenquake11931 9 місяців тому

      @@mayacho4910 'BRIDGET MARY TUROW"

    • @mayacho4910
      @mayacho4910 9 місяців тому

      @@greenquake11931 I'll like to connect with her. I want to invest.

    • @greenquake11931
      @greenquake11931 9 місяців тому

      @@mayacho4910 look with her name online for her page.

  • @albertenstein5965
    @albertenstein5965 3 роки тому

    Amazing channel! Thanks for the tutorial dude!

  • @loganathansiva7063
    @loganathansiva7063 2 роки тому

    Thank you very much. I was looking for predictions made like this.. May god bless u.

  • @PurpleGDuffy
    @PurpleGDuffy 3 роки тому +1

    This was great! Thank you!

  • @my-financial-wealthblog4423
    @my-financial-wealthblog4423 3 роки тому

    Wow! As a trader that's amazing thing to learn. Thanks for the video

  • @_Loki__Odinson_
    @_Loki__Odinson_ 3 роки тому +6

    Man believe me you would surely get a lots of subscribers in a very few time
    You are siriously awesome dude

  • @zulfadlizein5192
    @zulfadlizein5192 3 роки тому

    I immediately hit the subscribe button. Nice content, keep up the good work.

  • @cebeb16kmrdayaasaagar87
    @cebeb16kmrdayaasaagar87 3 роки тому

    dude thank u !! u are really great !!! Thank god i found your video !!! This helped me in the project thanks.

  • @andrijaciric4661
    @andrijaciric4661 2 роки тому +6

    I would like to see a detailed video where you explain the tensorflow implementation of the LSTM, because I'm not really sure how they work when you combine them with Dense layers.

  • @timmothysanders1324
    @timmothysanders1324 2 роки тому

    THANK YOU for making this.

  • @vsp540
    @vsp540 3 роки тому

    thanks for the video man it's great!
    and yeah it would be super cool if you made a video explaining the math!

  • @timothymagsino
    @timothymagsino 2 роки тому

    I’m a CS student and I gotta say, you really have fantastic helpful content

  • @julesancillon275
    @julesancillon275 3 роки тому

    Super nice content!
    A video about optimizers would be super welcomed !!

  • @loganathansiva7063
    @loganathansiva7063 2 роки тому

    Hai sir. Thanks for casting your videos. Learnt how to make predictions on stock prices watching your video. I was in search of videos like this. Luckily i got it. Very well narated and explained. Hats off to you sir. May god bless you. .

  • @bhuvanaggarwal7387
    @bhuvanaggarwal7387 3 роки тому

    Awesome content man!!

  • @Henrychc19970911
    @Henrychc19970911 3 роки тому

    Awesome content! Keep up going

  • @elvischen1590
    @elvischen1590 3 роки тому

    Thanks for sharing, good work! For whom is watching this video, again, the previous data does not correctly predict the future!

  • @dipikabudhathoki00
    @dipikabudhathoki00 3 роки тому

    💯% true n actual content u r on extremely right way

  • @damiangames1204
    @damiangames1204 3 роки тому +1

    I am interested in the theory and maths! Also, top quality video.

  • @kaushiksprabhakar9088
    @kaushiksprabhakar9088 3 роки тому +7

    Awesome work dude🔥

  • @ananyaiyer6049
    @ananyaiyer6049 3 роки тому

    Great video!! thank you so much

  • @stephenhobbs948
    @stephenhobbs948 3 роки тому +4

    Great video. Can you move the code up (hit the return 4-7 times) bc your camera is blocking part of the code to the right. If you press return, it will shift the code up so we can see entire line of code. Looking forward to seeing more. Do a video on Q learning.

  • @karthikeyan-kc2py
    @karthikeyan-kc2py 2 роки тому

    Thanks for your efforts and collection of Good informations 👍👍

  • @Krumplyn
    @Krumplyn 3 роки тому +16

    Hi, thank you for the quality content! I just wanted to let you know, that I would be also interested in the math behind the whole AI thing. Have a nice day and be safe :)

    • @press1to
      @press1to 2 роки тому

      I’m looking for someone to adapt this code with my parameter and formulas

  • @delalias5754
    @delalias5754 3 роки тому +34

    Those muscles.... damn nerds are jacked now... thanks brother

  • @timeshiftbr
    @timeshiftbr 3 роки тому +14

    I’d love to see a more technical video. I like to understand what is happening that actually takes me to the results I get, so I can then understand how to make it better. Nice video, man, congrats for your work

    • @marcoscully7021
      @marcoscully7021 2 роки тому

      you should check out coding trains neural network playlist it goes into a lot of depth into how neural networks function

    • @smalltribes88
      @smalltribes88 2 роки тому

      MIT posts all of their lectures in algorithmic models on UA-cam, more technical than you probably even want hahah

  • @stansuen8072
    @stansuen8072 3 роки тому +15

    Thanks! Love your videos. Wonder if there is a good way to detect pattern (instead of predict future prices) such as inverse head-and-shoulder and cup-and-handle?

  • @Itschotsch
    @Itschotsch 3 роки тому +6

    Yes please, theoretical videos would be of great help!

  • @msa3533
    @msa3533 3 роки тому +426

    thank you for this amazing content. I now went bankrupt

  • @Sturmbutcher
    @Sturmbutcher 2 роки тому +1

    Very well explained! I am trying to figure out if I can predict the price of certain currency and then calculate the "value at risk". My doubt is, I have to train this model every day to get a better result? I plan to use it on production to compare it with the actual state of art of "value at risk", using the covariance or the historical method.

  • @nickylo811
    @nickylo811 3 роки тому

    Thank you so much for the video, this is my first time using python, I copy the code step by step and lots of errors when it run maybe I do not have correct settings for those imports. Luckily it works well on Colab. I've learnt some logic on how it works thanks

  • @regeleionescu935
    @regeleionescu935 3 роки тому +45

    Line 60:
    model_inputs=total_dataset[len(total_dataset)-len(test_data)-prediction_days:].values

    • @muhammadvaliallah2781
      @muhammadvaliallah2781 2 роки тому

      Took me a while but the purpose of this line is to get from 60 days before test and include the test set

    • @Kotavedavyas
      @Kotavedavyas 2 роки тому +2

      does anyone know this error
      ValueError: Input 0 of layer "sequential" is incompatible with the layer: expected shape=(None, 5, 1), found shape=(None, 4, 1)

    • @Sturmbutcher
      @Sturmbutcher 2 роки тому +1

      ​@@Kotavedavyas I am on the same boat... did you find how to fix it?

    • @ishan_shrestha
      @ishan_shrestha 2 роки тому +1

      same... help

    • @ramach668
      @ramach668 2 роки тому

      Anyone able to resolve this error? "expected shape=(None, 5, 1), found shape=(None, 4, 1)". Please help with a workaround

  • @balloney2175
    @balloney2175 3 роки тому +1

    Learning python at the same time predicting stock success. Fantastic!

  • @mceiche6626
    @mceiche6626 3 роки тому +5

    I would love to see some theory about the opimizer. Really interesting but hard to understand on the Mathematical point of view

  • @ryanreddy8450
    @ryanreddy8450 2 роки тому +6

    Great stuff. Could you possibly do a video on how to deploy these into production where newer data is automatically fed in, so we do not have to keep training the models again and again?

    • @dvdplays8444
      @dvdplays8444 2 роки тому

      if that was possible then the stock market would be pointless cause everyone would use it

  • @angrwl
    @angrwl 3 роки тому

    Excellent video like always. As a maths student, I am kind of interested in the Adam and Ada grad optimisers so their understanding can we very beneficial for me thanks.

  • @faridparvez
    @faridparvez Рік тому

    Great video, very clear.
    Please make a video on roadmap to learning python from scratch, specifically for stock analysis, chart analysis, getting trade signals using charts and statistical analysis of stocks. I mean create a roadmap on the course tailored cut for only stock trading.
    Regards
    Farid

  • @_M_643
    @_M_643 3 роки тому +2

    You do the best programming tutorials. Easy to understand and learn. I have a question. Can you make a tutorial about how to make a Discord Bot written in Python. If you don't know what Discord is, it is one very popular chat platform.

  • @anant.jain11
    @anant.jain11 3 роки тому +2

    man, you're amazing.
    just amazing, no words
    i calculated the r2_score for FB dataset prediction it's 0.86
    you're predicting stock market with that much accuracy.
    i might just trade on that 😁
    love your content man, keep up the good work❤👍

    • @srkk3360
      @srkk3360 2 роки тому

      could you tell me the code for it

  • @NexGenSlayer
    @NexGenSlayer 3 роки тому +4

    FB Stock the next day from his prediction was 261.10 (1/19/21). The model seems to be pretty good at predicting momentum at least.

  • @shinrei19
    @shinrei19 3 роки тому +2

    wow! nice! i can learn phyton! awesome content!

  • @kaiprzadka6896
    @kaiprzadka6896 3 роки тому +4

    Very cool! I did the same, but tried it with linear regression. I really recommend changing the Programm a bit, so it tells you If the price will Go Up or down, NOT the exact Number. This is way more accurate and even though it's Not as informative, it probably is more usefull.
    I did the same with my linear regression attempt and that improved the average accuracy by quite a few percent.

    • @amarmemane2583
      @amarmemane2583 3 роки тому

      hey, kai is this possible to share your code with me?

    • @shakh1407
      @shakh1407 2 роки тому

      Hey ,what did you change to make that edit? Thanks

    • @kaiprzadka6896
      @kaiprzadka6896 2 роки тому

      @@shakh1407 Well, the easiest solution would be to compare the current price and the predicted price.

  • @fari4r588
    @fari4r588 2 роки тому

    Great work thanks a lot!

  • @Cristian-bg1pr
    @Cristian-bg1pr 3 роки тому +4

    Isn't TimeSeriesSplit Cross-Validation similar to your type of split? It kind of does the same thing. For example: "Train on first 3 days, predict on 4th, then train on first 4 days, predict on 5th" and so on, thank you!

  • @assdz3063
    @assdz3063 Рік тому

    Great Thanks for this job !

  • @jaredfiacco1107
    @jaredfiacco1107 3 роки тому

    Thank you, @NeuralNine! The people who gave you dislikes need a neural network to predict better taste in tutorials.

  • @markphethean3831
    @markphethean3831 3 роки тому

    I am interested in optimizers , would love to see a video!

  • @PeterPetahPetah
    @PeterPetahPetah 3 роки тому

    great video! subbed!

  • @media1critter
    @media1critter 2 роки тому +3

    Even though the models aren't perfect, it's amazing how close they are! They could definitely be handy in assisting day traders with determining how long to hold a position for :) Thanks so much dude!!

  • @joeyb8455
    @joeyb8455 2 роки тому

    A scatter plot and/or calculating the correlation of the predicted price change vs actual price change would give much more insight in wether or not the model has some predictability

  • @jorgecastelo8058
    @jorgecastelo8058 3 роки тому

    Very good work!

  • @rodkrebs9140
    @rodkrebs9140 3 роки тому

    Excellent video!

  • @AdoukaStalks
    @AdoukaStalks 3 роки тому +10

    Man you do be grinding!

  • @marbentraje3245
    @marbentraje3245 3 роки тому +1

    Optimizer and loss model could be a brain-breaking topic, but I'm curious. Very informative and interesting contests sir! GoodJob!

  • @serbrad6426
    @serbrad6426 3 роки тому

    Please do make more theoretical videos. It really helps to learn and understand the fundamentals of the underlying. We're gonna learn them fast and more accurate. Please do and let us join the channel. I would like to be a paid subscriber.

  • @juliopimentela
    @juliopimentela 3 роки тому

    Amazing video!

  • @KingCAMBO
    @KingCAMBO 2 роки тому +3

    I used the code from this lesson yesterday 5/12/2022 to predict today's close on DIA. The prediction last night was 322.19 - Today's 5/13/2022 real-time close was 322.24!

  • @tacowashington717
    @tacowashington717 3 роки тому

    I can’t wait to fully comprehend this

  • @fartabary
    @fartabary 2 роки тому

    hello
    the content and also the naration is very good. if you might be so kind to make a videos about MACD, Stochastic it would be great.

  • @atoffice7323
    @atoffice7323 3 роки тому

    yeah.. make some videos on optimizers and loss functions.. I want to understand them.. and what is the purpose and application of each optimizer and loss function..

  • @sliechti21
    @sliechti21 3 роки тому +1

    Nice video. Comparing the gradient of the true price vs. the predicted may have been an interesting metric as well.

  • @GianCampos
    @GianCampos Рік тому +1

    I don’t know if you’re going to see this comment, but I must say it:
    The way you teach the content in details explaining why and what that section does is amazing! Very good content, I’ll see all your videos now that I understand more about machine learning stuff than 3 months ago when I found your channel.
    Thank you so much! A hello from Brazil!

  • @danajanastova8550
    @danajanastova8550 3 роки тому +16

    Instead of reshaping with reshape: x_train = np.reshape(x_train, (x_train.shape[0], x_train.shape[1], 1)), there is a shortcut syntax: x_train = x_train[..., None], where None stands for the new axis added as the last axis. Maybe you want it to be understandable for begginers though, which I totally understand :).

  • @Dil-e-bayan
    @Dil-e-bayan Рік тому

    Great Video!!

  • @DilpreetSingh-sw3ei
    @DilpreetSingh-sw3ei 2 роки тому +4

    How to predict for next 90 or 100 days if we want to ?
    For other situations in which we need to predict data for a whole day for every 15 mins intervals

  • @alikellaway3901
    @alikellaway3901 3 роки тому +2

    Cool video bro 🙂

  • @adebayoognibo4211
    @adebayoognibo4211 3 роки тому +2

    hi thanks for the video, I have a little problem on line 68
    ---> AttributeError: 'numpy.ndarray' object has no attribute 'append'

  • @das250250
    @das250250 Рік тому

    Good videos , notes of possible ways to improve ..
    A. Lower keyboard sound relative to your voice ..maybe a noise cancel lapel microphone ? Maybe AI noise cancelling
    B. Some commentary on the commands used and what library they are from to connect the resources used and what goes on in each command . Thanks

  • @koyw4919
    @koyw4919 3 роки тому

    Do your think the delay is a problem? Base on the result graph, we can generate a similar graph by low pass filter and delay some day

  • @gustavoreyes6442
    @gustavoreyes6442 3 роки тому +1

    I would appreciate it if you explain the theory behind this project. Anyway, excellent video

  • @ojasdillikar4738
    @ojasdillikar4738 3 роки тому

    I see, You Honored my Comment on your last Video , Thank you

  • @CodeWithJoe
    @CodeWithJoe 3 роки тому +1

    What was the actual success rate you had in predicting?

  • @quadrionigbanjo7790
    @quadrionigbanjo7790 3 роки тому

    Amazing Content

  • @frederikdegn8221
    @frederikdegn8221 3 роки тому +1

    Hey man, super nice video, i have this problem, when the chart shows up, the first point on the chart (green line, most left) is super high, and then quickly dips and follows like it should. any way to fix this?

  • @tonycardinal413
    @tonycardinal413 2 роки тому

    Awesome ! One Ques: Why did you put a zero at the end of line 29? I am not sure what the function or the meaning of the zero is. thanks

  • @justdude8986
    @justdude8986 3 роки тому

    Greate video! However, may you explain how to do the same process if I want to have not one stock, but several?

  • @heribertoquintanilla743
    @heribertoquintanilla743 Рік тому

    Thanks a lot, very interesting. I have a question, if you allow me, once the model and training are done, how are you adding the new stock prices day by day son the model could incorporate to its weights without train again and again all the history of data. Thanks a lot!!

  • @leoccc
    @leoccc 3 роки тому +1

    Is there a way to predict not only next day’s price, but also next few days’ prices?

  • @RemorfChuket
    @RemorfChuket 2 роки тому +1

    24:26 shouldn't that be len(model_inputs)+1 with the parenthesis before the + 1?
    also I'm pretty sure that it doesn't even do anything since I tested it and it returns the same array

  • @noneedtoknowaname8199
    @noneedtoknowaname8199 3 роки тому +1

    Hi! I followed your tutorial step by step but all I am getting a mostly flat green line way on top of the actual share price. Why could this be the case and how can I make it more sensitive?

  • @widiwidya8633
    @widiwidya8633 3 роки тому

    Awesome contact 👍👍👍

  • @michelhaj43
    @michelhaj43 3 роки тому +1

    can you create a video to show us how do we calculate the model accuracy in numbers