class SimpleBond(object):
def__init__(self,OriginationDate,SettleDate,Coupon,CouponFreq,Maturity,Par,StartingPrice = None):
self.CouponCFDaysFromOrigination = np.arange(1,self.NumCouponCFs + 1) * self.CashFlowDelta
self.OriginationCashFlowDates = np.array([self.StartDate + np.timedelta64(int(i),'D') for i in self.CouponCFDaysFromOrigination])
self.StartDate = OriginationDate
def GenerateCashFlowsAndDates(self):
CashFlowDates = self.OriginationCashFlowDates
self.CashFlowDates = CashFlowDates[(CashFlowDates >= self.SettleDate) & (CashFlowDates <=self.MaturityDate)]
我有一个上面的类定义。我在其他地方实例化如下的类:
BondObj = SimpleBond(OriginationDate = InceptionDate,SettleDate= np.datetime64('2008-02-15'),Coupon = 8.875,CouponFreq = 2,Maturity = 9.5,Par = 100.)
BondObj.GenerateCashFlowsAndDates()
问题在于调用GenerateCashFlowDates()
,如上所示,一旦将BondObj分配给SimpleBond类的实例化,并带有设置状态的参数。
当我进入呼叫BondObj.GenerateCashFlowsAndDates()
时......我可以看到以下状态变量
self.StartDate
.....它显示实际状态
其中
self.OriginationCashFlowDates
没有显示任何价值。它是none
事实上,构造函数中设置的所有其他实例变量都可以从BondObj.GenerateCashFlowAndDates() call
非常感谢