FinancePy

FinancePy API Reference

Hw Tree

financepy.models.hw_tree

Classes

HWTree

HWTree(sigma: float, a: float, num_time_steps: int = 100, european_calc_type: financepy.utils.global_types.HWEuropeanCalcTypes = <HWEuropeanCalcTypes.EXPIRY_TREE: 3>) -> None

No description available.

Methods

option_on_zcb

option_on_zcb(self, t_exp: float, t_mat: float, strike: float, face_amount: float, df_times: numpy.ndarray, df_values: numpy.ndarray) -> Dict[str, float]
Price an option on a zero cpn bond using analytical solution of Hull-White model. User provides bond face and option strike and expiry date and maturity date.

european_bond_option_jamshidian

european_bond_option_jamshidian(self, t_exp: float, strike_price: float, face: float, cpn_times: numpy.ndarray, cpn_amounts: numpy.ndarray, df_times: numpy.ndarray, df_values: numpy.ndarray)
Valuation of a European bond option using the Jamshidian deconstruction of the bond into a strip of zero cpn bonds with the short rate that would make the bond option be at the money forward.

european_bond_option_expiry_only

european_bond_option_expiry_only(self, t_exp: float, strike_price: float, face_amount: float, cpn_times: numpy.ndarray, cpn_amounts: numpy.ndarray) -> Dict[str, float]
Price a European option on a cpn-paying bond using a tree to generate short rates at the expiry date and then to use the analytical solution of zero cpn bond prices in the HW model to calculate the corresponding bond price. User provides bond object and option details.

option_on_zero_cpn_bond_tree

option_on_zero_cpn_bond_tree(self, t_exp: float, t_mat: float, strike_price: float, face_amount: float) -> Dict[str, float]
Price an option on a zero cpn bond using a HW trinomial tree. The discount curve was already supplied to the tree build.

bermudan_swaption

bermudan_swaption(self, t_exp: float, t_mat: float, strike: float, face: float, cpn_times: numpy.ndarray, cpn_flows: numpy.ndarray, exercise_type: Any) -> Dict[str, float]
Swaption that can be exercised on specific dates over the exercise period. Due to non-analytical bond price we need to extend tree out to bond maturity and take into account cash flows through time.

bond_option

bond_option(self, t_exp: float, strike_price: float, face_amount: float, cpn_times: numpy.ndarray, cpn_flows: numpy.ndarray, exercise_type: Any) -> Dict[str, float]
Value a bond option that can have European or American exercise. This is done using a trinomial tree that we extend out to bond maturity. For European bond options, Jamshidian's model is faster and is used instead i.e. not this function.

callable_puttable_bond_tree

callable_puttable_bond_tree(self, cpn_times: numpy.ndarray, cpn_flows: numpy.ndarray, call_times: numpy.ndarray, call_prices: numpy.ndarray, put_times: numpy.ndarray, put_prices: numpy.ndarray, face_amount: float) -> Dict[str, float]
Value an option on a bond with cpns that can have European or American exercise. Some minor issues to do with handling cpns on the option expiry date need to be solved. Also this function should be moved out of the class so it can be sped up using NUMBA.

df_tree

df_tree(self, t_mat: float) -> float | tuple
Discount factor as seen from now to time t_mat as long as the time is on the tree grid.

build_tree

build_tree(self, tree_mat: float, df_times: numpy.ndarray, df_values: numpy.ndarray) -> None
Build the trinomial tree.

Functions

fwd_dirty_bond_price

fwd_dirty_bond_price(r_t: float, *args: Any) -> float
Price a cpn bearing bond on the option expiry date and return the difference from a strike price. This is used in a root search to find the future expiry time short rate that makes the bond price equal to the option strike price. It is a key step in the Jamshidian bond decomposition approach. The strike is a clean price. Args: r_t (float): Short rate at expiry. *args: See function body for unpacked arguments. Returns: float: Difference between bond price and strike.

option_exercise_types_to_int

option_exercise_types_to_int(option_exercise_type: Any) -> int
Convert option exercise type enum to integer. Args: option_exercise_type (ExerciseTypes): The exercise type. Returns: int: 1=European, 2=Bermudan, 3=American
Generated automatically from the FinancePy source code. Do not edit this file manually.