Predicting Stock Prices with Python using Machine Learning - Linear Regression
HTML-код
- Опубликовано: 1 июн 2024
- In this video we are covering the simplest form of Machine Learning to predict stock prices (or rather returns) in Python using a Linear Regression.
Get the Notebook/Source code by becoming a Tier-2 Channel member:
/ algovibes
As said in the video you should not take this as a valid trading strategy. It is just an idea how a linear Regression can be used and how overfitting can be avoided or at least diminished using a train test split.
I am purposely NOT showing a time horizon where this is working or looking nicely to make you aware of that.
I am planning on covering other algorithms and extending the strategy. If you find that interesting please leave the video a like and subscribe :-)
Mentioned videos:
Logit regression:
• Logistic Regression in...
Multiple linear regression:
• Multiple Linear Regres...
The video series is inspired by the Hands-On Algorithmic Trading with Python course by Deepak Kanungo. Anyhow, the code and some approaches strongly deviate from his.
#Python #MachineLearning #Regression
Disclaimer: This video is not an investment advice and is for informational and educational purposes only.
0:00 - 01:04 Introduction
01:04 - 04:53 Data prep
04:53 - 06:15 Model building, fitting & prediction
06:15 - 08:24 Strategy, Performance and Visualization
08:24 - 14:40 Overfitting and avoiding with train test split
14:40 - 16:42 Number of trades
16:42 - 18:59 Playing around with different assets, lags (skippable)
Fantastic how easy this was to follow and get some practical display of how to use these tools.
Very happy to read man. Be kindly invited to check out my other stuff!
great video, have been going back through some of your old videos. question, how do you get the next day's prediction based on the train_test_split?
Thanks Man! Cool video as always! Could you possibly do a video on Reinforcement Learning in the future? I'd love to see your perspective and application on the that particular subject. Again thanks for your work! Amazing!
Interesting topic indeed, agreed! On my list but not quite sure when I will cover it.
Very good video. Thank you for sharing!
Welcome! Thanks a lot for watching :-)
Thanks! Very informative!
Thanks for watching! :-)
@@Algovibes could you do something similar with SVM? Thanks!
Another great video.
one comment (or request), I totally agree that price predication using ML is a very risky idea, however, direction predication is might be a good approach with ML, please try to go further deep in ML classification for price direction prediction, I hope you will explain in simple way how to predict future (or next day) price direction. Thanks a lot.
Thanks a lot for your feedback. Appreciate it!
Thanks for the nice video!
Thanks for watching mate
Hey nice video !
Maybe I'm wrong, but in 13:35 shouldn't we subtract -1 to account for the initial investment ?
Thanks mate!
Thanks for watching my friend!
More Machine Learning vidoes :D :D :D It was great!
Thx man i was searching everywhere for this I'm started learing python a month ago
Awesome! Thanks for watching :-)
Thank you!
Thank YOU for watching :-)
Is there an option to add a plot title with this command in your code: np.exp(df[["returns", "strategy_LR"]].cumsum()).plot(). I don't see matplotlib being imported explicitly where the title method is available. Thanks.😀
Yea sure, you can also just plot this with matplotlib and make your customizations then.
Hi Algovibes. I found this video useful for learning about linear regression and data frames. I am trying to recreate your code but am encountering an error on the model fitting. Key error: "None of [Index(['lag_1', 'lag_2', 'lag_3', 'lag_4', 'lag_5'], dtype='object')] are in the [columns]" I have copied your code 1:1 and can't figure out what is going wrong. Do you have any ideas? Thank you!
Hard to say where exactly the error is occurring but you definitely slightly deviated somewhere from my approach. Just go through it line by line again and it will be fine.
how Can I do to get the recommendation from strategy? like the signals to buy and sell?
If the direction is -1 you should sell and if the direction is 1 you should buy. Is that answering your question?
Edit: I am referring to the column direction_LR
thanks you!
Welcome buddy, thanks for watching :-)
what do we do in feature extraction?
can you please make a video on detecting breakouts like a stock price breaking their high low chain?
Cool idea! It is not on my list right now but I noted that. Thanks for the suggestion.
@@Algovibes sure i was going to add this feature to my bot anyhow so i thought it would be great to see someone else's approach :) and yea thanks for your reply and adding it on your your to-do list and if it will be based on indian stock market it will be great....
I think if we add more supply demand combine your breakouts strategy for more performance
@@nguyenduyta7136 yep that will be a great help in trading that's why I was thinking of making such algorithm that can direct that
thanks , please provide code
I wish i understood WTF you are doing with this coding stuff but i enjoy watching it... just watching thses makes me feel smarter EVEN THO idk wtf this code really does or what each part mean but hey.... its a view hahaha
lol :D
You are invited to check out my Python Introduction playlist :-) Also Python for Finance playlist could help you out.
please make video on machine learning on option chain
Not planned but noted. Thanks for your suggestion!
Can u make a full course
Maybe one day if I find some time!
But I will continue this series on some other ML Algorithms (mostly classifications probably).
how can we use this to predict future prices?
By letting the model run for the most recent prices. But as I said this is just a play around and will definitely not result in profitable results!
@@Algovibes of course i understand its just for educational purposes, thank you for this! So by letting it run for recent prices, we can add an end date variable for a time in the future when reading in the data?
@@Algovibes how would you recommend doing a forecast for 30 days? thank you!
Can you update your codes to predict price for next day as an example@@Algovibes
oh yessss tks u any thing beside bitcoin
thx for watching bud :-)
I see you fixed the variables to fit your beliefs about returns 😂. Once I am done with python than we can discuss this.
What? Where? :D
I see the content on this channel is heating up