void PricingConfig::resetAllLmmComponent() { shifts.resize(pLMMTenorStructure->get_horizon()+1) ; std::fill(shifts.begin(), shifts.end(), shifted_value); liborsInitValue.resize(pLMMTenorStructure->get_horizon()+1) ; std::fill(liborsInitValue.begin(), liborsInitValue.end(), fwdRate); pVanillaSwap.reset( new VanillaSwap(strike, indexStart, indexEnd, floatLegTenorType, fixedLegTenorType, pLMMTenorStructure) ); pVanillaSwaption.reset(new VanillaSwaption(*pVanillaSwap,OptionType::CALL) ); size_t correlFullRank = pLMMTenorStructure->get_horizon()+1; size_t correlReducedRank = corr_nbFactor; CorrelationReductionType::CorrelationReductionType non_reduction=CorrelationReductionType::NON; //pCorrelation.reset(new Const_Correlation(correlFullRank,correlReducedRank, non_reduction , 0. ) ); pCorrelation.reset(new XY_beta_Correlation(correlFullRank,correlReducedRank, corr_ReductionType,XY_corr_alpha,XY_corr_beta) ); pCorrelation->calculate(); //pCorrelation->print("simuTest_MCvsApprox_SwaptionPricer_Correlation.csv"); pHGVolatilityFunction.reset( new ConstShifted_HGVolatilityFunction(pLMMTenorStructure, pCorrelation, abcd_params_ptr) ); pDispersion.reset(new Dispersion(pHGVolatilityFunction) ); pRNGenerator.reset( new McGenerator(seed) ); pLmm.reset(new Lmm(*pDispersion)); if(useTerminalProba) { pMCLmm.reset(new McTerminalLmm(pLmm, liborsInitValue, pRNGenerator, mcSchemeType) ) ; } else { pMCLmm.reset(new McSpotLmm(pLmm, liborsInitValue, pRNGenerator, mcSchemeType) ) ; } pMCLmmVanillaSwapPricer.reset( new McLmmVanillaSwapPricer(pMCLmm) ) ; pMCLmmVanillaSwaptionPricer.reset( new McLmmVanillaSwaptionPricer(pMCLmm) ) ; pLmmApproxVanillaSwaptionPricer.reset( new LmmVanillaSwaptionApproxPricer_Rebonato(pLmm) ); //YY: wrong! }
UpperTriangleVanillaSwaptionQuotes_ConstPTR create_UpperTriangleVanillaSwaptionQuotes(LMMTenorStructure_PTR pLMMTenorStructure, const Tenor& tenorfixedleg, const Tenor& tenorfloatleg) { /// Creation of Rebonato Approx ================================== size_t nbFactor = 3; // need to test nbFactor = 3, and nbFactor = size_t correlFullRank = pLMMTenorStructure->get_horizon()+1; size_t correlReducedRank = nbFactor; CorrelationReductionType::CorrelationReductionType correlReductionType = CorrelationReductionType::PCA; double correlAlpha = 0.0; double correlBeta = 0.1; Correlation_PTR correlation(new XY_beta_Correlation(correlFullRank,correlReducedRank, correlReductionType,correlAlpha,correlBeta)); correlation->calculate(); // for print. double a=0.22,b=0.4,c=0.6,d=0.15; double g_constParam = 1.; double shift_constParam = 0.0; Shifted_HGVolatilityParam::ABCDParameter abcdParam(a,b,c,d); ConstShifted_HGVolatilityParam_PTR pConstShifted_HGVolatilityParam( new ConstShifted_HGVolatilityParam(pLMMTenorStructure, abcdParam, g_constParam, shift_constParam)); Shifted_HGVolatilityFunction_PTR pVolatilityFunction (new ConstShifted_HGVolatilityFunction(pLMMTenorStructure, correlation, pConstShifted_HGVolatilityParam)); //! Dispersion Dispersion dispersion(pVolatilityFunction); Lmm_PTR lmm_ptr(new Lmm(dispersion) ); LmmVanillaSwaptionApproxPricer_Rebonato_PTR pLmmApproxVanillaSwaptionPricer(new LmmVanillaSwaptionApproxPricer_Rebonato(lmm_ptr)); /// End of creation of Rebonato Approx ================================== LiborQuotes_ConstPTR libor_quote_ptr = LiborQuotes::create_LiborInit(pLMMTenorStructure, 0.02); UpperTriangleVanillaSwaptionQuotes_ConstPTR atm_swaption_implied_vol_ptr = UpperTriangleVanillaSwaptionQuotes::create_ATMSwaptionImpliedVol( libor_quote_ptr, tenorfixedleg, tenorfloatleg, pLmmApproxVanillaSwaptionPricer ); //assert( atm_swaption_implied_vol_ptr->check_swaprate_consistency(libor_quote_ptr) ); return atm_swaption_implied_vol_ptr; }