public string set_discountCurve(string currency, YieldTermStructure discountCurve) { try { Excel_standardSwapParaViewModel e_sspvm = this.InstVM_.Excel_parameterViewModel_ as Excel_standardSwapParaViewModel; int count = e_sspvm.Excel_discountCurve_paraViewModel_.hasCurrencysYieldCurve(currency); discountCurve.Excel_yieldCurveViewModel_.Currency_ = currency; if (count == -1) { e_sspvm.Excel_discountCurve_paraViewModel_.Excel_yieldCurveViewModel_ .Add(discountCurve.Excel_yieldCurveViewModel_); } else { e_sspvm.Excel_discountCurve_paraViewModel_.Excel_yieldCurveViewModel_[count] = discountCurve.Excel_yieldCurveViewModel_; } return("set discountCurve complete : " + currency); } catch (Exception e) { string errStr = "set fail: " + e.Message; return(errStr); } }
public string set_correlation(string first, string second, double corr) { try { Excel_standardSwapParaViewModel e_sspvm = this.InstVM_.Excel_parameterViewModel_ as Excel_standardSwapParaViewModel; //if (first == second) // throw new Exception("underlying code is same"); if (!e_sspvm.Excel_underlyingCalcInfo_paraViewModel_.hasUnderlying(first)) { throw new Exception("underlying code doesn't exist : " + first); } if (!e_sspvm.Excel_underlyingCalcInfo_paraViewModel_.hasUnderlying(second)) { throw new Exception("underlying code doesn't exist : " + second); } if (corr > 1.0 || corr < -1.0) { throw new Exception("corr must be contained in [ -1.0 , 1.0 ] : " + corr); } e_sspvm.Excel_underlyingCalcInfo_paraViewModel_.Excel_correlationInfo_paraViewModel_. setCorrelation(first, second, corr); //Excel_correlation_paraViewModel e_corrvm = new Excel_correlation_paraViewModel(); //e_corrvm.First_ = first; //e_corrvm.Second_ = second; //e_corrvm.Value_ = corr.ToString(); //e_sspvm.Excel_underlyingCalcInfo_paraViewModel_.Excel_correlationInfo_paraViewModel_.Excel_correlation_paraViewModel_.Add(e_corrvm); //Excel_correlation_paraViewModel e_corrvm_converse = new Excel_correlation_paraViewModel(); //e_corrvm_converse.First_ = second; //e_corrvm_converse.Second_ = first; //e_corrvm_converse.Value_ = corr.ToString(); //e_sspvm.Excel_underlyingCalcInfo_paraViewModel_.Excel_correlationInfo_paraViewModel_.Excel_correlation_paraViewModel_.Add(e_corrvm_converse); return("set corr complete : " + first + " , " + second + " : " + corr); } catch (Exception e) { string errStr = "set fail: " + e.Message; return(errStr); } }
public string set_hullWhiteModel(string underCode, double currentValue, double alpha, double sigma, YieldTermStructure fittingCurve) { try { Excel_standardSwapParaViewModel e_sspvm = this.InstVM_.Excel_parameterViewModel_ as Excel_standardSwapParaViewModel; // under 에서 tenor를 가져옴 string tenor = "3M"; // defaultrrrr bool setFlag = false; Excel_hullWhiteOneFactorViewModel e_hwvm = new Excel_hullWhiteOneFactorViewModel(); foreach (var item in e_sspvm.Excel_underlyingCalcInfo_paraViewModel_.Excel_underlyingInfo_paraViewModel_) { if (underCode == item.KrCode_) { e_hwvm.CurrentValue_ = currentValue.ToString(); e_hwvm.Alpha_ = alpha.ToString(); e_hwvm.Volatility_ = sigma.ToString(); e_hwvm.Excel_yieldCurveViewModel_ = fittingCurve.Excel_yieldCurveViewModel_; item.Excel_underlyingModel_paraViewModel_ = e_hwvm; setFlag = true; } } foreach (var item in this.InstVM_.Excel_interfaceViewModel_.Excel_underlyingCalcInfoViewModel_.Excel_underlyingInfoViewModel_) { if (underCode == item.KrCode_) { Excel_interestRateViewModel e_irvm = item as Excel_interestRateViewModel; e_hwvm.setInterestRateInfo(e_irvm); } } if (!setFlag) { throw new Exception(underCode + " doesn't exist"); } return("set hullWhit_model complete : " + underCode); } catch (Exception e) { return("set fail : " + e.Message); } }
public int get_correlationNum() { try { Excel_standardSwapParaViewModel e_sspvm = this.InstVM_.Excel_parameterViewModel_ as Excel_standardSwapParaViewModel; int count = e_sspvm.Excel_underlyingCalcInfo_paraViewModel_.Excel_correlationInfo_paraViewModel_.Excel_correlation_paraViewModel_.Count; return(count); } catch (Exception) { return(0); } }
public string get_correlationInfo(int corrCount, InfoType infoType) { try { Excel_standardSwapParaViewModel e_sspvm = this.InstVM_.Excel_parameterViewModel_ as Excel_standardSwapParaViewModel; string vba_desc = e_sspvm.Excel_underlyingCalcInfo_paraViewModel_.Excel_correlationInfo_paraViewModel_.Excel_correlation_paraViewModel_[corrCount].vba_desciption(); return(this.infoParsing(vba_desc, infoType)); } catch (Exception e) { return("not implemented : " + e.Message); } }
private void addUnderlying(string underCodes) { string[] underCodeList = underCodes.Split(',', '|'); foreach (var item2 in underCodeList) { bool existFlag = false; // ir part A foreach (var item in this.swapInterfaceVM_.Excel_swapLegViewModel_[0].getExcel_underlyingCalcInfoViewModel().Excel_underlyingInfoViewModel_) { if (item2.Trim().ToUpper() == item.KrCode_.ToUpper()) { existFlag = true; } } // hifive part B foreach (var item in this.swapInterfaceVM_.Excel_swapLegViewModel_[1].getExcel_underlyingCalcInfoViewModel().Excel_underlyingInfoViewModel_) { if (item2.Trim().ToUpper() == item.KrCode_.ToUpper()) { existFlag = true; } } if (!existFlag) { Excel_underlyingInfoViewModel e_uivm = Excel_loaderViewModel.loadUnderInfoWithoutBasePrice(item2); this.InstVM_.Excel_interfaceViewModel_.Excel_underlyingCalcInfoViewModel_. Excel_underlyingInfoViewModel_.Add(e_uivm); Excel_standardSwapParaViewModel e_sspvm = this.InstVM_.Excel_parameterViewModel_ as Excel_standardSwapParaViewModel; Excel_underlyingInfo_paraViewModel e_ui_pvm = new Excel_underlyingInfo_paraViewModel(); e_ui_pvm.buildParaSetting(e_uivm); e_sspvm.Excel_underlyingCalcInfo_paraViewModel_.Excel_underlyingInfo_paraViewModel_.Add(e_ui_pvm); e_sspvm.Excel_underlyingCalcInfo_paraViewModel_.Excel_correlationInfo_paraViewModel_.addDiagonal(e_ui_pvm); } } return; }
public string set_forwardModel(string underCode, double currentValue, string tenor, YieldTermStructure fittingCurve) { try { Excel_standardSwapParaViewModel e_sspvm = this.InstVM_.Excel_parameterViewModel_ as Excel_standardSwapParaViewModel; // under 에서 tenor를 가져옴 //string tenor = "3M"; // defaultrrrr if (e_sspvm.Excel_underlyingCalcInfo_paraViewModel_.Excel_underlyingInfo_paraViewModel_.Count == 0) { throw new Exception("underlying parameter is empty"); } bool findFlag = false; foreach (var item in e_sspvm.Excel_underlyingCalcInfo_paraViewModel_.Excel_underlyingInfo_paraViewModel_) //foreach (var item in InstVM_.Excel_interfaceViewModel_.Excel_underlyingCalcInfoViewModel_.Excel_underlyingInfoViewModel_) { if (underCode.ToUpper() == item.KrCode_.ToUpper()) { Excel_forwardModelViewModel e_fmvm = new Excel_forwardModelViewModel(); e_fmvm.CurrentValue_ = currentValue.ToString(); e_fmvm.Tenor_ = tenor; e_fmvm.Excel_yieldCurveViewModel_ = fittingCurve.Excel_yieldCurveViewModel_; item.Excel_underlyingModel_paraViewModel_ = e_fmvm; findFlag = true; } } if (!findFlag) { throw new Exception(underCode + " does not exist"); } return("load complete"); } catch (Exception e) { return("load fail : " + e.Message); } }
public string set_gbmModel(string underCode, double currentValue, double drift, double dividend, double constVol) { try { Excel_standardSwapParaViewModel e_sspvm = this.InstVM_.Excel_parameterViewModel_ as Excel_standardSwapParaViewModel; bool setFlag = false; foreach (var item in e_sspvm.Excel_underlyingCalcInfo_paraViewModel_.Excel_underlyingInfo_paraViewModel_) //foreach (var item in InstVM_.Excel_interfaceViewModel_.Excel_underlyingCalcInfoViewModel_.Excel_underlyingInfoViewModel_) { if (underCode.ToUpper() == item.KrCode_.ToUpper()) { Excel_geometricBMViewModel e_gbmvm = new Excel_geometricBMViewModel(); e_gbmvm.CurrentValue_ = currentValue.ToString(); e_gbmvm.Drift_ = drift.ToString(); e_gbmvm.Dividend_ = dividend.ToString(); e_gbmvm.Volatility_ = constVol.ToString(); item.Excel_underlyingModel_paraViewModel_ = e_gbmvm; } } if (!setFlag) { throw new Exception(underCode + " doesn't exist"); } return("set gbm_model complete : " + underCode); } catch (Exception e) { string errStr = "set fail: " + e.Message; return(errStr); } }
public string set_hifiveLeg(SwapSide swapSide, Instrument_hifive inst_hifive) { try { Excel_hifiveSwapLegViewModel e_hifiveSwapLegVM = new Excel_hifiveSwapLegViewModel(); e_hifiveSwapLegVM.Excel_hifiveViewModel_ = inst_hifive.InstVM_.Excel_interfaceViewModel_ as Excel_hifiveViewModel; this.swapInterfaceVM_.Excel_swapLegViewModel_[1] = e_hifiveSwapLegVM; // para under add part Excel_standardSwapParaViewModel e_sspvm = this.InstVM_.Excel_parameterViewModel_ as Excel_standardSwapParaViewModel; foreach (var item in inst_hifive.InstVM_.Excel_interfaceViewModel_.Excel_underlyingCalcInfoViewModel_.Excel_underlyingInfoViewModel_) { this.addUnderlying(item.KrCode_); } return("OK"); } catch (Exception e) { return("set fail : " + e.Message); } }