Skip to content

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
aapl = pd.read_csv("data/AAPL.csv")
print(aapl.shape)
aapl.head(100)

Data Dictionary

ColumnExplanation
DateDate of observation
OpenOpening price
HighHighest price during trading day
LowLowest price during trading day
CloseClose price
Adj CloseAdjusted close price adjusted for splits and dividend and/or capital gain distribution
VolumeNumber 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.

import pandas as pd
import matplotlib.pyplot as plt

# Read CSV files for each company
aapl = pd.read_csv("data/AAPL.csv")
amzn = pd.read_csv("data/AMZN.csv")
baba = pd.read_csv("data/BABA.csv")
crm = pd.read_csv("data/CRM.csv")
fb = pd.read_csv("data/FB.csv")
goog = pd.read_csv("data/GOOG.csv")
intc = pd.read_csv("data/INTC.csv")
msft = pd.read_csv("data/MSFT.csv")
nvda = pd.read_csv("data/NVDA.csv")
tsla = pd.read_csv("data/TSLA.csv")

# List of dataframes for each company
companies = [aapl, amzn, baba, crm, fb, goog, intc, msft, nvda, tsla]

# List of company names for reference
company_names = ['AAPL', 'AMZN', 'BABA', 'CRM', 'FB', 'GOOG', 'INTC', 'MSFT', 'NVDA', 'TSLA']

# Convert 'Date' column to datetime
for company in companies:
    company['Date'] = pd.to_datetime(company['Date'])

# Create a dictionary to store the highest closing price for each company
highest_closing_prices = {}

# Calculate the highest closing price for each company
for i, company in enumerate(companies):
    highest_closing_prices[company_names[i]] = company['Close'].max()

# Find the company with the highest closing price
max_closing_company = max(highest_closing_prices, key=highest_closing_prices.get)
max_closing_value = highest_closing_prices[max_closing_company]

# Plot the closing prices at the end of each month for each company
plt.figure(figsize=(14, 8))

for i, company in enumerate(companies):
    company.set_index('Date', inplace=True)
    monthly_closing = company['Close'].resample('M').last()
    plt.plot(monthly_closing.index, monthly_closing, label=company_names[i])

plt.xlabel('Date')
plt.ylabel('Closing Price')
plt.title('Monthly Closing Prices for Tech Companies')
plt.legend()
plt.xticks(rotation=45)
plt.show()

# Display the company with the highest closing price
max_closing_company, max_closing_value