When to sell and buy funds or stocks

Discuss all general (i.e. non-personal) investing questions and issues, investing news, and theory.
Post Reply
Topic Author
international001
Posts: 832
Joined: Thu Feb 15, 2018 7:31 pm

When to sell and buy funds or stocks

Post by international001 » Mon Jun 10, 2019 3:56 pm

This is something that I never saw discussed

Let's say you have security X that you wan to sell to buy security Y at time T. Ideally, you should have bought Y in the first place, but let's assume you regretted about it for whatever reason. For simplicity, let's assume both of them are equivalent in terms of risk/return.

You want to minimize the impact of taxes, and you have to decide the time T when to do it.

What I found is that the worst case (let's assume percentage taxed is the same) is when:

T-T_X_sell = T_Y_sell-T

This has some practical implications. If you bought a security a couple of years ago and you want to hold them till retirement, sell them as fast as you can. Conversely, if you are near retirement and you can postpone selling X (again, for whatever reason, let's imagine you can sell another security instead and you want to maintain your AGI under control), then it would be better to hold X a little bit more.

I was wondering if this has been analyzed in the past and has larger strategic implications than the obvious ones I described.

User avatar
grabiner
Advisory Board
Posts: 24366
Joined: Tue Feb 20, 2007 11:58 pm
Location: Columbia, MD

Re: When to sell and buy funds or stocks

Post by grabiner » Mon Jun 10, 2019 7:18 pm

While the math here is correct, you are assuming equivalence of the funds. If the funds are equivalent, the best situation is to never sell at all; the tax cost is minimized when T=T_Y_sell (or when T=T_X_sell, but unless you just bought X, this is no longer possible.)

When the funds are different (for example, Y is more tax-efficient), it is still the case that the optimum must be at one of the endpoints: either switch now or never switch. Paying a tax cost to switch funds on the wiki shows how to work this out.

You might wait before switching if tax rates will change. For example, it may be desirable to wait to sell a fund for a large short-term gain until the gain becomes long-term, or to wait to sell a fund until you move to a low-tax state or a lower tax bracket.
Wiki David Grabiner

Topic Author
international001
Posts: 832
Joined: Thu Feb 15, 2018 7:31 pm

Re: When to sell and buy funds or stocks

Post by international001 » Wed Jun 12, 2019 7:08 am

Everything that you say is right. But this is not my point.
I'm trying to look at strategies whenever everything else is equal.

For instance, if you are young and you have to rebalance on taxable. Better to sell funds that you got 1 year ago than the ones you got 10 years ago.

User avatar
grabiner
Advisory Board
Posts: 24366
Joined: Tue Feb 20, 2007 11:58 pm
Location: Columbia, MD

Re: When to sell and buy funds or stocks

Post by grabiner » Wed Jun 12, 2019 10:12 pm

international001 wrote:
Wed Jun 12, 2019 7:08 am
Everything that you say is right. But this is not my point.
I'm trying to look at strategies whenever everything else is equal.

For instance, if you are young and you have to rebalance on taxable. Better to sell funds that you got 1 year ago than the ones you got 10 years ago.
A realistic example with things nearly equal: You have bought two lots of US stock in the past, and you need to sell one of those lots to buy foreign stock to rebalance.

However, your formula doesn't apply to this case. If you have two lots bought in 1999 and 2004, your formula gives a comparison between selling the 1999 lot now and holding the replacement until 2029, versus selling the 2004 lot now and holding it to 2034 (which costs more in taxes assuming a constantly rising market). Alternatively, it gives a comparison between selling the 2004 lot now and holding the replacement until 2034, versus selling the 2004 lot in 2024 and holding it until 2034 (which costs less in taxes assuming a constantly rising market).

But neither of these is a realistic choice. You aren't going to wait five years to sell in order to reduce taxes, since you have a reason to sell now, your need to rebalance (and presumably reduce risk). And whichever lot you sell, you will have the same replacement stock, so you will sell it in the same year. If the choice is between selling the 1999 and 2004 lots, and selling the replacement in the same year, it is always better to sell the higher-basis lot,
Wiki David Grabiner

Topic Author
international001
Posts: 832
Joined: Thu Feb 15, 2018 7:31 pm

Re: When to sell and buy funds or stocks

Post by international001 » Thu Jun 13, 2019 5:29 am

In many cases it's not a realistic option, but there can be exceptions where it would be handy to take this into consideration

What about if you have the 1999 lots and 2004 lots, and whatever you buy, and you plan to sell the replacement the same year? Given enough time, selling the 2004 lot should be better, no? I Think that's what you meant by selling the higer-basis lot, but only if you plan to keep the replacement for many years.

What initially trigger my interest is that a have some old ESPP that I want to sell, to buy TSM, and I want to sell a few each year. Is it better to sell the oldest (FIFO)? This is a different question, because I'm in worse situation by not selling everything today, so what I'd like to understand is which is the less bad of the options.

User avatar
grabiner
Advisory Board
Posts: 24366
Joined: Tue Feb 20, 2007 11:58 pm
Location: Columbia, MD

Re: When to sell and buy funds or stocks

Post by grabiner » Thu Jun 13, 2019 7:56 pm

international001 wrote:
Thu Jun 13, 2019 5:29 am
In many cases it's not a realistic option, but there can be exceptions where it would be handy to take this into consideration

What about if you have the 1999 lots and 2004 lots, and whatever you buy, and you plan to sell the replacement the same year? Given enough time, selling the 2004 lot should be better, no? I Think that's what you meant by selling the higer-basis lot, but only if you plan to keep the replacement for many years.
Selling the 2004 lot is better regardless of when you sell the replacement.

Suppose that your stock gained 6% annually. The 20-year-old lot, now worth $10000, has a basis of $3118. The 15-year-old lot, also worth $10000, has a basis of $4173. On your current sale, you have a capital gain of $5827 if you sell the newer lot, and $6882 if you sell the older lot. Then, when you sell the replacement lot, you have a capital gain of whatever you sell it for minus $10,000. If you never sell the other original lot, you will be ahead by the tax on the $1055 difference (and the gains from reinvesting that tax). If you eventually do sell the other original lot, you will pay the tax on the $1055 difference at that time, but you will gain by postponing the tax because you had years to invest the tax savings.
What initially trigger my interest is that a have some old ESPP that I want to sell, to buy TSM, and I want to sell a few each year. Is it better to sell the oldest (FIFO)? This is a different question, because I'm in worse situation by not selling everything today, so what I'd like to understand is which is the less bad of the options.
You should sell the highest-basis shares. Consider a variation of my example above, in which you sell one lot now, and the other lot next year for $10,600. If you sell the 20-year-old lot now, you have a capital gain of $6882 this year and $6427 next year. If you sell the 15-year-old lot now, you have a capital gain of $5827 this year and $7482 next year. Thus, selling the higher-basis new lot causes you to have $1055 less in taxable gains this year and $1055 more next year. It is better to pay the tax on the $1055 next year rather than this year because you can invest the tax savings.

Another reason to sell the highest-basis shares is that you can sell more shares for the same tax cost. If you are trying to stay under some tax limit (for example, the 3.8% Net Investment Income Tax limit, or the ACA income limit), then you want to sell for a specific capital gain, rather than a specific dollar amount or number of shares. Selling the higher-basis shares means a lower capital gain per share, and thus more shares sold and more opportunity to get the benefits of the replacement shares.
Wiki David Grabiner

Topic Author
international001
Posts: 832
Joined: Thu Feb 15, 2018 7:31 pm

Re: When to sell and buy funds or stocks

Post by international001 » Fri Jun 14, 2019 8:47 am

grabiner wrote:
Thu Jun 13, 2019 7:56 pm

Suppose that your stock gained 6% annually. The 20-year-old lot, now worth $10000, has a basis of $3118. The 15-year-old lot, also worth $10000, has a basis of $4173. On your current sale, you have a capital gain of $5827 if you sell the newer lot, and $6882 if you sell the older lot. Then, when you sell the replacement lot, you have a capital gain of whatever you sell it for minus $10,000. If you never sell the other original lot, you will be ahead by the tax on the $1055 difference (and the gains from reinvesting that tax). If you eventually do sell the other original lot, you will pay the tax on the $1055 difference at that time, but you will gain by postponing the tax because you had years to invest the tax savings.
Well, to measure apples to apples, I would do the comparison of lots with the same capital gain at time T
Also 'when you sell the replacement lot, you have a capital gain of whatever you sell it for minus ( $10,000 *minus the taxes you paid*)'
And I'm assuming you would sell the other lot at some time, that's the whole point
grabiner wrote:
Thu Jun 13, 2019 7:56 pm
You should sell the highest-basis shares. Consider a variation of my example above, in which you sell one lot now, and the other lot next year for $10,600. If you sell the 20-year-old lot now, you have a capital gain of $6882 this year and $6427 next year. If you sell the 15-year-old lot now, you have a capital gain of $5827 this year and $7482 next year. Thus, selling the higher-basis new lot causes you to have $1055 less in taxable gains this year and $1055 more next year. It is better to pay the tax on the $1055 next year rather than this year because you can invest the tax savings.
But you have to invest what you get (minus taxes) in the replacement fund Assuming same return of 6%, and that you will sell both sometime in the future *at the same time*, my quick spreadsheet showed me that you are better off by selling oldest lot first. This advantage is small and tends to vanish the longer time you wait to sell the replacement

I guess you want the bigger chunk of money to start compounding as soon as possible.
But the tradeoffs may not be intuitive w/o doing the whole math formula.
grabiner wrote:
Thu Jun 13, 2019 7:56 pm
Another reason to sell the highest-basis shares is that you can sell more shares for the same tax cost. If you are trying to stay under some tax limit (for example, the 3.8% Net Investment Income Tax limit, or the ACA income limit), then you want to sell for a specific capital gain, rather than a specific dollar amount or number of shares. Selling the higher-basis shares means a lower capital gain per share, and thus more shares sold and more opportunity to get the benefits of the replacement shares.
That's a good point. One thing is maximizing returns. But if you want to move as many shares from one fund A to fund B to minimize portfolio risk, that's the best strategy.

This would be the best strategy for a taxable re-balancing as well
But perhaps, if we are targeting a 60/40 on taxable, we should not consider just the overall AA, but the overall AA *after* cost basis. I haven't seen this much discussed in anyplace.

User avatar
grabiner
Advisory Board
Posts: 24366
Joined: Tue Feb 20, 2007 11:58 pm
Location: Columbia, MD

Re: When to sell and buy funds or stocks

Post by grabiner » Fri Jun 14, 2019 7:20 pm

international001 wrote:
Fri Jun 14, 2019 8:47 am
grabiner wrote:
Thu Jun 13, 2019 7:56 pm

Suppose that your stock gained 6% annually. The 20-year-old lot, now worth $10000, has a basis of $3118. The 15-year-old lot, also worth $10000, has a basis of $4173. On your current sale, you have a capital gain of $5827 if you sell the newer lot, and $6882 if you sell the older lot. Then, when you sell the replacement lot, you have a capital gain of whatever you sell it for minus $10,000. If you never sell the other original lot, you will be ahead by the tax on the $1055 difference (and the gains from reinvesting that tax). If you eventually do sell the other original lot, you will pay the tax on the $1055 difference at that time, but you will gain by postponing the tax because you had years to invest the tax savings.
Well, to measure apples to apples, I would do the comparison of lots with the same capital gain at time T
If you have two lots with the same capital gain, it's irrelevant which lot you sell, as the tax consequences will be the same when you sell this lot, and also the same when you sell the other lot. Your formula at the beginning of this thread was based on optimizing sales assuming a constant return, which implies that the older lot has a lower basis.
Also 'when you sell the replacement lot, you have a capital gain of whatever you sell it for minus ( $10,000 *minus the taxes you paid*)'
That's equivalent to my formulation; I am assuming you take the tax from some other investment, so you buy another lot for the full $10,000 and then take the $158 tax difference from, say, a bond fund.
Wiki David Grabiner

User avatar
arcticpineapplecorp.
Posts: 4107
Joined: Tue Mar 06, 2012 9:22 pm

Re: When to sell and buy funds or stocks

Post by arcticpineapplecorp. » Sat Jun 15, 2019 3:51 pm

international001 wrote:
Mon Jun 10, 2019 3:56 pm
This is something that I never saw discussed

Let's say you have security X that you wan to sell to buy security Y at time T. Ideally, you should have bought Y in the first place, but let's assume you regretted about it for whatever reason. For simplicity, let's assume both of them are equivalent in terms of risk/return.
if they have the same risk and return, why would you regret buying one and not the other?

assumedly, you're regretting not having bought the investment that has done better in the past. Because you missed out on getting higher returns on the investment you didn't buy (this blows the notion that the returns are the same. they're not).

furthermore, if you are regretting not having bought a stock (because it did better than the other one) this tells you absolutely nothing about the future performance of the stock you didn't buy. If you're assuming the stock you should have bought will do better than the one you did in the future, because that was true of the past, I think you may be mistaken. past performance is no indication of future results. that's not just a saying. sometimes the first shall be the last. the past is not prologue. this is known as chasing performance. you can't go back in time and get the performance of the past. and unfortunately, you really can't know the performance of any investment in the future.

i know this isn't the answer you're looking for, but i'd thought i'd throw in a couple things to think about.
“Hint: money flows into most funds after good performance, and goes out when bad performance follows.
— John C. Bogle

source: https://financinglife.org/bogle-quotes/
"May you live as long as you want and never want as long as you live" -- Irish Blessing | "Invest we must" -- Jack Bogle

Topic Author
international001
Posts: 832
Joined: Thu Feb 15, 2018 7:31 pm

Re: When to sell and buy funds or stocks

Post by international001 » Sun Jun 16, 2019 4:02 pm

arcticpineapplecorp. wrote:
Sat Jun 15, 2019 3:51 pm
international001 wrote:
Mon Jun 10, 2019 3:56 pm
This is something that I never saw discussed

Let's say you have security X that you wan to sell to buy security Y at time T. Ideally, you should have bought Y in the first place, but let's assume you regretted about it for whatever reason. For simplicity, let's assume both of them are equivalent in terms of risk/return.
if they have the same risk and return, why would you regret buying one and not the other?

assumedly, you're regretting not having bought the investment that has done better in the past. Because you missed out on getting higher returns on the investment you didn't buy (this blows the notion that the returns are the same. they're not).

furthermore, if you are regretting not having bought a stock (because it did better than the other one) this tells you absolutely nothing about the future performance of the stock you didn't buy. If you're assuming the stock you should have bought will do better than the one you did in the future, because that was true of the past, I think you may be mistaken. past performance is no indication of future results. that's not just a saying. sometimes the first shall be the last. the past is not prologue. this is known as chasing performance. you can't go back in time and get the performance of the past. and unfortunately, you really can't know the performance of any investment in the future.

i know this isn't the answer you're looking for, but i'd thought i'd throw in a couple things to think about.
“Hint: money flows into most funds after good performance, and goes out when bad performance follows.
— John C. Bogle

source: https://financinglife.org/bogle-quotes/
I'm assuming same return. I'm not trying to consider risk in the mixture (assume constant growth), since it's just a simple math exercise. Of course, things can get more complicated and you'd have to do something like a Montecarlo simulation

Post Reply