Use Artificial Intelligence (AI) to Predict the Stock Market with Python

Поділитися
Вставка
  • Опубліковано 17 лис 2024

КОМЕНТАРІ • 74

  • @leandrogoethals6599
    @leandrogoethals6599 Рік тому +28

    How the flow of a forwardtest such prediction is:
    Step 1: Download the csv till current date
    Step 2: Delete the last 20% of the timestamps of the csv so if it's like data of 2000 till 2023 then cut till 2019 and save this as training_SP500.csv
    Step 3: Do the opposite of step 2 wich u cut the first 80% off and save it as future_Sp500.csv
    Step 4: train only on the data of training_SP500.csv
    Step 5: u test the the prediction for the missing 20% of the current data
    Step 6: on same chart plot the original data of the current s&p500 data
    And Voila a chart wich u can clearly see is those prediction where in the right direction!!
    Nice vid, good education

    • @itssardine5351
      @itssardine5351 7 місяців тому

      So you’re just using 20% of available data to train? Seems like a whole lot of input is lost…

    • @leandrogoethals6599
      @leandrogoethals6599 7 місяців тому

      @@itssardine5351 Well 20% of what u find adaquite ofcourse

    • @MyTopAnime
      @MyTopAnime 5 місяців тому

      @@itssardine5351 If you know anything about AI, you generally use 20% as testing data and the rest as training data. Also sometimes too much data can cause overfitting. This means it can predict existing data with ease, but when it comes to new data, it will struggle to perform well.

    • @SPONGE2008
      @SPONGE2008 4 місяці тому

      ima be so fr i dont know how to get the csv file its like 2am im so tired lol anyone can help? would be appreciated

    • @leandrogoethals6599
      @leandrogoethals6599 4 місяці тому

      @@SPONGE2008 what u mean get "the" csv file u mean the one the video creator made(wath is his name again).
      I use my own csv wich is constructed by quering an api from a dataprovider, of course i don't wanna pay for data so i do this multiple times for diffrent time ranges and paste them togetther again

  • @joao_paiva
    @joao_paiva Рік тому +3

    This type of algo is usefull just to predict the next time event. You have 70% accuracy but you are predicting just the next day price based in the last day price multiple times

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

      that is right mr future billionaire

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

      ​@@rjsingh4255 lmao, just to share information bro 😂

    • @leonli891
      @leonli891 2 місяці тому

      so what? fake thing?

  • @pohu6296
    @pohu6296 Рік тому +3

    Use Your prediction and check the return %, the results is very very poor. The prediction is basically noise with baseline of open price. You can just plot open price vs close price, the are similar to your prediction.

    • @AB_498
      @AB_498 10 місяців тому

      that's true but i wonder why it still got an accuracy of 70% on test data

    • @kenhan168
      @kenhan168 6 місяців тому

      @@AB_498 , because it feed in the current open price and the volume, which is not available in actual trading. You can only get Volume after the market close.

  • @benzhou9751
    @benzhou9751 Рік тому +5

    How do I get it to predict more

  • @codeline9387
    @codeline9387 10 місяців тому +2

    actually thats almost useless prediction coz we know volume when only when close is known

  • @Mr._Cousin
    @Mr._Cousin Рік тому +10

    should it be more reasonable to use the price the day before to predict the price next day in train and testing?

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

      Smart idea but one days data might not be enough to make a good prediction

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

      it's what he did, the N day open price is equal to the N-1 day close price

    • @antonyhartley9586
      @antonyhartley9586 Місяць тому

      @@joao_paiva Totally incorrect closing_price != opening_price_next_day, google it!

  • @vyacheslavfiodorov5738
    @vyacheslavfiodorov5738 Рік тому +3

    Are you sure that it is not learning from the high and low prices of the current day that has not yet closed? How to make sure?

    • @kenhan168
      @kenhan168 6 місяців тому

      For the volume, you can only get it after the market close. So putting current day of volume while the market is open has no much use, as the volume is changing throughout the day.

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

    Hope you had tutorial for deployment of this and for real time price to predit.

    • @taneti_sanjay
      @taneti_sanjay 8 місяців тому

      Predicting real-time market prices presents significant challenges due to the need for up-to-date data. While it's theoretically possible to predict future prices, accessing real-time data is often limited by market closing times and costly data acquisition. APIs typically provide data once the market closes, hindering the ability to make real-time predictions. Moreover, obtaining live data usually incurs substantial expenses. Therefore, predicting prices for future points requires historical data for training models, making real-time prediction impractical in many cases.
      In addition to data accessibility challenges, there are inherent complexities in modeling financial markets that further complicate real-time predictions. Financial markets are influenced by a multitude of factors, including economic indicators, geopolitical events, investor sentiment, and market psychology. These factors can lead to sudden fluctuations and volatility, making it difficult to accurately forecast prices in real time.
      Furthermore, market dynamics are constantly evolving, with new information continuously being incorporated into prices. This makes it challenging for predictive models to adapt quickly enough to capture and react to these changes in real time.
      Moreover, the presence of noise and randomness in financial data adds another layer of complexity. Despite best efforts to develop sophisticated predictive models, there is always a degree of uncertainty inherent in predicting future prices accurately.

  • @shilpabaranwal5913
    @shilpabaranwal5913 7 місяців тому +1

    Nice Video but not useful for real time prediction, volume information will not be available beforehand

  • @IkaroSampaioDj
    @IkaroSampaioDj 10 місяців тому +16

    Stopped this video when he included 99% of the data in the train_data. Makes no sense

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

      Why , explain me
      I'm new in python

    • @mpregsonic5874
      @mpregsonic5874 8 місяців тому +8

      Yeah it does. He is doing EXTRApolation where the future is being predicted. Predicting more than 1 times step into the future in this case compounds the margin of error greatly. This means you’ll want to train on all of the data up until the time period you are trying to predict. This is standard in time series. Even if you want to train on 70 percent to predict the remaining 30 percent you do it in what’s called a rolling forecast way which essentially retrains the model on all the data up to the point you’re trying to predict for every point within that original 30 percent.
      In machine learning where time series is not involved, an INTERpolation problem, training the model on 70 percent and testing on the remaining 30 is a lot more common and makes sense.

    • @hyrumnielsen4390
      @hyrumnielsen4390 2 місяці тому

      Only predicting the next day (or time interval) for day traders.

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

    i keep getting an error at the "model.score" it says model is not defined

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

      you have to define the model ===> model = XGBRegressor()
      model.fit(train_data[features],train_data[TARGET])
      y_pred = model.predict(test_data[features])
      #Accuracy
      model.score(test_data[features], test_data[TARGET])

  • @yourbestlifebrandi
    @yourbestlifebrandi Рік тому +4

    Where or how did you produce the input file for historical data? Where can it be obtained?

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

      Same question

    • @吳嘎
      @吳嘎 11 місяців тому

      import pandas_datareader.data as web
      # Required steps to setup Yahoo Finance
      import yfinance as yfin
      yfin.pdr_override()
      aapl = web.get_data_yahoo('AAPL',
      start='2019-01-01',
      end='2020-01-01')@@MeghanaHM

    • @crackedatcurry
      @crackedatcurry 9 місяців тому +3

      kaggle

  • @kaushikmetha3429
    @kaushikmetha3429 Рік тому +3

    This works only for one stock. Is there any way to design a neural network model that can be used to predict stock price of more than one stock?

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

      No, there isn’t.

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

      Yes, you can predict multidimensional stock returns with a nn by having one or more output nodes for each return series that you want to predict.

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

      Just use threads and run the same program for many different stocks

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

      @@AI_Vania No, there isn’t. You can’t predict, you’re only building a measurement based system that estimates risk and when to purchase and sell based on estimated risk.

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

      @@Stopinvadingmyhardware What do you mean "you can't predict"? One can build a model to predict future prices or (maybe better) future price distributions. The NN doesn't necessarily make risk estimations or buy/sell decisions, those things may involve logic that is outside of the NN.

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

    I followed you step by step, but my historical chart is a downtrend for some reason.

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

    typo? train_data= data.iloc[:int(.99 * len(data)), :]
    test_data= data.iloc[int(.99 * len(data)):,:]

  • @JCCreatorStudio
    @JCCreatorStudio 8 місяців тому

    im new to ML, the final plot only show some orange line near the end, what does it mean and where are the rest?

    • @GamingWithAJ175679
      @GamingWithAJ175679 7 місяців тому

      the dataset had the entire data including the one at the end. However, he split the dataset into 2 parts. 1 big and 1 small (the one at the end). He fed the bigger chunk of data into the ml model and kept the smaller chunk aside. Once the thing was trained, he asked the model to predict the next prices which he then compared to the smaller chunk of data he did not allow the model to see.

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

    great tutorials 👍👍👍👍👍

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

    Hey, nice, can you do a tutorial for optimal execution on python using almgren kriss?

  • @antonyhartley9586
    @antonyhartley9586 Місяць тому

    shame there's no code (just pitching for sign-up), I'll just type it in:)

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

    How do I, predict more, like not only the test set for example 3 years forward

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

      this type of code is usefull just to predict the next time event

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

      in the last 3 years we had : covid, war on ukraine. no python script could take that into account

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

      easy money 😂

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

    way of Telling the program is brief . how can we get the csv files for example like yours SPY.csv

    • @gaurirajput9856
      @gaurirajput9856 7 місяців тому

      you can download it from google or you can get it from google search

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

    Very interesting! But, how could it be used in algotrading?

    • @jasonreviews
      @jasonreviews Рік тому +4

      you can't it's 30-60% accurate. You can't predict black swan events or news.

  • @wuyanchu
    @wuyanchu 2 місяці тому

    Thx and god bless 😊

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

    where to get dataset for this

  • @robertobonani8571
    @robertobonani8571 Рік тому +6

    Can see you are a programmer but not a data scientist

  • @王阿翰-j9r
    @王阿翰-j9r Рік тому +2

    Overfitting bruh

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

    Pregunta que le hago a todos, para que te sirve esto xD. Para nada, no te da ninguna info

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

    etni jhak marane ke bad prediction acuuracy only 70 %....11:30..!!!

  • @tristeub997
    @tristeub997 5 місяців тому

    It is totally useless wtf ??

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

    I'm surprised why this video is getting so many views and likes.
    You made a huge mistake in your logic.
    This is not the accuracy of your model. This is a coefficient of determination that does not play any useful role in building a trading strategy.
    The coefficient of determination shows how strongly you can describe the target variable using your features.
    If you take data from the previous day, and without a model. Your coefficient of determination will be 0.99
    In short, it’s not accurate and it’s useless what you did

  • @tuanvulet.9776
    @tuanvulet.9776 Рік тому

    thanks bro