QuantCalc Cost basis
All tools

Cost Basis Explained: Bought, Inherited (Step-Up) and Gifted Stock, With a Gain Calculator

Cost basis is the amount a sale is measured against: for shares you bought, what you paid including commissions, adjusted for reinvested dividends, splits and return-of-capital distributions. Inherited shares take their value at the date of death (the step-up); gifted shares keep the giver’s basis. Gain = sale price − basis (IRS Publication 551).

Basis by how you got the shares

Publication 551, Publication 550, IRC §1014, IRC §1015.
Acquired byBasisHolding period
PurchasePrice paid plus commissions and feesStarts the day after you bought
Dividend reinvestmentEach reinvestment: the amount reinvested (it was already taxed as a dividend)Each new share from the day after its purchase
InheritanceFair market value at the date of death (or alternate valuation date)Always long-term
Gift, value at least the giver’s basisThe giver’s adjusted basis (carryover)Includes the giver’s
Gift, value below the giver’s basisGiver’s basis for a gain; the value at the gift for a loss; in between, no gain or lossFor a loss, starts the day after the gift
RSU / restricted stock vestingThe value taxed as wages at vestingStarts at vesting

Which shares did you sell? FIFO, specific ID, average

If you bought the same stock at different times, you can pick the lots you sell by telling your broker at the time of the sale and getting written confirmation (specific identification). If you do not identify them, the shares you bought first are treated as sold first (FIFO). Shares of a mutual fund (or other regulated investment company) and DRIP shares left with a custodian may use the average basis method (Publication 550). Selling the highest-cost lots first (HIFO) is a specific identification choice.

Worthless securities

Stock that becomes completely worthless is treated as sold for $0 on the last day of the tax year (IRC §165(g)); report it on Form 8949.

Inherited vs gifted: the same shares, two bases

Shares the parent bought for $20,000, worth $100,000 at the transfer, sold for $105,000. Tax: 2026 federal, single filer aged 67 with $50,000 of IRA withdrawals, from the tax engine.
BasisLong-term gainFederal tax on it
Inherited at death (step-up)$100,000$5,000$0
Given during life (carryover)$20,000$85,000$10,182

Without the sale the retiree owes $2,857. The stepped-up sale brings taxable income to $30,850, where the gain sits in the 0% band; with the giver’s basis, taxable income is $114,450 and most of the gain is taxed at 15%.

An estimate from QuantCalc’s open tax engine (federal 2.6.0, state 1.26.0) for the 2026 tax year. Not tax advice: your return depends on facts this page does not ask about, so check a move with your tax preparer or custodian before acting. How the engine computes each line, with its official source: federal, state.

Cost basis and gain calculator

The tax is the change in your 2026 federal tax (the 0/15/20% or ordinary rates and the 3.8% NIIT) from adding this gain to the other income, with the standard deduction. Gift tax paid on a gift and losses beyond the $3,000 limit are not modelled.

Paid tool Selling inherited or gifted shares this year? The Tax Season Pass includes the Tax-Loss Harvesting tool — lot-by-lot basis, which lots to sell, wash-sale checks — and the 2026 Return Preview, your whole return line by line. Unlock with the Tax Season Pass — $39 this season → What the Tax Season Pass includes →

Deciding which account to draw from in retirement? QuantCalc runs withdrawals, capital gains and taxes year by year, free.

Run the free tax-aware simulation →

Common questions

What is cost basis in stocks?
What you paid for the shares, including commissions and fees, adjusted afterwards: up for reinvested dividends (each reinvestment buys new shares at its own cost), down for return-of-capital distributions and to spread it over the shares after a split. Your gain or loss is the sale price minus the basis (IRS Publication 551; Publication 550).
What is the cost basis of inherited stock?
Its fair market value on the date of death (or on the alternate valuation date if the estate elects it), not what the person who died paid: the “step-up” of IRC §1014. Shares bought for $20,000 and worth $100,000 at death have a $100,000 basis; sold for $105,000, the gain is $5,000, and it is long-term however briefly you held them (Publication 550).
What is the basis of shares received as a gift?
The giver’s basis carries over to you (IRC §1015), and so does their holding period. Exception: if the shares were worth less than the giver’s basis on the day of the gift, you use that lower value to figure a loss, and a sale price between the two values gives neither gain nor loss (Publication 551). The same $20,000 shares received as a gift and sold for $105,000 show a $85,000 gain.
How do I deduct worthless stock?
A security that becomes completely worthless during the year is treated as sold for zero on the last day of that year (IRC §165(g)), which decides whether the loss is short- or long-term; report it on Form 8949. Abandoning the security (giving up all rights for nothing) counts too (Publication 550).
How are ETFs taxed?
Like other fund shares: dividends are qualified or ordinary as the fund reports them on Form 1099-DIV, capital gain distributions are long-term however long you owned the shares, and selling shares is a capital gain or loss on your basis (Publication 550). Shares of a fund that is a regulated investment company may use the average basis method.

Sources