This will compare the price action of 2 tickers and export a image file in the form of a graph. Stock Price Comparison Tool This Python script allows you to compare the historical stock prices of two different companies and visualize the comparison using line charts. You can specify the stock symbols, the time period, and whether you want to compare daily or weekly prices.
Prerequisites Python 3.x yfinance library for fetching historical stock data. Install it using pip install yfinance. matplotlib library for creating line charts. Install it using pip install matplotlib.
Here's an example of how to use the script:
Enter the first stock symbol: AAPL Enter the second stock symbol: MSFT Enter the start date (YYYY-MM-DD): 2020-01-01 Enter the end date (YYYY-MM-DD): 2022-12-31 Choose interval (daily/weekly): daily Two line charts comparing the daily closing prices of AAPL and MSFT between January 1, 2020, and December 31, 2022, will be generated and saved as image files.