void test_Calib_gMatrix(const LmmCalibrationConfig& config , const std::string& mkt_data_filename) { std::string folder_data_file = "WithPositiveConstraint\\" + LMMPATH::get_BaseFileName(mkt_data_filename) + "\\"; LmmSwaptionMarketData_PTR pLmmSwaptionMarketData=get_LmmSwaptionMarketData(config, mkt_data_filename); { std::string sub_folder_data_file = folder_data_file + "Cascade\\"; LMMPATH::reset_Output_SubFolder(sub_folder_data_file ); GMatrixMapping_PTR pGMatrixMapping = marketData_LMM_CascadeExact_calibration(config, pLmmSwaptionMarketData, config.get_abcdArray() ,create_InitCorrelation(config)); config.print("calib_config.csv"); } { config.use_local_calib_=false; std::string sub_folder_data_file = folder_data_file + "Global\\"; LMMPATH::reset_Output_SubFolder(sub_folder_data_file ); marketData_LMM_Global_gCalibration(config, pLmmSwaptionMarketData,config.get_abcdArray(),create_InitCorrelation(config), GMatrixMapping_PTR() ); config.print("calib_config.csv"); } { config.use_local_calib_=true; std::string sub_folder_data_file = folder_data_file + "Local\\"; LMMPATH::reset_Output_SubFolder(sub_folder_data_file ); marketData_LMM_Global_gCalibration(config, pLmmSwaptionMarketData,config.get_abcdArray(),create_InitCorrelation(config), GMatrixMapping_PTR() ); config.print("calib_config.csv"); } }
void test_calib_gMatrix_OneFile(const std::string& mkt_data_file) { std::string folder_name;// = "TotalCalib\\" ; config.use_positive_constraint_=true; std::string base_name_file = LMMPATH::get_BaseFileName(mkt_data_file) + "\\"; folder_name+=base_name_file; LMMPATH::reset_Output_SubFolder(folder_name ); LmmCalibrationConfig config; config.model_nbYear_=16; LmmSwaptionMarketData_PTR pLmmSwaptionMarketData=get_LmmSwaptionMarketData(config, mkt_data_file); config.correl_ReducedRank_= 30 ; config.correl_alpha_ = 0.000000001 ; config.correl_beta_ = 0.05; QuantLib::Array found_abcd = marketData_LMM_ABCD_calibration(config,pLmmSwaptionMarketData); //Correlation_PTR found_correlation_ptr = marketData_LMM_Correlation_calibration(config,pLmmSwaptionMarketData,found_abcd); config.correl_ReducedRank_= 3 ; //marketData_LMM_CascadeExact_calibration(config, pLmmSwaptionMarketData, found_abcd , create_InitCorrelation(config) ); //config.use_local_calib_=true; //marketData_LMM_Local_gCalibration(config, pLmmSwaptionMarketData, found_abcd , create_InitCorrelation(config), GMatrixMapping_PTR() ); //config.use_local_calib_=false; config.penalty_time_homogeneity_ = 1e-4 ; config.penalty_libor_ = 1e-6 ; config.use_positive_constraint_= true; marketData_LMM_Global_gCalibration(config, pLmmSwaptionMarketData, found_abcd , create_InitCorrelation(config), GMatrixMapping_PTR() ); }
void test_calib_gMatrixNegative_allData() { std::vector<std::string> mkt_file_list = InputFileManager::get_VCUB_FileList(); //size_t nbFile = 2; size_t nbFile = mkt_file_list.size(); LmmCalibrationConfig config; config.model_nbYear_=16; //std::cout<<"------------------------------------------------------ HORIZON "<<nbYear<<" YR "<<std::endl;//ctndebug_calib_todelete for(size_t iFile=0 ; iFile< nbFile ; ++iFile) { std::string folder_name;// = "TotalCalib\\" ; config.use_positive_constraint_=true; std::string base_name_file = LMMPATH::get_BaseFileName(mkt_file_list[iFile]) + "\\"; folder_name+=base_name_file; LMMPATH::reset_Output_SubFolder(folder_name ); LmmSwaptionMarketData_PTR pLmmSwaptionMarketData=get_LmmSwaptionMarketData(config, mkt_file_list[iFile]); config.correl_ReducedRank_= 30 ; config.correl_alpha_ = 0.000000001 ; config.correl_beta_ = 0.05; QuantLib::Array found_abcd = marketData_LMM_ABCD_calibration(config,pLmmSwaptionMarketData); //Correlation_PTR found_correlation_ptr = marketData_LMM_Correlation_calibration(config,pLmmSwaptionMarketData,found_abcd); config.correl_ReducedRank_= 3 ; //marketData_LMM_CascadeExact_calibration(config, pLmmSwaptionMarketData, found_abcd , create_InitCorrelation(config) ); //config.use_local_calib_=true; //marketData_LMM_Local_gCalibration(config, pLmmSwaptionMarketData, found_abcd , create_InitCorrelation(config), GMatrixMapping_PTR() ); //config.use_local_calib_=false; //config.penalty_time_homogeneity_ = 1e-4 ; config.penalty_libor_ = 1e-6 ; config.use_positive_constraint_=false; marketData_LMM_Global_gCalibration(config, pLmmSwaptionMarketData, found_abcd , create_InitCorrelation(config), GMatrixMapping_PTR() ); } }
void test_calibration_Cascade_then_Global(const std::string& mkt_data_filename) { LmmCalibrationConfig config; config.reset_nbYear(16); config.correl_ReducedRank_= 3; config.correl_alpha_ = 0.000000001; config.correl_beta_ = 0.05; config.vol_abcd_.a_ = 0.25673; config.vol_abcd_.b_ = 0.00002; config.vol_abcd_.c_ = 0.547; config.vol_abcd_.d_ = 0.13998; config.use_positive_constraint_=true; std::stringstream foldername ; std::string base_name_file = LMMPATH::get_BaseFileName(mkt_data_filename) + "\\"; foldername<<"Cascade_Then_Global\\"; foldername << base_name_file ; LMMPATH::reset_Output_SubFolder(foldername.str() ); LmmSwaptionMarketData_PTR pLmmSwaptionMarketData=get_LmmSwaptionMarketData(config, mkt_data_filename ); GMatrixMapping_PTR pGMatrixMapping = marketData_LMM_CascadeExact_calibration(config, pLmmSwaptionMarketData, config.get_abcdArray() ,create_InitCorrelation(config)); marketData_LMM_Global_gCalibration(config, pLmmSwaptionMarketData,config.get_abcdArray(),create_InitCorrelation(config),pGMatrixMapping ); }
void test_LmmGenericSensitivity(const std::string& mkt_data_filename) { LmmCalibrationConfig config; config.reset_nbYear(16); config.correl_ReducedRank_= 3; config.correl_alpha_ = 0.000000001; config.correl_beta_ = 0.05; config.vol_abcd_.a_ = 0.136554 ; config.vol_abcd_.b_ = 8.45E-06 ; config.vol_abcd_.c_ = 0.0439938 ; config.vol_abcd_.d_ = 0.0269172 ; config.penalty_libor_ = 1e-6; config.penalty_time_homogeneity_ = 1e-4; config.use_positive_constraint_=true; std::stringstream foldername ; std::string base_name_file = LMMPATH::get_BaseFileName(mkt_data_filename) + "\\"; foldername<<"Regularized_"; foldername << base_name_file ; LMMPATH::reset_Output_SubFolder(foldername.str() ); LmmSwaptionMarketData_PTR pLmmSwaptionMarketData=get_LmmSwaptionMarketData(config, mkt_data_filename ); //config.print("config_for_abcd_calibration.csv"); //QuantLib::Array calibrated_abcd = marketData_LMM_ABCD_calibration(config,pLmmSwaptionMarketData); marketData_LMM_Global_gCalibration(config, pLmmSwaptionMarketData,config.get_abcdArray(),create_InitCorrelation(config), GMatrixMapping_PTR() ); //QuantLib::Array calibrated_abcd(4); //config.correl_alpha_= 1e-7 ; config.correl_beta_= 1; //calibrated_abcd[0]=0.223519;calibrated_abcd[1]=1.36E-05;calibrated_abcd[2]=0.455953;calibrated_abcd[3]=0.140501; //Correlation_PTR pCorrelation = marketData_LMM_Correlation_calibration(config,pLmmSwaptionMarketData, calibrated_abcd ); //config.print("config_for_correlation_calibration.csv"); //Correlation_PTR pCorrelation = marketData_LMM_Correlation_calibration(config,pLmmSwaptionMarketData, calibrated_abcd ); //Correlation_PTR pCorrelation = create_InitCorrelation(config); //GMatrixMapping_PTR pGMatrixMapping = marketData_LMM_CascadeExact_calibration(config, pLmmSwaptionMarketData, config.get_abcdArray() ,pCorrelation); //marketData_LMM_Global_gCalibration(config, pLmmSwaptionMarketData,config.get_abcdArray(),pCorrelation, pGMatrixMapping ); foldername.str( std::string() ) ; }
void test_LmmRegularizedCalibrationMarketData_OneFile(const std::string& mkt_data_file) { LmmCalibrationConfig config; config.reset_nbYear(16); LmmSwaptionMarketData_PTR pLmmSwaptionMarketData=get_LmmSwaptionMarketData(config, mkt_data_file); config.correl_ReducedRank_= 30 ; config.correl_alpha_ = 0.000000001 ; config.correl_beta_ = 0.05; QuantLib::Array found_abcd = marketData_LMM_ABCD_calibration(config,pLmmSwaptionMarketData); config.correl_ReducedRank_= 3; config.use_positive_constraint_= true; std::vector<double> pel_time ; std::vector<double> pel_libor; generating_penalties_values(pel_time, pel_libor); const size_t penalty_matrix_size1 = pel_time.size(); const size_t penalty_matrix_size2 = pel_libor.size(); boost::numeric::ublas::matrix<double> quote_error_l2(penalty_matrix_size1,penalty_matrix_size2); boost::numeric::ublas::matrix<double> quote_error_l1(penalty_matrix_size1,penalty_matrix_size2); boost::numeric::ublas::matrix<double> quote_error_linf(penalty_matrix_size1,penalty_matrix_size2); boost::numeric::ublas::matrix<double> pel_timehomo_error_l2(penalty_matrix_size1,penalty_matrix_size2); boost::numeric::ublas::matrix<double> pel_timehomo_error_l1(penalty_matrix_size1,penalty_matrix_size2); boost::numeric::ublas::matrix<double> pel_timehomo_error_linf(penalty_matrix_size1,penalty_matrix_size2); boost::numeric::ublas::matrix<double> pel_liborsmoth_error_l2(penalty_matrix_size1,penalty_matrix_size2); boost::numeric::ublas::matrix<double> pel_liborsmoth_error_l1(penalty_matrix_size1,penalty_matrix_size2); boost::numeric::ublas::matrix<double> pel_liborsmoth_error_linf(penalty_matrix_size1,penalty_matrix_size2); for(size_t iPelTime=0;iPelTime<penalty_matrix_size1;++iPelTime) { for(size_t jPelLibor=0;jPelLibor<penalty_matrix_size2;++jPelLibor) { config.penalty_time_homogeneity_ = pel_time[iPelTime] ; config.penalty_libor_ = pel_libor[jPelLibor]; marketData_LMM_Global_gCalibration(config, pLmmSwaptionMarketData, found_abcd , create_InitCorrelation(config), GMatrixMapping_PTR() ); quote_error_l2(iPelTime,jPelLibor) = config.result_quote_error_l2 ; quote_error_l1(iPelTime,jPelLibor) = config.result_quote_error_l1 ; quote_error_linf(iPelTime,jPelLibor) = config.result_quote_error_linf ; pel_timehomo_error_l2(iPelTime,jPelLibor) = config.result_pelTime_error_l2 ; pel_timehomo_error_l1(iPelTime,jPelLibor) = config.result_pelTime_error_l1 ; pel_timehomo_error_linf(iPelTime,jPelLibor) = config.result_pelTime_error_linf ; pel_liborsmoth_error_l2(iPelTime,jPelLibor) = config.result_pelLibor_error_l2 ; pel_liborsmoth_error_l1(iPelTime,jPelLibor) = config.result_pelLibor_error_l1 ; pel_liborsmoth_error_linf(iPelTime,jPelLibor) = config.result_pelLibor_error_linf ; config.reset_result(); } } print_matrices_error ( pel_time ,pel_libor ,quote_error_l2 ,quote_error_l1 ,quote_error_linf ,pel_timehomo_error_l2 ,pel_timehomo_error_l1 ,pel_timehomo_error_linf ,pel_liborsmoth_error_l2 ,pel_liborsmoth_error_l1 ,pel_liborsmoth_error_linf ); }