tmval.parse_cgr

bond.parse_cgr(cfreq: Union[float, list] = None, cgr: Union[tmval.rate.Rate, tmval.growth.TieredTime] = None) → dict[source]

Parses the coupon-related arguments provided to the Bond class. It returns a dictionary containing items that are used to calculate other features of the bond - alpha, cfreq, and cgr. This is used to improve the flexibility of the arguments one may supply to specify coupons.

This function can for example, extract the rate and frequency components out of the cgr argument and supply them to alpha and cfreq, respectively. Or, it can take the alpha and cfreq values to calculate cgr.

It also handles the case where alpha and cfreq are not constant throughout the term of the bond, in which case cgr is calculated to be a TieredTime and vice versa.

Parameters
  • alpha (float, list) – When supplied as a float, a nominal coupon rate. When supplied as a list of tuples of the form [(x1, y_1), (x2, y2), …], represents a series of coupon rates x supplied during periods beginning at time y. For example alpha=[(.05, 0), (.04, 2)] means a 5% coupon rate the first two years and a 4% rate after that.

  • cfreq (float, list) – The coupon frequency, or a list of coupon frequencies. When supplied as a list, alpha must also be supplied as a list and each element in cfreq needs to correspond to a tuple in alpha.

  • cgr (Rate, TieredTime) – A nominal rate representing the coupon rate and frequency.

Returns

A dictionary containing the alpha, cfreq, and cgr values.

Return type

dict