FIFO-based IRS Form 8949 capital gains calculator for assets.
Project description
IRS asset FIFO calculator
Tax calculator that tracks capital gains from multiple purchases and sales. This program uses a CSV file as input.
This file is called "asset_tx.csv" in the published example, but any name can be be used, using this name in the python call. The file has the following header: "Date", "Asset", "Amount (asset)", "Sell price ($)", "Buy price ($)", "Account number", "Entity", "Notes", "Remaining"
Table of Contents
- What this project does
- FIFO in one paragraph
- Installation
- Quick start
- Technologies
- Development
- Contributing
- Contributors
- Author
- Change log
- License
What this project does
This repository implements a small Python tool to calculate IRS-style capital gains using the FIFO (First In, First Out) method and produce Form 8949–style output.
Given a CSV of asset transactions (buys, sells, exchanges, transfers), the library:
- Groups related rows by
Tx Indexinto logical “blocks” (one trade). - Parses each block into:
- Buy side (what you acquired)
- Sell side (what you disposed of)
- Fees (possibly in one or more assets)
- Maintains a FIFO ledger of “lots” for each asset (amount, price, cost basis, date).
- For each sale, consumes the oldest lots first to compute:
- Cost basis
- Proceeds
- Gain or loss
- Writes the result as rows suitable for Form 8949.
FIFO in one paragraph
Under FIFO, the earliest purchased units are considered sold first. If you bought 10 NVDA on January 1 and 5 NVDA on February 1, then sell 12 NVDA on March 1, the sale is treated as:
- 10 units from the January lot, and
- 2 units from the February lot.
Each slice gets a proportional share of the total proceeds, and its own cost basis and gain/loss. This tool automates that book-keeping and emits one Form 8949 row per “slice”.
For a more detailed explanation (with tables and numeric examples),
see docs/fifo_overview.md.
Installation
No installation is required.
Quick start
- Put your transactions in
asset_tx.csvwith the header:Date, Tx Index, Asset, Amount (asset), Sell price ($), Buy price ($), Type, ... - Run from CLI:
cd src
python -m irs_asset_fifo_calculator.calculate_taxes
Technologies
IRS asset FIFO calculator uses the following technologies and tools:
Development
Building the docs
In order to create Sphinx documentation from the docstrings in PyCharm, a new run task must be created: Run > Edit Configurations... > + (top-left) > Sphinx task. In the window that opens, name the Sphinx task in the "Name" field, select "html" under the "Command:" dropdown, select the docs folder in the root folder in the "Input:" field, and select the docs/_build folder in the "Output:" field. If the docs or docs/_build folder do not already exist, they will perhaps need to be created. The Sphinx documentation can now be created by going to Run > Run... and selecting the Sphinx task name.
Contributing
To contribute to the development of IRS asset FIFO calculator, follow the steps below:
- Fork IRS asset FIFO calculator from https://github.com/elliottbache/irs_asset_fifo_calculator/fork
- Create your feature branch (
git checkout -b feature-new) - Make your changes
- Commit your changes (
git commit -am 'Add some new feature') - Push to the branch (
git push origin feature-new) - Create a new pull request
Contributors
Here's the list of people who have contributed to IRS asset FIFO calculator:
- Elliott Bache – elliottbache@gmail.com
The IRS asset FIFO calculator development team really appreciates and thanks the time and effort that all these fellows have put into the project's growth and improvement.
Author
- Elliott Bache – elliottbache@gmail.com
Change log
- 0.1.0
- First public FIFO release
License
IRS asset FIFO calculator is distributed under the MIT license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file irs_asset_fifo_calculator-0.1.0.tar.gz.
File metadata
- Download URL: irs_asset_fifo_calculator-0.1.0.tar.gz
- Upload date:
- Size: 61.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0d8fd9e178de4d2f72195f95949613fea49354d6e72201b9241ffb93bf1efef8
|
|
| MD5 |
51c071d0e92d24d6eb4bfd9476eb5069
|
|
| BLAKE2b-256 |
0df43361c78873dd4a6e08ed49396fdecb8a767f7e66e0778aeefa0a0cd0a326
|
File details
Details for the file irs_asset_fifo_calculator-0.1.0-py3-none-any.whl.
File metadata
- Download URL: irs_asset_fifo_calculator-0.1.0-py3-none-any.whl
- Upload date:
- Size: 39.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7daf6b199f16f09e10c22483771f48b3dceebbe1b98008a5f49737ef5aa94454
|
|
| MD5 |
0b38cfdbafb1f37dd97b733733f29dd4
|
|
| BLAKE2b-256 |
f7d8465628ea3a670024c4b8b603b183fb47d411af49c9c976ab504dbd417db3
|