During a market downturn, two things happen: interest rates go down and spreads go up. Interest rates go down primarily because of monetary policy (the Fed adjusts short term rates down). Spreads go up because there is now more default risk for riskier corporate bonds.
A bond has two sources of value: the current trading value (as reflected by the price) and the value of future payments (as reflected by the yield).
It’s further useful to categorize bonds into old and new issues. Old issues have a variable price because their coupons are locked in. New issues have a variable yield because their prices are locked at par (at the time of issuance).
So we can consider 4 categories of bonds to highlight what happens during a market downturn.
Risk Free Treasuries (New Issues): For a new issue, the yield is the coupon rate paid on the bond and the the price is par. Because market interest rates have gone down, the yield has gone down. There’s no need to offer a 2.5% coupon rate when the interest rate the market will accept is at 2%. A new issue becomes an old issue as soon as it starts trading on the secondary market (as soon as it’s issued, basically). Once it becomes an old issue, the yield is no longer the same as the coupon rate, since the yield is affected by the fluctuating trading price.
Risk Free Treasuries (Old Issues): Old issues need to have the same yields as new issues since they are the same class of assets (risk free bonds). In order to sell the treasuries you have on hand, you’re going to have to price it in a way that it’s competitive to the new issues. Thus, because lower interest rates means lower yields on new issues (aforementioned), old issues must also have lower yields. Since the coupon is fixed, the price of the bond must go up to ensure the yield decreases. So, in a declining market, old issues of treasuries see lower yields and higher prices. You would purchase treasuries because you expect interests rates to decline even further, which would mean the price of the treasury increases even more, which you can then sell at a profit.
Risky Corporate (New Issues): Unlike treasuries, corporate bonds have a default risk that increases as the economy suffers. As the market suffers a downturn, the company’s business may sour and it may not be able to pay its bond obligations. As a result, the company must offer a high coupon rate on its bonds to attract investors, despite the decrease in interest rates. Since coupon rate = yield for new issues, spreads (corporate yield - treasury yield) increases. Spreads increase more for riskier bonds than they do for lower risk bonds because riskier bonds have to offer a higher yield to offset their higher default risk. Another way of saying this is bonds that are more risk-free like a treasury will have a yield that closely tracks the treasury yield (decreasing), whereas bonds that are more risky will have a yield that diverges strongly from the treasury yield (decreasing slower or increasing).
Risky Corporate (Old Issues): Old issues of corporate bonds will also have to match the yield (and spread) of new issues. Suppose a BB bond issued last year is yielding 7% when the economy was stronger and new BB bonds issued are paying 9% to account for higher default risk in a bad economy. All else being equal, the old issue will also have to match the 9% yield. Since coupon payments are static, the bond price must go down. As a result, if you had owned this bond, the value of your bond portfolio just decreased if you were to trade it now. You would avoid these risky bonds during a slowdown in the economy because their yields will diverge from the treasury yield (spread increases) and depending on their credit rating, may even increase to the point that prices go down.