예제 #1
0
        public string set_discountCurve(string currency, YieldTermStructure discountCurve)
        {
            try
            {
                Excel_standardParaViewModel e_sphvm = this.InstVM_.Excel_parameterViewModel_ as Excel_standardParaViewModel;

                int count = e_sphvm.Excel_discountCurve_paraViewModel_.hasCurrencysYieldCurve(currency);

                discountCurve.Excel_yieldCurveViewModel_.Currency_ = currency;

                if (count == -1)
                {
                    e_sphvm.Excel_discountCurve_paraViewModel_.Excel_yieldCurveViewModel_
                    .Add(discountCurve.Excel_yieldCurveViewModel_);
                }
                else
                {
                    e_sphvm.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);
            }
        }
예제 #2
0
        public string set_gbmModel(string underCode, double currentValue, double drift, double dividend, double constVol)
        {
            try
            {
                Excel_standardParaViewModel e_sphvm = this.InstVM_.Excel_parameterViewModel_ as Excel_standardParaViewModel;

                foreach (var item in e_sphvm.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;
                    }
                }

                return("set gbm_model complete : " + underCode);
            }
            catch (Exception e)
            {
                string errStr = "set fail: " + e.Message;

                return(errStr);
            }
        }
예제 #3
0
        public string set_basePrice(string underCode, double basePrice)
        {
            string errLog = "";

            foreach (var item in this.InstVM_.Excel_interfaceViewModel_.Excel_underlyingCalcInfoViewModel_.Excel_underlyingInfoViewModel_)
            {
                if (underCode.Trim().ToUpper() == item.KrCode_.ToUpper())
                {
                    item.BasePrice_ = basePrice.ToString();

                    errLog = errLog + "inst under complete ";
                }
            }

            Excel_standardParaViewModel e_sphvm = this.InstVM_.Excel_parameterViewModel_ as Excel_standardParaViewModel;

            foreach (var item in e_sphvm.Excel_underlyingCalcInfo_paraViewModel_.Excel_underlyingInfo_paraViewModel_)
            {
                if (underCode.Trim().ToUpper() == item.KrCode_.ToUpper())
                {
                    item.BasePrice_ = basePrice.ToString();

                    errLog = errLog + "para under complete";
                }
            }

            if (errLog == "")
            {
                return("set fail");
            }

            return("set complete");
        }
예제 #4
0
        public string set_hullWhiteModel(string underCode, double currentValue, double alpha, double sigma, YieldTermStructure fittingCurve)
        {
            try
            {
                Excel_standardParaViewModel e_sphvm = this.InstVM_.Excel_parameterViewModel_ as Excel_standardParaViewModel;

                // under 에서 tenor를 가져옴
                string tenor = "3M"; // defaultrrrr

                Excel_rateInfoViewModel e_rateInfoVM = new Excel_rateInfoViewModel();

                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_rateInfoVM.Tenor_     = e_irvm.Tenor_;
                        e_rateInfoVM.LegTenor_  = e_irvm.LegTenor_;
                        e_rateInfoVM.IndexType_ = e_irvm.RateType_;
                        e_rateInfoVM.Currency_  = e_irvm.Currency_;
                    }
                }

                bool setFlag = false;

                foreach (var item in e_sphvm.Excel_underlyingCalcInfo_paraViewModel_.Excel_underlyingInfo_paraViewModel_)
                {
                    if (underCode == item.KrCode_)
                    {
                        Excel_hullWhiteOneFactorViewModel e_hwvm = new Excel_hullWhiteOneFactorViewModel();

                        e_hwvm.CurrentValue_ = currentValue.ToString();

                        e_hwvm.Excel_rateInfoViewModel_ = e_rateInfoVM;

                        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;
                    }
                }

                if (!setFlag)
                {
                    throw new Exception(underCode + " doesn't exist");
                }

                return("set hullWhit_model complete : " + underCode);
            }
            catch (Exception e)
            {
                return("set fail : " + e.Message);
            }
        }
예제 #5
0
        public int get_underlyingParaNum()
        {
            try
            {
                Excel_standardParaViewModel e_spvm = this.InstVM_.Excel_parameterViewModel_ as Excel_standardParaViewModel;

                int count = e_spvm.Excel_underlyingCalcInfo_paraViewModel_.Excel_underlyingInfo_paraViewModel_.Count;

                return(count);
            }
            catch (Exception)
            {
                return(0);
            }
        }
예제 #6
0
        public string get_correlationInfo(int corrCount, InfoType infoType)
        {
            try
            {
                Excel_standardParaViewModel e_spvm = this.InstVM_.Excel_parameterViewModel_ as Excel_standardParaViewModel;

                string vba_desc = e_spvm.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);
            }
        }
예제 #7
0
        public string set_forwardModel(string underCode, double currentValue, string tenor, YieldTermStructure fittingCurve)
        {
            try
            {
                Excel_standardParaViewModel e_sphvm = this.InstVM_.Excel_parameterViewModel_ as Excel_standardParaViewModel;

                // under 에서 tenor를 가져옴
                //string tenor = "3M"; // defaultrrrr
                if (e_sphvm.Excel_underlyingCalcInfo_paraViewModel_.Excel_underlyingInfo_paraViewModel_.Count == 0)
                {
                    throw new Exception("underlying parameter is empty");
                }

                bool findFlag = false;

                foreach (var item in e_sphvm.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);
            }
        }
예제 #8
0
        private void addUnderlying(string underCodes)
        {
            string[] underCodeList = underCodes.Split(',', '|');

            foreach (var item2 in underCodeList)
            {
                bool existFlag = false;

                foreach (var item in this.InstVM_.Excel_interfaceViewModel_.Excel_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_standardParaViewModel e_sphvm = this.InstVM_.Excel_parameterViewModel_ as Excel_standardParaViewModel;

                    Excel_underlyingInfo_paraViewModel e_ui_pvm = new Excel_underlyingInfo_paraViewModel();

                    e_ui_pvm.buildParaSetting(e_uivm);

                    e_sphvm.Excel_underlyingCalcInfo_paraViewModel_.Excel_underlyingInfo_paraViewModel_.Add(e_ui_pvm);

                    e_sphvm.Excel_underlyingCalcInfo_paraViewModel_.Excel_correlationInfo_paraViewModel_.addDiagonal(e_ui_pvm);
                }
            }

            return;
        }
예제 #9
0
        public string load_instrument(string itemCode)
        {
            try
            {
                Excel_instrumentViewModel e_i_hvm = MasterInformationViewModel.loadInstrumentVM(itemCode);

                //this.InstVM_ = new Excel_instrument_hifiveViewModel();
                this.InstVM_ = e_i_hvm as Excel_instrument_structuredBondViewModel;

                if (this.InstVM_ == null)
                {
                    throw new Exception("instrument is not structuredBond type");
                }

                this.InstVM_.loadInterfaceVMFromXml(XMLFileLoader.LoadInstrument(itemCode));

                //
                Excel_standardParaViewModel e_spvm = this.InstVM_.Excel_parameterViewModel_ as Excel_standardParaViewModel;
                //

                foreach (var item in InstVM_.Excel_interfaceViewModel_.Excel_underlyingCalcInfoViewModel_.Excel_underlyingInfoViewModel_)
                {
                    Excel_underlyingInfo_paraViewModel e_u_pvm = new Excel_underlyingInfo_paraViewModel();

                    e_u_pvm.buildParaSetting(item);

                    e_spvm.Excel_underlyingCalcInfo_paraViewModel_.Excel_underlyingInfo_paraViewModel_.Add(e_u_pvm);
                    e_spvm.Excel_underlyingCalcInfo_paraViewModel_.Excel_correlationInfo_paraViewModel_.addDiagonal(e_u_pvm);
                }

                return("load complete");
            }
            catch (Exception e)
            {
                return("load err : " + e.Message);
            }
        }
예제 #10
0
        public string set_correlation(string first, string second, double corr)
        {
            try
            {
                Excel_standardParaViewModel e_sphvm = this.InstVM_.Excel_parameterViewModel_ as Excel_standardParaViewModel;

                //if (first == second)
                //    throw new Exception("underlying code is same");

                if (!e_sphvm.Excel_underlyingCalcInfo_paraViewModel_.hasUnderlying(first))
                {
                    throw new Exception("underlying code doesn't exist : " + first);
                }

                if (!e_sphvm.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_sphvm.Excel_underlyingCalcInfo_paraViewModel_.Excel_correlationInfo_paraViewModel_.
                setCorrelation(first, second, corr);

                return("set corr complete : " + first + " " + second);
            }
            catch (Exception e)
            {
                string errStr = "set fail: " + e.Message;

                return(errStr);
            }
        }