How to calculate your cost basis — stocks, crypto, and the FIFO vs Specific ID decision
Cost basis is the number that determines how much tax you owe every time you sell an investment. Get it wrong and you either overpay the IRS. Or you create an audit risk. The method you choose — FIFO, Specific Identification, or Average Cost — can change your tax bill by thousands of dollars on the exact same trade. And for crypto specifically, the rules changed meaningfully in 2025 and continue evolving into 2026. Here's how it actually works.
What cost basis is
Cost basis is what you paid for an investment — the purchase price plus any commissions or fees. When you sell, your taxable gain or loss is simply: proceeds minus cost basis. Sell for more than your basis, you owe tax on the gain. Sell for less, you have a deductible loss (subject to wash sale rules, covered below).
The complexity arises when you've purchased the same investment multiple times at different prices — creating multiple "lots," each with its own basis. When you sell only part of your position, which lot's basis applies? That's where cost basis methods come in, and the method you choose can meaningfully change your tax outcome on the exact same sale.
The three cost basis methods
Assumes your oldest shares or coins are sold first. This is the default method for both stocks and crypto if you don't specify otherwise. In a rising market, FIFO tends to sell your lowest-basis (oldest, cheapest) lots first — which usually produces the largest taxable gain. The upside: those older lots are more likely to qualify for lower long-term capital gains rates if held over a year.
Lets you choose exactly which lot you're selling, giving you the most control over your tax outcome. To use it for stocks, you generally must identify the specific shares at or before the trade — brokers typically require this at execution rather than allowing it after the fact. For crypto, you must document the specific lot — including date, quantity, and cost — before or at the time of disposal; after-the-fact selection is not permitted. "HIFO" (highest-in, first-out) and "LIFO" (last-in, first-out) are not separate IRS methods — they're lot-selection strategies executed through Specific Identification.
Divides your total cost by total shares to get a single blended per-share basis. This method is permitted for mutual funds and certain broker-held DRIP shares — not universally across all DRIP setups — and is not available for individual stocks or, under current IRS crypto guidance, for digital assets. Simplest to calculate, but offers no control over which specific gains or losses are realized.
It's common to see HIFO and LIFO described as independent cost basis methods, but for tax compliance purposes that framing is inaccurate — for both stocks and crypto, they are lot-selection strategies applied within Specific Identification, not separate IRS-approved elections. Selecting "HIFO" in tax software does not, by itself, satisfy the documentation requirement. The underlying lot-level records — date, quantity, and cost of the specific lot — must support the selection, made contemporaneously, not reconstructed after the fact at filing time.
FIFO: simplest, no extra record-keeping, but often produces higher taxable gains in a rising market. Specific ID: best for tax control if you're willing to track and document lots carefully. Average cost: simplicity over optimization — only available for mutual funds and certain DRIP shares.
Worked example — stocks
You bought Apple stock in three lots over two years, and now want to sell 150 shares at $210/share:
| Method | Lots used | Cost basis (150 shares) | Taxable gain | Holding period |
|---|---|---|---|---|
| FIFO | All Lot 1 + 50 of Lot 2 | $24,000 | $7,500 | Long-term (Lot 1) |
| Specific ID (HIFO) | All Lot 3 + 50 of Lot 2 | $29,000 | $2,500 | Mixed — includes short-term (Lot 3) |
| Average cost* | Blended across all lots | $26,167 | $5,333 | N/A |
*Average cost is shown for illustration only — not available for individual stocks under current IRS rules.
HIFO produces $5,000 less taxable gain than FIFO on this exact same sale — but part of that gain (from Lot 3, purchased in March 2026) would be short-term, taxed at ordinary income rates rather than the lower long-term capital gains rate. Whether HIFO or FIFO produces the better after-tax outcome depends on your tax bracket and whether the short-term portion is offset by losses elsewhere. Method selection isn't just about minimizing the gain shown on paper — it's about controlling the character, timing, and amount of taxable income in the context of your full tax picture.
What changed for crypto in 2025–2026
Crypto cost basis rules underwent a significant structural change that every crypto investor needs to understand:
- Wallet-by-wallet tracking (effective January 1, 2025). Previously, many investors used a "universal wallet" approach — treating all holdings of the same crypto across every exchange and wallet as one combined pool, allowing cherry-picking of the most tax-efficient lots regardless of where assets actually sat. Current guidance effectively shifts this toward account-by-account tracking: each exchange account and each self-hosted wallet is treated as a separate ledger for cost basis purposes, with FIFO and Specific ID applied independently within each one.
- Form 1099-DA reporting (2026 transactions, reported in early 2027). Exchanges must now report both gross proceeds and adjusted cost basis for "covered" digital assets — those acquired and sold on the same platform. Assets transferred between platforms become "non-covered," since cost basis doesn't automatically transfer on the blockchain, shifting the burden of accurate basis reporting back onto the taxpayer for those transfers.
- Contemporaneous identification requirement (2025 forward). Specific Identification for crypto now requires identifying the lot before or at the time of the sale — not after the fact at tax filing. This closes the door on after-the-year-end optimization approaches that some investors previously used.
- Transitional relief through 2026. IRS guidance has extended relief allowing taxpayers to apply their own lot identification in their books and records, even if it differs from a broker's internal default method, provided documentation supports the choice and it's recorded before disposal. In practice, this means your own records can currently override an exchange's default method — for now. This relief is transitional and its future beyond 2026 is not yet settled — check current guidance before relying on it.
If you hold the same cryptocurrency across multiple exchanges or wallets, you can no longer treat them as one combined pool for cost basis purposes. Each account is now calculated independently using only the lots actually held in that account. Investors who moved crypto between platforms over the years — extremely common — may find reconstructing accurate per-wallet basis history genuinely difficult without dedicated crypto tax software. This is one of the most consequential and least understood changes in crypto tax compliance.
The wash sale rule
The wash sale rule (IRC §1091) disallows a capital loss deduction if you buy a "substantially identical" security within 30 days before or after the sale that generated the loss — a 61-day window in total. The disallowed loss isn't lost forever; it's added to the cost basis of the replacement shares, effectively deferring the loss rather than eliminating it. This rule has long applied to stocks and applies across all your accounts, including IRAs and a spouse's accounts. One costly nuance: if the replacement shares are purchased in an IRA, the disallowed loss is not added to the IRA's basis — it's effectively lost permanently, since IRAs don't track cost basis the way taxable accounts do. Avoid repurchasing in an IRA within the wash sale window.
Under current law, the wash sale rule as written applies specifically to "stock or securities" — most cryptocurrencies are not classified as securities, so the rule does not clearly apply to them today. Tokenized securities and certain crypto-linked instruments that are classified as securities are a separate matter and may already be subject to it. Separately, proposals to formally extend wash sale treatment to all digital assets have circulated but have not been enacted as of this writing. Treat "does the wash sale rule apply to my crypto" as depending heavily on how that specific asset is classified, not as a single yes/no answer. Don't rely on any single source, including this one — verify current status with a crypto-specialized tax professional or the latest IRS guidance before assuming crypto losses are, or are not, subject to wash sale disallowance.
Stock splits and DRIP reinvestment
Two common events change your cost basis calculation without you actively buying or selling:
Stock splits change the number of shares you own but not your total cost basis. A 4-for-1 split turns 100 shares worth $200/share ($20,000 total) into 400 shares — your total investment remains $20,000, but your per-share basis drops to $50. Your brokerage should automatically adjust this, but always verify the adjustment is correct on your 1099-B before filing.
DRIP (Dividend Reinvestment Plan) purchases create a new cost basis lot every time a dividend is automatically reinvested — even small quarterly reinvestments. Over years of participation, this can produce dozens of tiny lots, each with its own purchase date and basis. This is one of the most common sources of cost basis tracking errors, since investors often forget these automatic purchases happened at all. Average cost is permitted for mutual funds and certain broker-held DRIP shares specifically, which can simplify tracking considerably compared to tracking each reinvestment as a separate lot — confirm with your broker whether your specific DRIP setup qualifies.
Track your crypto cost basis automatically
Use the crypto cost basis calculator to track your average purchase price across multiple buys and see your unrealized gain or loss in real time.
Try the crypto cost basis calculatorFrequently asked questions
Which cost basis method should I use?
There's no universally correct answer — it depends on your goals. FIFO is simplest and requires no ongoing lot-level record-keeping, making it the practical default for most casual investors. Specific Identification (including HIFO) offers the most tax control but requires meticulous, contemporaneous documentation — if you claim it but can't substantiate adequate identification during an audit, the IRS may default the sale to FIFO, often resulting in a higher tax bill plus potential penalties. Active traders and those with larger positions where the tax difference is material generally benefit most from the added record-keeping burden of Specific ID.
Can I switch cost basis methods between tax years?
Generally yes, for future transactions — you can change your method from one year to the next without IRS approval. However, the method must be applied consistently to a given lot once it's been sold and reported; you cannot retroactively change how a prior sale was calculated after filing. Consult a tax professional before changing methods if you have a complex position.
What happens if I don't specify a cost basis method?
FIFO applies automatically as the default for both stocks and crypto. If you intended to use Specific Identification but didn't properly document your lot selection before the sale — for stocks, before settlement date; for crypto, before or at the time of disposal — the IRS treats the sale as FIFO, potentially producing a different (often larger) taxable gain than you expected.
Do I need crypto tax software, or can I track this myself?
For simple situations — a handful of purchases on a single exchange, held and sold on that same platform — manual tracking or basic broker reporting may be sufficient, especially now that 2026-forward "covered" transactions get 1099-DA reporting. For anyone with transfers between wallets, multiple exchanges, DeFi activity, staking rewards, or a long transaction history, dedicated crypto tax software that automates per-wallet lot tracking is strongly advisable. The wallet-by-wallet requirement effective 2025 makes manual reconstruction genuinely difficult for anyone with a nontrivial transaction history across platforms.
How does cost basis affect tax-loss harvesting?
Cost basis is the foundation of tax-loss harvesting — you need accurate, lot-level basis to identify which specific positions have unrealized losses worth harvesting. Specific Identification is particularly valuable here, since it lets you precisely select which losing lots to sell for the deduction while retaining winning lots. See our tax-loss harvesting guide for the full strategy, including how the wash sale rule interacts with harvesting decisions.
This article is for informational and educational purposes only and does not constitute tax or legal advice. Cost basis rules, particularly for digital assets, are evolving rapidly — the crypto wash sale rule status described in this article reflects genuinely conflicting guidance as of publication and should be independently verified. Worked examples are illustrative and simplified; they do not account for state taxes, the Net Investment Income Tax, or your complete tax situation. Consult a qualified tax professional, particularly one experienced with digital assets, before making cost basis method elections.