Skip to content
US Tariff Policy and Impact on Stock Market
Report Purpose
The goal of this report is to serve as a personal investment tool for evaluating potential stock purchases. Specifically, it aims to track the performance of investments following Trump's Canadian tariff announcements.
SPY is the SP500 benchmark etf.
Key Objectives:
- Monitor Market Reactions โ Assess how stocks respond to the tariff announcements.
 - Evaluate Investment Performance โ Track price trends of selected stocks over time.
 - Identify Opportunities โ Determine whether certain stocks present buying or selling opportunities post-announcement.
 - Compare Multiple Investments โ Analyze different stocks side by side to see which are most affected.
 
How to Use
Simply modify the stock ticker symbols below and run the script. Up to three stocks can be tracked.
Stock Selection
import yfinance as yf
import datetime
import pandas as pd
import matplotlib.pyplot as plt# Declare variables
stock1 = "SPY" ## This is the S&P Benchmark
stock2 = "AAPL"
stock3 = "TSLA"
start_date = '2024-01-01'
end_date = datetime.datetime.now()Set-up Environment
Installing the packages we require for our review.
pip install yfinanceExtract Data
Using market data from Yahoo! Finance's API. Closing prices are updated each day.
# Get data stock1
ticker_symbol = stock1
end_date = datetime.datetime.now()
start_date = end_date - datetime.timedelta(days=365)
stock_data1 =yf.download(ticker_symbol, start=start_date, end=end_date)
print(stock_data1)# Get data stock2
ticker_symbol = stock2
end_date = datetime.datetime.now()
start_date = end_date - datetime.timedelta(days=365)
stock_data2 =yf.download(ticker_symbol, start=start_date, end=end_date)# Get data stock3
ticker_symbol = stock3
end_date = datetime.datetime.now()
start_date = end_date - datetime.timedelta(days=365)
stock_data3 =yf.download(ticker_symbol, start=start_date, end=end_date)Plot Closing Price Results
import matplotlib.pyplot as plt
import matplotlib.colors as mcolors
import pandas as pd
# Get tab10 color palette
colors = mcolors.TABLEAU_COLORS
# Create plot with increased width
fig, ax = plt.subplots(figsize=(12, 6))  # Increased width to 12 inches
# Plot each stock
ax.plot(stock_data1.index, stock_data1['Close'], linewidth=2, color=list(colors.values())[0],  label=stock1)
ax.plot(stock_data2.index, stock_data2['Close'], linewidth=2, color=list(colors.values())[1],  label=stock2)
ax.plot(stock_data3.index, stock_data3['Close'], linewidth=2, color=list(colors.values())[2],  label=stock3)
# Add vertical lines for significant events
ax.axvline(x=pd.to_datetime('2024-11-04'), color='#9467bd', linestyle='-', linewidth=2, alpha=0.5, label='US Election Day')
ax.axvline(x=pd.to_datetime('2025-02-01'), color='#D62728', linestyle='--', linewidth=2, alpha=0.5, label='All CAD Imports 25%')
#ax.axvline(x=pd.to_datetime('2025-02-10'), color='#D62728', linestyle=':', linewidth=2, alpha=1, label='CAD Steel and Aluminum 25%')
ax.axvline(x=pd.to_datetime('2025-04-02'), color='#D62728', linestyle='-', linewidth=2, alpha=0.5, label='Liberation Day')
# Update layout
title = 'Stock Close Prices During Trump Administration'
subtitle = 'With Significant Events Marked'
ax.set_title(f'{title}\n{subtitle}', loc='left', color='white', fontsize=12)
ax.set_ylabel('Close Price', color='white')
ax.yaxis.tick_left()
ax.yaxis.set_label_position("left")
# Remove all ticks on the y and x
ax.tick_params(axis='both', which='both', length=0, colors='white')
# Update grid and axis lines
ax.grid(True, color='#3A3F4A', linestyle='dashed', linewidth=0.5, alpha=0.5)
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.spines['left'].set_visible(False)
ax.spines['bottom'].set_visible(False)
# Add legend
legend = ax.legend(loc='center left', bbox_to_anchor=(1, 0.5), fontsize=10, title_fontsize=12, frameon=False)
for text in legend.get_texts():
    text.set_color('white')
# Set background color
fig.patch.set_facecolor('#1E1E2E')
ax.set_facecolor('#1E1E2E')
# Adjust layout for better spacing
plt.tight_layout()
# Show plot
plt.show()Stock Performance
key_dates = pd.to_datetime(["2024-11-04", "2025-02-10"])
most_recent_date = stock_data1.index.max()
all_dates = key_dates.tolist() + [most_recent_date]
closing_prices = pd.DataFrame(index=pd.to_datetime(all_dates))
closing_prices[stock1] = stock_data1['Close'].loc[stock_data1.index.intersection(closing_prices.index)]
closing_prices[stock2] = stock_data2['Close'].loc[stock_data2.index.intersection(closing_prices.index)]
closing_prices[stock3] = stock_data3['Close'].loc[stock_data3.index.intersection(closing_prices.index)]
closing_prices.index = closing_prices.index.strftime("%Y-%m-%d")
earliest = closing_prices.iloc[0]
latest = closing_prices.iloc[-1]
difference = latest - earliestโ
โ
โ
โ
โ