BY DEFAULT, the IRS, brokerage firms, and most trade accounting programs use the First-In-First-Out (FIFO) accounting method. If you sell security A, its cost-basis is the first lot purchased — the first one “out” or sold.
But there is another option called the Specific Identification (SI) accounting method. Assume you bought several lots of security A over the year while the stock increased in price. You might prefer to use SI accounting instead of FIFO to specify a higher cost-basis lot to reduce your short-term capital gains for 2021. This enables you to hold the older purchased stock for 12 months at a lower cost-basis for a long-term capital gain taxed at a lower rate (up to 20% for 2021 and 2022).
The IRS requires contemporaneous action for using SI. You must specify the lot to sell before executing the sale, and the broker must confirm those instructions in writing at that same time. You cannot decide to use SI after the sale’s settlement date, like when preparing your tax returns. The IRS provides a little leeway to correct communication errors with the broker by allowing a settlement date rather than a trade date.
FIFO is also the default accounting method for cryptocurrencies. While SI is allowed, it’s challenging to use. See Frequently Asked Questions on Virtual Currency Transactions | Internal Revenue Service (irs.gov)
“You may identify a specific unit of virtual currency either by documenting the specific unit’s unique digital identifier such as a private key, public key, and address, or by records showing the transaction information for all units of a specific virtual currency, such as Bitcoin, held in a single account, wallet, or address. This information must show (1) the date and time each unit was acquired, (2) your basis and the fair market value of each unit at the time it was acquired, (3) the date and time each unit was sold, exchanged, or otherwise disposed of, and (4) the fair market value of each unit when sold, exchanged, or disposed of, and the amount of money or the value of property received for each unit.”