Join Early Retirement Today
Reply
 
Thread Tools Search this Thread Display Modes
Selling / rebalancing algorithm (the opposite of dollar-cost averaging)
Old 11-03-2022, 01:34 AM   #1
Recycles dryer sheets
 
Join Date: May 2020
Location: Calgary
Posts: 61
Selling / rebalancing algorithm (the opposite of dollar-cost averaging)

I've always liked dollar-cost averaging during the accumulation phase of life, to automatically and mindlessly buy more units of when prices are down, and less units when prices are up. You know, the "buy low" part.

But I have yet to come across or devise a simple algorithm for selling equities to support a lifestyle in retirement. Obviously the worst answer would be to sell the same dollar-value each month, since then you'd be selling more units when prices are low, the opposite of "sell high".

Anyone know of any selling algorithms?

I'm thinking something along the lines of setting a limit order to sell at a price x% higher than the maximum price over the past year, and then burn through your cash while you wait for your limit order to come through. If the limit order doesn't come through and you start running out of cash, you'd might have to progressively lower your threshold to avoid selling in desperation, and maybe you'd also change the size of your order (I could see an argument to increasing the size of your sell order so that when it does come through you're replenishing your cash basket more, but I could see an argument to reducing the size of your order since you're selling at a cheaper price.)

When the stocks eventually rise to the point where you hit the limit and replenish your cash position, you'd then put in another stop limit order at a higher price, for the next replenishment.

Anyone know any strategy like this? I guess it's really a rebalancing timing strategy, to shift equity positions into cash (or fixed income products), to support regular withdrawals from the cash position.

I guess I could write an algorithm and try to optimize it over historic data by adjusting the few parameters. I do optimizing like this in my day job. I'd just need historic high/low/close data over 25ish years. Where can I download such data for free?
music-and-ski is offline   Reply With Quote
Join the #1 Early Retirement and Financial Independence Forum Today - It's Totally Free!

Are you planning to be financially independent as early as possible so you can live life on your own terms? Discuss successful investing strategies, asset allocation models, tax strategies and other related topics in our online forum community. Our members range from young folks just starting their journey to financial independence, military retirees and even multimillionaires. No matter where you fit in you'll find that Early-Retirement.org is a great community to join. Best of all it's totally FREE!

You are currently viewing our boards as a guest so you have limited access to our community. Please take the time to register and you will gain a lot of great new features including; the ability to participate in discussions, network with our members, see fewer ads, upload photographs, create a retirement blog, send private messages and so much, much more!

Old 11-03-2022, 02:54 AM   #2
Thinks s/he gets paid by the post
 
Join Date: Mar 2012
Posts: 3,345
Quote:
Obviously the worst answer would be to sell the same dollar-value each month, since then you'd be selling more units when prices are low, the opposite of "sell high".
Instead of withdrawing the same dollar value each month, how about withdrawing the same percentage each month? So, when the price is low you'll withdraw less and when the price is high you'll withdraw more.

The "algorithm" you're attempting define is little more than market timing. We know it rarely works for buying, so it's going to be little different when selling.

Quote:
I guess I could write an algorithm and try to optimize it over historic data by adjusting the few parameters. I do optimizing like this in my day job. I'd just need historic high/low/close data over 25ish years.
Folks with technical backgrounds want to believe that they can excel at investing by analyzing data, that past data is a predictor for future results...or how markets will move. It's not true. It's a waste of time and the simple no-effort approach will likely provide better results. You're certainly free to experiment and prove it for yourself.

Yahoo Finance provides the data you want on the historical prices tab for any security you want. There is a download link on the top right of the table.

For example:
https://finance.yahoo.com/quote/XOM/history?p=XOM

https://query1.finance.yahoo.com/v7/...stedClose=true
njhowie is offline   Reply With Quote
Old 11-03-2022, 03:49 AM   #3
Thinks s/he gets paid by the post
gcgang's Avatar
 
Join Date: Sep 2012
Posts: 1,500
If you have a MF or ETF sell same number of shares each month. Some months you can live the hi life, others youíll need to tighten your belt.
__________________
In theory, there's no difference between theory and practice. In practice, there is. YB
gcgang is offline   Reply With Quote
Old 11-03-2022, 03:54 AM   #4
Full time employment: Posting here.
 
Join Date: Feb 2019
Location: St Pete
Posts: 832
A regular withdrawal ($) effectively is reverse DCA... you'll sell fewer shares to get x dollars when prices are high. My "algorithm" is simple, end of year, sell enough to replenish cash to cover the next years anticipated expenses while minimizing taxes (which makes it a bit less simple - primarily managing MAGI for ACA). If taxes were non-existent, I would likely keep a smaller cash cushion and withdraw monthly to keep more fully invested but that would lock in too much income early in the year and make managing MAGI much more difficult.


Not my Plan A but a contingency plan that would technically be timing the market is that if there was a major market decline at the end of the year just as I'm preparing to sell, I might draw from my HELOC to keep fully invested until (hoping) the market recovered. I would still sell to realize income for MAGI and stepping up the basis but still remaining in the market beyond my planned "sell" point at the end of the year. Of course, this would be adding a little bit of leverage and interest expenses to my portfolio.
__________________
FIREd 7/2021 at age 47
FLSUnFIRE is offline   Reply With Quote
Old 11-03-2022, 04:45 AM   #5
Give me a museum and I'll fill it. (Picasso)
Give me a forum ...
 
Join Date: Aug 2016
Location: Northern Virginia
Posts: 5,302
I sell tactically, not by a schedule. I raised quite a bit last year. Fortunately now you can get a decent return from cash.
Montecfo is offline   Reply With Quote
Old 11-03-2022, 06:14 AM   #6
Give me a museum and I'll fill it. (Picasso)
Give me a forum ...
audreyh1's Avatar
 
Join Date: Jan 2006
Location: Rio Grande Valley
Posts: 33,891
Selling algorithm: rebalancing takes care of that. It automatically sells from the winners (or least losers). I do the withdrawal and rebalancing one a year in early Jan. The withdrawal typically goes to a high yield savings account which then feeds my checking monthly.

My withdrawal calculation is based on each Dec 31 portfolio value so I do take a pay cut after market down years as we draw the same x% each year. The pay cut has not been a problem for us as we often experience strong market up years ahead of it so income rises on average.
__________________
Retired since summer 1999.
audreyh1 is online now   Reply With Quote
Old 11-03-2022, 02:22 PM   #7
Recycles dryer sheets
 
Join Date: May 2020
Location: Calgary
Posts: 61
Quote:
Originally Posted by njhowie View Post
The "algorithm" you're attempting define is little more than market timing. We know it rarely works for buying, so it's going to be little different when selling.

Folks with technical backgrounds want to believe that they can excel at investing by analyzing data, that past data is a predictor for future results...or how markets will move. It's not true. It's a waste of time and the simple no-effort approach will likely provide better results. You're certainly free to experiment and prove it for yourself.

Yahoo Finance provides the data you want on the historical prices tab for any security you want. There is a download link on the top right of the table.

For example:
https://finance.yahoo.com/quote/XOM/history?p=XOM

https://query1.finance.yahoo.com/v7/...stedClose=true
Thanks for the thoughts and the link to data. I donít want to design a fancy algorithm, I wish there was something as brainless as dollar cost averaging is for buying. I just think there must be something simple thatís a little better than selling on December 31st each year. Iíll work on something as simple as possible.
music-and-ski is offline   Reply With Quote
Old 11-03-2022, 03:06 PM   #8
Thinks s/he gets paid by the post
GravitySucks's Avatar
 
Join Date: Feb 2014
Location: Syracuse
Posts: 3,354
I usually withdraw once a quarter rebalancing on the way out. The last few years I take out more or less than a quarters worth based on how I feel things are going.
__________________
ďNo, not rich. I am a poor man with money, which is not the same thing"
GravitySucks is online now   Reply With Quote
Old 11-03-2022, 03:56 PM   #9
Give me a museum and I'll fill it. (Picasso)
Give me a forum ...
OldShooter's Avatar
 
Join Date: Mar 2017
Location: City
Posts: 9,062
Quote:
Originally Posted by njhowie View Post
... Folks with technical backgrounds want to believe that they can excel at investing by analyzing data, that past data is a predictor for future results...or how markets will move. It's not true. ...
Yes! How true. My first foray into investing, literally 50 years ago, was an effort to use Fourier transforms to analyze stock price series. It didn't work, of course.

@music-and-ski, what I slowly learned is what sixty years of academic research has shown: The equity market is best viewed as a random process with a slight upward bias. So while it is certainly possible to develop an algorithm that fits historical data, it will not be predictive. You can't predict random.

Assuming you have a simple portfolio of broad index funds as the research recommends, the withdrawal decision just becomes a decision to sell from the equity side, the fixed income side, or a little from both. Your AA and recent market effects on it will guide you in most cases.

As far as when to sell, that's mostly a matter of psychology. Selling in January maybe indicates some pessimism about the year's market. Selling only as needed leaves money in the market longer and is maybe a sign of optimism (or of faith in the market's long-term upward bias). Like all decisions to trade, this too is a market timing decision. No reason to be ashamed.

One salvation is that you are withdrawing a relatively small amount of money; just a few percent of the portfolio. So a decision that turns out to be wrong will not affect you very much and you can still crow about decisions that turn out to be right.
__________________
Ignoramus et ignorabimus
OldShooter is offline   Reply With Quote
Old 11-03-2022, 04:03 PM   #10
Give me a museum and I'll fill it. (Picasso)
Give me a forum ...
 
Join Date: Jun 2016
Posts: 6,301
I have always followed the formula of spending cash on hand first, replenishing cash on hand from fixed income interest and or maturing bonds, then using equities.
I haven’t touched equities yet and there exists a chance I may never have to touch equities out of need and only by desire for rebalancing.
COcheesehead is offline   Reply With Quote
Old 11-03-2022, 04:11 PM   #11
Give me a museum and I'll fill it. (Picasso)
Give me a forum ...
SecondCor521's Avatar
 
Join Date: Jun 2006
Location: Boise
Posts: 7,054
When I was buying, my algorithm was to buy as much as possible, as soon as possible, and rebalance to my target AA according to my IPS, which in turn was based on my life circumstances.

Now that I am selling, my algorithm is to sell as little as possible, as late as possible, and rebalance to my target AA according to my IPS, which in turn is based on my life circumstances.
__________________
"At times the world can seem an unfriendly and sinister place, but believe us when we say there is much more good in it than bad. All you have to do is look hard enough, and what might seem to be a series of unfortunate events, may in fact be the first steps of a journey." Violet Baudelaire.
SecondCor521 is offline   Reply With Quote
Old 11-03-2022, 04:53 PM   #12
Give me a museum and I'll fill it. (Picasso)
Give me a forum ...
NW-Bound's Avatar
 
Join Date: Jul 2008
Posts: 34,755
People here know that I am a self-proclaiming market timer (a clean and not dirty one, as I take a shower everyday).

My withdrawal has nothing to do with my market timing, because I have a big cash buffer, way bigger than my annual expenses. I withdraw cash for expenses as I need, and never sell because I need cash.


Quote:
Originally Posted by OldShooter View Post
...
One salvation is that you are withdrawing a relatively small amount of money; just a few percent of the portfolio. So a decision that turns out to be wrong will not affect you very much and you can still crow about decisions that turn out to be right.
Yes. A few percent of selling or rebalancing will not make much of a difference.

My WR is less than 1%/year. My cash level is currently almost 40% of portfolio.

In the last month of October, I sold many OTM call options, and enough got assigned such that my stock AA dropped from 74% to 60%. This 14% additional cash is now sitting in a T-bill fund earning almost 3%/year.

And I am waiting to move this cash back to stocks. I like high stock AA, at 70-80%.
__________________
"Old age is the most unexpected of all things that happen to a man" -- Leon Trotsky (1879-1940)

"Those Who Can Make You Believe Absurdities Can Make You Commit Atrocities" - Voltaire (1694-1778)
NW-Bound is offline   Reply With Quote
Old 11-03-2022, 07:45 PM   #13
Recycles dryer sheets
 
Join Date: May 2020
Location: Calgary
Posts: 61
Quote:
Originally Posted by OldShooter View Post
Yes! How true. My first foray into investing, literally 50 years ago, was an effort to use Fourier transforms to analyze stock price series. It didn't work, of course.

@music-and-ski, what I slowly learned is what sixty years of academic research has shown: The equity market is best viewed as a random process with a slight upward bias. So while it is certainly possible to develop an algorithm that fits historical data, it will not be predictive. You can't predict random.

Assuming you have a simple portfolio of broad index funds as the research recommends, the withdrawal decision just becomes a decision to sell from the equity side, the fixed income side, or a little from both. Your AA and recent market effects on it will guide you in most cases.

As far as when to sell, that's mostly a matter of psychology. Selling in January maybe indicates some pessimism about the year's market. Selling only as needed leaves money in the market longer and is maybe a sign of optimism (or of faith in the market's long-term upward bias). Like all decisions to trade, this too is a market timing decision. No reason to be ashamed.

One salvation is that you are withdrawing a relatively small amount of money; just a few percent of the portfolio. So a decision that turns out to be wrong will not affect you very much and you can still crow about decisions that turn out to be right.
Ha I can tell we are the same in spirit. Thanks. Nice to meet you.

If itís a random process with a slight upward bias, then one should be able to do better than fixed % withdrawal on a schedule just by putting in some limit orders and waiting for things to rise before selling. Maybe Iíll model it as a Monte Carlo as a random correlated time series, rather than using historic data, to prove the point. Itís not ďmarket timingĒ, itís just recognizing that random processes have highs and lows. Hopefully Iíll be able to report back soon.
music-and-ski is offline   Reply With Quote
Old 11-03-2022, 08:16 PM   #14
Give me a museum and I'll fill it. (Picasso)
Give me a forum ...
OldShooter's Avatar
 
Join Date: Mar 2017
Location: City
Posts: 9,062
Nice to meet you too. Sad to say, though, is that there is a catch to "random." The distribution is not Gaussian.
__________________
Ignoramus et ignorabimus
OldShooter is offline   Reply With Quote
Old 11-03-2022, 10:11 PM   #15
Recycles dryer sheets
 
Join Date: May 2020
Location: Calgary
Posts: 61
Quote:
Originally Posted by audreyh1 View Post
Selling algorithm: rebalancing takes care of that. It automatically sells from the winners (or least losers). I do the withdrawal and rebalancing one a year in early Jan. The withdrawal typically goes to a high yield savings account which then feeds my checking monthly.

My withdrawal calculation is based on each Dec 31 portfolio value so I do take a pay cut after market down years as we draw the same x% each year. The pay cut has not been a problem for us as we often experience strong market up years ahead of it so income rises on average.
Have you thought about:
1) setting a trigger level for rebalancing, eg 5% off-target is when you sell the part that went high, and/or
2) using something less arbitrary than Dec 31 valuations for your calculation
??
music-and-ski is offline   Reply With Quote
Old 11-03-2022, 10:20 PM   #16
Recycles dryer sheets
 
Join Date: May 2020
Location: Calgary
Posts: 61
Quote:
Originally Posted by OldShooter View Post
Nice to meet you too. Sad to say, though, is that there is a catch to "random." The distribution is not Gaussian.
Ahh hereís an article https://towardsdatascience.com/statistical-properties-of-stock-prices-15145be752a2 looks complicated maybe Iíll just use historic prices instead, reality us sometimes so much easier to work with than math.
music-and-ski is offline   Reply With Quote
Old 11-03-2022, 10:31 PM   #17
Give me a museum and I'll fill it. (Picasso)
Give me a forum ...
audreyh1's Avatar
 
Join Date: Jan 2006
Location: Rio Grande Valley
Posts: 33,891
Quote:
Originally Posted by music-and-ski View Post
Have you thought about:
1) setting a trigger level for rebalancing, eg 5% off-target is when you sell the part that went high, and/or
2) using something less arbitrary than Dec 31 valuations for your calculation
??
1) I do have some bands and in Jan if things are pretty close to in balance thatís good enough. If there is a huge change during the year I may do some rebalancing. This doesnít happen often.

2) No. Dec 31 is it. I donít mess around with that. The timing is not that arbitrary because end of year I typically get a lot of distributions affecting my asset allocation.
__________________
Retired since summer 1999.
audreyh1 is online now   Reply With Quote
Old 11-04-2022, 12:29 AM   #18
Recycles dryer sheets
 
Join Date: May 2020
Location: Calgary
Posts: 61
I did some simulation with the daily TSX quotes from 1979, adjusted for inflation. Scenario was:
* Start with 800K investment (1979 dollars)
* Spending needs 100K 2022 dollars (26K 1979 dollars)
* Cash earns zero interest
* No commissions on sales.
Also, I didn't find the TSX total return index, just the TSX index (so, I guess dividends are ignored).


Parameters were:
a) cash refill amount (how high to fill up the tank of cash when choosing to sell)
b) if cash is less than X% and growth over Y days is greater than Z%, refill the tank.
Additionally, if the tank of cash ever gets completely empty, fill it up again to the top.

After running some genetic algorithm search, it seems that the best strategy in this scenario is quite simple:

KEEP CASH RESERVES AS SMALL AS POSSIBLE. Any gain from trying to wait until the TSX had risen an appropriate percentage is offset by the fact that having enough cash on hand to wait it out meant less was invested in equities.

Not the result I was expecting.
music-and-ski is offline   Reply With Quote
Old 11-04-2022, 04:09 AM   #19
Give me a museum and I'll fill it. (Picasso)
Give me a forum ...
NW-Bound's Avatar
 
Join Date: Jul 2008
Posts: 34,755
^^^

I am not sure about the Canadian market, but the period of 1980-2000 may be the strongest and longest bull run of the US market. It would pay to invest 100% during this period (I did not).

I wonder if your result changes any if you start from 2000. Or if you look at individual 10-year periods.

If the result does not change, then you know what to do.

If it changes, then there is no universal method that is applicable both for bull and bear periods. Next, one would need a bull/bear detector.
__________________
"Old age is the most unexpected of all things that happen to a man" -- Leon Trotsky (1879-1940)

"Those Who Can Make You Believe Absurdities Can Make You Commit Atrocities" - Voltaire (1694-1778)
NW-Bound is offline   Reply With Quote
Old 11-04-2022, 08:10 AM   #20
Give me a museum and I'll fill it. (Picasso)
Give me a forum ...
OldShooter's Avatar
 
Join Date: Mar 2017
Location: City
Posts: 9,062
Quote:
Originally Posted by music-and-ski View Post
Ahh hereís an article https://towardsdatascience.com/stati...s-15145be752a2 looks complicated maybe Iíll just use historic prices instead, reality us sometimes so much easier to work with than math.
Probably wise. To amplify a little from post #14:

The distribution has fat tails.
The distribution is asymmetric; the left tail is fatter.
Samples are not uncorrelated. The momentum effect is small but real.
The rightward bias is very noisy; it may take averaging over years to see it.

Finally, Nassim Taleb has observed that unless one knows what a distribution looks like (which we do not), one cannot know how many samples are needed to characterize it.

But at the bottom, sadly, IMO you are attempting to predict random behavior. If you figure it out, though, please let me know and tell no one else.
__________________
Ignoramus et ignorabimus
OldShooter is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dollar Cost Averaging - Anyone still buying? Disappointed FIRE and Money 31 02-13-2009 09:39 PM
Systematic Purchase (Dollar Cost Averaging) Frequency? Dude FIRE and Money 10 04-28-2008 07:44 PM
Dollar cost averaging is... a lie? Sisyphus Young Dreamers 43 07-09-2007 04:15 PM
Lump Sum or Dollar Cost Averaging your Roth/IRA mickeyd FIRE and Money 3 11-23-2006 04:38 PM

» Quick Links

 
All times are GMT -6. The time now is 10:49 AM.
 
Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2023, vBulletin Solutions, Inc.