Stock market project in python with source code #mlwithakansha

Akansha Yadav shows how to analyze Apple stock in Python using yfinance to fetch data, pandas to calculate 50-day and 200-day moving averages, and matplotlib to plot them. The tutorial covers installing libraries, downloading historical prices, and visualizing the results with a customized line chart.
Chapters
Ladies and gentlemen, hello everyone, welcome back to my YouTube channel. In today's video, we are going to see how we can do stocks analysis using Python. So we are going to see multiple graphs, that how we can plot them using Python and how we can take the data of stocks into our Python notebook. So let's get started. So here I am back with my screen. So I have already written few code for us to save our time and to enhance the explanation of this video. So to work with that stock data analysis, what do we need is we need the Python library, which is yfinance library, matplotlib library, and the pandas library. So basically, to do the data manipulation, we need the library called pandas, and to get the data of stocks, we need the library called yfinance. So yfinance is also one of the app— one of the website through which we get the data of the stocks, like what was the price of the stock in 2022, or like that. And matplotlib is one of the library of Python which helps us to plot the graphs. So these three libraries may be majorly we will be using in our stock market analysis. So let's see how we have to work with this. So to install these libraries, you can directly use the command called pip install yfinance, matplotlib, and pandas. I have already installed it, that's why it's giving me the response that requirement already satisfied. If it is not installed, it will take some time to install all of these libraries for you. So let's see how we can get the Apple data into our Python notebook. So first is we need to import all three libraries. So first I have imported the yfinance library, then I have imported pandas library, and then the matplotlib Lib library. So what we have to do is we have to retrieve the data. So first is we need the data in our file. So for that, I have created a variable called stock_data, and in this I'm using yfinance.download function to download the data. First is you have to write down the symbol of that particular stock. So if I'm looking for the Apple stock, I have written the symbol for the Apple. If you are looking for the Google, you will write the symbol for the Google. Then you have to write down the start price, the starting date, and the ending date, and then it will give you the moving average of that particular stock. So I have written it. It's like an optional part. It's totally up to you what do you want to analyze. Price exactly. So using the rolling function, I have written windows is equal to 50, and then I want windows is equal to 200, and I am calculating the mean of these two close. There are multiple parameters like opening value, closing value, and last open, last day open, everything. So it will just take the close one and it will do the mean of that. And for plotting it, I am using the function of matplotlib, which is .figure function, .figsize 10, 5. Then I am plotting the close with the label, so it's close price. And then I am plotting the stock data, which is MA50, labeling it with the 50-day MA MA200, which is 200-day MA. So this is the graph plotted. I have taken the legends as well, and this show function is to display the graph. So here we have the graph. So here on the y-axis we have the prices, on the x-axis we have the dates, and in the mid you are able to see the graph, which is the line graph by default. So that's how you can get the data into your Python notebook, and you can do some basic visualization using the Matplotlib. So I would recommend you to try all these things, and in case if you have any questions, you can drop it in the comment section so that I can take your questions on there and come up with the next video. It's gonna be a complete series of these stocks analysis using Python and how to implement machine learning onto the stocks and how to predict the prices as well. So stay tuned.










