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-DDformatname: optional (can be blank)shares: purchases have positiveshares; sales have negativesharesprice: non-negativefee: 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
Metadata
Release files for capital-gains 1.0.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| capital_gains-1.0.8.tar.gz | 7.7 kB | Without provenance | Details for capital_gains-1.0.8.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| capital_gains-1.0.8-py3-none-any.whl | Python 3 | none | any | Details for capital_gains-1.0.8-py3-none-any.whl |
Total release size: 16.3 kB
Release files / capital_gains-1.0.8.tar.gz
| Download URL | capital_gains-1.0.8.tar.gz |
|---|---|
| Size | 7.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
75e787370a8a51338d31bd79f900dc92e7e15d0b10affa3abd3dad75d56b5f7a
|
|
BLAKE2b-256 checksum How to use checksums |
b2398ef1a79d8521022360587f38c059b723e87176bebf58e1f5df28a20a17da
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.13.5
|
Release files / capital_gains-1.0.8-py3-none-any.whl
| Download URL | capital_gains-1.0.8-py3-none-any.whl |
|---|---|
| Size | 8.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2f4bb860017e37ed9ce760f0a0122fbf5aaace4fa8fbe269de56484a6fd02538
|
|
BLAKE2b-256 checksum How to use checksums |
9dc9e58fc2258198dabdf2a698f52f1d03e36a591d647ca1438575b820fbf796
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.13.5
|
Security for capital-gains 1.0.8
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.