Skip to main content

Capital gains calculator

Project description

capital-gains

Capital gains calculator.

This transforms transaction histories into a format suitable for IRS form 8949, taking care of wash sale adjustments.

Note: The logic is ignorant of share type, and cannot account for e.g. bargain elements for ESPP, ISO, and NSO. You must enter the appropriate cost basis depending on your situation, e.g. the fair market value on exercise date for ESPP disqualifying dispositions.

See also nkouevda/estimated-taxes.

Installation

pip install capital-gains

Or:

brew install nkouevda/nkouevda/capital-gains

Usage

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

Capital gains calculator

options:
  -h, --help            show this help message and exit
  -d, --decimal-places <n>
                        round $ to <n> decimal places (default: 0)
  -s, --shares-decimal-places <n>
                        round shares to <n> decimal places (default: 0)
  -t, --totals          output totals (default: False)
  -v, --verbose         verbose output (default: False)
  -V, --version         show program's version number and exit
  -w, --wash-sales, --no-wash-sales
                        identify wash sales and adjust cost basis (default: True)

Input Format

See input/example.csv.

Each entry has the following format:

date,symbol,name,shares,price,fee
  • date: YYYY-MM-DD format
  • name: optional (can be blank)
  • shares: purchases have positive shares; sales have negative shares
  • price: non-negative
  • fee: non-negative; optional (can be blank)

Entries must be in ascending date order, i.e. oldest first.

A sale without a name will sell all open lots FIFO; a sale with a name will only sell lots with the same name. Thus name can be used to specify orders other than FIFO.

Examples

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

TODO

  • STCG vs. LTCG

License

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.

Source Distribution

capital_gains-1.0.8.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

capital_gains-1.0.8-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file capital_gains-1.0.8.tar.gz.

File metadata

  • Download URL: capital_gains-1.0.8.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.13.5

File hashes

Hashes for capital_gains-1.0.8.tar.gz
Algorithm Hash digest
SHA256 75e787370a8a51338d31bd79f900dc92e7e15d0b10affa3abd3dad75d56b5f7a
MD5 1f36c738f20a92007757f978d6570222
BLAKE2b-256 b2398ef1a79d8521022360587f38c059b723e87176bebf58e1f5df28a20a17da

See more details on using hashes here.

File details

Details for the file capital_gains-1.0.8-py3-none-any.whl.

File metadata

  • Download URL: capital_gains-1.0.8-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.13.5

File hashes

Hashes for capital_gains-1.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 2f4bb860017e37ed9ce760f0a0122fbf5aaace4fa8fbe269de56484a6fd02538
MD5 cde9c335f654435f1e562285d6be19ca
BLAKE2b-256 9dc9e58fc2258198dabdf2a698f52f1d03e36a591d647ca1438575b820fbf796

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page