My IPS in computer pseudocode [Investment Policy Statement]

Have a question about your personal investments? No matter how simple or complex, you can ask it here.
Post Reply
User avatar
Topic Author
villars
Posts: 206
Joined: Sat Jan 18, 2014 10:07 pm

My IPS in computer pseudocode [Investment Policy Statement]

Post by villars »

Since I joined this board 8 months ago, I have developed an investing habit that is so mechanical , I can describe it in computer pseudocode.
It is basically another way to write an IPS.
For the IT Bogleheads , here's my algorithm in pseudocode. I'm curious if others invest like this.

Code: Select all

SETUP: 

BOND_ALLOCATION = ( age -  35 ) * 2  //at my current age ( 41.5 ) , this is 13%  ,  at age 60 it will be 50/50
INTERNATIONAL_ALLOCATION = 35%  // my preference
SAVING_RATE = 0.3  //30% as recommended to me in another thread 


Adjust 401k incoming contrubutions to match asset allocation // currently 13% bonds, 87% stocks
Adjust 401k contributions to 15% of paycheck // goes to zero when annual max is hit


EVERY PAYCHEK //  2 times a month 

deposit paycheck 
total savings=gross pay * SAVING_RATE  
taxable savings = total savings - 401k contribution this paycheck 

round taxable savings to closest 100

if taxable savings < 1000 , wait till next paycheck

if taxable savings >1000 , send to vanguard
  check current porfolio numbers ( taxable and non taxable)
  if bonds > BOND_ALLOCATION //buy stocks
      if international stock < INTERNATIONAL_ALLOCATION 
       buy VTIAX //vanguard international
     else 
       buy VTSAX // total stock market
  else //bond allocation is too low  
      buy VWITX // intermediate tax exempt
 end  
end 


EVERY QUARTER :

//1) rebalance using 401k to avoid tax issues 

check asset allocation in entire portfolio
if bonds > BOND_ALLOCATION + 5 // 5% tolerance band 
  buy equities in 401k to adjust bonds back to BOND_ALLOCATION
else if  bonds < BOND_ALLOCATION - 5 
  buy bonds in 401k to adjust bonds back to BOND_ALLOCATION
end 

//2) check for extra savings:
go to checking account
extra savings = total in  checking - 30,000 //30K is for spending + first tier EF 
if extra savings >0 
  pay down mortgage with extra savings
end
if extra savings < 0 
  throw exception ( "We need to spend less!")
end


EVERY YEAR:

recalculate BOND_ALLOCATION 
adjust incoming contributions to 401k to match allocation 
calculate net worth
reassess saving rate


//TO DO: 
//incorporate I-bond purchases
//incorporate backdoor roth 
//incorporate HSA contributions

//potential problems: may end up with too much VWITX from new contributions if stocks grow quickly 
User avatar
Steelersfan
Posts: 4129
Joined: Thu Jun 19, 2008 8:47 pm

Re: My IPS in computer pseudocode

Post by Steelersfan »

Can you redo that in IBM 360 Assembler? That's the last programming language I knew. :annoyed

Then I could comment. :happy
User avatar
cheese_breath
Posts: 11786
Joined: Wed Sep 14, 2011 7:08 pm

Re: My IPS in computer pseudocode

Post by cheese_breath »

Steelersfan wrote:Can you redo that in IBM 360 Assembler? That's the last programming language I knew. :annoyed

Then I could comment. :happy
What about 1401 autocoder? Or maybe 1620 SPS?
The surest way to know the future is when it becomes the past.
joppy
Posts: 534
Joined: Thu Feb 22, 2007 2:45 am

Re: My IPS in computer pseudocode

Post by joppy »

So at age 85 you are 100% bonds, and at age 90 you buy bonds on margin?

- Joppy
User avatar
whaleknives
Posts: 1238
Joined: Sun Jun 24, 2012 7:19 pm

Re: My IPS in computer pseudocode

Post by whaleknives »

joppy wrote:So at age 85 you are 100% bonds, and at age 90 you buy bonds on margin?
Thus we come to Limitations of models, where the rules change at the limits. All you need are more formulas. Thus we see the exponential growth of software patches.
"I'm an indexer. I own the market. And I'm happy." (John Bogle, "BusinessWeek", 8/17/07) ☕ Maritime signal flag W - Whiskey: "I require medical assistance."
User avatar
Topic Author
villars
Posts: 206
Joined: Sat Jan 18, 2014 10:07 pm

Re: My IPS in computer pseudocode

Post by villars »

I better turn off the program before I retire in that case :D

Seriously though, I did the exercise to really see how much I can simplify investing.

Surprisingly, even with a simple 3-fund portfolio like I am doing, you still cannot get all cases covered with a one page algorithm, especially if you want to be tax efficient.

The big benefit for me to writing the IPS this way is staying the course. Just follow the instructions and I should be fine.
User avatar
dodecahedron
Posts: 6607
Joined: Tue Nov 12, 2013 11:28 am

Re: My IPS in computer pseudocode

Post by dodecahedron »

villars wrote:I better turn off the program before I retire in that case :D

Seriously though, I did the exercise to really see how much I can simplify investing.

Surprisingly, even with a simple 3-fund portfolio like I am doing, you still cannot get all cases covered with a one page algorithm, especially if you want to be tax efficient.

The big benefit for me to writing the IPS this way is staying the course. Just follow the instructions and I should be fine.
Very elegant approach to succinctly stating your operational process. Although I am at a very different age and stage of life, I might well use the pseudo-code approach in writing down my own IPS (once I figure it out!) because it is a very efficient way of letting my daughters know what to do with my investments should I become incapacitated and possibly as a model to inspire emulation/adaptation for their own uses after my death.
User avatar
BL
Posts: 9874
Joined: Sun Mar 01, 2009 1:28 pm

Re: My IPS in computer pseudocode

Post by BL »

Good way to practice your thought processes to help you follow through. Grandkids in Science Olympiad do something like "Write it, Do it". It is probably not in code, but is good mental practice of precise writing so that someone (else) can follow the directions precisely.
User avatar
dratkinson
Posts: 6116
Joined: Thu Jul 26, 2007 6:23 pm
Location: Centennial CO

Re: My IPS in computer pseudocode

Post by dratkinson »

For those of us too lazy to re-read our IPS every month, I say let the machine do.


Conditional formatting.

If you want to, you can implement your pseudo code in Excel by using conditional formatting to change the font color of an asset's value. Then let Excel's font-color changes implement your IPS to remind you where to allocate new money/rebalance.

Target AA sheet. Defines your desired conditions: stocks/bonds%, US/foreign%, rebalance bands%. Then given total portfolio value, compute low/target/high values for each asset.

Rebalance AA sheet. Compare current asset values against computed values and use conditional formatting to mark each value appropriately: red font=too low, black front=within range, green font=too high... like a runway VASI system for each asset.

I did above. It seems to work well. And for the past two years my Excel tracking sheet has been nagging, "buy bonds". So I do and the bond's red font value changes back to black.

Haven't yet figured out how to implement an age glide path to increment stock/bond allocation; so for now that remains a manual process of tweaking my Target AA sheet. But as I'm thinking I may want to be permanently 40/60 in retirement, there is no real need for a glide path feature.


Macros.

Can also use Excel's marcos in blank cells to give you additional reminders. I use one in my Roth tracking to tell me where to send fund distributions, to "buy low", because I don't use a mmkt as a distribution target.

A blank cell adjacent to each asset contains a macro to display "--distro-->", or blank. Determination is made based on fund with lowest price in 52-week range: manual look-up/entry prior to fund distributions. Then I call CRS and make distribution changes.

It gives me something to do since I'm saving a lot of time by not re-reading my IPS every month.
Last edited by dratkinson on Sat Aug 02, 2014 4:02 pm, edited 2 times in total.
d.r.a., not dr.a. | I'm a novice investor; you are forewarned.
User avatar
LadyGeek
Site Admin
Posts: 95696
Joined: Sat Dec 20, 2008 4:34 pm
Location: Philadelphia
Contact:

Re: My IPS in computer pseudocode

Post by LadyGeek »

Very cool. 8-) However, you didn't initialize your age - it's in the comment field. :)

I also expanded the variable in the thread title. (You can change it by editing the Subject: line in Post #1.)
Wiki To some, the glass is half full. To others, the glass is half empty. To an engineer, it's twice the size it needs to be.
sscritic
Posts: 21853
Joined: Thu Sep 06, 2007 8:36 am

Re: My IPS in computer pseudocode

Post by sscritic »

⍝ Your comments are all wrong. A comment starts with *. See your COBOL manual.

⍝ My favorite comment indicator is the lamp.
The symbol ⍝, for obvious reasons called "lamp", indicates a comment:
User avatar
LadyGeek
Site Admin
Posts: 95696
Joined: Sat Dec 20, 2008 4:34 pm
Location: Philadelphia
Contact:

Re: My IPS in computer pseudocode [Investment Policy Stateme

Post by LadyGeek »

villars wrote:

Code: Select all

if extra savings < 0 
  throw exception ( "We need to spend less!")
end
Hilarious! Where do you catch the exception (throw must have a catch)? Go to: Household budget
Wiki To some, the glass is half full. To others, the glass is half empty. To an engineer, it's twice the size it needs to be.
User avatar
Topic Author
villars
Posts: 206
Joined: Sat Jan 18, 2014 10:07 pm

Re: My IPS in computer pseudocode

Post by villars »

LadyGeek wrote:Very cool. 8-) However, you didn't initialize your age - it's in the comment field. :)

I also expanded the variable in the thread title. (You can change it by editing the Subject: line in Post #1.)
Ah, yes!. un-initialized variables and uncaught exceptions :oops: . classic signs of sloppy code. Good thing I don't write code for a living.

The exception for "spend less money" is meant as time for a conversation with DW. So far has not been triggered.

Now , how to incorporate I-bond purchases twice a year?
EyeDee
Posts: 1388
Joined: Mon Feb 19, 2007 11:15 pm

Excel Stock Percentage

Post by EyeDee »

dratkinson wrote:. . .
Haven't yet figured out how to implement an age glide path to increment stock/bond allocation; so for now that remains a manual process of tweaking my Target AA sheet. But as I'm thinking I may want to be permanently 40/60 in retirement, there is no real need for a glide path feature.
. . .
.
In Excel to get a glide path for stock allocation, you could do something like:

=IF(G7>89,40,IF(G7>59,55.5-0.5*(G7-59),115-G7))

where G7 is your age and bonds would be 100 - stock percentage.

If you do not want to update G7 yearly with your age, I believe you could do something like making G7 be: =YEAR(TODAY())-1963 where TODAY() is the internal function to return the current date and 1963 would need to be replaced with your birth year. Unfortunately, I believe use of TODAY() function might cause you to get prompted on exit to save your spreadsheet each time you go in if you do not save it for other reasons.
Last edited by EyeDee on Sat Aug 02, 2014 6:30 pm, edited 1 time in total.
Randy | SCA - Build Savings early by living below one's means, minimize Costs including taxes, and maintain a diverse Allocation.
User avatar
LadyGeek
Site Admin
Posts: 95696
Joined: Sat Dec 20, 2008 4:34 pm
Location: Philadelphia
Contact:

Re: My IPS in computer pseudocode [Investment Policy Stateme

Post by LadyGeek »

^^^ Remember that the OP is using Pseudocode. Excel formulas might be overkill.
villars wrote:The exception for "spend less money" is meant as time for a conversation with DW. So far has not been triggered.

Now , how to incorporate I-bond purchases twice a year?
That's easy:
villars wrote:

Code: Select all

EVERY QUARTER :

if QUARTER Mod 2 = 0
  buy I-Bond
end
I'm hoping that DW is involved with both your IPS and budget discussions before you need to throw an exception. I suspect DW will throw something else, and not virtually, if you get to this point.
Wiki To some, the glass is half full. To others, the glass is half empty. To an engineer, it's twice the size it needs to be.
EyeDee
Posts: 1388
Joined: Mon Feb 19, 2007 11:15 pm

Excel Stock Percentage

Post by EyeDee »

LadyGeek wrote:^^^ Remember that the OP is using Pseudocode. Excel formulas might be overkill.
.
Sorry for the confusion, my post was not for the OP but for dratkinson who was talking about Excel implementations or so I thought.
Randy | SCA - Build Savings early by living below one's means, minimize Costs including taxes, and maintain a diverse Allocation.
User avatar
LadyGeek
Site Admin
Posts: 95696
Joined: Sat Dec 20, 2008 4:34 pm
Location: Philadelphia
Contact:

Re: My IPS in computer pseudocode [Investment Policy Stateme

Post by LadyGeek »

Sorry, I missed that.
Wiki To some, the glass is half full. To others, the glass is half empty. To an engineer, it's twice the size it needs to be.
User avatar
dratkinson
Posts: 6116
Joined: Thu Jul 26, 2007 6:23 pm
Location: Centennial CO

Re: Excel Stock Percentage

Post by dratkinson »

EyeDee wrote:
LadyGeek wrote:^^^ Remember that the OP is using Pseudocode. Excel formulas might be overkill.
.
Sorry for the confusion, my post was not for the OP but for dratkinson who was talking about Excel implementations or so I thought.
An implementation is the next logical step after one goes through the effort to create pseudocode for a process. Happy to share the ideas for my implementation after recognizing same in portions OP's pseudocode.
d.r.a., not dr.a. | I'm a novice investor; you are forewarned.
User avatar
Topic Author
villars
Posts: 206
Joined: Sat Jan 18, 2014 10:07 pm

Re: My IPS in computer pseudocode [Investment Policy Stateme

Post by villars »

LadyGeek wrote: I'm hoping that DW is involved with both your IPS and budget discussions before you need to throw an exception. I suspect DW will throw something else, and not virtually, if you get to this point.
That cracked me up !!. She is involved .
:sharebeer
User avatar
dratkinson
Posts: 6116
Joined: Thu Jul 26, 2007 6:23 pm
Location: Centennial CO

Re: My IPS in computer pseudocode [Investment Policy Stateme

Post by dratkinson »

OP. Your idea for reminder messages took root when I read it.

This month I'm responded to my first Excel reminder based on your idea. With no new money going into my Roth, still accumulating, and wanting to shoot for the moon (equities only, no bonds), the equities are rebalanced by redirecting quarterly distributions: no mmkt fund drag. But I need to remember quarterly to check/change the distribution instructions. So solution was to display a quarterly-only reminder, implemented as:

=IF(MONTH(NOW())/3=INT(MONTH(NOW())/3),"Quarterly reminder: check/reset distribution target.","")

Now all I need to do is decide whether to buy low, or chase momentum. But at least I didn't miss the distribution schedule this time.

Thanks for the idea.
d.r.a., not dr.a. | I'm a novice investor; you are forewarned.
User avatar
aainvestor
Posts: 512
Joined: Fri Mar 02, 2007 1:12 pm
Location: Northern Virginia

Re: My IPS in computer pseudocode [Investment Policy Stateme

Post by aainvestor »

I don't know how I missed this. Any chance I can get this coded on punch cards for my IBM mainframe?

F=
technovelist
Posts: 3611
Joined: Wed Dec 30, 2009 8:02 pm

Re: My IPS in computer pseudocode [Investment Policy Stateme

Post by technovelist »

aainvestor wrote:I don't know how I missed this. Any chance I can get this coded on punch cards for my IBM mainframe?

F=
I think you would find that the air-conditioning bill for your mainframe would be your biggest investment expense item. :moneybag
In theory, theory and practice are identical. In practice, they often differ.
User avatar
Sunny Sarkar
Posts: 2443
Joined: Fri Mar 02, 2007 12:02 am
Location: Flower Mound, TX
Contact:

Re: My IPS in computer pseudocode

Post by Sunny Sarkar »

villars wrote:Surprisingly, even with a simple 3-fund portfolio like I am doing, you still cannot get all cases covered with a one page algorithm, especially if you want to be tax efficient.
why not?

Code: Select all

tbm  = if age>100 then 100, else age  //tax-sheltered account
tism = 20% of (100-tbm)   
tsm  = 100 -tbm -tism 

if currentbonds - tbm > 5 or < -5 then rebalance, else chill
Last edited by Sunny Sarkar on Sat Jul 11, 2015 2:39 am, edited 1 time in total.
"Buy-and-hold, long-term, all-market-index strategies, implemented at rock-bottom cost, are the surest of all routes to the accumulation of wealth" - John C. Bogle
User avatar
JamesSFO
Posts: 3404
Joined: Thu Apr 26, 2012 10:16 pm

Re: My IPS in computer pseudocode

Post by JamesSFO »

Sunny Sarkar wrote:
villars wrote:Surprisingly, even with a simple 3-fund portfolio like I am doing, you still cannot get all cases covered with a one page algorithm, especially if you want to be tax efficient.
why not?

Code: Select all

tbm  = if age>100 then 100, else age  //tax-sheltered account
tism = 20*(100-tbm)   
tsm  = 100 -tbm -tism 

if currentbonds - tbm > 5 or < -5 then rebalance, else chill
Possible error maybe 0.20*(100-tbm)?
User avatar
dratkinson
Posts: 6116
Joined: Thu Jul 26, 2007 6:23 pm
Location: Centennial CO

Re: My IPS in computer pseudocode [Investment Policy Stateme

Post by dratkinson »

villars, I've continued to play with your idea for automated reminder notes.

Believe I've created a reminder of everything I typically need. So far I've got these working:
  • "January: Set annual fed/state tax withholdings. See note, left."
    "January: Reset Target Asset Allocation. See note, left."
    "September: Double check fed/state tax withholdings estimate. See note, left."
    "Investment account: asset rebalance required. See note, left."
    "Roth account: asset rebalance required. See note, left."
    "Quarterly: Double check Roth distribution target. See note, left."
    "End of quarter: Update high-low price data. See note, left."
    "Portfolio: Sector rebalance required. See note, left."
The reminders are place on my "Home, Rebalance" sheet. Each reminder is composed of 2 cells:
Left cell: (1) contains comment/note of amplifying instructions and (2) used to indicate task completion.
Right cell: contains test condition and popup reminder.

Conditional formatting (bold red font, bright yellow background---not able to duplicate here) is applied to both cells and all cells containing reminder, while condition is active, otherwise not. Makes active reminder hard to miss. And allows inactive reminder to "disappear".

Example. On 1 Jan, these reminders will appear.
January: Set annual fed/state tax withholdings. See note, left.
January: Reset Target Asset Allocation. See note, left.

Following my notes, I check/adjust withholdings and mark comment/note cell as "done", inactive, giving:
done | January: Set annual fed/state tax withholdings. See note, left.
January: Reset Target Asset Allocation. See note, left.

Following my notes, I adjust target AA for I bonds I will buy during the year and mark comment/note cell as "done", inactive, giving:
done | January: Set annual fed/state tax withholdings. See note, left.
done | January: Reset Target Asset Allocation. See note, left.

When February arrives, the triggering condition is gone and the reminders disappear, giving:
done
done

...which reminds me to clear the "done" flag from the comment/note cell.


I use to have to remember more things, create task lists, check off items completed. What month is it? What should I be doing? Have I done it? What am I forgetting? ....

Thankfully, using your idea, believe I've automated most needed investment reminders. And the amplifying notes remind me how to do each task and are easy to update.

And if I've forgotten any reminder, should be easy enough to add when I do remember it. We'll see how the next year goes.


Did I tell you that I really, really like your idea! :D
d.r.a., not dr.a. | I'm a novice investor; you are forewarned.
Post Reply