Guide To Calculating Cost Basis For Tax Savings

Calculating Cost BasisOne of the most overlooked areas of tax savings is understanding how realized gains and losses impact your taxes. When you sell an investment, calculating cost basis and good record keeping plays a vital role in controlling those savings now and in the future.

To confuse things the IRS made several cost basis reporting changes. It revamped stock basis reporting in 2011, followed by changes in mutual fund, ETF and DRIPs (Dividend Reinvestment Plans) in 2012.

Some say it makes the process easier. Which it does. Really, it enforces accuracy so nobody fudges their numbers. Good or bad, the changes force you to make cost basis accounting decisions at the time of sale. This is easy enough when you sell all the shares of a stock.

But it doesn’t always work out that way. Maybe you want to sell half your shares. Then there are reinvested dividends to account for now and the intricacies of mutual fund shares, reinvested distributions, and return of capital. Or you just want to rebalancing your portfolio. In other words, it’s complicated.

How you report cost basis directly affects your tax bill, which is the point of this guide. It’s also a big piece to a tax efficient investment strategy. That is where you can save money by knowing the rules and planning ahead for taxes.

Table of Contents

  1. Intro to Cost Basis
    1. Basis
    2. Capital Gain
    3. Capital Loss
    4. Carryover Loss
    5. Cost Basis Method
  2. How to Calculate Cost Basis
    1. Stocks
      1. Stock Splits
    1. ETFs
    2. Reinvestment Dividends
    3. Mutual Funds
    4. Inherited Stocks
    5. Gifted Stocks
  3. Find Old Cost Basis Information
  4. Return of Capital
  5. Cost Basis Spreadsheet

Intro to Cost Basis


When we talk investments (stocks, ETFs, mutual funds etc.), basis is the cost at the time of purchase plus any transaction costs or commissions. There are exceptions like gifts and inheritance, which we’ll cover later.

When you buy 1,000 shares of Ford at $14 and your broker charges you a $10 commission, your cost basis is $14,010 for those shares. That transaction is given a unique  tax lot ID so you and the IRS can track those shares separately from other Ford stock you might buy later.

The process is the same for mutual funds, ETFs, and reinvested dividends.

Capital Gain

Anytime you sell shares for a profit, it’s known as a capital gain. The IRS has two classifications of capital gains:

  • Short Term Capital Gain – realized gain from assets sold inside of one year of the purchase date
  • Long Term Capital Gain – realized gain from assets sold one year or beyond the purchase date

This is important. The tax rate for each capital gain is different and there are rules on how each gain is offset by a capital loss.

Capital Loss

Anytime you sell shares for a loss, it’s known as a capital loss. Again, the IRS has two classifications of capital losses:

  • Short Term Capital Loss – realized loss from assets sold inside of one year of the purchase date
  • Long Term Capital Loss – realized loss from assets sold one year or beyond the purchase date

A capital loss offsets a capital gain or your income which lowers your tax burden. The IRS has rules in place on what gets first priority.

The rule of thumb is – capital losses first offset gains of the same type, then gains of the other type, and lastly, your income.

So, if you have a big short-term capital loss, it will first offset any short-term gains. Anything left, will offset any long-term capital gains. The rest will offset other income up to $3,000 per year. Any loss beyond that is rolled forward to future years.

Carryover Loss

When a loss exceeds the $3,000 deduction limit, it can be carried over to future tax years. The same rule of thumb applies for carryover losses. It offsets capital gains first, then income, and the rest is carryover for the next tax year until there is no loss left.

Say you sell several stocks for a net $4,000 capital loss this year. You can write off $3,000 of that loss against your income for the current tax year. Then you can use the remaining $1,000 loss to offset any capital gains or income next year.

Cost Basis Method

None of this matters if you use the wrong cost basis method. You remember the lot ID mentioned earlier? When you sell shares, you need to decide which lot ID those shares correspond too. If, like the Ford example earlier, you only bought 1,000 shares of Ford, there is only one lot ID to choose.

But what if you bought 1,000 shares of Ford, three separate times, each at a different share price. Now choosing a lot ID is important. To do this, you’ll need to specify one of these cost basis methods at the time of sale:

  • Average Cost – an average of the total purchase cost divided by the total shares held. This is only available for funds.
  • LIFO – or Last In, First Out sells shares in the most recent lot ID first.
  • FIFO – or First In, First Out sells shares in the oldest lot ID first.
  • Highest Cost – sells shares in the lot ID with the highest cost basis.
  • Lowest Cost – sells shares in the lot ID with the lowest cost basis.
  • Specific Lot – sells shares in the lot ID of your choice.

Every broker and fund company sets a default basis method. If you’re not sure which one is used, contact your broker and find out. Their default method makes tracking your gains and losses easier for them. It is not setup to give you the best tax results.

When you sell all the shares of a stock, you have the full capital gain or loss. But when you only sell some of your shares, you can pick those with the basis and holding period that gives you the best tax results.

By the way, there isn’t a right cost basis method per se. It all depends on your existing capital gain/loss, how a lot ID sale changes that capital gain/loss, the potential for future capital gain/loss on remaining unsold shares, and your tax rate.

I always use the specific lot method because it offers flexibility. In the end you need to weigh the trade-off between your current tax bill and possible future taxes.

To do this, you’ll need to keep track of everything. Now, I know that brokers and fund companies do it for you. It’s always a good idea to have your own records. So, to get you started, we included a free cost basis spreadsheet template at the bottom of this post. Plus, if you ever switch brokers, inherit stock, or just need to double-check, you’ll have the records.

How To Calculate Cost Basis

Stock Cost Basis

You calculate the cost basis for stock you’ve purchased by taking the cost of the shares plus the commission your broker charges. Lets use the Ford example from earlier: 1,000 shares at $14/share with a $10 commission. Your cost basis is $14,010, per share it’s $14.01.

What if you sell those 1,000 share of Ford for $12? Your broker charges another $10 commission for the sale and your proceeds are $11,990. Don’t forget to subtract the commission from the sale. You get a capital loss of $2,020 ($14,010 cost basis – $11,990 sale).

Stock Splits

If a company declares a stock split, the cost basis of your old shares is evenly split between the old and new shares. Say, you own 1,000 shares with a cost basis of $20/share ($20,000 basis). The company does a two for one stock split. Now, that $20,000 basis is split between 2,000 shares with a $10/share basis.

ETF Cost Basis

When calculating cost basis for ETFs, just use the same process we went through for stocks. Thanks to the low costs of ETFs, it’s easy to see someone owning the same ETF for years, regularly buying new shares each month and reinvesting dividends. Not unlike a mutual fund.

Every one of those events is a new lot ID to track with a different holding period and basis. Do that over several years and there is your excuse to have accurate records for tax purposes.

Cost Basis For Reinvested Dividends

The basis calculation for reinvested dividends is the same as those used for ETFs and stocks. But is easily overlooked with DRIPs. Dividend Reinvestment Plans automatically buy shares when dividends are paid out. It’s no different from having the dividends paid in cash, then you immediately turn around and buy new shares. So you get a new lot ID for each reinvestment.

Over several years, the number of shares can quickly add up. So will the number of lot IDs to choose from when you finally start selling shares. This is why tracking everything is important.

Cost Basis For Mutual Funds

Mutual funds have been very popular over the past two decades. They usually come in two forms: load and no load mutual funds.

You calculate cost basis for mutual funds the same as stocks: purchase price plus transaction cost or commission. Purchase price will be the net asset value (NAV) on the day shares were purchased.

A mutual fund with a 5% load, would have a cost basis of NAV plus a 5% commission. So 100 shares bought at an NAV of $10/share ($1,000 + 5%($1,000)) would have a $1,050 cost basis with a basis of $10.50/share.

The average cost method is one method allowed by the IRS when you sell mutual fund shares. You figure out average cost by adding up all the money invested into the fund, including reinvested dividends and divide by the number of shares you own. Then you assume the sold shares are a long-term capital gain/loss.

It’s the easiest method to use for long-held funds, but it probably won’t offer the best tax savings. Once you choose the average cost method, the rest of the shares in that fund must use it too.  It’s worth weighing before you lock shares into the average cost method.

Cost Basis Of Inherited Stock

When you inherit stock your cost basis is calculated based on the date of the previous owners death. Even if the previous owner bought those shares years or decades ago at a lower cost basis, you won’t get hit by the tax burden. Instead your cost basis is updated to a current valuation.

For stock, your cost basis per share is the share price on the date of death. It’s the same for ETFs, mutual funds, and any asset where basis plays a role in taxes.

The one exception is if the estate of the previous owner was subject to estate tax. In that case, an alternative valuation date six months after the previous owners death can be used by the executor to value the shares. The executor decides on the date used to calculate basis.

Cost Basis Of Gifted Stock

Unfortunately, gifts don’t get the same privileges as an inheritance. When a family or friend is generous enough to gift you shares of a stock or fund, your basis stays the same as when it was purchased.

There is one exception. When you sell those shares for a loss, the basis is the lesser of – the previous owner’s basis or the value when you received the shares. You can’t benefit from the previous owner’s cost basis.

If you do get a gift, make sure you find out all the cost basis information from the previous owner and the value on the day you received them.

Find Old Cost Basis Information

When you inherit or receive stock as a gift, the last thing anyone thinks about is the original cost basis. Or maybe it was overlooked when you switched brokers years ago. Either way, its information you’ll need when you sell the stock.

When dealing with stocks, this process gets difficult the further back you go. Capital changes, things like spinoffs, stock splits, or issued dividend shares, become more likely. It can make a big difference on the original cost basis.

This can be difficult if you don’t know the date it was bought. In which case, you can ask the prior owner or their old broker for past transaction statements.

But if you do know the date, you can use historical stock quotes to find the information. Just take the average of the high and low price on the date in question. Yahoo Finance is a good place to start and adjusts all historical prices for stock dividends and splits.

Return Of Capital

You might run into a few special situations where you have to adjust basis. Return of capital is the most common found. I’ve covered it with REIT tax rules, but you see it with mutual funds and MLPs too.

When a fund, REIT, or MLP sells an asset, it can reinvest the money or pay it out to shareholders. If the money is paid out to shareholders as a return of capital. It’s not taxed as ordinary income. Instead, it lowers or adjusts the cost basis of the shares by the amount paid out. Eventually the adjusted basis will be taxed as a capital gain when you sell the shares. Unless, the share price drops and it becomes a capital loss.

Say you have 1,000 shares with a $20/share cost basis. You get a 1099-DIV showing a $2/share return on capital. Your new cost basis for the those shares become $18 ($20 -$2). It’s fairly simple but gets complicated the more lot IDs you track and have to adjust.

Cost Basis Spreadsheet

The best way to track your cost basis is with a simple spreadsheet. It’s an easy way to know exactly where you stand before any transaction and throughout the year. When it’s time to finally do your taxes, it makes calculating cost basis that much easier.

You can download our free cost basis spreadsheet template below.

Cost Basis Spreadsheet It’s available in Excel and Google Docs:

If you choose the Google Docs version, you’ll need to make a copy. Just go to File and select Make A Copy like in the image below.

Copy To Your Google Docs

That will copy the spreadsheet to your Google Drive folder and label it “Copy of Cost Basis Spreadsheet Template”. Feel free to make changes, improve it, and share it.

If you don’t want to use a spreadsheet, make sure you find an online broker that tracks your cost basis for you. I use TD Ameritrade, which comes with the Gainskeeper tax reporting service. It tracks my cost basis, along with realized and unrealized gains and losses, to help me make better tax related decisions when I do sell shares.


Every time you buy a stock or fund you start a paper trail that will directly impact your future taxes. But when it comes time to sell those shares, calculating cost basis and good records will decide your tax burden. The hard part is deciding which lot ID to sell.

Of course, the work around to all this is just keep good records going forward. The better discount brokers, like TD Ameritrade (I know because I use it), let you download your transaction statements complete with all your cost basis information. Keeping your own separate records is a good idea too.

If your records are accurate and up to date, you only have to choose those shares with the basis and holding period that give you the best tax results now and in the future.

If you enjoyed this article, get email updates (it's free).


  1. Raul says

    Great article!
    I have some questions on it.

    1) What if I buy several times a day, the same price, the same stock or fund, would it open different tax lots? If the answer is positive, wouldnt it be strange looking a statement position report having tons of lines for a single date?

    2) Is it possible to open to the same account and security both long and short positions?

    3) What about daytrade trading, how is it computed in terms of cost and positions?

    • Jon says

      Raul, to your questions:

      1) You get a new tax lot for every purchase. So if you buy the same stock, at the same price, 10 times in one day, you get 10 different tax lots. It might seem strange but that’s the rules.
      2) Sure, but why would you want to go short and long the same stock?
      3) The tax law is different for “investors” and “traders” and the rules are fuzzy for traders. I don’t know enough about it myself, but a search for “tax rules for traders” will get you started. I’d also recommend talking with a tax pro just to make sure you qualify.

  2. Raul says

    Thanks Jon for your answers.

    I understand for mutual funds we may use the average cost basis. In this case, isnt it much more simple to have only one tax lot with the average cost, instead of having many tax lots all of them carrying the exactly same cost?

    As for the daytrading, I just needed to understand if there might be a pre-match of buys and sells in such a way my open positions would only be affected after the daily match had been computed (netted).

    • Jon says

      You can use average cost basis for mutual funds (though it may not be the best choice) because it’s simpler to use, but it won’t change the rules regarding tax lots. The tax lot is just a record used to track share purchases and sales. Your suggestion might be more simple to use, until you buy new shares, the average changes, and the IRS needs to track those changes.

      Regarding day trading, a tax lot is a tax lot. It doesn’t matter when you buy or how long you hold shares. How daily buys and sells are settled at the end of day depends on which cost basis method you choose at the time of sale. Keep in mind, it’s the IRS we’re talking about here – not known for simplicity.

      • Raul says

        Jon first I would like to really thank you for not only being so amazingly fast in your answers but also so precise in it.

        So bottom line regarding the average cost is having literally tons of tax lots, all of them with the same cost (imagine I trade multiple times the same stock a day, everyday for several years, not disposing any of these lots), poor investor having to read thousands of pages of holdings report :)

        Regarding the day trading, I thought there might be a smart netting of buys and sells before using what is left “long” or “short” to close against the opening position. I know there are some countries that do that.

        You wouldnt have a skype, would you?


        • Jon says

          Re: average cost basis – exactly. Keep in mind, average cost basis can only be used on funds. So someone buying a mutual fund every month, plus reinvesting dividends quarterly will have 16 tax lots each year. After 10 years, they have 160. Two decades, 320, etc. Using average cost basis just makes it easier when that person finally decides to sell shares. However, it might not be the best cost basis method to use if they want the lowest tax hit.

          Sidenote: the number of pages to read through is directly proportional to your trading activity. If you want the least amount of pages, just trade less.

          Re: day trading – maybe there is a vague rule for those that qualify as a “trader”. Even if there is, you still need to qualify as far as the IRS is concerned. As I said in my first comment, I don’t know enough about the “trading” rules to comment with certainty because I don’t daytrade. You’re better off asking a tax pro there for clarification.

          Sorry, I don’t have skype, but I do have email.

          • Raul says

            Thank you again.
            So supposing I have chosen to use AverageCost for my funds positions, when I sell some of them, it makes no difference at all from each position I might deplete. I am asking this because we know there is a thing called bifurcation, which has to do with the time you have held that position associated with the tax.

  3. Raul says


    “Then you assume the sold shares are a long-term capital gain/loss.”

    That makes AvgCost just perfect, since from day-one my new positions would be taxed the lowest bracket.

  4. Raul says

    Hi Jon again!

    I was reading about corporate actions and came across this document:
    There it pictures a situation in which one might have 2 different lots (thus different purchase dates) and when a corporate action occurs (say a merger) though each lot might produce fractional shares, in total they might be summed avoiding cash in lieau to receive (it is described right after the subtitle “After the Spin-Off Comes a Merger” in 1st paragraph). This to me sounds completely strange, since different purchase dates mean possible different tax %.
    Do you agree?

    • Raul says

      I think it is strange because in case of having short and long term lots, which one would be considered to receive the rounded or integer part of both fractional shares??

    • Jon says

      Not really. Short and long term, i.e. purchase dates, only matter when something is sold. Put differently, you don’t know if a lot is short or long term until it’s sold. The example in the referenced article, assuming I read it correctly, nothing was sold. The cash in lieu is taxed as a capital gain (based on holding period which was long term). Beyond that, nothing is taxed.

      In the future, I’m happy to answer any further questions you might have. The best way to ask is through the contact form.

  5. Kathy says

    I’ve a DRIP plan with monthly installment back in 1996. Now, I’m thinking to sell all shares at once, but I lost some of the record.

    My questions here are
    1) may I use AverageCost for tax?
    2)How do I find out my cost basis?
    or any better suggestion for tax.


    • Jon says

      Kathy, it depends on what you’re selling. You can only use average cost basis for mutual fund shares. If that’s the case, and since you’re selling every share, your cost basis is the total amount you put into the plan since 1996.

Leave a Reply

Your email address will not be published. Required fields are marked *