Computer Science (compsci112358)
#Programming #Python
How I used AI & XGBoost to predict the stock market
Disclaimer: The material in this video is purely for educational purposes and should not be taken as professional investment advice. Invest at your own discretion.
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
⭐Please Subscribe !⭐
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
🐦🔥🐤 Support The Channel🐤🔥🐦
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
⭐Get the code and data sets or just support the channel by becoming a supporter on Patreon:
►https://www.patreon.com/computerscience
⭐Website:
►http://everythingcomputerscience.com/
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
📚Helpful Python Programming Books📚
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
► Hands-On Machine Learning with Scikit-Learn and TensorFlow:
https://amzn.to/2AD1axD
► Learning Python:
https://amzn.to/3dQGrEB
►Head First Python:
https://amzn.to/3fUxDiO
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
📚Helpful Financial Books📚
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
🌟Stock Market Investing Books:
✔️The Bogleheads’ Guide to Investing
https://amzn.to/3s0icxA
✔️The Intelligent Investor
https://amzn.to/34Mj7t1
✔️A Random Walk Down Wall Street
https://amzn.to/3Bv0ghW
🌟Money Mindset Books
✔️Rich Dad Poor Dad:
https://amzn.to/3rZW6eE
✔️Get Good With Money: Ten Simple Steps To Becoming Financially Whole:
https://amzn.to/3I1UXc1
Source
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?
typo? train_data= data.iloc[:int(.99 * len(data)), :]
test_data= data.iloc[int(.99 * len(data)):,:] <———test data 1%
i also get a xgboost error. probably has something to do with the shape of the train and test data not matching
great tutorials 👍👍👍👍👍
should it be more reasonable to use the price the day before to predict the price next day in train and testing?
Very interesting! But, how could it be used in algotrading?
Hey, nice, can you do a tutorial for optimal execution on python using almgren kriss?
thanks bro
where to get dataset for this
Can see you are a programmer but not a data scientist
I followed you step by step, but my historical chart is a downtrend for some reason.
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?
Hope you had tutorial for deployment of this and for real time price to predit.
Where or how did you produce the input file for historical data? Where can it be obtained?
How do I, predict more, like not only the test set for example 3 years forward
i keep getting an error at the "model.score" it says model is not defined
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
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.
How do I get it to predict more
etni jhak marane ke bad prediction acuuracy only 70 %….11:30..!!!
Overfitting bruh
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
actually thats almost useless prediction coz we know volume when only when close is known
Stopped this video when he included 99% of the data in the train_data. Makes no sense
Pregunta que le hago a todos, para que te sirve esto xD. Para nada, no te da ninguna info
#Import the libraries
import pandas as pd
import xgboost as xgb
import matplotlib.pyplot as plt
#load the data
data= pd.read_csv('all_stocks_5yr.csv')
data
#show th data
data['close'].plot()
#split the data in to training and testing data sets
train_data= data.iloc[:int(.99*len(data)),:]
test_data= data.iloc[:int(.99*len(data)):,:]
#Define the features and target variable
features=['open','volume']
target='close'
#create and train the model
model= xgb.XGBRegressor()
model.fit(train_data[features],train_data[target])
#makeand show the predictions on the test data
predictions= model.predict(test_data[features])
print('Model predictions:')
print(predictions)
#Show the actual valurs
print('Actual values:')
print(test_data[target])
#Show the model's accuracy
accuracy=model.score(test_data[features],test_data[target])
print('Accuracy')
print(accuracy)
#plot the predictions and the close price
plt.plot(data['close'],label='close price')
plt.plot(test_data[target].index,predictions,label='predictions')
plt.legend()
plt.show()
😄
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
way of Telling the program is brief . how can we get the csv files for example like yours SPY.csv
im new to ML, the final plot only show some orange line near the end, what does it mean and where are the rest?
I run the same test on 30 years of data from Yahoo Finance, the score was 96%. Also ran the same on 30 years of data of Nasdaq(NDX) and again the score was 97%. The prediction does not look bad.
Nice Video but not useful for real time prediction, volume information will not be available beforehand
found on tests with ticker 'SAP.DE' and other stocks
at 5 min, 1h , 1d interval
to get max accuracy in those intervals:
5 min: 99.55 % accuracy
1 h : 80.12 %
1 d : 94.46 %
————————————-
using notebook: type into cell: !pip install xgboost
helped me to import xgboost as xgb (py)
and
import yfinance as yf
data = yf.download(ticker, period='60d', interval='5m')
It is totally useless wtf ??
Thx and god bless 😊
Can I get a sample data, 'SPY.csv'?
shame there's no code (just pitching for sign-up), I'll just type it in:)
Merci (:
What is that csv file and how do i get it
7