Esempio n. 1
0
        private void ViewModelChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            this.viewModel_ = this.DataContext as Excel_simpleCalculationViewModel;

            this.eventCalGrid_.Children.Clear();
            this.eventCalGrid_.Children.Add(this.viewModel_.Excel_eventCalcInfoViewModel_.loaderView());

            this.returnCalGrid_.Children.Clear();
            this.returnCalGrid_.Children.Add(this.viewModel_.Excel_returnCalcInfoViewModel_.loaderView());

            this.compReturnCalGrid_.Children.Clear();
            this.compReturnCalGrid_.Children.Add(this.viewModel_.Excel_complementReturnCalcViewModel_.loaderView());

            this.eventCalCallGrid_.Children.Clear();
            this.eventCalCallGrid_.Children.Add(this.viewModel_.Excel_eventCalcInfo_CallViewModel_.loaderView());

            this.returnCalCallGrid_.Children.Clear();
            this.returnCalCallGrid_.Children.Add(this.viewModel_.Excel_returnCalcInfo_CallViewModel_.loaderView());
        }
        private void ViewModelChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            this.viewModel_ = this.DataContext as Excel_simpleCalculationViewModel;

            this.eventCalGrid_.Children.Clear();
            this.eventCalGrid_.Children.Add(this.viewModel_.Excel_eventCalcInfoViewModel_.loaderView());

            this.returnCalGrid_.Children.Clear();
            this.returnCalGrid_.Children.Add(this.viewModel_.Excel_returnCalcInfoViewModel_.loaderView());

            this.compReturnCalGrid_.Children.Clear();
            this.compReturnCalGrid_.Children.Add(this.viewModel_.Excel_complementReturnCalcViewModel_.loaderView());

            this.eventCalCallGrid_.Children.Clear();
            this.eventCalCallGrid_.Children.Add(this.viewModel_.Excel_eventCalcInfo_CallViewModel_.loaderView());

            this.returnCalCallGrid_.Children.Clear();
            this.returnCalCallGrid_.Children.Add(this.viewModel_.Excel_returnCalcInfo_CallViewModel_.loaderView());

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