Created
December 6, 2011 16:50
-
-
Save nkabir/1438915 to your computer and use it in GitHub Desktop.
Code Review Discount Factor Mayur Patel
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 DiscountFactor(object): | |
| ''' | |
| Holds the discount factor for a specific date. Includes: | |
| 1. referenceDate | |
| 2. discountFactorDate | |
| 3. factor | |
| ''' | |
| def __init__(self, reference_date, discount_factor_date, discount_factor): | |
| ''' | |
| We set the initial values | |
| ''' | |
| self.reference_date = reference_date | |
| self.discount_factor_date = discount_factor_date | |
| self.discount_factor = discount_factor | |
| def __repr__(self): | |
| """Return a string representation of this class. | |
| """ | |
| return self.__class__.__name__ + "(" + repr(self.reference_date) + "," + repr(self.discount_factor_date) + "," + repr(self.discountFactor) + ")" | |
| def __str__(self): | |
| """Return a human-friendly string for this class. | |
| """ | |
| return self.__class__.__name__ + "(" + repr(self.reference_date.as_datetime()) + "," + repr(self.discount_factor_date.as_datetime()) + "," + repr(self.discountFactor) + ")" | |
| def make(reference_date, discount_factor_date, discount_factor): | |
| ''' | |
| Make a new DiscountFactor. | |
| reference_date -- SerialDate | |
| discount_factor_date -- SerialDate | |
| discount_factor -- double | |
| ''' | |
| return DiscountFactor(reference_date, discount_factor_date, discount_factor) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment