A cost-basis adjustment updates a tax lot’s recorded purchase price when a wash sale occurs. Rather than leaving the loss solely on the closed lot, the workflow marks washed lots and adds their basis to the replacement shares, preserving the tax-relevant history in the lot data. section 14.2.2
Replacing washed VTI shares
Two VTI lots are sold at losses, then 12 VTI shares are bought at $90. The new lot is recorded with a purchase price of $114.166667 because basis from washed shares is added. A three-share remainder from one prior lot remains separate and is not marked as a wash sale. section 14.2.2
An automatable lot-update workflow:
- Create new tax lots from buy trades with ticker, price, quantity, date, and wash-sale fields. section 14.2.2
- Identify blocking lots, limit washed shares to the replacement quantity, and process blocking lots in purchase-date order. section 14.2.2
- Split lots when only part is affected, flag closed washed lots, and retain leftover shares as distinct lots. section 14.2.2
- For sales, first close unblocked lots, then calculate remaining quantities and update lots involved in wash sales. section 14.2.2
import datetime as dt
import numpy as np
import pandas as pd
lots = \
pd.DataFrame({'ticker': ['VTI', 'VTI', 'VTI'],
'purchase_price': [90, 85, 105],
'quantity': [25, 30, 20],
'purchase_date': ['2021-02-10', '2021-07-21',
'2022-03-15'],
'sell_price': [75, np.NaN, np.NaN],
'sell_date': ['2022-04-01', np.NaN, np.NaN],
})
A minimal pandas tax-lot table supplies the ticker, purchase and sale data needed to calculate and store adjustments. section 14.2.2
