private void ViewModelChanged(object sender, DependencyPropertyChangedEventArgs e)
 {
     this.viewModel_ = this.DataContext as Excel_constReturnCalViewModel;
 }
        private Excel_simpleCalculationViewModel excel_simpleCalculationVMBuild(Excel_stepDownKI_subScheduleViewModel scheduleData)
        {
            Excel_simpleCalculationViewModel e_cvm = new Excel_simpleCalculationViewModel();

            e_cvm.Excel_underlyingCalcInfoViewModel_ = this.Excel_underlyingCalcInfoViewModel_;

            e_cvm.EventDate_ = scheduleData.EventDate_;

            e_cvm.PayoffDate_ = this.scheduleGeneratorVM_.addDays(scheduleData.EventDate_,this.settlementDays_);
            
            #region EventCal
            //---------------------------------------------------------------
            {
                //Excel_eventCalcInfoViewModel e_ecivm = new Excel_eventCalcInfoViewModel();

                Excel_singleRangeEventCalViewModel e_srecvm = new Excel_singleRangeEventCalViewModel();

                e_srecvm.Excel_underlyingCalcInfoViewModel_ = this.Excel_underlyingCalcInfoViewModel_;

                e_srecvm.LowerRng_ = (Convert.ToDouble(scheduleData.Trigger_) /100.0).ToString();
                e_srecvm.UpperRng_ = "1000";

                // 우선 max를 사용함
                Excel_underlyingCalcIDViewModel e_mucidvm = Excel_stepDownKI_subScheduleViewModel.CreateExcel_underlyingCalcID(scheduleData);

                e_mucidvm.setUnderlying(this.Excel_underlyingCalcInfoViewModel_);

                e_srecvm.Excel_underlyingCalcIDViewModel_ = e_mucidvm;

                //e_ecivm.Excel_eventCalcViewModel_.Add(e_srecvm);

                e_cvm.Excel_eventCalcInfoViewModel_ = e_srecvm;

                //info 에 드가는 곱하기라던지 floor라던지 postCalculation 같은게 붙어야함

            }

            #endregion

            #region ReturnCal
            //---------------------------------------------------------------
            {
                //Excel_returnCalcInfoViewModel e_rcivm = new Excel_returnCalcInfoViewModel();

                Excel_constReturnCalViewModel e_crcvm = new Excel_constReturnCalViewModel();

                e_crcvm.Excel_underlyingCalcInfoViewModel_ = this.Excel_underlyingCalcInfoViewModel_;

                e_crcvm.ConstReturn_ = (Convert.ToDouble(scheduleData.Coupon_) / 100).ToString();

                //e_rcivm.Excel_returnCalcViewModel_.Add(e_crcvm);

                e_cvm.Excel_returnCalcInfoViewModel_ = e_crcvm;

                //info 에 드가는 곱하기라던지 floor라던지 postCalculation 같은게 붙어야함

            }
            #endregion

            #region ComplementReturnCal
            {
                Excel_complementReturnCalcViewModel e_comp_rcvm = new Excel_complementReturnCalcViewModel();

                Excel_constReturnCalViewModel e_crcvm = new Excel_constReturnCalViewModel();

                e_crcvm.Excel_underlyingCalcInfoViewModel_ = this.Excel_underlyingCalcInfoViewModel_;

                e_crcvm.ConstReturn_ = "0.0";

                e_comp_rcvm.Excel_returnCalcInfoViewModel_ = e_crcvm;

                e_cvm.Excel_complementReturnCalcViewModel_ = e_comp_rcvm;
            }
            #endregion

            #region AutoCall_Event

            //---------------------------------------------------------------
            {
                Excel_eventCalcInfo_CallViewModel e_ecicvm = new Excel_eventCalcInfo_CallViewModel();

                Excel_singleRangeEventCalViewModel e_srecvm = new Excel_singleRangeEventCalViewModel();
                
                e_srecvm.Excel_underlyingCalcInfoViewModel_ = this.Excel_underlyingCalcInfoViewModel_;

                e_srecvm.LowerRng_ = (Convert.ToDouble(scheduleData.Trigger_) / 100.0).ToString();
                e_srecvm.UpperRng_ = "1000";

                //처음꺼만 사용함
                Excel_underlyingCalcIDViewModel e_mucidvm = Excel_stepDownKI_subScheduleViewModel.CreateExcel_underlyingCalcID(scheduleData);

                e_mucidvm.setUnderlying(this.Excel_underlyingCalcInfoViewModel_);

                e_srecvm.Excel_underlyingCalcIDViewModel_ = e_mucidvm;

                e_ecicvm.Excel_eventCalcInfoViewModel_ = e_srecvm;

                e_cvm.Excel_eventCalcInfo_CallViewModel_ = e_ecicvm;

                //info 에 드가는 곱하기라던지 floor라던지 postCalculation 같은게 붙어야함

            }

            #endregion

            #region AutoCall_ReturnCal

            //---------------------------------------------------------------
            {
                Excel_returnCalcInfo_CallViewModel e_rcicvm = new Excel_returnCalcInfo_CallViewModel();

                Excel_constReturnCalViewModel e_crcvm = new Excel_constReturnCalViewModel();

                e_crcvm.Excel_underlyingCalcInfoViewModel_ = this.Excel_underlyingCalcInfoViewModel_;

                e_crcvm.ConstReturn_ = "1.0"; // 원금

                e_rcicvm.Excel_returnCalcInfoViewModel_ = e_crcvm;

                e_cvm.Excel_returnCalcInfo_CallViewModel_ = e_rcicvm;

                //info 에 드가는 곱하기라던지 floor라던지 postCalculation 같은게 붙어야함

            }

            #endregion

            return e_cvm;
        }
        public override void excel_kiEventCalculationBuild()
        {
            Excel_simpleKiEventCalcViewModel e_simpleKiEvent = new Excel_simpleKiEventCalcViewModel();

            e_simpleKiEvent.Excel_underlyingCalcInfoViewModel_ = this.Excel_underlyingCalcInfoViewModel_;

            e_simpleKiEvent.EventDate_ = this.KiObEndDate_;
            e_simpleKiEvent.PayoffDate_ = this.KiObEndDate_;

            #region EventCal
            {
                Excel_singleBarrierEventCalViewModel e_singleBarrierEvent = new Excel_singleBarrierEventCalViewModel();

                e_singleBarrierEvent.UpperTrigger_ = "1000";
                e_singleBarrierEvent.LowerTrigger_ = ( Convert.ToDouble(this.Ki_) /100.0 ).ToString();

                // 우선 max를 사용함

                Excel_minimumUnderlyingCalcIDViewModel e_mucidvm = new Excel_minimumUnderlyingCalcIDViewModel();

                e_mucidvm.EventDate_ = this.KiObEndDate_;

                e_mucidvm.setUnderlying(this.Excel_underlyingCalcInfoViewModel_);

                e_singleBarrierEvent.Excel_underlyingCalcIDViewModel_ = e_mucidvm;

                e_singleBarrierEvent.setUnderlying(this.Excel_underlyingCalcInfoViewModel_);

                e_singleBarrierEvent.ObservationStartDate_ = this.KiObStartDate_;
                e_singleBarrierEvent.ObservationEndDate_ = this.KiObEndDate_;

                e_simpleKiEvent.Excel_eventCalcInfoViewModel_ = e_singleBarrierEvent;
            }
            #endregion

            #region OccReturn
            {
                Excel_vanillaReturnCalViewModel e_vanillaReturn = new Excel_vanillaReturnCalViewModel();

                e_vanillaReturn.Excel_underlyingCalcInfoViewModel_ = this.Excel_underlyingCalcInfoViewModel_;

                //e_vanillaReturn.Gearing_ = "-1";
                //e_vanillaReturn.Spread_ = "-0.2";

                e_vanillaReturn.Gearing_ = "1.0";
                e_vanillaReturn.Spread_ = "0.0";

                Excel_minimumUnderlyingCalcIDViewModel e_mucidvm = new Excel_minimumUnderlyingCalcIDViewModel();

                e_mucidvm.EventDate_ = this.KiObEndDate_;
                e_mucidvm.setUnderlying(this.Excel_underlyingCalcInfoViewModel_);

                e_vanillaReturn.ReturnUnderlyingCalcIDViewModel_ = e_mucidvm;

                e_simpleKiEvent.Excel_occReturnCalcInfoViewModel_ = new Excel_occReturnCalcInfoViewModel();
                e_simpleKiEvent.Excel_occReturnCalcInfoViewModel_.Excel_returnCalcInfoViewModel_ = e_vanillaReturn;
            }
            #endregion

            #region noOccReturn
            {
                Excel_constReturnCalViewModel e_constReturnCalc = new Excel_constReturnCalViewModel();
                int count = this.subScheduleDataList_.Count;

                //입력으로 받아도 대는데 지금은 마지막껄로함.
                e_constReturnCalc.ConstReturn_ = (1.0 + Convert.ToDouble(this.subScheduleDataList_[count - 1].Coupon_) / 100.0).ToString();

                e_constReturnCalc.Excel_underlyingCalcInfoViewModel_ = this.Excel_underlyingCalcInfoViewModel_;

                e_simpleKiEvent.Excel_noOccReturnCalcInfoViewModel_ = new Excel_noOccReturnCalcInfoViewModel();
                e_simpleKiEvent.Excel_noOccReturnCalcInfoViewModel_.Excel_returnCalcInfoViewModel_ = e_constReturnCalc;

                e_simpleKiEvent.Excel_noOccReturnCalcInfoViewModel_.setUnderlying(this.Excel_underlyingCalcInfoViewModel_);
            }
            #endregion

            this.Excel_kiEventCalculationViewModel_ = e_simpleKiEvent;
        }
        private Excel_simpleCalculationViewModel excel_simpleCalculationVMBuild(Excel_stepDownKI_subScheduleViewModel scheduleData)
        {
            Excel_simpleCalculationViewModel e_cvm = new Excel_simpleCalculationViewModel();

            e_cvm.Excel_underlyingCalcInfoViewModel_ = this.Excel_underlyingCalcInfoViewModel_;

            e_cvm.EventDate_ = scheduleData.EventDate_;

            e_cvm.PayoffDate_ = this.scheduleGeneratorVM_.addDays(scheduleData.EventDate_, this.settlementDays_);

            #region EventCal
            //---------------------------------------------------------------
            {
                //Excel_eventCalcInfoViewModel e_ecivm = new Excel_eventCalcInfoViewModel();

                Excel_singleRangeEventCalViewModel e_srecvm = new Excel_singleRangeEventCalViewModel();

                e_srecvm.Excel_underlyingCalcInfoViewModel_ = this.Excel_underlyingCalcInfoViewModel_;

                e_srecvm.LowerRng_ = (Convert.ToDouble(scheduleData.Trigger_) / 100.0).ToString();
                e_srecvm.UpperRng_ = "1000";

                // 우선 max를 사용함
                Excel_underlyingCalcIDViewModel e_mucidvm = Excel_stepDownKI_subScheduleViewModel.CreateExcel_underlyingCalcID(scheduleData);

                e_mucidvm.setUnderlying(this.Excel_underlyingCalcInfoViewModel_);

                e_srecvm.Excel_underlyingCalcIDViewModel_ = e_mucidvm;

                //e_ecivm.Excel_eventCalcViewModel_.Add(e_srecvm);

                e_cvm.Excel_eventCalcInfoViewModel_ = e_srecvm;

                //info 에 드가는 곱하기라던지 floor라던지 postCalculation 같은게 붙어야함
            }

            #endregion

            #region ReturnCal
            //---------------------------------------------------------------
            {
                //Excel_returnCalcInfoViewModel e_rcivm = new Excel_returnCalcInfoViewModel();

                Excel_constReturnCalViewModel e_crcvm = new Excel_constReturnCalViewModel();

                e_crcvm.Excel_underlyingCalcInfoViewModel_ = this.Excel_underlyingCalcInfoViewModel_;

                e_crcvm.ConstReturn_ = (Convert.ToDouble(scheduleData.Coupon_) / 100).ToString();

                //e_rcivm.Excel_returnCalcViewModel_.Add(e_crcvm);

                e_cvm.Excel_returnCalcInfoViewModel_ = e_crcvm;

                //info 에 드가는 곱하기라던지 floor라던지 postCalculation 같은게 붙어야함
            }
            #endregion

            #region ComplementReturnCal
            {
                Excel_complementReturnCalcViewModel e_comp_rcvm = new Excel_complementReturnCalcViewModel();

                Excel_constReturnCalViewModel e_crcvm = new Excel_constReturnCalViewModel();

                e_crcvm.Excel_underlyingCalcInfoViewModel_ = this.Excel_underlyingCalcInfoViewModel_;

                e_crcvm.ConstReturn_ = "0.0";

                e_comp_rcvm.Excel_returnCalcInfoViewModel_ = e_crcvm;

                e_cvm.Excel_complementReturnCalcViewModel_ = e_comp_rcvm;
            }
            #endregion

            #region AutoCall_Event

            //---------------------------------------------------------------
            {
                Excel_eventCalcInfo_CallViewModel e_ecicvm = new Excel_eventCalcInfo_CallViewModel();

                Excel_singleRangeEventCalViewModel e_srecvm = new Excel_singleRangeEventCalViewModel();

                e_srecvm.Excel_underlyingCalcInfoViewModel_ = this.Excel_underlyingCalcInfoViewModel_;

                e_srecvm.LowerRng_ = (Convert.ToDouble(scheduleData.Trigger_) / 100.0).ToString();
                e_srecvm.UpperRng_ = "1000";

                //처음꺼만 사용함
                Excel_underlyingCalcIDViewModel e_mucidvm = Excel_stepDownKI_subScheduleViewModel.CreateExcel_underlyingCalcID(scheduleData);

                e_mucidvm.setUnderlying(this.Excel_underlyingCalcInfoViewModel_);

                e_srecvm.Excel_underlyingCalcIDViewModel_ = e_mucidvm;

                e_ecicvm.Excel_eventCalcInfoViewModel_ = e_srecvm;

                e_cvm.Excel_eventCalcInfo_CallViewModel_ = e_ecicvm;

                //info 에 드가는 곱하기라던지 floor라던지 postCalculation 같은게 붙어야함
            }

            #endregion

            #region AutoCall_ReturnCal

            //---------------------------------------------------------------
            {
                Excel_returnCalcInfo_CallViewModel e_rcicvm = new Excel_returnCalcInfo_CallViewModel();

                Excel_constReturnCalViewModel e_crcvm = new Excel_constReturnCalViewModel();

                e_crcvm.Excel_underlyingCalcInfoViewModel_ = this.Excel_underlyingCalcInfoViewModel_;

                e_crcvm.ConstReturn_ = "1.0"; // 원금

                e_rcicvm.Excel_returnCalcInfoViewModel_ = e_crcvm;

                e_cvm.Excel_returnCalcInfo_CallViewModel_ = e_rcicvm;

                //info 에 드가는 곱하기라던지 floor라던지 postCalculation 같은게 붙어야함
            }

            #endregion

            return(e_cvm);
        }
        public override void excel_kiEventCalculationBuild()
        {
            Excel_simpleKiEventCalcViewModel e_simpleKiEvent = new Excel_simpleKiEventCalcViewModel();

            e_simpleKiEvent.Excel_underlyingCalcInfoViewModel_ = this.Excel_underlyingCalcInfoViewModel_;

            e_simpleKiEvent.EventDate_  = this.KiObEndDate_;
            e_simpleKiEvent.PayoffDate_ = this.KiObEndDate_;

            #region EventCal
            {
                Excel_singleBarrierEventCalViewModel e_singleBarrierEvent = new Excel_singleBarrierEventCalViewModel();

                e_singleBarrierEvent.UpperTrigger_ = "1000";
                e_singleBarrierEvent.LowerTrigger_ = (Convert.ToDouble(this.Ki_) / 100.0).ToString();

                // 우선 max를 사용함

                Excel_minimumUnderlyingCalcIDViewModel e_mucidvm = new Excel_minimumUnderlyingCalcIDViewModel();

                e_mucidvm.EventDate_ = this.KiObEndDate_;

                e_mucidvm.setUnderlying(this.Excel_underlyingCalcInfoViewModel_);

                e_singleBarrierEvent.Excel_underlyingCalcIDViewModel_ = e_mucidvm;

                e_singleBarrierEvent.setUnderlying(this.Excel_underlyingCalcInfoViewModel_);

                e_singleBarrierEvent.ObservationStartDate_ = this.KiObStartDate_;
                e_singleBarrierEvent.ObservationEndDate_   = this.KiObEndDate_;

                e_simpleKiEvent.Excel_eventCalcInfoViewModel_ = e_singleBarrierEvent;
            }
            #endregion

            #region OccReturn
            {
                Excel_vanillaReturnCalViewModel e_vanillaReturn = new Excel_vanillaReturnCalViewModel();

                e_vanillaReturn.Excel_underlyingCalcInfoViewModel_ = this.Excel_underlyingCalcInfoViewModel_;

                //e_vanillaReturn.Gearing_ = "-1";
                //e_vanillaReturn.Spread_ = "-0.2";

                e_vanillaReturn.Gearing_ = "1.0";
                e_vanillaReturn.Spread_  = "0.0";

                Excel_minimumUnderlyingCalcIDViewModel e_mucidvm = new Excel_minimumUnderlyingCalcIDViewModel();

                e_mucidvm.EventDate_ = this.KiObEndDate_;
                e_mucidvm.setUnderlying(this.Excel_underlyingCalcInfoViewModel_);

                e_vanillaReturn.ReturnUnderlyingCalcIDViewModel_ = e_mucidvm;

                e_simpleKiEvent.Excel_occReturnCalcInfoViewModel_ = new Excel_occReturnCalcInfoViewModel();
                e_simpleKiEvent.Excel_occReturnCalcInfoViewModel_.Excel_returnCalcInfoViewModel_ = e_vanillaReturn;
            }
            #endregion

            #region noOccReturn
            {
                Excel_constReturnCalViewModel e_constReturnCalc = new Excel_constReturnCalViewModel();
                int count = this.subScheduleDataList_.Count;

                //입력으로 받아도 대는데 지금은 마지막껄로함.
                e_constReturnCalc.ConstReturn_ = (1.0 + Convert.ToDouble(this.subScheduleDataList_[count - 1].Coupon_) / 100.0).ToString();

                e_constReturnCalc.Excel_underlyingCalcInfoViewModel_ = this.Excel_underlyingCalcInfoViewModel_;

                e_simpleKiEvent.Excel_noOccReturnCalcInfoViewModel_ = new Excel_noOccReturnCalcInfoViewModel();
                e_simpleKiEvent.Excel_noOccReturnCalcInfoViewModel_.Excel_returnCalcInfoViewModel_ = e_constReturnCalc;

                e_simpleKiEvent.Excel_noOccReturnCalcInfoViewModel_.setUnderlying(this.Excel_underlyingCalcInfoViewModel_);
            }
            #endregion

            this.Excel_kiEventCalculationViewModel_ = e_simpleKiEvent;
        }
        public string add_monthlyCoupon_sch(DateTime eventDate,
                                       DateTime payoffDate,
                                       double lowerTrigger,
                                       double upperTrigger,
                                       //CalculationEnum underCalcType, 
                                       string underCalcType,
                                       string underlyings,
                                       double constCoupon)
        {
            try
            {
                #region CheckParameter

                if (underlyings == "")
                    throw new Exception("underlying input is empty");

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


                #endregion

                Excel_simpleCalculationViewModel e_scvm = new Excel_simpleCalculationViewModel();

                //this.addUnderlying(underlyings);

                Excel_underlyingCalcInfoViewModel e_ucivm = this.InstVM_.Excel_interfaceViewModel_.Excel_underlyingCalcInfoViewModel_;

                e_scvm.Excel_underlyingCalcInfoViewModel_ = e_ucivm;

                e_scvm.EventDate_ = eventDate;

                e_scvm.PayoffDate_ = payoffDate;

                #region EventCal
                //---------------------------------------------------------------
                {
                    //Excel_eventCalcInfoViewModel e_ecivm = new Excel_eventCalcInfoViewModel();

                    Excel_singleRangeEventCalViewModel e_srecvm = new Excel_singleRangeEventCalViewModel();

                    e_srecvm.Excel_underlyingCalcInfoViewModel_ = e_ucivm;

                    e_srecvm.LowerRng_ = lowerTrigger.ToString();
                    e_srecvm.UpperRng_ = upperTrigger.ToString();

                    // 우선 max를 사용함
                    Excel_underlyingCalcIDViewModel e_mucidvm = 
                        Excel_underlyingCalcIDViewModel.CreateExcel_underlyingCalcID(underCalcType);

                    e_mucidvm.EventDate_ = eventDate;

                    e_mucidvm.setUnderlying(e_ucivm);
                    e_mucidvm.selectUnderlyings(underlyings);

                    e_srecvm.Excel_underlyingCalcIDViewModel_ = e_mucidvm;

                    //e_ecivm.Excel_eventCalcViewModel_.Add(e_srecvm);

                    e_scvm.Excel_eventCalcInfoViewModel_ = e_srecvm;

                    //info 에 드가는 곱하기라던지 floor라던지 postCalculation 같은게 붙어야함

                }

                #endregion

                #region ReturnCal
                //---------------------------------------------------------------
                {
                    //Excel_returnCalcInfoViewModel e_rcivm = new Excel_returnCalcInfoViewModel();

                    Excel_constReturnCalViewModel e_crcvm = new Excel_constReturnCalViewModel();

                    e_crcvm.Excel_underlyingCalcInfoViewModel_ = e_ucivm;

                    e_crcvm.ConstReturn_ = constCoupon.ToString();

                    //e_rcivm.Excel_returnCalcViewModel_.Add(e_crcvm);

                    e_scvm.Excel_returnCalcInfoViewModel_ = e_crcvm;

                    //info 에 드가는 곱하기라던지 floor라던지 postCalculation 같은게 붙어야함

                }
                #endregion

                #region ComplementReturnCal
                {
                    Excel_complementReturnCalcViewModel e_comp_rcvm = new Excel_complementReturnCalcViewModel();

                    Excel_constReturnCalViewModel e_crcvm = new Excel_constReturnCalViewModel();

                    e_crcvm.Excel_underlyingCalcInfoViewModel_ = e_ucivm;

                    e_crcvm.ConstReturn_ = "0.0";

                    e_comp_rcvm.Excel_returnCalcInfoViewModel_ = e_crcvm;

                    e_scvm.Excel_complementReturnCalcViewModel_ = e_comp_rcvm;
                }
                #endregion

                Excel_hifiveViewModel e_hvm = this.InstVM_.Excel_interfaceViewModel_ as Excel_hifiveViewModel;

                e_hvm.Excel_scheduleListViewModel_.Excel_scheduleViewModel_.Add(e_scvm);

                return "add complete";
            }
            catch (Exception e)
            {
                return "add fail : " + e.Message;
            }
        }
        // ki 계열
        public string set_constKI_sch(double lowerTrigger,
                                       double upperTrigger,
                                       //CalculationEnum kiCheckType,
                                       string kiCheckType,
                                       string underlyings,
                                       //LossType lossType,
                                       string lossType, // 이거 구분 아직 안함
                                       double noKICoupon,
                                       DateTime obStartDate,
                                       DateTime obEndDate)
        {
            try
            {
                #region CheckParameter

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

                #endregion

                Excel_simpleKiEventCalcViewModel e_simpleKiEvent = new Excel_simpleKiEventCalcViewModel();

                //this.addUnderlying(underlyings);

                Excel_underlyingCalcInfoViewModel e_ucivm = this.InstVM_.Excel_interfaceViewModel_.Excel_underlyingCalcInfoViewModel_;

                e_simpleKiEvent.Excel_underlyingCalcInfoViewModel_ = e_ucivm;
                
                e_simpleKiEvent.EventDate_ = obEndDate;
                e_simpleKiEvent.PayoffDate_ = obEndDate;

                #region EventCal
                {
                    Excel_singleBarrierEventCalViewModel e_singleBarrierEvent = new Excel_singleBarrierEventCalViewModel();

                    e_singleBarrierEvent.UpperTrigger_ = upperTrigger.ToString();
                    e_singleBarrierEvent.LowerTrigger_ = lowerTrigger.ToString(); 

                    // 우선 max를 사용함

                    Excel_minimumUnderlyingCalcIDViewModel e_mucidvm = new Excel_minimumUnderlyingCalcIDViewModel();

                    e_mucidvm.EventDate_ = obEndDate;

                    e_mucidvm.setUnderlying(e_ucivm);
                    e_mucidvm.selectUnderlyings(underlyings);

                    e_singleBarrierEvent.Excel_underlyingCalcIDViewModel_ = e_mucidvm;

                    //e_singleBarrierEvent.setUnderlying(e_ucivm);
                    
                    e_singleBarrierEvent.ObservationStartDate_ = obStartDate;
                    e_singleBarrierEvent.ObservationEndDate_ = obEndDate;

                    e_simpleKiEvent.Excel_eventCalcInfoViewModel_ = e_singleBarrierEvent;
                }
                #endregion

                #region OccReturn
                {
                    Excel_vanillaReturnCalViewModel e_vanillaReturn = new Excel_vanillaReturnCalViewModel();

                    e_vanillaReturn.Excel_underlyingCalcInfoViewModel_ = e_ucivm;

                    //e_vanillaReturn.Gearing_ = "-1";
                    //e_vanillaReturn.Spread_ = "-0.2";

                    e_vanillaReturn.Gearing_ = "1.0";
                    e_vanillaReturn.Spread_ = "-1.0";

                    Excel_minimumUnderlyingCalcIDViewModel e_mucidvm = new Excel_minimumUnderlyingCalcIDViewModel();

                    e_mucidvm.EventDate_ = obEndDate;
                    e_mucidvm.setUnderlying(e_ucivm);
                    e_mucidvm.selectUnderlyings(underlyings);

                    e_vanillaReturn.ReturnUnderlyingCalcIDViewModel_ = e_mucidvm;

                    e_simpleKiEvent.Excel_occReturnCalcInfoViewModel_ = new Excel_occReturnCalcInfoViewModel();
                    e_simpleKiEvent.Excel_occReturnCalcInfoViewModel_.Excel_returnCalcInfoViewModel_ = e_vanillaReturn;
                }
                #endregion

                #region noOccReturn
                {
                    Excel_constReturnCalViewModel e_constReturnCalc = new Excel_constReturnCalViewModel();
                    
                    e_constReturnCalc.ConstReturn_ = noKICoupon.ToString();

                    e_constReturnCalc.Excel_underlyingCalcInfoViewModel_ = e_ucivm;

                    e_simpleKiEvent.Excel_noOccReturnCalcInfoViewModel_ = new Excel_noOccReturnCalcInfoViewModel();
                    e_simpleKiEvent.Excel_noOccReturnCalcInfoViewModel_.Excel_returnCalcInfoViewModel_ = e_constReturnCalc;

                    e_simpleKiEvent.Excel_noOccReturnCalcInfoViewModel_.setUnderlying(e_ucivm);
                }
                #endregion

                Excel_hifiveViewModel e_hvm = this.InstVM_.Excel_interfaceViewModel_ as Excel_hifiveViewModel;

                e_hvm.Excel_kiEventCalculationViewModel_ = e_simpleKiEvent;

                List<string> member = new List<string>() {"instType", "schtype","lowerTrigger", "upperTrigger", "kiCheckType", "underlyings", "lossType", "noKICoupon", "obStartDate", "obEndDate" };
                List<string> value = new List<string>() { "hifive" ,"constKI",lowerTrigger.ToString(), upperTrigger.ToString(), kiCheckType.ToString(), underlyings.ToString(), lossType.ToString(), noKICoupon.ToString(), StringConverter.xmlDateTimeToDateString(obStartDate), StringConverter.xmlDateTimeToDateString(obEndDate) };

                e_simpleKiEvent.VBA_description_ = this.vba_description(member, value);

                return "set complete";
            }
            catch (Exception e)
            {
                return "set fail : " + e.Message;
            }
        }
        public string add_autoCall_sch(DateTime eventDate,
                                       DateTime payoffDate,
                                       double lowerTrigger,
                                       double upperTrigger,
                                       //CalculationEnum underCalcType,
                                       string underCalcType,
                                       string underlyings,
                                       double constCoupon)
        {
            try
            {
                #region CheckParameter

                if (underlyings == "")
                    throw new Exception("underlying input is empty");

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

                #endregion

                Excel_simpleCalculationViewModel e_scvm = new Excel_simpleCalculationViewModel();
                
                //this.addUnderlying(underlyings);

                Excel_underlyingCalcInfoViewModel e_ucivm = this.InstVM_.Excel_interfaceViewModel_.Excel_underlyingCalcInfoViewModel_;

                e_scvm.Excel_underlyingCalcInfoViewModel_ = e_ucivm;

                e_scvm.EventDate_ = eventDate;

                e_scvm.PayoffDate_ = payoffDate;

                #region EventCal
                //---------------------------------------------------------------
                {
                    //Excel_eventCalcInfoViewModel e_ecivm = new Excel_eventCalcInfoViewModel();

                    Excel_singleRangeEventCalViewModel e_srecvm = new Excel_singleRangeEventCalViewModel();

                    e_srecvm.Excel_underlyingCalcInfoViewModel_ = e_ucivm;

                    e_srecvm.LowerRng_ = lowerTrigger.ToString();
                    e_srecvm.UpperRng_ = upperTrigger.ToString();

                    // 우선 max를 사용함
                    Excel_underlyingCalcIDViewModel e_mucidvm = 
                        Excel_underlyingCalcIDViewModel.CreateExcel_underlyingCalcID(underCalcType);

                    e_mucidvm.EventDate_ = eventDate;

                    e_mucidvm.setUnderlying(e_ucivm);
                    e_mucidvm.selectUnderlyings(underlyings);

                    e_srecvm.Excel_underlyingCalcIDViewModel_ = e_mucidvm;

                    //e_ecivm.Excel_eventCalcViewModel_.Add(e_srecvm);

                    e_scvm.Excel_eventCalcInfoViewModel_ = e_srecvm;

                    //info 에 드가는 곱하기라던지 floor라던지 postCalculation 같은게 붙어야함

                }

                #endregion

                #region ReturnCal
                //---------------------------------------------------------------
                {
                    //Excel_returnCalcInfoViewModel e_rcivm = new Excel_returnCalcInfoViewModel();

                    Excel_constReturnCalViewModel e_crcvm = new Excel_constReturnCalViewModel();

                    e_crcvm.Excel_underlyingCalcInfoViewModel_ = e_ucivm;

                    e_crcvm.ConstReturn_ = constCoupon.ToString();

                    //e_rcivm.Excel_returnCalcViewModel_.Add(e_crcvm);

                    e_scvm.Excel_returnCalcInfoViewModel_ = e_crcvm;

                    //info 에 드가는 곱하기라던지 floor라던지 postCalculation 같은게 붙어야함

                }
                #endregion

                #region ComplementReturnCal
                {
                    Excel_complementReturnCalcViewModel e_comp_rcvm = new Excel_complementReturnCalcViewModel();

                    Excel_constReturnCalViewModel e_crcvm = new Excel_constReturnCalViewModel();

                    e_crcvm.Excel_underlyingCalcInfoViewModel_ = e_ucivm;

                    e_crcvm.ConstReturn_ = "0.0";

                    e_comp_rcvm.Excel_returnCalcInfoViewModel_ = e_crcvm;

                    e_scvm.Excel_complementReturnCalcViewModel_ = e_comp_rcvm;
                }
                #endregion

                #region AutoCall_Event

                //---------------------------------------------------------------
                {
                    Excel_eventCalcInfo_CallViewModel e_ecicvm = new Excel_eventCalcInfo_CallViewModel();

                    Excel_singleRangeEventCalViewModel e_srecvm = new Excel_singleRangeEventCalViewModel();

                    e_srecvm.Excel_underlyingCalcInfoViewModel_ = e_ucivm;

                    e_srecvm.LowerRng_ = lowerTrigger.ToString();
                    e_srecvm.UpperRng_ = upperTrigger.ToString();;

                    //처음꺼만 사용함
                    Excel_underlyingCalcIDViewModel e_mucidvm = 
                        Excel_underlyingCalcIDViewModel.CreateExcel_underlyingCalcID(underCalcType);

                    e_mucidvm.EventDate_ = eventDate;

                    e_mucidvm.setUnderlying(e_ucivm);
                    e_mucidvm.selectUnderlyings(underlyings);

                    e_srecvm.Excel_underlyingCalcIDViewModel_ = e_mucidvm;

                    e_ecicvm.Excel_eventCalcInfoViewModel_ = e_srecvm;

                    e_scvm.Excel_eventCalcInfo_CallViewModel_ = e_ecicvm;

                    //info 에 드가는 곱하기라던지 floor라던지 postCalculation 같은게 붙어야함

                }

                #endregion

                #region AutoCall_ReturnCal

                //---------------------------------------------------------------
                {
                    Excel_returnCalcInfo_CallViewModel e_rcicvm = new Excel_returnCalcInfo_CallViewModel();

                    Excel_constReturnCalViewModel e_crcvm = new Excel_constReturnCalViewModel();

                    e_crcvm.Excel_underlyingCalcInfoViewModel_ = e_ucivm;

                    e_crcvm.ConstReturn_ = "0.0"; // 원금

                    e_rcicvm.Excel_returnCalcInfoViewModel_ = e_crcvm;

                    e_scvm.Excel_returnCalcInfo_CallViewModel_ = e_rcicvm;

                    //info 에 드가는 곱하기라던지 floor라던지 postCalculation 같은게 붙어야함

                }

                #endregion

                Excel_hifiveViewModel e_hvm = this.InstVM_.Excel_interfaceViewModel_ as Excel_hifiveViewModel;

                e_hvm.Excel_scheduleListViewModel_.Excel_scheduleViewModel_.Add(e_scvm);

                int schNum = e_hvm.Excel_scheduleListViewModel_.Excel_scheduleViewModel_.Count -1;
                //Type type = this. GetType();
                //MethodInfo methodInfo = type.GetMethod("add_autoCall_sch");
                //ParameterInfo[] paraList = methodInfo.GetParameters();

                List<string> member = new List<string>() { "instType", "type" , "schNum", "eventDate", "payoffDate", "lowerTrigger", "upperTrigger", "underCalcType", "underlyings", "constCoupon" };
                List<string> value = new List<string>() { "hifive", "autoCall_sch", schNum.ToString() , StringConverter.xmlDateTimeToDateString(eventDate), StringConverter.xmlDateTimeToDateString(payoffDate), lowerTrigger.ToString(), upperTrigger.ToString(), underCalcType, underlyings, constCoupon.ToString() };

                e_scvm.VBA_description_ = this.vba_description(member, value);

                return "add complete";
            }
            catch (Exception e)
            {
                return "add fail : " + e.Message;
            }
        }
        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;
        }
示例#12
0
 private void ViewModelChanged(object sender, DependencyPropertyChangedEventArgs e)
 {
     this.viewModel_ = this.DataContext as Excel_constReturnCalViewModel;
 }