Type the shares you sold at a loss, what a share cost you, the price you sold at, and then each lot you bought back with its date. This wash sale cost basis calculator takes the loss the sale produced, works out how much of it is disallowed by the repurchase, adds that money onto what the replacement shares cost, and prints each lot on its own line: what it was bought for, how much loss landed on it, its new cost basis, and its new cost a share. The part of the sale that no repurchase covers is printed on a line of its own as the loss you can still claim. The dates are optional, and the 61-day window is worked out from the two you typed, so a lot outside the window keeps the cost it was bought at and has nothing added to it. No account, no broker connection, no tax table: every figure is typed by you, and every figure is cut off downwards, never rounded up.
The loss comes first, and the basis follows from it. A share cost you one figure and sold for another, and the gap between them is the loss a share. Times the shares sold, that is the loss on the sale. Then the repurchases take a share of it: each lot bought inside the window carries away as much of that loss as it has shares to carry, and the money it carries goes straight onto what the lot cost. What is left of the loss at the end, the part no repurchase had shares to carry, is still yours to claim.
Loss a share = cost a share minus sale price a share
Loss on the sale = loss a share × shares sold
Loss disallowed on a lot = loss a share × shares in that lot that were matched
New cost basis of that lot = what the matched shares cost + the loss disallowed on it
New cost a share = new cost basis of that lot / shares matched in it
Loss you can still claim = loss a share × shares sold that no repurchase matched
Here it is with an example, and every line below is printed under the result with your own figures in it: 100 shares that cost 50.00 a share, sold at 40.00, and bought back in two lots, 60 shares at 42.00 and then 20 shares at 45.00, both inside the window.
Shares sold = 100
Cost a share = 50.00
Sale price a share = 40.00
Loss a share = 50.00 minus 40.00 = 10.0000
Loss on the sale = 10.0000 × 100 = 1,000.00
Lot 1: 60 shares at 42.00, matched 60 of the 100 sold
bought for 60 × 42.00 = 2,520.00
loss disallowed on this lot = 10.0000 × 60 = 600.00
new cost basis of this lot = 2,520.00 + 600.00 = 3,120.00
new cost a share = 3,120.00 / 60 = 52.0000
Lot 2: 20 shares at 45.00, matched 20 of the 40 still unmatched
bought for 20 × 45.00 = 900.00
loss disallowed on this lot = 10.0000 × 20 = 200.00
new cost basis of this lot = 900.00 + 200.00 = 1,100.00
new cost a share = 1,100.00 / 20 = 55.0000
Shares sold that were matched by a repurchase = 80
Loss disallowed across every lot = 600.00 + 200.00 = 800.00
Cost basis of the replacement shares = 3,120.00 + 1,100.00 = 4,220.00
Cost a share across every replacement lot = 4,220.00 / 80 = 52.7500
Shares sold with no repurchase behind them = 20
Loss you can still claim = 10.0000 × 20 = 200.00
Check: 800.00 disallowed + 200.00 still claimable = 1,000.00, against a loss on the sale of 1,000.00
So the two lots cost 4,220.00 between them after 800.00 of the loss was pushed onto them, which is 52.7500 a share across the 80 shares they bought. The remaining 20 shares of the sale were never bought back, so their 200.00 of loss was never disallowed and stands on its own line. And the last line is the one worth reading every time: the disallowed part and the claimable part have to add back to the loss the sale produced. When they do not, the shares being matched are not the shares that were sold.
Top: the window runs 30 days either side of the sale, which is 61 days counting the sale day itself. A purchase outside the span is an ordinary purchase and carries no disallowed loss. Bottom: the disallowed loss is added to the money the replacement shares cost, so the new cost a share sits above the repurchase price.
A repurchase only replaces shares if it happens close enough to the sale, and close enough means this: 30 days before the sale, the day of the sale, and 30 days after, which is 61 days counting the sale day itself. A purchase on day 31 either side is an ordinary purchase. It carries none of the loss, and it costs exactly what it cost.
Two boxes hold that judgment here, the date of the sale and the date on each lot, and both are optional. Fill both in and the page works the window out from them and drops the lots that fall outside it. Leave either one empty and the page does not guess: it counts the lots as inside the window and says so in the line under the result, because a page that invented a date would be quietly deciding the whole question for you. If you are checking a lot you believe sits outside the window, put both dates in, that is the only way this page can confirm it rather than assume it.
A full repurchase is the easy case: the same number of shares came back, so the whole loss moves onto them. Almost nothing in a real account looks like that, and the part that trips people up is the lot that buys back fewer shares than were sold. The loss is not all disallowed and it is not all kept, it is split in proportion, by shares: a lot that replaces 60 of 100 shares carries 60 of the 100 shares worth of loss, and the other 40 shares worth stays claimable.
This page prints that split lot by lot rather than blending it into one figure, and there are three reasons that matters. The first is that each lot gets its own cost a share. In the example above the two lots came back at 52.0000 and 55.0000, because the loss added to each is the same 10.0000 a share while the prices they were bought at are not, and a blended 52.7500 is not the figure either lot carries. The second is that the lots stop being interchangeable from here: if one of them is sold next, its cost is the cost printed on its line, not the average across the position. The third is the edge that catches people out at the end of a year, a lot that buys back more shares than were sold. The shares past the match have no loss to carry, so they cost what they cost, and the page prints them without anything added.
The other half of the same idea is the line most calculators leave out entirely. Whatever the repurchases did not cover is not disallowed, and it reads as its own figure: 200.00 in the example above, from the 20 shares that were sold and never bought back. That number and the disallowed number add back to the loss the sale produced, and the page prints that check so you can see the two halves reconcile before you carry either of them anywhere.
One line, and it is the rule everywhere on this site: nothing here is ever rounded up. A cost a share is shown to four decimals, every money figure to two, and each is cut off at that point rather than brought to the nearest. The basis on the screen is therefore never higher than the arithmetic behind it, and the loss disallowed is never larger than the loss the sale produced.
Each line of the working is worked out from the line above it exactly as that line is printed, so checking the sum with the figures on screen lands on the printed answer. That is also why the loss is worked out a share first and only then multiplied out: the same loss a share drives the disallowed part and the claimable part, so the two of them always add back to the loss on the sale.
The arithmetic here is one rule, and the judgment around it is not on this page. It does not know and does not claim to know:
None of that is tax advice, and none of it is a substitute for it. Whether a rule applies to your trade, in your accounts, in your year, is a question for your own circumstances or for someone who knows them.
One loss sale and the lots bought back are the whole input. These things are outside it, with no box to put them in:
Put the shares sold in A1, the cost a share in A2, the sale price a share in A3, the shares in the repurchase lot in A4 and the price a share of that lot in A5. As four formulas, typed into any empty cells:
Loss a share = =A2-A3
Loss disallowed on this lot = =(A2-A3)*MIN(A4,A1)
New cost basis of this lot = =A4*A5+(A2-A3)*MIN(A4,A1)
Loss you can still claim = =(A2-A3)*MAX(A1-A4,0)
The new cost a share is the third of those divided by A4. One difference is worth knowing about: a spreadsheet rounds when it displays a number but keeps the full value underneath, while this page cuts every figure down at the point shown. On the same inputs the last decimal can differ, and when it does, this page is the one that matches the working printed above it.
A wash sale is one thing that moves a basis after the shares were bought, and the others sit beside it. If the shares were bought at more than one price and you want the starting figure before any adjustment, the cost basis calculator pools them into one cost per share. If a split changed the share count and the price, the stock split calculator works out the new count and the new price from a ratio. If the shares were sold rather than replaced, the capital gains tax calculator works out the gain, the tax on it at a rate you type, and the after-tax net. And if the same shares were bought again at a lower price without a sale in between, the average down calculator handles that, which is a different sum from this one and not a substitute for it.
The disallowed loss is added to what the replacement shares cost, and nothing else moves. Take the loss a share on the sale, multiply it by the shares that the repurchase replaced, and add that money to the purchase price of those shares. In the example above, a 10.0000 loss a share on 60 shares is 600.00, and it goes onto 2,520.00 of repurchase cost to give a new basis of 3,120.00, or 52.0000 a share. The shares that were sold and never replaced get nothing added, because there is nothing there for the loss to attach to, and their loss stays claimable.
This page cannot work without it, and it will not invent one: the cost a share is what the whole loss is measured against, so a wrong figure there makes every figure below it wrong. The places it usually comes from are the trade confirmations, the broker's tax documents for the year of the sale, and the lots page of the account itself. Reinvested dividends are the common gap, because each reinvestment is its own purchase at its own price. If a figure cannot be found, the honest move is to carry the position at a cost you can document and say what is missing, rather than to fill the box with a number nobody can stand behind.
One where the repurchase replaced some of the shares sold but not all of them. The loss splits by shares rather than moving as a whole: a lot that replaces 60 of 100 shares carries 60 hundredths of the loss, and the other 40 hundredths stays claimable for that year. The two halves are printed on separate lines here, and they add back to the loss the sale produced. The other half of the phrase is a repurchase that bought more than was sold, where the shares past the match carry no loss at all and cost what they cost.
No, and this page will not run on one. The rule is about a loss being claimed, so a sale at a profit has nothing to disallow and nothing to add to a basis. If the sale price you typed is at or above what the shares cost, the page says so instead of producing a figure. What makes this confusing in practice is that a loss on one lot and a gain on another can happen in the same sale, so the page has to be run on the loss lot alone, with that lot's own shares and its own cost.
Thirty days after the sale, counting from the day after it, and the same stretch before it matters just as much. The window is 30 days before the sale, the sale day, and 30 days after, which is 61 days in total, and a purchase on day 31 on either side sits outside it. Waiting only the 30 days after is not enough on its own if there was a purchase in the 30 days before, which is the case people miss. Fill in both dates on this page and the lots outside the window are dropped from the sum rather than assumed in or out.
Just the replacement shares, and only to the shares in them that were matched. This is the mistake that quietly inflates a basis: the loss attaches to the shares that replaced the ones sold, not to every share of the holding you already had. A lot that bought 60 shares gets the loss on 60 shares, and the 40 shares of the position that were never sold keep the cost they already had. That is also why this page prints each lot on its own line instead of one blended figure, because a blended figure across the whole position is not a basis of anything.
No, the replacement shares pick up the holding period of the shares they replaced. The period is not asked for and not printed on this page, because it is a fact about your own records rather than a figure this arithmetic produces. What the page can tell you is which shares were matched, and therefore which shares the old period travels to, which is the part that is usually hard to reconstruct later.
They can, and it is one of the easiest ways to trip the rule without meaning to, because a dividend reinvestment plan buys shares on a fixed date whether or not anyone decided to buy that day. If a reinvestment inside the window bought substantially identical shares, it is a lot like any other here: put its shares, its price and its date on a row and it is matched alongside the rest. Whether the shares it bought are substantially identical is the judgment this page leaves to you.
This page is a calculator, not tax advice. It holds no rule about what counts as substantially identical, no lot identification method and no holding period: those are yours, and the dates and lots you type are the only things the window is worked out from. There are no live prices and no broker connection. Contact: contact@stockavg.com