How Is Tax Calculated When Selling Stocks?
When you sell stock for more than your adjusted cost basis, the difference can create a capital gain. The important part is determining the correct basis for the shares you actually sold.
This article explains how tax is calculated when selling stocks, including cost basis, holding period, short-term vs long-term gains, and key tax considerations.
A simplified stock-sale calculation is:
Example: Sell shares for $20,000. Adjusted basis: $14,000. Estimated gain: $6,000.
Do You Pay Tax When You Sell Stocks?
Yes, selling stocks can create a taxable capital gain. However, the actual tax you may owe depends on several factors:
- Gain or loss β Whether you sold for more or less than your adjusted basis.
- Holding period β How long you held the stock.
- Taxable income β Your overall tax situation.
- Filing status β Single, married, etc.
- Applicable federal and state rules β Tax laws can vary.
Understanding these factors is essential before estimating potential tax consequences.
How Is a Stock Capital Gain Calculated?
The capital gain or loss from selling stocks is calculated using a straightforward formula:
If sale proceeds exceed adjusted basis, you have a capital gain. If adjusted basis exceeds sale proceeds, you have a capital loss.
What Is Cost Basis?
Cost basis is generally the amount you paid for the shares, plus certain acquisition costs. Common components include:
- Purchase price β The amount you paid per share.
- Number of shares β The quantity purchased.
- Transaction costs β Certain commissions and fees associated with the purchase.
- Reinvested dividends β May increase basis in certain circumstances.
Brokerage records can be useful for determining basis. Keep trade confirmations and account statements for reference.
What Is Adjusted Cost Basis?
Your cost basis may need adjustments because of certain events. Possible adjustments include:
- Reinvested dividends β Dividends reinvested to purchase additional shares.
- Stock splits β Adjusting the number of shares and basis per share.
- Corporate actions β Mergers, acquisitions, and spin-offs.
- Return of capital β Certain distributions that reduce basis.
How Does the Holding Period Affect Stock Gains?
The holding period determines whether a gain or loss is generally treated as short-term or long-term:
The holding period generally starts the day after you acquire the shares and ends on the day you sell them. The distinction can affect the tax treatment of your gain or loss.
Short-Term vs Long-Term Capital Gains
Under current federal tax rules, short-term and long-term capital gains may receive different tax treatment:
The applicable tax rate depends on the taxpayer's income, filing status, and other factors. Consult current IRS guidance for specific rates.
What If You Bought Shares at Different Times?
A taxpayer may buy the same stock at different prices on different dates. This creates multiple "lots" with different cost bases and holding periods.
- Lot A: 100 shares purchased at $20
- Lot B: 100 shares purchased at $30
If 100 shares are sold, the basis depends on which shares are treated as sold.
Identifying which shares were sold is an important part of calculating the correct gain or loss.
Specific Share Identification and FIFO
Investors may be able to identify particular shares when selling securities if applicable requirements are satisfied:
- Specific Identification β You may be able to choose which specific shares are being sold.
- FIFO β First-In, First-Out: the earliest purchased shares are treated as sold first.
- Broker default methods β Many brokers use specific default methods unless you specify otherwise.
Do Brokerage Fees Affect the Calculation?
Certain transaction costs can affect the calculation of gain or loss. Brokerage fees paid when buying shares may be added to the cost basis. Fees paid when selling shares may reduce the sale proceeds.
The treatment can depend on the nature of the fees and applicable tax rules. Review your trade confirmations and Form 1099-B for specific information.
What Happens When You Sell at a Loss?
If sale proceeds are below adjusted basis, the transaction may produce a capital loss:
Capital losses have their own federal tax rules. They may be used to offset capital gains and, in some cases, a portion of ordinary income. Consult current IRS guidance for specific limitations and rules.
What Is a Wash Sale?
The wash-sale rule is a federal tax provision that can affect the recognition of losses from stock sales. In general, a wash sale occurs when:
- You sell shares at a loss, and
- You acquire substantially identical securities within 30 days before or after the sale.
What Is Form 1099-B?
Brokers may issue Form 1099-B reporting securities transactions. This form typically includes:
- Sale proceeds β The amount received from the sale.
- Cost basis β The reported basis of the shares sold.
- Holding period information β Short-term or long-term indicators.
- Adjustments β Wash-sale adjustments and other modifications.
Worked Example
Let's walk through an example of calculating a stock sale gain.
Scenario: You purchased 200 shares at $25 per share ($5,000 basis). You sell all 200 shares at $40 per share ($8,000 proceeds) with $50 in selling-related transaction costs.
| Calculation | |
| Sale Proceeds | $8,000 |
| β Transaction Costs | -$50 |
| Net Proceeds | $7,950 |
| β Adjusted Basis | -$5,000 |
| Estimated Capital Gain | $2,950 |
Second Example With Multiple Lots
This example shows how the gain can differ depending on which shares are treated as sold.
Scenario: You have two lots:
- Lot A: 100 shares purchased at $20
- Lot B: 100 shares purchased at $35
You sell 100 shares at $50 per share ($5,000 proceeds) with $25 in transaction costs.
| If Lot A is Sold | |
| Net Proceeds | $4,975 |
| β Basis (Lot A) | -$2,000 |
| Gain | $2,975 |
| If Lot B is Sold | |
| Net Proceeds | $4,975 |
| β Basis (Lot B) | -$3,500 |
| Gain | $1,475 |
Federal vs State Tax
Federal tax rules and state tax rules can differ. State tax treatment varies widely:
- Some states have no capital gains tax (e.g., Texas, Florida, Washington).
- Other states tax capital gains as ordinary income (e.g., California, New York).
- Some states have special rules for stock sales.
Do not assume every state follows federal treatment. Check your state's current rules or consult a qualified professional.
Records to Keep
Keep these records to support your stock sale calculation:
- Trade confirmations β Records of each purchase and sale.
- Brokerage statements β Monthly or quarterly account statements.
- Purchase dates β Dates shares were acquired.
- Purchase prices β Cost per share for each lot.
- Number of shares β Quantity of shares in each lot.
- Cost basis β Basis for each lot.
- Sale proceeds β Amount received from sales.
- Form 1099-B β Broker's tax reporting form.
- Dividend records β Reinvested dividends affecting basis.
- Stock-split records β Adjustments for splits.
- Corporate-action records β Mergers, spin-offs, etc.
- Wash-sale adjustments β Records of disallowed losses.
- Previous tax records β Prior returns and related schedules.
Common Mistakes
Here are some common mistakes to avoid when estimating stock sale tax:
- Treating sale proceeds as taxable gain β Proceeds are not the gain.
- Using the wrong cost basis β Basis can change over time.
- Ignoring holding period β Holding period affects tax treatment.
- Mixing different stock lots β Each lot has its own basis and period.
- Ignoring basis adjustments β Splits, dividends, and corporate actions matter.
- Forgetting reinvested dividends β Reinvested dividends increase basis.
- Ignoring stock splits β Splits affect number of shares and per-share basis.
- Ignoring wash-sale adjustments β Wash sales can disallow losses.
- Blindly trusting incomplete broker basis information β Verify basis records.
- Using outdated tax rates β Rates and brackets can change.
- Ignoring state tax β State tax can add to your liability.
- Confusing capital gain with capital gains tax β Gain is not the same as tax.
How to Estimate Stock Sale Tax
Before filing taxes after selling stocks, use this checklist:
- Sale date β When the sale occurred.
- Purchase date β When shares were acquired.
- Number of shares sold β Quantity sold.
- Sale proceeds β Amount received from the sale.
- Cost basis β Basis of the shares sold.
- Adjusted basis β Basis adjusted for splits, dividends, etc.
- Holding period β Short-term or long-term.
- Brokerage records β Trade confirmations and statements.
- Form 1099-B β Broker's tax reporting form.
- Basis adjustments β Wash-sale, splits, etc.
- Capital gains/losses β Calculate gain or loss for each sale.
- Federal tax considerations β Review current IRS guidance.
- State tax considerations β Check your state's rules.
For a quick estimate, try our Stock Sale Tax Calculator.
You may also find these related calculators helpful:
Frequently Asked Questions
Yes, selling stocks can create a taxable capital gain. The tax you may owe depends on the gain, holding period, and your overall tax situation.
Calculate as: Sale Proceeds β Adjusted Cost Basis = Capital Gain or Loss. Sale proceeds include the amount received from the sale, adjusted for transaction costs.
Cost basis is generally the amount you paid for the shares, plus certain acquisition costs such as commissions and fees paid when buying.
Adjusted cost basis reflects changes to your original basis due to stock splits, reinvested dividends, corporate actions, and other adjustments.
Yes. The holding period determines whether a gain is treated as short-term or long-term, which can affect the tax treatment.
Short-term gains apply to assets held for 1 year or less and are generally taxed as ordinary income. Long-term gains apply to assets held for more than 1 year and may qualify for preferential tax rates.
You have multiple lots with different cost bases and holding periods. The gain or loss depends on which shares are treated as sold.
FIFO stands for First-In, First-Out. It means the earliest purchased shares are treated as sold first. This is a common default method used by brokers.
Yes, through specific identification. You may be able to choose which specific shares are being sold if you follow applicable requirements and keep proper records.
Yes. Fees paid when buying may be added to the cost basis. Fees paid when selling may reduce the sale proceeds. The treatment depends on the nature of the fees.
You have a capital loss. Capital losses may be used to offset capital gains and, in some cases, a portion of ordinary income, subject to applicable rules.
The wash-sale rule disallows a loss on a sale if you acquire substantially identical securities within 30 days before or after the sale. The disallowed loss is added to the basis of the new shares.
Form 1099-B is a tax form issued by brokers that reports securities transactions, including sale proceeds, cost basis, and holding period information.
Yes, in many states. State tax treatment varies widely. Some states have no capital gains tax, while others tax it as ordinary income. Check your state's rules.
Yes. Our Stock Sale Tax Calculator can help you estimate gain and tax based on the information you provide. Calculators provide estimatesβnot official tax determinations.
Read full disclaimer β