An open API service indexing awesome lists of open source software.

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.

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:

![Input of Stock Profit Calculator](./screenshots/cmdCalculator_in.png)

![Output of Stock Profit Calculator](./screenshots/cmdCalculator_out.png)

## 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:

![Input and output of Real-time Stock Price Fetcher](./screenshots/financialInfo.png)

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