Skip to content

Cost Basis Methods

Method ID Country Notes
First In, First Out FIFO 🌍 Oldest lots sold first (IRS default)
Last In, First Out LIFO 🌍 Must elect Specific ID (IRS)
Highest In, First Out HIFO 🌍 Must elect Specific ID (IRS)
Specific ID SPECIFIC_ID 🌍 Manual lot selection
Germany FIFO GERMANY_FIFO 🇩🇪 §23 EStG, 1-year holding exemption
PMPA PMPA 🇫🇷 Plus-value mobilière, weighted average
Total Average TOTAL_AVERAGE 🌍 Average cost basis
UK Share Pooling UK_SHARE_POOLING 🇬🇧 Section 104 pool + same-day and 30-day rules
AU CGT Discount AU_CGT_DISCOUNT 🇦🇺 FIFO + 50% discount on long-term gains (ATO s.115)
CA ACB CA_ACB 🇨🇦 Weighted average Adjusted Cost Base (CRA IT-387R2)
KR Virtual Asset KR_VIRTUAL_ASSET 🇰🇷 FIFO; 22% flat rate + KRW 2.5M exemption at report layer
IN VDA IN_VDA 🇮🇳 FIFO; losses not deductible (s.115BBH)
ES CGT ES_CGT 🇪🇸 FIFO; tiered 19–27% rates at report layer

The IRS allows FIFO and Specific Identification for crypto (Rev. Rul. 2023-14). LIFO and HIFO are technically Specific ID strategies — you must maintain lot-level records and consistently apply your method.

import { computeGains, compareAllMethods } from '@dtax/tax-engine';
// Single method
const result = computeGains(transactions, {
method: 'FIFO',
taxYear: 2024,
});
// Compare all comparable methods (excludes SPECIFIC_ID)
const comparison = compareAllMethods(transactions, 2024);
comparison.forEach(({ method, totalGain, recommendation }) => {
console.log(`${method}: $${totalGain} ${recommendation ? '← recommended' : ''}`);
});
interface GainResult {
shortTermGain: number;
longTermGain: number;
totalGain: number;
disposals: Disposal[];
unrealizedGain?: number;
}

Each lot is held for its own period. A sale that takes units from lots on both sides of the one-year line is therefore not one short-term or long-term disposal: it is reported as two lines on Form 8949, a short-term line (Box A–C) and a long-term line (Box D–F), with the sale’s proceeds and fee shared by units. The summary totals and Schedule D use the same two parts, so they agree with the form to the cent.

  • Applies to FIFO, LIFO, HIFO and Specific ID, where units come from individual lots. Pooled methods have no per-lot period.
  • Units with no purchase on record have no acquisition date and are reported short-term.
  • A wash-sale loss is judged part by part: the loss on the short-term part is disallowed even when the long-term part gained more, and only the loss part counts. The Form 8949 W amount and the cost added to the replacement lot in later years are the same figure.
  • The one-year line is a calendar-day rule: the holding period starts the day after acquisition, and the lot is long-term from the same calendar day one year later (bought 24 Mar 2025, long-term from a sale on 25 Mar 2026), whatever the time of day. The simulator, portfolio view and harvesting use the same definition.
  • Each part’s proceeds are rounded to the cent and the long-term part takes the remainder, so the two lines add up to the sale. A broker that reports the whole sale on one line may differ from the two lines by a cent in the split.
  • In results, holdingPeriod is MIXED for such a sale; each matched lot carries its own holdingPeriod. termLegs(result) returns the parts.

What the simulator and the method comparison start from

Section titled “What the simulator and the method comparison start from”

Both start from what you still hold, worked out the way the tax report works it out: every earlier sale and every confirmed transfer between your own wallets is replayed first, so units already sold are gone and units moved to another wallet sit in that wallet.

  • In wallet-by-wallet mode (the default for FIFO, LIFO and HIFO from 2025) a sale comes out of one wallet, and the network-fee units of a transfer are taken off the sending wallet. The simulator uses the wallet holding the most of the coin until you pick another one; the result lists every wallet with its name and how much it holds, and the method comparison follows the wallet you picked.
  • The wallet only limits FIFO, LIFO, HIFO and specific identification. The methods of other countries pool or average across all wallets, so they always see every wallet, in the simulator and in the comparison alike.
  • Earlier sales are replayed with FIFO. Cost carried over from a past wash sale onto a lot you still hold is not included.
  • A sale booked in a wallet that has no purchase on record (for example a transfer you have not confirmed yet) takes nothing from your other wallets, exactly as in the tax report, which lists such sales as missing a purchase. Confirm the transfer and the units move.

The portfolio view, the holdings PDF and tax-loss harvesting answer a different question, how much you own, so they pool your wallets, as the pooled tax report does: a sale counts whichever wallet it was booked in, and transfers between your wallets are not applied. They count purchases of every type the tax report counts and take off the units sold.

When a sale has no matching purchase, the unmatched units are reported with no cost basis, so the gain may be overstated. The report lists each coin and wallet with the units that are missing.

If you know what those units cost (for example from the cost column of a 1099-B or an account statement), use Add known cost basis next to the coin on the Form 8949 section of the tax page. Enter only the units that have no purchase on record; units and cost already in your records are not counted again.

  • The entry is stored as an ordinary purchase tagged opening-balance. You can find and delete it in Transactions (search “Opening balance”); recalculate afterwards.
  • If you know only whether the coins were held for more than a year, the entry gets a stand-in acquisition date. It only decides short or long term; Form 8949 shows VARIOUS for it. If part of the sales were held over a year and part not, add one entry for each, matching your 1099-B.
  • A stand-in date is refused when the coin was sold or sent between that date and the first sale, because those sales would change. Enter the real purchase date in that case.
  • A declared lot is a holding you already had, not a new purchase: it is never a replacement purchase for a wash sale, and under UK share pooling it joins the section 104 pool instead of being matched by the same-day or 30-day rule.
  • If the coins came from another of your wallets, confirm that transfer first; otherwise the cost is counted twice.
  • The report says how many declared entries its sales used and their cost, so you can check them against your statement.