/wash-sale-calculator

Calculator for wash sales for US taxes

Primary LanguagePythonBSD 2-Clause "Simplified" LicenseBSD-2-Clause

wash-sale-calculator

Calculator for wash sales for US taxes

Note that the author is not a CPA or tax expert. This program most certainly contains bugs.

To use, you'll need a CSV file with the initial state. I've provided a dummy one called dummy_example.csv.

To use the program from a terminal, run:

python wash.py -w dummy_example.csv -o out.csv

The csv file must have one buy or buy-sell trade per row. Each row has the following columns:

ColumnHeader Type Description
Cnt integer # of shares in this lot
Sym string stock symbol. Note that all symbols are considered substantially identical to each other, so if you trade in multiple stocks that aren't substantially identical, feed them into the calculator separately.
Desc string description provided on 1099b or statement. Unused by this program, but carried through for your records
BuyDate date (mm/dd/yyyy) Date lot purchased
Basis floating point number Acquisition price or basis. Value is typically share price on BuyDate * Cnt
SellDate date (mm/dd/yyyy) Optional. If sold, the date of sale
Proceeds floating point number Optional. If sold, proceeds. Value is typically share price on SellDate * Cnt - fees
AdjCode string Optional. Must be empty for the input. May be set to W if there's a wash sale. This would go into the IRS form 8949.
Adj floating point number Optional. Applies only if sold. Value is amount of loss disallowed. Input must have this set to 0. Output value may go onto IRS form 8949.
FormPosition string Optional but recommended. Useful for tracking this lot. When a lot is split, it will have '.1' or '.2' appended. Recommended is to enumerate all lines in your 1099b and use that number here. E.g., "Line 1" for the first lot on the 1099b.
BuyLot string Optional. Generally can be left blank. If two lots were acquired as part of the same buy order, put the same value here. This may occur if you bought a lot of stock, then sold off the lot in pieces (each piece would get a new line on the 1099b); if the broker automatically divided your buy order into pieces to execute; or if other factors caused the broker to split one buy lot into multiple lines on the 1099b. (This field is used because shares from a given buy lot can't replace shares from the same buy lot in a wash sale)
IsReplacement bool (True/False) Optional (left blank = False). This is set to true when the lot is used as a replacement in a wash sale. Since a lot may only be used as a replacement once, you can prevent a lot from absorbing a loss in wash sale computation by setting this to true.

If you commit changes to this software, make sure all tests are passing. To verify that all the tests pass:

python run_tests.py