Created
August 12, 2012 00:15
-
-
Save tlmaloney/3328070 to your computer and use it in GitHub Desktop.
InterestPayment class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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