Example #1
0
        public string addConditionMultiRangAccrualFixedCoupon(DateTime calculationStartDate,
                                                              DateTime calculationEndDate,
                                                              DateTime payoffDate,
                                                              List <double> lowerRngList,
                                                              List <string> referenceUnderCodeList,
                                                              List <double> upperRngList,
                                                              double fixedRate)
        {
            try
            {
                Excel_multiCondi_structuredAccrualCouponScheduleViewModel e_mc_sacsvm
                    = new Excel_multiCondi_structuredAccrualCouponScheduleViewModel();

                e_mc_sacsvm.EventDate_ = payoffDate;

                e_mc_sacsvm.CalculationStartDate_ = calculationStartDate;
                e_mc_sacsvm.CalculationEndDate_   = calculationEndDate;
                e_mc_sacsvm.PaymentDate_          = payoffDate;

                int rangeCount = lowerRngList.Count;

                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_mc_sacsvm.Range1DViewModel_.Add(accRng1D);
                    e_mc_sacsvm.Excel_underlyingCalcIDViewModel_.Add(choiceUnderCalcIDVM);
                }


                Excel_constReturnCalViewModel e_crcvm = new Excel_constReturnCalViewModel();

                e_crcvm.ConstReturn_ = fixedRate.ToString();

                e_mc_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_sacsvm);

                //this.instVM_.Excel_interfaceViewModel_ = e_sbvm;

                return("OK");
            }
            catch (Exception)
            {
                return("conditionMultiRangAccrualFixedCoupon add Fail.");

                throw;
            }
        }
Example #2
0
        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");
            }
        }