algebraicBootstrapperExample.cpp
This example show how to build curve using Algebraic bootstrapper. Programme uses data files stored as csv in ./data directory
Name: df_instruments Object: DataFrame Size: 9 col 25 rows -------------------------------------------------------------------------------------------------------- Type Rate FRAstart Tenor YF1 YF2 RateConvention FreqFix FreqFlo -------------------------------------------------------------------------------------------------------- Deposit 0.0487 . ON ACT365 . simple . . Deposit 0.0487 . TN ACT365 . simple . . Deposit 0.0483 . 1W ACT365 . simple . . Deposit 0.0485 . 2W ACT365 . simple . . Deposit 0.0491 . 1M ACT365 . simple . . Deposit 0.0494 . 2M ACT365 . simple . . Deposit 0.0513 . 3M ACT365 . simple . . Deposit 0.0514 . 6M ACT365 . simple . . FRA 0.05115 1M 7M ACT365 . simple . . FRA 0.05105 2M 8M ACT365 . simple . . FRA 0.0508 3M 9M ACT365 . simple . . FRA 0.04865 6M 12M ACT365 . simple . . FRA 0.04415 12M 18M ACT365 . simple . . IRS 0.04734 . 2Y ActActISDA ACT365 simple annually semiannually IRS 0.04659 . 3Y ActActISDA ACT365 simple annually semiannually IRS 0.04662 . 4Y ActActISDA ACT365 simple annually semiannually IRS 0.04678 . 5Y ActActISDA ACT365 simple annually semiannually IRS 0.04699 . 6Y ActActISDA ACT365 simple annually semiannually IRS 0.04722 . 7Y ActActISDA ACT365 simple annually semiannually IRS 0.04744 . 8Y ActActISDA ACT365 simple annually semiannually IRS 0.04761 . 9Y ActActISDA ACT365 simple annually semiannually IRS 0.04765 . 10Y ActActISDA ACT365 simple annually semiannually IRS 0.04717 . 12Y ActActISDA ACT365 simple annually semiannually IRS 0.04550 . 15Y ActActISDA ACT365 simple annually semiannually IRS 0.04262 . 20Y ActActISDA ACT365 simple annually semiannually -------------------------------------------------------------------------------------------------------- Name: df_settings Object: DataFrame Size: 11 col 7 rows -------------------------------------------------------------------------------------------------------------------------------------------------------------------- Id Interpolation InterpolationInput Compounding YF Estimator SmoothingParam Iterations SmoothingInput FirstDerivative SecondDerivative -------------------------------------------------------------------------------------------------------------------------------------------------------------------- Set22 linear ZCR simple ACT365 algebraic . . . . . Set23 cubic_spline ZCR simple ACT365 algebraic . . . . . Set24 AKIMA ZCR simple ACT365 algebraic . . . . . Set25 Steffen ZCR simple ACT365 algebraic . . . . . Set26 linear DF simple ACT365 algebraic . . . . . Set27 linear invDF simple ACT365 algebraic . . . . . Set28 linear logDF simple ACT365 algebraic . . . . . -------------------------------------------------------------------------------------------------------------------------------------------------------------------- ********************************** ProgrammeRunTime:1s451ms **********************************
Plots below presents the interest rate curves build using different interpolation type
Plots below presents the interest rate curves build using different interpolation inputs
Here we present the calibration of the curve. We see perfect match between market quotings and curve implied par rates.
#include <juliant.hpp>
#include "factoryInit.hpp"
#include <algorithm>
#include <vector>
#include <set>
using namespace julian;
int main(int argc, char *argv[]) {
RunTimeMeasurment timer;
//
// Setting the calendar and the today date
//
Date today(2018, JUN, 20);
PLNHoliday holiday;
.addHoliday(holiday)
.withSpotLag(2);
//
// Reading the command line arguments; If not provided, program uses default names
//
auto data_file = args.first.empty() ? "../data/curve_data.csv" : args.first;
auto settings_file = args.second.empty() ? "../data/curve_settings.csv" : args.second;
//
// Creating benchmark instruments
//
//
// Printing instruments set
//
SHOW(df_instruments);
std::vector<Deposit> deposits = ir::readDeposit(df_depo, today, calendar);
std::vector<FRA> fras = ir::readFRA(df_fra, today, calendar);
std::vector<IRS> swaps = ir::readIRS(df_irs, today, calendar);
std::vector<SmartPointer<ir::BuildingBlock> > instruments;
instruments.insert(instruments.end(), deposits.begin(), deposits.end());
instruments.insert(instruments.end(), fras.begin(), fras.end());
instruments.insert(instruments.end(), swaps.begin(), swaps.end());
//
// Reading data settings
//
//
// Printing curves' settings
//
SHOW(df_settings);
//
// Constructing the curve
//
DataFrame estimation_resuts;
DataFrame calibration_results;
auto set_name = df_settings("Id", r);
InterestRate rate(compounding, yf);
ir::CompoundedInterpolator interpolator(interpolation, inputs);
ir::AlgebraicBootstrapper estimator;
.asOfDate(today)
.withCalendar(calendar)
.withInterestRate(rate)
.withInterpolator(interpolator)
.withSetOfInstruments(instruments)
.usingEstimator(estimator);
calibration_results.append(calib);
estimation_resuts.append(curve_data);
}
//
// Saving results
//
estimation_resuts.printToCsv("algebraic_bootstrapper_results");
}