Skip to main content

FIFO-based IRS Form 8949 capital gains calculator for assets.

Project description

IRS asset FIFO calculator

Documentation Status

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

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:

  1. Groups related rows by Tx Index into logical “blocks” (one trade).
  2. Parses each block into:
    • Buy side (what you acquired)
    • Sell side (what you disposed of)
    • Fees (possibly in one or more assets)
  3. Maintains a FIFO ledger of “lots” for each asset (amount, price, cost basis, date).
  4. For each sale, consumes the oldest lots first to compute:
    • Cost basis
    • Proceeds
    • Gain or loss
  5. 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

  1. Put your transactions in asset_tx.csv with the header: Date, Tx Index, Asset, Amount (asset), Sell price ($), Buy price ($), Type, ...
  2. Run from CLI:
   cd src
   python -m irs_asset_fifo_calculator.calculate_taxes

Technologies

IRS asset FIFO calculator uses the following technologies and tools:

  • Python
  • Sphinx

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:

  1. Fork IRS asset FIFO calculator from https://github.com/elliottbache/irs_asset_fifo_calculator/fork
  2. Create your feature branch (git checkout -b feature-new)
  3. Make your changes
  4. Commit your changes (git commit -am 'Add some new feature')
  5. Push to the branch (git push origin feature-new)
  6. Create a new pull request

Contributors

Here's the list of people who have contributed to IRS asset FIFO calculator:

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

Change log

  • 0.1.0
    • First public FIFO release

License

IRS asset FIFO calculator is distributed under the 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

irs_asset_fifo_calculator-0.1.0.tar.gz (61.1 kB view details)

Uploaded Source

Built Distribution

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

irs_asset_fifo_calculator-0.1.0-py3-none-any.whl (39.4 kB view details)

Uploaded Python 3

File details

Details for the file irs_asset_fifo_calculator-0.1.0.tar.gz.

File metadata

File hashes

Hashes for irs_asset_fifo_calculator-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0d8fd9e178de4d2f72195f95949613fea49354d6e72201b9241ffb93bf1efef8
MD5 51c071d0e92d24d6eb4bfd9476eb5069
BLAKE2b-256 0df43361c78873dd4a6e08ed49396fdecb8a767f7e66e0778aeefa0a0cd0a326

See more details on using hashes here.

File details

Details for the file irs_asset_fifo_calculator-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for irs_asset_fifo_calculator-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7daf6b199f16f09e10c22483771f48b3dceebbe1b98008a5f49737ef5aa94454
MD5 0b38cfdbafb1f37dd97b733733f29dd4
BLAKE2b-256 f7d8465628ea3a670024c4b8b603b183fb47d411af49c9c976ab504dbd417db3

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