Skip to content

Instantly share code, notes, and snippets.

@tlmaloney
Created August 12, 2012 00:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tlmaloney/3328070 to your computer and use it in GitHub Desktop.
Save tlmaloney/3328070 to your computer and use it in GitHub Desktop.
InterestPayment class
class InterestPayment(SeriesPayment):
""" One of a series of rate-based payments """
def __init__(self, rate_level_model, measure, period, inception_date, payment_date,
interest, asset_id, name, description):
SeriesPayment.__init__(self, inception_date, payment_date, interest,
asset_id, name, description)
self.rate_level_model = rate_level_model
self.measure = measure
self.period = period
def calc_level(self, market, date):
"""Returns the amount of interest to be paid on the payment date if
the input date is before the payment date
"""
if date <= self.payment_date:
rate_level = self.rate_level_model.calc_level(market,
self.inception_date)
rate = RateKit.make(rate_level, self.measure, self.period)
accrual = rate.calc_accrual_factor(self.inception_date,
self.payment_date)
principal = self.payment_series.principal
notional_level = principal.calc_level(market, self.inception_date)
return notional_level * (accrual - 1)
else:
return 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment