Bond Future
financepy.products.bonds.bond_future
Classes
BondFuture
BondFuture(ticker_name: str, first_delivery_dt: financepy.utils.date.Date, last_delivery_dt: financepy.utils.date.Date, contract_size: int, cpn: float)
Class for managing futures contracts on government bonds that follows
CME conventions and related analytics.
Attributes
----------
ticker_name : str
Identifier name of the futures contract.
first_delivery_dt : Date
The first delivery date of the futures contract (usually IMM date).
last_delivery_dt : Date
The last delivery date of the futures contract.
contract_size : int
Contract size in currency units (e.g. \$100,000).
cpn : float
Contract standard coupon rate, used for conversion factor calculations.
Methods
conversion_factor
conversion_factor(self, bond: financepy.products.bonds.bond.Bond)
Compute the CME-style conversion factor for a given bond.
The conversion factor normalizes bonds with different coupons and
maturities to a standard contract coupon and maturity schedule.
Steps:
- Calculate years to maturity from 1st delivery date to bond maturity.
- Round this maturity to the nearest 3-month (quarter year) multiple.
- Construct a hypothetical bond starting on the first delivery date
with the standard contract coupon and rounded maturity.
- Calculate the clean price of this hypothetical bond yielding the
contract coupon.
- Normalize and round to 4 decimal places.
Parameters
----------
bond : Bond
The deliverable bond for which conversion factor is calculated.
Returns
-------
float
Conversion factor rounded to 4 decimals.
principal_invoice
principal_invoice(self, bond: financepy.products.bonds.bond.Bond, futures_price: float) -> float
Calculate the principal invoice amount for delivering a bond.
CME defines this as contract size × futures price × conversion factor / 100.
Parameters
----------
bond : Bond
The deliverable bond.
futures_price : float
The quoted futures price (in percentage points).
Returns
-------
float
Principal invoice amount in currency units.
total_invoice_amount
total_invoice_amount(self, settle_dt: financepy.utils.date.Date, bond: financepy.products.bonds.bond.Bond, futures_price: float) -> float
Calculate total invoice amount paid on delivery, including
accrued interest.
Parameters
----------
settle_dt : Date
Settlement date when the invoice is paid.
bond : Bond
The deliverable bond.
futures_price : float
Quoted futures price.
Returns
-------
float
Total invoice amount including accrued interest.
delivery_years
delivery_years(self, bond: financepy.products.bonds.bond.Bond) -> float
Calculate the fractional years from the first delivery date to the
bond maturity.
Uses ACT/ACT ISDA day count convention.
Parameters
----------
bond : Bond
The deliverable bond.
Returns
-------
float
Fractional years (e.g., 5.25 years).
gross_basis
gross_basis(self, bond: financepy.products.bonds.bond.Bond, clean_price: float, futures_price: float) -> float
Compute the gross basis: what is received on delivery vs. bond price.
gross_basis = clean_price - (conversion_factor × futures_price)
Parameters
----------
bond : Bond
The deliverable bond.
clean_price : float
The current clean price of the bond.
futures_price : float
The quoted futures price.
Returns
-------
float
Gross basis value.
net_basis
net_basis(self, bond, settle_dt: financepy.utils.date.Date, clean_price: float, futures_price: float, repo_rate: float)
Compute net basis, adjusting for financing cost (repo rate).
net_basis = forward_price - (conversion_factor × futures_price)
Parameters
----------
bond : Bond
Deliverable bond.
settle_dt : Date
Settlement date.
clean_price : float
Current bond clean price.
futures_price : float
Futures contract price.
repo_rate : float
Repo financing rate (annualized decimal, e.g. 0.02 for 2%).
Returns
-------
float
Net basis value.
Raises
------
ValueError
If any price or repo_rate is negative.
implied_repo_rate
implied_repo_rate(self, bond: financepy.products.bonds.bond.Bond, settle_dt: financepy.utils.date.Date, clean_price: float, futures_price: float)
Calculate implied repo rate consistent with futures price.
This is the IRR of financing the bond purchase and delivering at
futures price, accounting for accrued interest and coupon payments
between settle and delivery.
Parameters
----------
bond : Bond
Deliverable bond.
settle_dt : Date
Settlement date.
clean_price : float
Current clean price of bond.
futures_price : float
Futures price.
Returns
-------
float
Implied repo rate (annualized decimal).
Raises
------
ValueError
If clean_price or futures_price is negative.
ctd
ctd(self, bonds: list, bond_clean_prices: list, futures_price: float)
Determine the Cheapest to Deliver (CTD) bond among candidates.
The CTD is the bond with the lowest gross basis
(= clean price - cf × futures price).
Parameters
----------
bonds : list of Bond
List of deliverable bonds.
bond_clean_prices : list of float
Corresponding clean prices of the bonds.
futures_price : float
Futures contract price.
Returns
-------
Bond
The bond identified as Cheapest to Deliver.
Generated automatically from the FinancePy source code.
Do not edit this file manually.