Compare Stock Price History Using Python Script

 The idea of this python script is to compare the current stock price from a past date. When the stock market crash or gain significantly, this script become very useful.

For example, let’s say that the stock market is currently going down a lot and having market correction. And, the most recent all time high date is 12/27/2021. So, let’s pick this date and comparing it with today's price to see which stocks are going down a lot. By adding two the value metrics price per sales and price per book value to help you determine whether the price is undervalued or overvalued.

The script is written with python 3.x and usually yahoo_fin, prettytable modules. The output will show the gain or loss percentage. Additionally, it will also show two useful value metrics -- price per sales, price per book and also the upcoming earning release date.

Stock History Output Table


Prerequisite: python3

The following are the steps to how to download, install and run it.

1. Download stock.py and stock_list.txt from https://github.com/zayarsoe1/compare-stock-history

2. Then run “pip3 install yahoo_fin” and “pip3 install prettyable” in command line and all other dependencies required by those modules should be also installed automatically .

3. Open stock_list.txt and enter each stock symbols per line.

4. Open stock.py and look for past_date field and change it with your desired date.

5. Then, Save and run “python3 stock.py”

Comments

Popular Posts