Get startedGet started for free

Creating a duration neutral portfolio

Hedging is a very important part of working with bonds and bond portfolios. In this exercise, you are going to find the quantity of a bond needed to hedge a portfolio, as well as the dollar amount of this quantity.

Say you own a portfolio of bonds whose combined DV01 is USD 5,000. You decide to hedge this portfolio by selling a fixed amount of the 30 year bond from the previous exercise, which has a price of USD 76.94 and a DV01 of 12.88 cents.

This exercise is part of the course

Bond Valuation and Analysis in Python

View Course

Exercise instructions

  • Assign the DV01 of the portfolio and the bond to portfolio_dv01, bond_dv01, respectively, and the bond price to bond_price.
  • Find the number of bonds needed to hedge the portfolio.
  • Find the dollar value of this amount of bonds.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Assign DV01 of portfolio and bond to variables
portfolio_dv01 = ____
bond_dv01 = ____
bond_price = ____

# Calculate quantity of bond to hedge portfolio
hedge_quantity = ____
print("Number of bonds to sell: ", ____)

# Calculate dollar amount of bond to hedge portfolio
hedge_amount = ____
print("Dollar amount to sell: USD", ____)
Edit and Run Code