Stock Exchange Data
This dataset consists of stock exchange data since 1965 for several indexes. It contains the daily stock prices along with the volume traded each day.
Not sure where to begin? Scroll to the bottom to find challenges!
import pandas as pd
stock_data = pd.read_csv("stock_data.csv", index_col=None)
stock_data
Data Dictionary
Column | Explanation |
---|---|
Index | Ticker symbol for indexes |
Date | Data of observation |
Open | Opening price |
High | Highest price during trading day |
Low | Lowest price during trading day |
Close | Close price |
Adj Close | Close price adjusted for stock splits and dividends |
Volume | Number of shares traded during trading day |
CloseUSD | Close price in terms of USD |
Source of dataset.
Don't know where to start?
Challenges are brief tasks designed to help you practice specific skills:
- πΊοΈ Explore: Which index has produced the highest average annual return?
- π Visualize: Create a plot visualizing a 30 day moving average for an index of your choosing.
- π Analyze: Compare the volatilities of the indexes included in the dataset.
Scenarios are broader questions to help you develop an end-to-end project for your portfolio:
You are working for an investment firm that is looking to invest in index funds. They have provided you with a dataset containing the returns of 13 different indexes. Your manager has asked you to make short-term forecasts for several of the most promising indexes to help them decide which would be a good fund to include. Your analysis should also include a discussion of the associated risks and volatility of each fund you focus on.
You will need to prepare a report that is accessible to a broad audience. It should outline your motivation, steps, findings, and conclusions.
Before we start exploring and analysing our data, let's explain the concept of stock data and Why did we neet to analyses. Stock data refers to the historical and real-time information about a company's stock, incloude its price trading volume and other relevant metrics. Analyzing stock data is crucial for making informed investment decisions. Investors and traders analyze this data to identify trends, patterns and potential opportunities or risks in the market. Not analyzing stock data could lead to uninformed decisions, increasing the likelihood of financial losses
# Numbers of columns
stock_data.shape
# Check if the data is clean
stock_data.isna().sum()
# Data type
stock_data.dtypes
We can convert our object date to datatime once or or several times if we need it.
# import pandas
import pandas as pd
# import date
from datetime import datetime
# Convert date object to datetime
stock_data['Date'] = pd.to_datetime(stock_data['Date'])
# Verify the changes
stock_data.dtypes
Use Histogram graphic to show the distribution of Close price date
import matplotlib.pyplot as plt
# Plot histogram of the "Close" column in stock_data
plt.hist(stock_data["Close"], bins=20, color='skyblue')
# Add labels and title
plt.xlabel("Closing Price")
plt.ylabel("Frequency")
plt.title("Distribution of Stock Closing Prices")
# Show the plot
plt.show()
Calculate the highest price and lowest price during the trading day
To calculate highest orice we use 'High' column dot mex.
To calculate lowest price we use 'Low' column dot min
# Calculate the highest and lowest price during the trading day
highest_price = stock_data['High'].max()
lowest_price = stock_data['Low'].min()
print('Highhest Price =', highest_price, 'Lowest Price =', lowest_price)
β
β