def clean_price(self): if self.value_date > self.end: return 0.0 ws = 1.0 if (self.otype[0].upper() == 'C') else -1.0 n = len(self.fixing_dates) m = len(self.past_fix) if n == m: return max((self.past_avg - self.strike) * ws, 0.0) strike = (self.strike * n - self.past_avg * m)/float(n - m) if strike < 0: return max((self.past_avg * m + self.fwd_avg * (n - m))/float(n) - self.strike, 0) if ws > 0 else 0.0 volnode = cmq_volgrid.Delta5VolNode( self.value_date, \ self.volmark['expiry'], \ self.fwd_avg, \ self.volmark['COMVolATM'], \ self.volmark['COMVolV90'], \ self.volmark['COMVolV75'], \ self.volmark['COMVolV25'], \ self.volmark['COMVolV10'], \ "act365") ivol = volnode.GetVolByStrike( strike, self.end) cal_str = cmq_crv_defn.COM_Curve_Map[self.fwd_index]['calendar'] + '_Holidays' hols = getattr(misc, cal_str) tau = misc.conv_expiry_date(self.value_date + datetime.timedelta(days = int(self.eod_flag)), \ self.start - datetime.timedelta(days=1), \ self.accrual, hols) t_exp = misc.conv_expiry_date(self.value_date + datetime.timedelta(days = int(self.eod_flag)), \ self.end, self.accrual, hols) vol_adj = bsopt.asian_vol_adj(ivol, t_exp, tau) pr = bsopt.BSFwd((ws>0), self.fwd_avg, strike, vol_adj, t_exp, 0) * self.df * float(n - m) / float(n) return pr
def clean_price(self): ws = 1.0 if (self.otype[0].upper() == 'C') else -1.0 n = len(self.fixing_dates) m = len(self.past_fix) if n == m: return max((self.past_avg - self.strike) * ws, 0.0) strike = (self.strike * n - self.past_avg * m) / float(n - m) if strike < 0: return max( (self.past_avg * m + self.fwd_avg * (n - m)) / float(n) - self.strike, 0) if ws > 0 else 0.0 volnode = cmq_volgrid.Delta5VolNode( self.value_date, \ self.volmark['expiry'], \ self.fwd_avg, \ self.volmark['COMVolATM'], \ self.volmark['COMVolV90'], \ self.volmark['COMVolV75'], \ self.volmark['COMVolV25'], \ self.volmark['COMVolV10'], \ "act365") ivol = volnode.GetVolByStrike(strike, self.end) cal_str = cmq_crv_defn.COM_Curve_Map[ self.fwd_index]['calendar'] + '_Holidays' hols = getattr(misc, cal_str) tau = misc.conv_expiry_date(self.value_date + datetime.timedelta(days = int(self.eod_flag)), \ self.start - datetime.timedelta(days=1), \ self.accrual, hols) t_exp = misc.conv_expiry_date(self.value_date + datetime.timedelta(days = int(self.eod_flag)), \ self.end, self.accrual, hols) vol_adj = bsopt.asian_vol_adj(ivol, t_exp, tau) pr = bsopt.BSFwd((ws > 0), self.fwd_avg, strike, vol_adj, t_exp, 0) * self.df * float(n - m) / float(n) return pr
def clean_price(self): ws = 1.0 if (self.otype[0].upper() == 'C') else -1.0 cal_str = cmq_crv_defn.COM_Curve_Map[self.fwd_index]['calendar'] + '_Holidays' hols = getattr(misc, cal_str) t_exp = misc.conv_expiry_date(self.value_date, self.end, self.accrual, hols) pr = bsopt.BSFwdNormal((ws > 0), self.fwd_a - self.fwd_b, self.strike, self.ivol, t_exp, 0) * self.df return pr
def clean_price(self): ws = 1.0 if (self.otype[0].upper() == 'C') else -1.0 self.volnode = cmq_volgrid.SamuelDelta5VolNode(self.value_date, \ self.volmark['expiry'], \ self.fwd_avg, \ self.volmark['COMVolATM'], \ self.volmark['COMVolV90'], \ self.volmark['COMVolV75'], \ self.volmark['COMVolV25'], \ self.volmark['COMVolV10'], \ self.alpha,\ self.beta, \ self.accrual) self.ivol = self.volnode.GetVolByStrike(self.strike, self.end) t_exp = misc.conv_expiry_date(self.value_date, self.end, self.accrual, []) pr = bsopt.BSFwd((ws > 0), self.fwd_avg, self.strike, self.ivol, t_exp, 0) * self.df return pr
def clean_price(self): ws = 1.0 if (self.otype[0].upper() == 'C') else -1.0 self.volnode = cmq_volgrid.Delta5VolNode(self.value_date, \ self.end, \ self.fx_fwd, \ self.volmark['FXVolATM'], \ self.volmark['FXVolV90'], \ self.volmark['FXVolV75'], \ self.volmark['FXVolV25'], \ self.volmark['FXVolV10'], \ self.accrual) self.ivol = self.volnode.GetVolByStrike(self.strike, self.end) t_exp = misc.conv_expiry_date(self.value_date, self.end, self.accrual, []) pr = bsopt.BSFwd((ws > 0), self.fx_fwd, self.strike, self.ivol, t_exp, 0) / self.fx_fwd * self.df return pr
def clean_price(self): ws = 1.0 if (self.otype[0].upper() == 'C') else -1.0 volnode = cmq_volgrid.SamuelDelta5VolNode(self.value_date, \ self.volmark['expiry'], \ self.fwd_avg, \ self.volmark['COMVolATM'], \ self.volmark['COMVolV90'], \ self.volmark['COMVolV75'], \ self.volmark['COMVolV25'], \ self.volmark['COMVolV10'], \ self.alpha,\ self.beta, \ "act365") ivol = volnode.GetVolByStrike(self.strike, self.end) t_exp = misc.conv_expiry_date(self.value_date, self.end, self.accrual, []) pr = bsopt.BSFwd( (ws > 0), self.fwd_avg, self.strike, ivol, t_exp, 0) * self.df return pr
def calc_texp(self, exp_date): hols = misc.Holiday_Map.get(self.calendar, []) return misc.conv_expiry_date(self.value_date, exp_date, self.accrual, hols=[])