This paper analyzes how the risks of nominal and inflation-indexed Treasury bonds vary with the presence of supply and demand shocks through the lens of a small-scale New Keynesian model with habit formation preferences, where investors become more risk averse following adverse economic shocks. We calibrate the model separately for the time periods 1979.Q4-2001.Q1 and 2001.Q2-2019.Q4. For the 1980s calibration, volatile supply shocks raise inflation and the Fed responds by raising interest rates, leading to a recession and simultaneous drops in nominal bond and stock prices. For the 2000s calibration, volatile demand shocks lower the output gap and raise interest rates, leading to simultaneous increases in nominal and real bond prices and a stock market downturn. As a result, nominal Treasury bond-stock betas are positive in the 1980s calibration, and negative in the 2000s calibration, as in the data. Counterfactual exercises show that volatile supply shocks alone are not sufficient to generate the high and positive nominal Treasury bond betas of the stagflationary 1980s, but that a monetary policy rule that responds strongly to supply shocks is also needed. Partially backward-looking inflation expectations by wage-setters are important to match the predictability of bond excess returns as in Campbell and Shiller (1991).