gnucash bond quotes

Discussion of the Bond portion of the Permanent Portfolio

Moderator: Global Moderator

Post Reply
User avatar
ZedThou
Full Member
Full Member
Posts: 53
Joined: Thu Sep 22, 2011 9:59 pm

gnucash bond quotes

Post by ZedThou »

Ever since buying bonds I've been unable to track their price in gnucash without manually entering the prices. So now I've made an extension of the Finance::Quote Perl modules that grabs the quotes from Fidelity Fixed Income Search, given the CUSIP. I'll submit it for inclusion into the Finance::Quote distribution, but in the meantime I thought I'd advertise it here since it may be useful to some. The module is at
http://hea-www.harvard.edu/~rpete/FidelityFixed.pm which you would put into the Finance/Quote Perl module subdirectory, and then modify Quote.pm to include FidelityFixed (line 170 or so).
Oh, such a beautiful tarmac. Look how smooth it is. See how smooth it is? And it's warm, and it's hard. - Charley Boorman Long Way Round
User avatar
ZedThou
Full Member
Full Member
Posts: 53
Joined: Thu Sep 22, 2011 9:59 pm

Re: gnucash bond quotes

Post by ZedThou »

Here are the security editor settings for a specific bond.

edit - it is counterintuitive but the Symbol field is the important one, rather than the CUSIP field

Image
Last edited by ZedThou on Fri Feb 10, 2012 7:46 pm, edited 1 time in total.
Oh, such a beautiful tarmac. Look how smooth it is. See how smooth it is? And it's warm, and it's hard. - Charley Boorman Long Way Round
User avatar
Storm
Executive Member
Executive Member
Posts: 1652
Joined: Tue Aug 24, 2010 1:04 pm

Re: gnucash bond quotes

Post by Storm »

Very interesting.  Does gnucash work well in Windows?  I've been using Google Docs to track my PP, but it is also quite a pain to have to manually type in the price of my long term treasuries every time.
"I came here for financial advice, but I've ended up with a bunch of shave soaps and apparently am about to start eating sardines.  Not that I'm complaining, of course." -ZedThou
User avatar
ZedThou
Full Member
Full Member
Posts: 53
Joined: Thu Sep 22, 2011 9:59 pm

Re: gnucash bond quotes

Post by ZedThou »

gnucash is a full-fledged double-entry accounting package, so it might be overkill for portfolio tracking. On the other hand, I have set up a separate "Tracking - positive" account that does exactly that - every disparate asset which is a "stock", "bond" or "gold" are put into their own subaccounts. Then for accounting purposes there's the exact mirror, "Tracking - negative", whose assets balance the positive. In this way I can see the total value of each PP asset class that I have at a given moment in time.

I've never tried gnucash in Windows but I imagine it works fine based on my experiences with other gtk+ apps on Windows (gimp, in particular). I think to get the quoting feature working you'd have to install ActivePerl as well.

This may be too much work just for the purpose of keeping an eye on allocations.
Oh, such a beautiful tarmac. Look how smooth it is. See how smooth it is? And it's warm, and it's hard. - Charley Boorman Long Way Round
TBV
Executive Member
Executive Member
Posts: 250
Joined: Wed Jan 26, 2011 2:20 pm

Re: gnucash bond quotes

Post by TBV »

ZedThou:  Thanks for your valuable contribution.  I tried it out on a random 30-yr Treasury (CUSIP=912810QN1) and noticed that it returned a value of $134.72 following the close on Jan. 6, 2012.  The FidelityFixed website's BID price was $134.687.  The ASK price was $134.750 and the THIRD PARTY Price was $134.703.  So that leaves me with two questions: 1) What did the $134.72 represent?  2) How can I tweak the code so that your pm file delivers the BID price?
User avatar
ZedThou
Full Member
Full Member
Posts: 53
Joined: Thu Sep 22, 2011 9:59 pm

Re: gnucash bond quotes

Post by ZedThou »

Right now the "price" is the average of bid/ask rounded to the nearest cent. I don't really know what would be most appropriate. Perhaps the 3rd party price. The code is easy to modify, just add a line

$info{$symbol, 'price'}  = $info{$symbol, 'bid'};

after the '# clean things up a bit' section of code, and then restart gnucash.

edit - I've updated the pm file to set price=bid
Last edited by ZedThou on Sun Jan 08, 2012 10:40 pm, edited 1 time in total.
Oh, such a beautiful tarmac. Look how smooth it is. See how smooth it is? And it's warm, and it's hard. - Charley Boorman Long Way Round
TBV
Executive Member
Executive Member
Posts: 250
Joined: Wed Jan 26, 2011 2:20 pm

Re: gnucash bond quotes

Post by TBV »

Thanks very much. I was hoping someone would come along and do precisely what you've done.  Good job!!
TBV
Executive Member
Executive Member
Posts: 250
Joined: Wed Jan 26, 2011 2:20 pm

Re: gnucash bond quotes

Post by TBV »

ZedThou wrote: gnucash is a full-fledged double-entry accounting package, so it might be overkill for portfolio tracking. On the other hand, I have set up a separate "Tracking - positive" account that does exactly that - every disparate asset which is a "stock", "bond" or "gold" are put into their own subaccounts. Then for accounting purposes there's the exact mirror, "Tracking - negative", whose assets balance the positive. In this way I can see the total value of each PP asset class that I have at a given moment in time.

I've never tried gnucash in Windows but I imagine it works fine based on my experiences with other gtk+ apps on Windows (gimp, in particular). I think to get the quoting feature working you'd have to install ActivePerl as well.

This may be too much work just for the purpose of keeping an eye on allocations.
For those GnuCash users who want to keep a more conventional chart of accounts, they can still track their HB4xPP holdings in a single, simple screen.  First, export their GnuCash "Advanced Portfolio" report to an html file.  Second, link the html file to a sheet in an Excel or LibreOffice Calc file.  Third, inside the spreadsheet file, create a second sheet that uses SUMIF calculated fields to capture the relevant asset data from the linked report found on the first sheet.  Fourth, create a final third sheet that uses calculated expressions to concatenate the asset data listed on the second sheet into the four categories of the HB4xPP.

Step 3 is needed to provide step 4 with stable cell references, since actual assets (and their location in the linked report) may change over time.  Each time the AP report is exported to overwrite the target file, the spreadsheet file will update the results when opened.
MikeK
Associate Member
Associate Member
Posts: 29
Joined: Thu Jan 05, 2012 8:43 am

Re: gnucash bond quotes

Post by MikeK »

ZedThou,

I've been a gnucash user for close to 13 years now, but quit trying to track my portfolio with it many years ago.  Now that I'm considering moving to the PP, I might just have to give the portolio parts of gnucash another try and will be sure to use your patched Finance::Quote perl module for updates.

Can you post more info on how you set up the accounts?  (Via email if this isn't the appropriate forum is fine)
User avatar
ZedThou
Full Member
Full Member
Posts: 53
Joined: Thu Sep 22, 2011 9:59 pm

Re: gnucash bond quotes

Post by ZedThou »

MikeK, send me a pm with your email and I'll send you a bare-bones gnucash file with example tracking accounts set up.
Oh, such a beautiful tarmac. Look how smooth it is. See how smooth it is? And it's warm, and it's hard. - Charley Boorman Long Way Round
fnord123
Executive Member
Executive Member
Posts: 233
Joined: Sun Apr 25, 2010 9:33 pm

Re: gnucash bond quotes

Post by fnord123 »

While I don't use gnucash, this is still an extremely helpful post to me.  I use google spreadsheets to track my PP, and until now had been using the PRICE() function to calculate the value of 30 year treasuries, based on the current yield of treasuries.  Now I can have much more exact values, even accounting for bid/ask spreads.  Thank you!!!

Edit: Just saw this thread - http://gyroscopicinvesting.com/forum/ht ... ic.php?t=6 - so removing my equivalent formula here.
Last edited by fnord123 on Sat Feb 04, 2012 4:48 pm, edited 1 time in total.
bradrh

Re: gnucash bond quotes

Post by bradrh »

Thanks for doing this & sharing it.  This is really useful, or at least it will be when I get it working :)
I installed it just like you said.  If I run gnc-fq-dump on the cmd line it works, and it looks like it is returning everything needed.  I have the security set up just like your example.  But when I press the GetQuotes button it says: 'Unable to retrieve quotes for these items:' & lists the 5 bonds that I'm trying to get quotes for from fidelityfixed.
Any ideas?
User avatar
ZedThou
Full Member
Full Member
Posts: 53
Joined: Thu Sep 22, 2011 9:59 pm

Re: gnucash bond quotes

Post by ZedThou »

bradrh, are you using a Unix-like system? If so, could you try running the following command and then send me a PM with the output? Hopefully we can troubleshoot this via PM.
perl -MData::Dumper -MFinance::Quote -le '$q = Finance::Quote->new(); print Dumper { $q->fetch("fidelityfixed", shift) };' 912810QT8
Oh, such a beautiful tarmac. Look how smooth it is. See how smooth it is? And it's warm, and it's hard. - Charley Boorman Long Way Round
User avatar
ZedThou
Full Member
Full Member
Posts: 53
Joined: Thu Sep 22, 2011 9:59 pm

Re: gnucash bond quotes

Post by ZedThou »

I'm not sure if there was anyone using my previous module. If so, they'll have noticed that it stopped working quite some time ago since Fidelity now requires a login to view bond quotes.

So, I've written a new module, which grabs the quotes from Treasury Direct  :) Of course it will only fetch quotes for government bonds, but otherwise it works just the same as the previous module. If anyone wants it, send me a PM.
Oh, such a beautiful tarmac. Look how smooth it is. See how smooth it is? And it's warm, and it's hard. - Charley Boorman Long Way Round
User avatar
Pointedstick
Executive Member
Executive Member
Posts: 8866
Joined: Tue Apr 17, 2012 9:21 pm
Contact:

Re: gnucash bond quotes

Post by Pointedstick »

Nice work! Are you planning to commit it to the source repo too?
Human behavior is economic behavior. The particulars may vary, but competition for limited resources remains a constant.
- CEO Nwabudike Morgan
User avatar
ZedThou
Full Member
Full Member
Posts: 53
Joined: Thu Sep 22, 2011 9:59 pm

Re: gnucash bond quotes

Post by ZedThou »

Pointedstick wrote: Nice work! Are you planning to commit it to the source repo too?
I tried with the last version and received zero response, so I won't bother this time.
Oh, such a beautiful tarmac. Look how smooth it is. See how smooth it is? And it's warm, and it's hard. - Charley Boorman Long Way Round
User avatar
Pointedstick
Executive Member
Executive Member
Posts: 8866
Joined: Tue Apr 17, 2012 9:21 pm
Contact:

Re: gnucash bond quotes

Post by Pointedstick »

They don't have a github repo where you can submit a merge request or something? Or you did and nobody cared?
Human behavior is economic behavior. The particulars may vary, but competition for limited resources remains a constant.
- CEO Nwabudike Morgan
User avatar
ZedThou
Full Member
Full Member
Posts: 53
Joined: Thu Sep 22, 2011 9:59 pm

Re: gnucash bond quotes

Post by ZedThou »

Pointedstick wrote: They don't have a github repo where you can submit a merge request or something? Or you did and nobody cared?
I'm so glad you asked, since it made me go looking to find out. It turns out that they have moved to github and someone had put my previous module there! So, this new module has a few kinks, but I will work them out and hopefully get it added and have the previous one removed.
Oh, such a beautiful tarmac. Look how smooth it is. See how smooth it is? And it's warm, and it's hard. - Charley Boorman Long Way Round
User avatar
Pointedstick
Executive Member
Executive Member
Posts: 8866
Joined: Tue Apr 17, 2012 9:21 pm
Contact:

Re: gnucash bond quotes

Post by Pointedstick »

Awesome! That's great news. I appreciate your effort on this. It's nice to know that one day when I go back to Linux, this option will be there.
Human behavior is economic behavior. The particulars may vary, but competition for limited resources remains a constant.
- CEO Nwabudike Morgan
Jack Jones
Executive Member
Executive Member
Posts: 527
Joined: Mon Aug 24, 2015 3:12 pm

Re: gnucash bond quotes

Post by Jack Jones »

ZedThou wrote: So, this new module has a few kinks, but I will work them out and hopefully get it added and have the previous one removed.
Do you have the new module available anywhere for me to test?
Post Reply