Tech Stock Prices
This dataset consists of the daily stock prices and volume of ten different tech companies: Apple (AAPL), Amazon (AMZN), Alibaba (BABA), Salesforce (CRM), Facebook (FB), Alphabet (GOOG), Intel (INTC), Microsoft (MSFT), Nvidia (NVDA), and Tesla (TSLA).
There are ten CSV files in the data/ folder named with the stock symbol for each of the ten companies listed above.
Looking for another company? You can download it from Yahoo Finance and upload it to your workspace.
Not sure where to begin? Scroll to the bottom to find challenges!
import pandas as pd
pd.read_csv("data/AAPL.csv")Data Dictionary
| Column | Explanation | 
|---|---|
| Date | Date of observation | 
| Open | Opening price | 
| High | Highest price during trading day | 
| Low | Lowest price during trading day | 
| Close | Close price | 
| Adj Close | Adjusted close price adjusted for splits and dividend and/or capital gain distribution | 
| Volume | Number of shares traded during trading day | 
Source of dataset.
Don't know where to start?
Challenges are brief tasks designed to help you practice specific skills:
- πΊοΈ Explore: Which of the ten companies has the highest closing price based on the most recent data?
- π Visualize: Create a plot that visualizes the closing price at the end of each month for the 10 tech stocks.
- π Analyze: Which of the ten companies have experienced the greatest percent increase in closing price over the course of their existence?
Scenarios are broader questions to help you develop an end-to-end project for your portfolio:
You have been hired as an analyst for a small investment firm. They currently specialize in commodities, focusing on coffee, cocoa, and sugar. However, they are now interested in expanding to technology companies. Your manager has asked you to explore the returns and volatilities of the ten stocks provided and contrast them with the three commodities they currently invest in.
They also want you to recommend how tech stocks could be integrated into a portfolio with the existing commodities they invest in to minimize risk while gaining exposure to the new market.
You will need to prepare a report that is accessible to a broad audience. It should outline your motivation, steps, findings, and conclusions.
Commodity prices can be found here.
- πΊοΈ Explore: Which of the ten companies has the highest closing price based on the most recent data?
# Importing and joing all companies together
companies = ['AAPL', 'AMZN', 'BABA', 'CRM', 'FB', 'GOOG', 'INTC', 'MSFT', 'NVDA', 'TSLA']
data = pd.DataFrame()
for i in companies:
    filename = 'data/' + i + '.csv'
    df = pd.read_csv(filename, parse_dates = ['Date'], index_col = 'Date').assign(stock_symbol = i)
    data = pd.concat([data, df], axis = 0)
# Inspecting the result
print(data.sample(5))
print(data.info())# When do the data begin and end for each company?
print(data.reset_index().groupby('stock_symbol')['Date'].agg([min,max]))# Which company has the highest close price for the most recent data?
print(data[data.index == '2021-11-29'].groupby('stock_symbol')['Close'].max().sort_values(ascending = False))- Amazon is the company with the highest close price in 2021-11-29. Intel has the lowest price.
- π Visualize: Create a plot that visualizes the closing price at the end of each month for the 10 tech stocks.
# Importing visualization package
import seaborn as sns
# Downsampling data to month frequency
month_data1 = data.groupby('stock_symbol').resample('M').last().droplevel(0)
month_data2 = data.groupby('stock_symbol').resample('M').mean().reset_index(0)
# Showing the price at the end of each month
print(month_data1.head(12))
print(month_data2.head(12))
# Ploting the closing price at the end of each month
sns.relplot(x = month_data1.index, y = 'Close', hue = 'stock_symbol', data = month_data1, kind = 'line')
sns.relplot(x = month_data2.index, y = 'Close', hue = 'stock_symbol', data = month_data2, kind = 'line')- π Analyze: Which of the ten companies have experienced the greatest percent increase in closing price over the course of their existence?
# Calculating one day return for each company
data['return'] = data.groupby('stock_symbol')['Close'].pct_change().fillna(0).mul(100)
print(data[['stock_symbol', 'Close', 'return']])grouped = data.groupby('stock_symbol')
grouped['all_time_return'] = (1 + grouped['return']).cumprod() - 1β
β