Tracking bonds in google spreadsheet or other from CUSIP?

Discussion of the Bond portion of the Permanent Portfolio

Moderator: Global Moderator

Post Reply
coinstar
Associate Member
Associate Member
Posts: 36
Joined: Mon Jan 05, 2015 8:02 pm

Tracking bonds in google spreadsheet or other from CUSIP?

Post by coinstar »

I found an old thread on here where one member found a way to pull the bond value from Fidelity but that method doesn't work anymore. I think Fidelity locked it off. Now I'm updating my spreadsheets by hand. Any better way to do it? I'm not locked into google spreadsheets.
User avatar
Kriegsspiel
Executive Member
Executive Member
Posts: 4052
Joined: Sun Sep 16, 2012 5:28 pm

Re: Tracking bonds in google spreadsheet or other from CUSIP?

Post by Kriegsspiel »

=Index(importxml("http://wsj.com/mdc/public/page/2_3020-t ... tml","//tr[td='"&D6&"']"),1,4)

Where D6 is my cell with the maturity in it. I can't even remember where I got that formula from. Probably fnord.
You there, Ephialtes. May you live forever.
User avatar
dualstow
Executive Member
Executive Member
Posts: 14292
Joined: Wed Oct 27, 2010 10:18 am
Location: synagogue of Satan
Contact:

Re: Tracking bonds in google spreadsheet or other from CUSIP?

Post by dualstow »

Yeah, probably from fnord.
I have this in a cell:

=vlookup(date(2041,11,15),wsj!A206:C304,3,FALSE)
- "wsj" is the name of a tab in the same sheet that loads all that Wall Street Journal data, the same as Krieg's above I guess.
- After enough instruments are issued, I have to adjust the cell range, putting a bigger number after "C:" so that the CUSIP can still be found.
- I think the google sheet updates around 3:00pm EST and Fidelity the next morning, but I'm not positive.
9pm EST Explosions in Iran (Isfahan) and Syria and Iraq. Not yet confirmed.
coinstar
Associate Member
Associate Member
Posts: 36
Joined: Mon Jan 05, 2015 8:02 pm

Re: Tracking bonds in google spreadsheet or other from CUSIP?

Post by coinstar »

Kriegsspiel wrote: =Index(importxml("http://wsj.com/mdc/public/page/2_3020-t ... tml","//tr[td='"&D6&"']"),1,4)

Where D6 is my cell with the maturity in it. I can't even remember where I got that formula from. Probably fnord.
This works, thank you. It only updates at 3pm EST daily, correct?
fnord123
Executive Member
Executive Member
Posts: 233
Joined: Sun Apr 25, 2010 9:33 pm

Re: Tracking bonds in google spreadsheet or other from CUSIP?

Post by fnord123 »

Dualstow pretty much nailed what I do.  The only difference is I lay out the cells like this:

02/15/2039 30 Year Treasury    | $1,216.17
05/15/2039 30 Year Treasury    | $1,357.89

The first (A) column is a text description of the bond - nice and readable
The second (B) column has the following formula:  =10*vlookup(datevalue(left(A32,10)),'WSJ Treasury Prices'!$A$1:$D$498,3,FALSE)

The datevalue(left(A32,10)) part is a tweak that allows me to avoid having to go in and muck with the formula to add new bonds.  Instead, I just cut'n'paste the same formula next to every text label of every 30Y Treasury whose price I am interested in.
User avatar
jason
Executive Member
Executive Member
Posts: 248
Joined: Mon Jun 10, 2013 4:10 pm

Re: Tracking bonds in google spreadsheet or other from CUSIP?

Post by jason »

Kriegsspiel wrote: =Index(importxml("http://wsj.com/mdc/public/page/2_3020-t ... tml","//tr[td='"&D6&"']"),1,4)

Where D6 is my cell with the maturity in it. I can't even remember where I got that formula from. Probably fnord.
Regarding importing long term Treasury prices into my Google doc spreadsheet, one problem is that if I import using the above WSJ.com link, the prices are updated occasionally throughout the day, apparently, but are not priced real-time.  What I did in the past was add the % gain of TLT to the previous day's closing price of my Treasuries to get a very close estimation of the exact current price.  But since the WSJ prices change a few times during the day, I really can't add TLT"s % gain to the price because I may end up double-adding any price changes.  This was not a problem when I used to import the prices from Fidelity because that always just imported the previous day's closing price.  So, I could check it at any time during day and add the TLT % change to the price.  But Fidelity killed price importing into my spreadsheet.  So, my question is, is there any way that I can import the previous closing price rather than importing prices from WSJ, so that I can estimate real-time prices by adding the % change of TLT?
Thanks!
Jason
Last edited by jason on Fri Jan 29, 2016 1:17 pm, edited 1 time in total.
TrevorShrade
Junior Member
Junior Member
Posts: 5
Joined: Fri Dec 20, 2013 4:45 pm

Re: Tracking bonds in google spreadsheet or other from CUSIP?

Post by TrevorShrade »

jason wrote: is there any way that I can import the previous closing price rather than importing prices from WSJ, so that I can estimate real-time prices by adding the % change of TLT?
=IFERROR(Importxml("http://wsj.com/mdc/public/page/2_3020-treasury-"&TEXT(TODAY()-1,"YYYYMMDD")&".html","//tr[td='"&A1&"']/td[3]"),IFERROR(Importxml("http://wsj.com/mdc/public/page/2_3020-treasury-"&TEXT(TODAY()-2,"YYYYMMDD")&".html","//tr[td='"&A1&"']/td[3]"),Importxml("http://wsj.com/mdc/public/page/2_3020-treasury-"&TEXT(TODAY()-3,"YYYYMMDD")&".html","//tr[td='"&A1&"']/td[3]")))


Just change A1 to the cell that contains the maturity date in M/D/YYYY format.

If you receive an error make sure cell A1 is set to "Plain Text" by selecting Formant>Number>Plain Text
Last edited by TrevorShrade on Sat Jan 30, 2016 2:01 am, edited 1 time in total.
DragonJoey3
Full Member
Full Member
Posts: 56
Joined: Wed Dec 05, 2012 3:00 pm

Re: Tracking bonds in google spreadsheet or other from CUSIP?

Post by DragonJoey3 »

This pulls the data direct from the US treasury website where "A8" is the cell with the CUSIP in it. 

Code: Select all

=VLOOKUP(A8,IMPORTHTML("https://www.treasurydirect.gov/GA-FI/FedInvest/todaySecurityPriceDate.htm","table",1), 7, FALSE)
However it has a few limitations:
  • It only works after 1:00pm EST on days when the market is open
  • It is occasionally finicky and needs the 1 changed to a 0.  (Treasury removes a table from the site).


Still it's the best resource I've found without bothering to lookup how to POST data to a URL from Google Docs.  I recommend giving it a shot after 1pm Monday afternoon.
User avatar
Greg
Executive Member
Executive Member
Posts: 1126
Joined: Sun May 20, 2012 6:12 pm
Location: Maryland

Re: Tracking bonds in google spreadsheet or other from CUSIP?

Post by Greg »

For those that track U.S. Treasury STRIPS, I figured this one out today:

=ImportXml("http://wsj.com/mdc/public/page/2_3020-t ... tml","//tr[td='2042 Aug 15']/td[3]")

Put the bond in the "2042 Aug 15" spot. It'll pop up with two numbers (not sure why). But then you can just hide those and choose the bottom number which is the bond price and copy and paste it into a location you want.

Also is another thread that maybe should get linked together with this one. Not sure if there are other ones on this forum or not.

http://gyroscopicinvesting.com/forum/bo ... ogle-docs/
Background: Mechanical Engineering, Robotics, Control Systems, CAD Modeling, Machining, Wearable Exoskeletons, Applied Physiology, Drawing (Pencil/Charcoal), Drums, Guitar/Bass, Piano, Flute

"you are not disabled by your disabilities but rather, abled by your abilities." -Oscar Pistorius
Post Reply