https://github.com/manymeeting/stockprofitcalculator
This repository comprises python utilities such as command line style stock profit calculator and real-time stock price fetcher.
https://github.com/manymeeting/stockprofitcalculator
financial realtime stock-data stock-prices
Last synced: 7 months ago
JSON representation
This repository comprises python utilities such as command line style stock profit calculator and real-time stock price fetcher.
- Host: GitHub
- URL: https://github.com/manymeeting/stockprofitcalculator
- Owner: manymeeting
- Created: 2017-10-31T02:01:02.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-11-04T06:09:24.000Z (almost 8 years ago)
- Last Synced: 2025-01-28T20:29:57.218Z (9 months ago)
- Topics: financial, realtime, stock-data, stock-prices
- Language: Python
- Homepage:
- Size: 129 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Financial Tools in Python
This repository comprises python utilities such as command line style stock profit calculator and real-time stock price fetcher.
## Stock Profit Calculator
Run the program:
python ./command_utilities/cmdCalculator.py
The calculator is a cmd-like program that will take the following inputs:
- A stock symbol
- Allotment (number of shares)
- Final share price (in dollars)
- Sell commission (in dollars)
- Inital share price (in dollars)
- Buy commission (in dollars)
- Captial gain tax rate (in %)
then output the following items after computation:
- Proceeds (Allotment x Final share price)
- Cost (Allotment x Initial Share Price + commissions + Tax on Capital Gain)
- Net Profit (in dollars)
- Return on investment (in %)
- Break even price (in dollars)
Screenshot of input and output:


## Real-time Stock Price Fetcher
Before June 2017, Most of the real-time stock price fetching tools depends on Yahoo Finance API, which has been abandoned by its owner in the middle of 2017. In order to get the real-time stock price, I analyzed Google Finance web pages and discovered a relatively stable and simple way to fetch all the necessary values from HTML meta data.
Of course the page view may change in the future, though, I believe this program method will probably work fine as long as Google keeps their meta tags. For example:
We can get values like price, priceChange, and priceChangePercent directly from the attributes in meta tags.
Run the program:
python ./command_utilities/financialInfo.py
This program will take a stock symbol as input and output the following:
- Current date and time
- Full name of the company
- Stock price
- Value changes (+ for increase and - for decrease)
- Percentage changes (+ for increase and - for decrease)
A typical use case looks like:
Input:
Please enter a symbol ('exit' to quit) :
ADBE
Output:
Sat Nov 4 03:42:50 2017
Adobe Systems Incorporated (ADBE)
182.30 +1.36 (0.75)
Screenshot of input and output:

-------------------------------------------------------------------------------
Copyright (C) 2017 Mutian Wang, licensed under the [MIT License](http://www.opensource.org/licenses/mit-license.php)