public Excel_selectedUnderlyingViewModel Clone()
        {
            Excel_selectedUnderlyingViewModel clone = new Excel_selectedUnderlyingViewModel();

            clone.Code_      = this.code_;
            clone.NameTrans_ = this.nameTrans_;
            clone.Checked_   = this.checked_;

            return(clone);
        }
        //public static Excel_underlyingCalcIDViewModel CreateExcel_underlyingCalcID(string typeStr)
        //{
        //    //    Maximum ,
        //    //    Minimum ,
        //    //    Average

        //    if (typeStr.ToUpper() == "MAXIMUM")
        //    {
        //        return new Excel_maximumUnderlyingCalcIDViewModel();
        //    }
        //    else if (typeStr.ToUpper() == "MINIMUM")
        //    {
        //        return new Excel_minimumUnderlyingCalcIDViewModel();
        //    }
        //    else if (typeStr.ToUpper() == "AVERAGE")
        //    {
        //        return new Excel_averageUnderlyingCalcIDViewModel();
        //    }
        //    else
        //    {
        //        throw new NotImplementedException();
        //    }
        //}


        //이건 calculationEngine에 들어갈 꺼
        //public ReferenceCalculationInfoViewModel referenceCalcInfoVM()
        //{
        //    ReferenceCalculationInfoViewModel rcivm = new ReferenceCalculationInfoViewModel();

        //    if (this.excel_type_.ToUpper() == "MAXIMUM")
        //    {
        //        MaximumReferenceCalViewModel mrcvm = new MaximumReferenceCalViewModel();
        //        //mrcvm.SelectedUnderName_ = this.selectedUnderlyingName_;
        //        //mrcvm.Nth_ = this.nth_;
        //        rcivm.ReferenceCalculationViewModel_.Add(mrcvm);
        //    }
        //    else if (this.excel_type_.ToUpper() == "MINIMUM")
        //    {
        //        MinimumReferenceCalViewModel mrcvm = new MinimumReferenceCalViewModel();
        //        //mrcvm.SelectedUnderName_ = this.selectedUnderlyingName_;
        //        //mrcvm.Nth_ = this.nth_;
        //        rcivm.ReferenceCalculationViewModel_.Add(mrcvm);
        //    }
        //    else
        //    {
        //        throw new NotImplementedException();
        //    }

        //    //FixedFixingDateInfoViewModel ffdivm = new FixedFixingDateInfoViewModel();
        //    //ffdivm.Date_ = dateTime.ToString("yyyy-MM-dd");
        //    //mrcvm.FixingDateInfoViewModel_ = ffdivm;

        //    // operatorND set 이런거

        //    return rcivm;
        //}

        //public ReferenceCalculationInfoViewModel referenceCalcInfoVM()
        //{
        //    ReferenceCalculationInfoViewModel rcivm = new ReferenceCalculationInfoViewModel();

        //    ObservableCollection<EventCalculationViewModel> eventCalcViewModelList
        //        = new ObservableCollection<EventCalculationViewModel>();

        //    ecivm.EventCalculationViewModel_ = eventCalcViewModelList;

        //    foreach (var item in excel_eventCalcViewModel_)
        //    {
        //        eventCalcViewModelList.Add(item.eventCalcVM());
        //    }

        //    return ecivm;


        //}

        public virtual void setUnderlying(Excel_underlyingCalcInfoViewModel excel_under)
        {
            this.excel_selectedUnderlyingViewModel_.Clear();

            this.excel_underlyingCalcInfoViewModel_ = excel_under;

            foreach (var item in excel_under.Excel_underlyingInfoViewModel_)
            {
                Excel_selectedUnderlyingViewModel e_suvm = new Excel_selectedUnderlyingViewModel();

                e_suvm.Code_      = item.KrCode_;
                e_suvm.NameTrans_ = item.NameTrans_;
                e_suvm.Checked_   = false;

                this.excel_selectedUnderlyingViewModel_.Add(e_suvm);
            }
        }
        public override void setFromSerial(FpmlSerializedCSharp.ISerialized serial_Class)
        {
            FpmlSerializedCSharp.Excel_underlyingCalcID serial_Excel_underlyingCalcID = serial_Class as FpmlSerializedCSharp.Excel_underlyingCalcID;
            FpmlSerializedCSharp.Excel_maximumUnderlyingCalcID serial_Excel_maximumUnderlyingCalcID = serial_Excel_underlyingCalcID.Excel_maximumUnderlyingCalcID_;

            List<FpmlSerializedCSharp.Excel_selectedUnderlying> serial_excel_selectedUnderlying = serial_Excel_maximumUnderlyingCalcID.Excel_selectedUnderlying_;
            this.excel_selectedUnderlyingViewModel_ = new ObservableCollection<Excel_selectedUnderlyingViewModel>();
            foreach (var item in serial_excel_selectedUnderlying)
            {
                Excel_selectedUnderlyingViewModel viewModel = new Excel_selectedUnderlyingViewModel();
                viewModel.setFromSerial(item);
                this.excel_selectedUnderlyingViewModel_.Add(viewModel);
            }

            this.eventDate_ = serial_Excel_maximumUnderlyingCalcID.EventDate_.DateTimeValue();
            this.averageDays_ = serial_Excel_maximumUnderlyingCalcID.AverageDays_.ValueStr;
        }
        public override void setFromSerial(FpmlSerializedCSharp.ISerialized serial_Class)
        {
            FpmlSerializedCSharp.Excel_underlyingCalcID       serial_Excel_underlyingCalcID       = serial_Class as FpmlSerializedCSharp.Excel_underlyingCalcID;
            FpmlSerializedCSharp.Excel_choiceUnderlyingCalcID serial_Excel_choiceUnderlyingCalcID = serial_Excel_underlyingCalcID.Excel_choiceUnderlyingCalcID_;

            List <FpmlSerializedCSharp.Excel_selectedUnderlying> serial_excel_selectedUnderlying = serial_Excel_choiceUnderlyingCalcID.Excel_selectedUnderlying_;

            this.excel_selectedUnderlyingViewModel_ = new ObservableCollection <Excel_selectedUnderlyingViewModel>();
            foreach (var item in serial_excel_selectedUnderlying)
            {
                Excel_selectedUnderlyingViewModel viewModel = new Excel_selectedUnderlyingViewModel();
                viewModel.setFromSerial(item);
                this.excel_selectedUnderlyingViewModel_.Add(viewModel);
            }

            this.eventDate_   = serial_Excel_choiceUnderlyingCalcID.EventDate_.DateTimeValue();
            this.averageDays_ = serial_Excel_choiceUnderlyingCalcID.AverageDays_.ValueStr;
        }
        public override void setFromSerial(FpmlSerializedCSharp.ISerialized serial_Class)
        {
            FpmlSerializedCSharp.Excel_underlyingCalcID        serial_Excel_underlyingCalcID        = serial_Class as FpmlSerializedCSharp.Excel_underlyingCalcID;
            FpmlSerializedCSharp.Excel_minimumUnderlyingCalcID serial_Excel_minimumUnderlyingCalcID = serial_Excel_underlyingCalcID.Excel_minimumUnderlyingCalcID_;

            List <FpmlSerializedCSharp.Excel_selectedUnderlying> serial_excel_selectedUnderlying = serial_Excel_minimumUnderlyingCalcID.Excel_selectedUnderlying_;

            this.excel_selectedUnderlyingViewModel_ = new ObservableCollection <Excel_selectedUnderlyingViewModel>();
            foreach (var item in serial_excel_selectedUnderlying)
            {
                string type = item.Excel_type_.ValueStr;
                Excel_selectedUnderlyingViewModel viewModel = Excel_selectedUnderlyingViewModel.CreateExcel_selectedUnderlying(type);
                viewModel.setFromSerial(item);
                this.excel_selectedUnderlyingViewModel_.Add(viewModel);
            }

            this.eventDate_ = StringConverter.xmlDateToDateTime(serial_Excel_minimumUnderlyingCalcID.EventDate_.ValueStr);

            this.averageDays_ = serial_Excel_minimumUnderlyingCalcID.AverageDays_.ValueStr;
        }
        public Excel_selectedUnderlyingViewModel Clone()
        {
            Excel_selectedUnderlyingViewModel clone = new Excel_selectedUnderlyingViewModel();

            clone.Code_ = this.code_;
            clone.NameTrans_= this.nameTrans_;
            clone.Checked_= this.checked_;

            return clone;
        }
        public void addSingleConditionDualRangAccrualFixedCoupon(DateTime calculationStartDate,
                                                DateTime calculationEndDate,
                                                DateTime payoffDate,
                                                List<double> lowerRngList,
                                                List<string> referenceUnderCodeList,
                                                List<double> upperRngList,
                                                double fixedRate)
        {
            Excel_multiCondi_multiRng_structuredAccrualCouponScheduleViewModel e_mc_mr_sacsvm
                    = new Excel_multiCondi_multiRng_structuredAccrualCouponScheduleViewModel();

            e_mc_mr_sacsvm.EventDate_ = payoffDate;

            e_mc_mr_sacsvm.CalculationStartDate_ = calculationStartDate;
            e_mc_mr_sacsvm.CalculationEndDate_ = calculationEndDate;
            e_mc_mr_sacsvm.PayoffDate_ = payoffDate;

            int rangeCount = lowerRngList.Count;

            Excel_multi_rangeNDViewModel e_m_rngNDVM = new Excel_multi_rangeNDViewModel();

            for (int i = 0; i < rangeCount; i++)
            {
                Range1DViewModel accRng1D = new Range1DViewModel();

                accRng1D.LowerBound_ = lowerRngList[i].ToString();

                DateTime effDate = this.instVM_.Excel_interfaceViewModel_.Excel_issueInfoViewModel_.EffectiveDate_;
                
                //this.addUnderlying(Excel_loaderViewModel.loadUnderInfo2(effDate, referenceUnderCodeList[i]));
                this.addUnderlying(effDate, referenceUnderCodeList[i]);

                Excel_choiceUnderlyingCalcIDViewModel choiceUnderCalcIDVM = new Excel_choiceUnderlyingCalcIDViewModel();

                choiceUnderCalcIDVM.EventDate_ = payoffDate;

                Excel_selectedUnderlyingViewModel selectedUnder = new Excel_selectedUnderlyingViewModel();
                selectedUnder.Code_ = referenceUnderCodeList[i];
                selectedUnder.NameTrans_ = new NameTrans(referenceUnderCodeList[i]);
                selectedUnder.Checked_ = true;

                choiceUnderCalcIDVM.Excel_selectedUnderlyingViewModel_.Add(selectedUnder);

                accRng1D.UpperBound_ = upperRngList[i].ToString();

                e_m_rngNDVM.Range1DViewModel_.Add(accRng1D);
                e_m_rngNDVM.Excel_underlyingCalcIDViewModel_.Add(choiceUnderCalcIDVM);
            }

            e_mc_mr_sacsvm.Excel_multi_rangeNDViewModel_.Add(e_m_rngNDVM);

            Excel_constReturnCalViewModel e_crcvm = new Excel_constReturnCalViewModel();

            e_crcvm.ConstReturn_ = fixedRate.ToString();

            e_mc_mr_sacsvm.Excel_returnCalcInfoViewModel_.Add(e_crcvm);

            //e_mc_sacsvm.FixedRate_ = fixedRate.ToString();

            Excel_structuredBondViewModel e_sbvm = this.instVM_.Excel_interfaceViewModel_ as Excel_structuredBondViewModel;

            e_sbvm.Excel_couponScheduleListViewModel_.Excel_couponScheduleViewModel_.Add(e_mc_mr_sacsvm);

            //this.instVM_.Excel_interfaceViewModel_ = e_sbvm;
        }
        public string addSingleConditionDualRangAccrualFixedCoupon(DateTime calculationStartDate,
                                                DateTime calculationEndDate,
                                                DateTime payoffDate,
                                                List<double> lowerRngList,
                                                List<string> referenceUnderCodeList,
                                                List<double> upperRngList,
                                                double fixedRate)
        {
            try
            {
                #region CheckParameter

                if (calculationStartDate >= calculationEndDate)
                    throw new Exception("startDate must be earlier than endDate");

                //// check underlying 
                //if ( !this.hasUnderlyings(underlyings))
                //    throw new Exception(underlyings + " does not exist. add underlying first.");


                #endregion

                Excel_multiCondi_multiRng_structuredAccrualCouponScheduleViewModel e_mc_mr_sacsvm
                        = new Excel_multiCondi_multiRng_structuredAccrualCouponScheduleViewModel();

                e_mc_mr_sacsvm.EventDate_ = payoffDate;

                e_mc_mr_sacsvm.CalculationStartDate_ = calculationStartDate;
                e_mc_mr_sacsvm.CalculationEndDate_ = calculationEndDate;
                e_mc_mr_sacsvm.PayoffDate_ = payoffDate;

                int rangeCount = lowerRngList.Count;

                Excel_multi_rangeNDViewModel e_m_rngNDVM = new Excel_multi_rangeNDViewModel();

                for (int i = 0; i < rangeCount; i++)
                {
                    Range1DViewModel accRng1D = new Range1DViewModel();

                    accRng1D.LowerBound_ = lowerRngList[i].ToString();

                    DateTime effDate = this.InstVM_.Excel_interfaceViewModel_.Excel_issueInfoViewModel_.EffectiveDate_;

                    //this.addUnderlying(Excel_loaderViewModel.loadUnderInfo2(effDate, referenceUnderCodeList[i]));
                    this.addUnderlying(referenceUnderCodeList[i]);

                    Excel_choiceUnderlyingCalcIDViewModel choiceUnderCalcIDVM = new Excel_choiceUnderlyingCalcIDViewModel();

                    choiceUnderCalcIDVM.EventDate_ = payoffDate;

                    Excel_selectedUnderlyingViewModel selectedUnder = new Excel_selectedUnderlyingViewModel();
                    selectedUnder.Code_ = referenceUnderCodeList[i];
                    selectedUnder.NameTrans_ = new NameTrans(referenceUnderCodeList[i]);
                    selectedUnder.Checked_ = true;

                    choiceUnderCalcIDVM.Excel_selectedUnderlyingViewModel_.Add(selectedUnder);

                    accRng1D.UpperBound_ = upperRngList[i].ToString();

                    e_m_rngNDVM.Range1DViewModel_.Add(accRng1D);
                    e_m_rngNDVM.Excel_underlyingCalcIDViewModel_.Add(choiceUnderCalcIDVM);
                }

                e_mc_mr_sacsvm.Excel_multi_rangeNDViewModel_.Add(e_m_rngNDVM);

                Excel_constReturnCalViewModel e_crcvm = new Excel_constReturnCalViewModel();

                e_crcvm.ConstReturn_ = fixedRate.ToString();

                e_mc_mr_sacsvm.Excel_returnCalcInfoViewModel_.Add(e_crcvm);

                //e_mc_sacsvm.FixedRate_ = fixedRate.ToString();

                Excel_structuredBondViewModel e_sbvm = this.InstVM_.Excel_interfaceViewModel_ as Excel_structuredBondViewModel;

                e_sbvm.Excel_couponScheduleListViewModel_.Excel_couponScheduleViewModel_.Add(e_mc_mr_sacsvm);

                //this.instVM_.Excel_interfaceViewModel_ = e_sbvm;

                return "OK";
            }
            catch (Exception)
            {
                return "singleConditionDualRangAccrualFixedCoupon Add Fail";
            }
        }
        public void addSingleConditionDualRangAccrualFixedCoupon(DateTime calculationStartDate,
                                                                 DateTime calculationEndDate,
                                                                 DateTime payoffDate,
                                                                 List <double> lowerRngList,
                                                                 List <string> referenceUnderCodeList,
                                                                 List <double> upperRngList,
                                                                 double fixedRate)
        {
            Excel_multiCondi_multiRng_structuredAccrualCouponScheduleViewModel e_mc_mr_sacsvm
                = new Excel_multiCondi_multiRng_structuredAccrualCouponScheduleViewModel();

            e_mc_mr_sacsvm.EventDate_ = payoffDate;

            e_mc_mr_sacsvm.CalculationStartDate_ = calculationStartDate;
            e_mc_mr_sacsvm.CalculationEndDate_   = calculationEndDate;
            e_mc_mr_sacsvm.PayoffDate_           = payoffDate;

            int rangeCount = lowerRngList.Count;

            Excel_multi_rangeNDViewModel e_m_rngNDVM = new Excel_multi_rangeNDViewModel();

            for (int i = 0; i < rangeCount; i++)
            {
                Range1DViewModel accRng1D = new Range1DViewModel();

                accRng1D.LowerBound_ = lowerRngList[i].ToString();

                DateTime effDate = this.instVM_.Excel_interfaceViewModel_.Excel_issueInfoViewModel_.EffectiveDate_;

                //this.addUnderlying(Excel_loaderViewModel.loadUnderInfo2(effDate, referenceUnderCodeList[i]));
                this.addUnderlying(effDate, referenceUnderCodeList[i]);

                Excel_choiceUnderlyingCalcIDViewModel choiceUnderCalcIDVM = new Excel_choiceUnderlyingCalcIDViewModel();

                choiceUnderCalcIDVM.EventDate_ = payoffDate;

                Excel_selectedUnderlyingViewModel selectedUnder = new Excel_selectedUnderlyingViewModel();
                selectedUnder.Code_      = referenceUnderCodeList[i];
                selectedUnder.NameTrans_ = new NameTrans(referenceUnderCodeList[i]);
                selectedUnder.Checked_   = true;

                choiceUnderCalcIDVM.Excel_selectedUnderlyingViewModel_.Add(selectedUnder);

                accRng1D.UpperBound_ = upperRngList[i].ToString();

                e_m_rngNDVM.Range1DViewModel_.Add(accRng1D);
                e_m_rngNDVM.Excel_underlyingCalcIDViewModel_.Add(choiceUnderCalcIDVM);
            }

            e_mc_mr_sacsvm.Excel_multi_rangeNDViewModel_.Add(e_m_rngNDVM);

            Excel_constReturnCalViewModel e_crcvm = new Excel_constReturnCalViewModel();

            e_crcvm.ConstReturn_ = fixedRate.ToString();

            e_mc_mr_sacsvm.Excel_returnCalcInfoViewModel_.Add(e_crcvm);

            //e_mc_sacsvm.FixedRate_ = fixedRate.ToString();

            Excel_structuredBondViewModel e_sbvm = this.instVM_.Excel_interfaceViewModel_ as Excel_structuredBondViewModel;

            e_sbvm.Excel_couponScheduleListViewModel_.Excel_couponScheduleViewModel_.Add(e_mc_mr_sacsvm);

            //this.instVM_.Excel_interfaceViewModel_ = e_sbvm;
        }