BW #40: Sovereign Bonds
The bond market is huge, and some countries' bonds are (as usual) worth more than others. What countries pay the highest interest to their bondholders... and what do ratings agencies have to say?
When I was in elementary school, one of my teachers thought it was important to teach us about the stock market. We talked about companies, shares, prices going up and down, and each chose a company whose stock we followed for a week. (Back then, newspapers printed stock prices each day, so you could look for a company and see its current price. Getting the prices online is so much more convenient!)
It was fascinating to learn about stocks, but it turns out that an even bigger market for investors is the bond market. When you buy a bond, you're lending money — and just as your bank earns interest when it lends you money, you earn interest when you lend someone else money. In other words, bondholders earn interest from whoever issued the bond. Two of the best-known types of bonds are corporate (where you're lending money to a company) and sovereign (where you're lending money to a government).
When you borrow money from the bank, the interest that you're charged depends on a lot of things, including how likely you are to repay the loan. Someone with a history of repaying even large loans will get to pay a low interest rate. By contrast, someone who hasn't repaid their loans, and who doesn't have a full-time salary, will have to pay a very high interest rate — if they can get them at all.
The same is true for companies and countries: If a country, for example, has a history of always paying its bondholders on time and with the appropriate interest, then their bonds will typically fetch a low rate. By contrast, a country that has previously defaulted on its bonds has to pay a lot of interest, in order to convince people to buy the bonds. If they’re corporate bonds, then they’re often known as "junk bonds," where the high interest you'll earn is offset by the low probability of actually getting your money back.
NPR's Planet Money had some fun buying a junk bond several years ago: https://www.npr.org/2020/09/09/911162693/we-buy-a-junk-bond
Things would be complex enough if people just bought bonds from companies and governments, collected the interest, and called it a day. But just as there's a used-car market, there's also a used-bond market. (No, no one really calls it that, it's really known as the "secondary bond market.") If I bought a $1,000 US Treasury bond when they were paying 2% a year, but now they're paying 5% a year, then it would make sense for me to sell my existing bond to someone else, and buy a new bond that'll pay me more. Of course, buyers aren't dumb; they know that they could get a new bond that pays more, so they'll expect to pay me less for my existing bond. There are formulas for reselling bonds that takes the face value, maturity, and interest rates (original and current) into account.
Bonds are bought and sold this way every day, all the time. It's a huge, messy market, one which I've read about off and on over the years — and the more I learn about it, the more fascinating I find it, in part because it cuts across so many different aspects of our world. This is particularly true for government bonds, which are subject not only to market realities, but also to the interest rate set by central banks, government and economist stability, and people's sense of where the economy is going.
A number of commercial ratings agencies are also part of this picture, analyzing and scoring governments, and then indicating how likely a bond is to be repaid. Of course, the ratings agencies aren't always right, as "The Big Short" by Michael Lewis (a great book, also a great movie) made clear.
I've been hearing a bit more about bonds, and the bond market, in the last few weeks. And so this week, I thought it might be interesting to look at the sovereign (government) bond market, exploring what countries are considered better bets (and thus pay lower interest rates), and which are considered riskier.
Data and six questions
Data on the secondary bond market, and especially the corporate bond market, is hard to come by. But sovereign bonds are a different story, and I found a site — "World Government Bonds," at https://www.worldgovernmentbonds.com/, that tries to summarize the latest data. We'll work with a few of the tables that they provide, and see if we can get any insights into the bond market.
The main page is
https://www.worldgovernmentbonds.com/
But we'll be retrieving data from a number of pages on that site.
Along the way, we'll look at a few different features in Pandas, including scraping data from HTML tables, joining, cleaning data, and regular expressions.
Here are my six questions; I'll be back tomorrow with my complete solutions, as well as the Jupyter notebook I used to solve them:
- Retrieve the per-country bond ratings from https://www.worldgovernmentbonds.com/world-credit-ratings/ into a data frame, in which the country name is the index, and the columns consist of the three main ratings agencies: S&P, Moody's, and Fitch.
- Which countries' bond ratings are all of the highest grade, namely AAA or Aaa?