Shares profit calculator

1. Info

Python script used to calculate stock/shares profit/loss.

It can be used to print profit (or loss) to terminal or send it via Gmail.

2. Demo

2.1. Example of stock/shares list

If "date_sell" is equal to "" the calculator scrapes current price of the stock using yahooquery.

[
    {
        "symbol": "AAPL",
        "company": "Apple Inc.",
        "numb_of_shares": 2.5,
        "currency": "USD",
        "price_buy": 125.49,
        "price_sell": 170,
        "date_buy": "2021/05/28",
        "date_sell": "2022/05/28",
        "commission_buy": 0,
        "commission_sell": 1.21,
        "cap_gain_tax": 27.5
    },
    {
        "symbol": "MSFT",
        "company": "Microsoft Corporation",
        "numb_of_shares": 2,
        "currency": "USD",
        "price_buy": 250.84,
        "price_sell": 0,
        "date_buy": "2021/05/28",
        "date_sell": "",
        "commission_buy": 1.21,
        "commission_sell": 1.21,
        "cap_gain_tax": 27.5
    }
]

2.2. Printing short profit information

example_short
Figure 1. Example short

2.3. Printing detailed profit information

example_detailed
Figure 2. Example detailed
2024/01