API Documentation

Interpolation

interpolation.interpolation
interpolation.no
interpolation.left
interpolation.constant
interpolation.flat
interpolation.right
interpolation.flat
interpolation.nearest
interpolation.zero
Inheritance diagram of interpolation
class interpolation.constant(x_list=[], y_list=[])[source]

Bases: interpolation.left

class interpolation.flat(y=0.0)[source]

Bases: interpolation.interpolation

class interpolation.interpolation(x_list=[], y_list=[])[source]

Bases: object

classmethod from_dict(xy_dict)[source]
update(x_list=[], y_list=[])[source]

update interpolation data :param list(float) x_list: x values :param list(float) y_list: y values

class interpolation.left(x_list=[], y_list=[])[source]

Bases: interpolation.interpolation

class interpolation.linear(x_list=[], y_list=[])[source]

Bases: interpolation.interpolation

class interpolation.nearest(x_list=[], y_list=[])[source]

Bases: interpolation.interpolation

class interpolation.no(x_list=[], y_list=[])[source]

Bases: interpolation.interpolation

class interpolation.right(x_list=[], y_list=[])[source]

Bases: interpolation.interpolation

class interpolation.zero(x_list=[], y_list=[])[source]

Bases: interpolation.interpolation

Curve

curve.Curve Curve object to build function
curve.DateCurve
curve.RateCurve
curve.DiscountFactorCurve
curve.ZeroRateCurve
curve.CashRateCurve
curve.ShortRateCurve
curve.CreditCurve generic curve for default probabilities (under construction)
curve.SurvivalProbabilityCurve
curve.FlatIntensityCurve
curve.ForwardSurvivalRate
curve.HazardRateCurve
Inheritance diagram of curve
class curve.CashRateCurve(x_list, y_list, y_inter=None, origin=None, day_count=None, forward_tenor=None)[source]

Bases: curve.RateCurve

get_cash_rate(start, stop=None, step=None)[source]
get_discount_factor(start, stop)[source]
get_storage_type(x)[source]
class curve.CreditCurve(x_list, y_list, y_inter=None, origin=None, day_count=None, forward_tenor=None)[source]

Bases: curve.RateCurve

generic curve for default probabilities (under construction)

get_flat_intensity(start, stop)[source]
get_forward_survival_rate(start, stop=None, step=None)[source]
get_hazard_rate(start, shift=None)[source]
get_survival_prob(start, stop)[source]
class curve.Curve(x_list=None, y_list=None, y_inter=None)[source]

Bases: object

Curve object to build function

Parameters:
  • x_list (list(float)) – source values
  • y_list (list(float)) – target values
  • y_inter (list(interpolation.interpolation)) – interpolation function on x_list (optional) or triple of (left, mid, right) interpolation functions with left for x < x_list[0] (as default triple.right is used) right for x > x_list][-1] (as default interpolation.constant is used) mid else (as default interpolation.linear is used)

Curve object to build function \(f:R \rightarrow R, x \mapsto y\) from finite point vectors \(x\) and \(y\) using piecewise various interpolation functions.

domain
shifted(delta=0.0)[source]
update(x_list=[], y_list=[])[source]
curve.DAY_COUNT(start, end)
class curve.DateCurve(x_list, y_list, y_inter=None, origin=None, day_count=None)[source]

Bases: curve.Curve

domain
to_curve()[source]
update(x_list=[], y_list=[])[source]
class curve.DiscountFactorCurve(x_list, y_list, y_inter=None, origin=None, day_count=None, forward_tenor=None)[source]

Bases: curve.RateCurve

get_discount_factor(start, stop)[source]
get_storage_type(x)[source]
class curve.FlatIntensityCurve(x_list, y_list, y_inter=None, origin=None, day_count=None, forward_tenor=None)[source]

Bases: curve.CreditCurve

class curve.ForwardSurvivalRate(x_list, y_list, y_inter=None, origin=None, day_count=None, forward_tenor=None)[source]

Bases: curve.CreditCurve

class curve.HazardRateCurve(x_list, y_list, y_inter=None, origin=None, day_count=None, forward_tenor=None)[source]

Bases: curve.CreditCurve

class curve.RateCurve(x_list, y_list, y_inter=None, origin=None, day_count=None, forward_tenor=None)[source]

Bases: curve.DateCurve

classmethod cast(other)[source]
get_cash_rate(start, stop=None, step=None)[source]
get_discount_factor(start, stop)[source]
get_short_rate(start, shift='1D')[source]
get_storage_type(x)[source]
get_swap_annuity(date_list)[source]
get_swap_leg_valuation(date_list, flow_list)[source]
get_zero_rate(start, stop)[source]
class curve.ShortRateCurve(x_list, y_list, y_inter=None, origin=None, day_count=None, forward_tenor=None)[source]

Bases: curve.RateCurve

get_short_rate(start, shift=None)[source]
get_storage_type(x)[source]
get_zero_rate(start, stop)[source]
class curve.SurvivalProbabilityCurve(x_list, y_list, y_inter=None, origin=None, day_count=None, forward_tenor=None)[source]

Bases: curve.DiscountFactorCurve, curve.CreditCurve

class curve.ZeroRateCurve(x_list, y_list, y_inter=None, origin=None, day_count=None, forward_tenor=None)[source]

Bases: curve.RateCurve

get_storage_type(x)[source]
get_zero_rate(start, stop)[source]

Fx Objects

fx.FxCurve fx rate curve for currency pair
fx.FxContainer FxDict factory object
Inheritance diagram of fx
class fx.FxContainer(currency, domestic_curve)[source]

Bases: dict

FxDict factory object

using triangulation over self.currency defined as a global container of fx information (mainly vs base currency)

today = businessdate()
curve = ZeroRateCurve([today], [.02])
container = FxContainer('USD', curve)
foreign = ZeroRateCurve([today], [.01])
container.add('EUR', foreign, 1.2)
fx_curve = container['USD', 'EUR']  # fx_curve is FxCurve
fx_dict = container['USD']  # fx_dict is dict of FxCurves containing fx_curve
container['USD']['EUR'](today) == container['USD', 'EUR'](today)  # True
Parameters:
  • currency – base currency of FxContainer
  • domestic_curve (RateCurve) – base curve of FxContainer for discounting
add(foreign_currency, foreign_curve=None, fx_spot=1.0)[source]

adds contents to FxShelf. If curve is FxCurve or FxDict, spot should turn curve.currency into self.currency, else spot should turn currency into self.currency by N in EUR * spot = N in USD for currency = EUR and self.currency = USD

get_forward(domestic_currency, foreign_currency, value_date)[source]
get_fx_rate(domestic_currency, foreign_currency, value_date)[source]
class fx.FxCurve(x_list, y_list=None, y_inter=None, origin=None, day_count=None, domestic_curve=None, foreign_curve=None)[source]

Bases: curve.DateCurve

fx rate curve for currency pair

classmethod cast(fx_spot, domestic_curve=None, foreign_curve=None)[source]

creator method to build FxCurve

Parameters:
  • fx_spot (float) – fx spot rate
  • domestic_curve (RateCurve) – domestic discount curve
  • foreign_curve (RateCurve) – foreign discount curve
Returns:

get_fx_rate(value_date)[source]

Compounding

compounding.annually_compounding(rate_value, maturity_value)[source]
compounding.continuous_compounding(rate_value, maturity_value)[source]
compounding.continuous_rate(df, period_fraction)[source]
compounding.daily_compounding(rate_value, maturity_value)[source]
compounding.monthly_compounding(rate_value, maturity_value)[source]
compounding.periodic_compounding(rate_value, maturity_value, period_value)[source]
compounding.periodic_rate(df, period_fraction, frequency)[source]
compounding.quarterly_compounding(rate_value, maturity_value)[source]
compounding.semi_compounding(rate_value, maturity_value)[source]
compounding.simple_compounding(rate_value, maturity_value)[source]
compounding.simple_rate(df, period_fraction)[source]

Cashflow

cashflow.CashFlowList
cashflow.AmortizingCashFlowList
cashflow.AnnuityCashFlowList
cashflow.RateCashFlowList
cashflow.MultiCashFlowList
cashflow.FixedLoan
cashflow.FloatLoan
cashflow.FixedFloatSwap ir swap that pays fixed and receives float.
Inheritance diagram of cashflow
class cashflow.AmortizingCashFlowList(pay_date_list, amount_list=None)[source]

Bases: cashflow.CashFlowList

class cashflow.AnnuityCashFlowList(pay_date_list, amount_list=None)[source]

Bases: cashflow.CashFlowList

class cashflow.CashFlowList(pay_date_list, amount_list=None)[source]

Bases: collections.OrderedDict

get_value(discount_curve, valuation_date=None)[source]
yield_to_maturity(valuation_date)[source]
class cashflow.FixedFloatSwap(date_list, fixed_rate, forward_curve, notional_list=None, day_count=None)[source]

Bases: cashflow.MultiCashFlowList

ir swap that pays fixed and receives float.

static gather_float_dates(date_list, notional_list, forward_tenor)[source]
get_par_rate(discount_curve, leg_int=0, err=1e-08)[source]
class cashflow.FixedLoan(legs)[source]

Bases: cashflow.MultiCashFlowList

class cashflow.FloatLoan(legs)[source]

Bases: cashflow.MultiCashFlowList

class cashflow.MultiCashFlowList(legs)[source]

Bases: cashflow.CashFlowList

interest_accrued(valuation_date)[source]
Parameters:valuation_date
Returns:
Return type:
class cashflow.RateCashFlowList(date_list, day_count, fixed_rate=0.0, forward_curve=None, notional_list=None)[source]

Bases: cashflow.CashFlowList

interest_accrued(valuation_date)[source]