Bond Pricer
- torchquantlib.core.asset_pricing.bond.bond_pricer.callable_bond(face_value: tensor, coupon_rate: tensor, rate: tensor, periods: tensor, call_price: tensor, call_period: tensor) tensor[source]
Calculate the price of a callable bond.
- Parameters:
face_value (tensor) – The face value of the bond
coupon_rate (tensor) – The coupon rate (as a decimal)
rate (tensor) – The interest rate (as a decimal)
periods (tensor) – Number of coupon periods
call_price (tensor) – The price at which the bond can be called
call_period (tensor) – The period at which the bond can be called
- Returns:
The price of the callable bond
- Return type:
tensor
- torchquantlib.core.asset_pricing.bond.bond_pricer.convertible_bond(face_value: tensor, coupon_rate: tensor, rate: tensor, periods: tensor, conversion_ratio: tensor, conversion_price: tensor) tensor[source]
Calculate the price of a convertible bond.
- Parameters:
face_value (tensor) – The face value of the bond
coupon_rate (tensor) – The coupon rate (as a decimal)
rate (tensor) – The interest rate (as a decimal)
periods (tensor) – Number of coupon periods
conversion_ratio (tensor) – The number of shares received upon conversion
conversion_price (tensor) – The price of the underlying stock for conversion
- Returns:
The price of the convertible bond
- Return type:
tensor
- torchquantlib.core.asset_pricing.bond.bond_pricer.coupon_bond(face_value: tensor, coupon_rate: tensor, rate: tensor, periods: tensor) tensor[source]
Calculate the price of a coupon-paying bond.
- Parameters:
face_value (tensor) – The face value of the bond
coupon_rate (tensor) – The coupon rate (as a decimal)
rate (tensor) – The interest rate (as a decimal)
periods (tensor) – Number of coupon periods
- Returns:
The price of the coupon bond
- Return type:
tensor
- torchquantlib.core.asset_pricing.bond.bond_pricer.putable_bond(face_value: tensor, coupon_rate: tensor, rate: tensor, periods: tensor, put_price: tensor, put_period: tensor) tensor[source]
Calculate the price of a putable bond.
- Parameters:
face_value (tensor) – The face value of the bond
coupon_rate (tensor) – The coupon rate (as a decimal)
rate (tensor) – The interest rate (as a decimal)
periods (tensor) – Number of coupon periods
put_price (tensor) – The price at which the bond can be put
put_period (tensor) – The period at which the bond can be put
- Returns:
The price of the putable bond
- Return type:
tensor
- torchquantlib.core.asset_pricing.bond.bond_pricer.stochastic_rate_bond(face_value: tensor, coupon_rate: tensor, rate: tensor, periods: tensor) tensor[source]
Calculate the price of a bond with stochastic interest rates.
- Parameters:
face_value (tensor) – The face value of the bond
coupon_rate (tensor) – The coupon rate (as a decimal)
rate (tensor) – A tensor of interest rates for each period
periods (tensor) – Number of coupon periods
- Returns:
The price of the bond with stochastic rates
- Return type:
tensor
- torchquantlib.core.asset_pricing.bond.bond_pricer.zero_coupon_bond(face_value: tensor, rate: tensor, maturity: tensor) tensor[source]
Calculate the price of a zero-coupon bond.
- Parameters:
face_value (tensor) – The face value of the bond
rate (tensor) – The interest rate (as a decimal)
maturity (tensor) – Time to maturity in years
- Returns:
The price of the zero-coupon bond
- Return type:
tensor
This module provides implementations for various bond pricing models.
Zero Coupon Bond
- torchquantlib.core.asset_pricing.bond.bond_pricer.zero_coupon_bond(face_value: tensor, rate: tensor, maturity: tensor) tensor[source]
Calculate the price of a zero-coupon bond.
- Parameters:
face_value (tensor) – The face value of the bond
rate (tensor) – The interest rate (as a decimal)
maturity (tensor) – Time to maturity in years
- Returns:
The price of the zero-coupon bond
- Return type:
tensor
Usage Example
import torch
from torchquantlib.core.asset_pricing.bond.bond_pricer import zero_coupon_bond
face_value = torch.tensor(1000.0)
rate = torch.tensor(0.05)
maturity = torch.tensor(5.0)
price = zero_coupon_bond(face_value, rate, maturity)
print(f"Zero Coupon Bond Price: {price.item():.2f}")
Coupon Bond
- torchquantlib.core.asset_pricing.bond.bond_pricer.coupon_bond(face_value: tensor, coupon_rate: tensor, rate: tensor, periods: tensor) tensor[source]
Calculate the price of a coupon-paying bond.
- Parameters:
face_value (tensor) – The face value of the bond
coupon_rate (tensor) – The coupon rate (as a decimal)
rate (tensor) – The interest rate (as a decimal)
periods (tensor) – Number of coupon periods
- Returns:
The price of the coupon bond
- Return type:
tensor
Usage Example
from torchquantlib.core.asset_pricing.bond.bond_pricer import coupon_bond
face_value = torch.tensor(1000.0)
coupon_rate = torch.tensor(0.06)
rate = torch.tensor(0.05)
periods = torch.tensor(10)
price = coupon_bond(face_value, coupon_rate, rate, periods)
print(f"Coupon Bond Price: {price.item():.2f}")
Callable Bond
- torchquantlib.core.asset_pricing.bond.bond_pricer.callable_bond(face_value: tensor, coupon_rate: tensor, rate: tensor, periods: tensor, call_price: tensor, call_period: tensor) tensor[source]
Calculate the price of a callable bond.
- Parameters:
face_value (tensor) – The face value of the bond
coupon_rate (tensor) – The coupon rate (as a decimal)
rate (tensor) – The interest rate (as a decimal)
periods (tensor) – Number of coupon periods
call_price (tensor) – The price at which the bond can be called
call_period (tensor) – The period at which the bond can be called
- Returns:
The price of the callable bond
- Return type:
tensor
Usage Example
from torchquantlib.core.asset_pricing.bond.bond_pricer import callable_bond
face_value = torch.tensor(1000.0)
coupon_rate = torch.tensor(0.06)
rate = torch.tensor(0.05)
periods = torch.tensor(10)
call_price = torch.tensor(1050.0)
call_period = torch.tensor(5)
price = callable_bond(face_value, coupon_rate, rate, periods, call_price, call_period)
print(f"Callable Bond Price: {price.item():.2f}")
Putable Bond
- torchquantlib.core.asset_pricing.bond.bond_pricer.putable_bond(face_value: tensor, coupon_rate: tensor, rate: tensor, periods: tensor, put_price: tensor, put_period: tensor) tensor[source]
Calculate the price of a putable bond.
- Parameters:
face_value (tensor) – The face value of the bond
coupon_rate (tensor) – The coupon rate (as a decimal)
rate (tensor) – The interest rate (as a decimal)
periods (tensor) – Number of coupon periods
put_price (tensor) – The price at which the bond can be put
put_period (tensor) – The period at which the bond can be put
- Returns:
The price of the putable bond
- Return type:
tensor
Usage Example
from torchquantlib.core.asset_pricing.bond.bond_pricer import putable_bond
face_value = torch.tensor(1000.0)
coupon_rate = torch.tensor(0.06)
rate = torch.tensor(0.05)
periods = torch.tensor(10)
put_price = torch.tensor(950.0)
put_period = torch.tensor(5)
price = putable_bond(face_value, coupon_rate, rate, periods, put_price, put_period)
print(f"Putable Bond Price: {price.item():.2f}")
Convertible Bond
- torchquantlib.core.asset_pricing.bond.bond_pricer.convertible_bond(face_value: tensor, coupon_rate: tensor, rate: tensor, periods: tensor, conversion_ratio: tensor, conversion_price: tensor) tensor[source]
Calculate the price of a convertible bond.
- Parameters:
face_value (tensor) – The face value of the bond
coupon_rate (tensor) – The coupon rate (as a decimal)
rate (tensor) – The interest rate (as a decimal)
periods (tensor) – Number of coupon periods
conversion_ratio (tensor) – The number of shares received upon conversion
conversion_price (tensor) – The price of the underlying stock for conversion
- Returns:
The price of the convertible bond
- Return type:
tensor
Usage Example
from torchquantlib.core.asset_pricing.bond.bond_pricer import convertible_bond
face_value = torch.tensor(1000.0)
coupon_rate = torch.tensor(0.06)
rate = torch.tensor(0.05)
periods = torch.tensor(10)
conversion_ratio = torch.tensor(20)
conversion_price = torch.tensor(55.0)
price = convertible_bond(face_value, coupon_rate, rate, periods, conversion_ratio, conversion_price)
print(f"Convertible Bond Price: {price.item():.2f}")
Stochastic Rate Bond
- torchquantlib.core.asset_pricing.bond.bond_pricer.stochastic_rate_bond(face_value: tensor, coupon_rate: tensor, rate: tensor, periods: tensor) tensor[source]
Calculate the price of a bond with stochastic interest rates.
- Parameters:
face_value (tensor) – The face value of the bond
coupon_rate (tensor) – The coupon rate (as a decimal)
rate (tensor) – A tensor of interest rates for each period
periods (tensor) – Number of coupon periods
- Returns:
The price of the bond with stochastic rates
- Return type:
tensor
Usage Example
import torch
from torchquantlib.core.asset_pricing.bond.bond_pricer import stochastic_rate_bond
face_value = torch.tensor(1000.0)
coupon_rate = torch.tensor(0.06)
rate = torch.tensor([0.05, 0.052, 0.054, 0.056, 0.058])
periods = torch.tensor(5)
price = stochastic_rate_bond(face_value, coupon_rate, rate, periods)
print(f"Stochastic Rate Bond Price: {price.item():.2f}")