Skip to main content

Capital gains calculator

Project description


Capital gains calculator.


pip install capital-gains


usage: capital-gains [<options>] [--] <input file>

Capital gains calculator

optional arguments:
  -h, --help            show this help message and exit
  -d <n>, --decimal-places <n>
                        round $ to <n> decimal places; default: 0
  -s <n>, --shares-decimal-places <n>
                        round shares to <n> decimal places; default: 0
  -t, --totals          output totals
  -v, --version         show program's version number and exit

Input format

See example/input.csv.

Each entry has the following format:


Buys have positive shares; sells have negative shares. price and fee are always positive. fee and name are optional. A sell without a name will sell all open lots FIFO; a sell with a name will only sell lots with the same name. Thus name can be used to specify sell orders other than FIFO.

Output format

Closed lots are tabulated in a format suitable for form 8949, rounded to the nearest dollar (use -d 2 to round to the nearest cent).

Open lots, and optionally totals for both closed and open lots (use -t), are also summarized.


capital-gains -t example/input.csv > example/output.txt


MIT License

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
capital_gains-1.0.2-py2.py3-none-any.whl (6.1 kB) Copy SHA256 hash SHA256 Wheel py2.py3
capital-gains-1.0.2.tar.gz (4.6 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page