#include <ql/quantlib.hpp>
#include <iostream>
#include <iomanip>
using namespace QuantLib;
int main(int, char* [])
{
try {
QL_IO_INIT
Calendar calendar = TARGET();
Date settlementDate(22, September, 2004);
settlementDate = calendar.adjust(settlementDate);
Integer fixingDays = 2;
Date todaysDate = calendar.advance(settlementDate, -fixingDays, Days);
Settings::instance().setEvaluationDate(todaysDate);
todaysDate = Settings::instance().evaluationDate();
std::cout << "Today: " << todaysDate.weekday()
<< ", " << todaysDate << std::endl;
std::cout << "Settlement date: " << settlementDate.weekday()
<< ", " << settlementDate << std::endl;
Rate d1wQuote=0.0382;
Rate d1mQuote=0.0372;
Rate d3mQuote=0.0363;
Rate d6mQuote=0.0353;
Rate d9mQuote=0.0348;
Rate d1yQuote=0.0345;
Rate fra3x6Quote=0.037125;
Rate fra6x9Quote=0.037125;
Rate fra6x12Quote=0.037125;
Real fut1Quote=96.2875;
Real fut2Quote=96.7875;
Real fut3Quote=96.9875;
Real fut4Quote=96.6875;
Real fut5Quote=96.4875;
Real fut6Quote=96.3875;
Real fut7Quote=96.2875;
Real fut8Quote=96.0875;
Rate s2yQuote=0.037125;
Rate s3yQuote=0.0398;
Rate s5yQuote=0.0443;
Rate s10yQuote=0.05165;
Rate s15yQuote=0.055175;
boost::shared_ptr<Quote> d1wRate(new SimpleQuote(d1wQuote));
boost::shared_ptr<Quote> d1mRate(new SimpleQuote(d1mQuote));
boost::shared_ptr<Quote> d3mRate(new SimpleQuote(d3mQuote));
boost::shared_ptr<Quote> d6mRate(new SimpleQuote(d6mQuote));
boost::shared_ptr<Quote> d9mRate(new SimpleQuote(d9mQuote));
boost::shared_ptr<Quote> d1yRate(new SimpleQuote(d1yQuote));
boost::shared_ptr<Quote> fra3x6Rate(new SimpleQuote(fra3x6Quote));
boost::shared_ptr<Quote> fra6x9Rate(new SimpleQuote(fra6x9Quote));
boost::shared_ptr<Quote> fra6x12Rate(new SimpleQuote(fra6x12Quote));
boost::shared_ptr<Quote> fut1Price(new SimpleQuote(fut1Quote));
boost::shared_ptr<Quote> fut2Price(new SimpleQuote(fut2Quote));
boost::shared_ptr<Quote> fut3Price(new SimpleQuote(fut3Quote));
boost::shared_ptr<Quote> fut4Price(new SimpleQuote(fut4Quote));
boost::shared_ptr<Quote> fut5Price(new SimpleQuote(fut5Quote));
boost::shared_ptr<Quote> fut6Price(new SimpleQuote(fut6Quote));
boost::shared_ptr<Quote> fut7Price(new SimpleQuote(fut7Quote));
boost::shared_ptr<Quote> fut8Price(new SimpleQuote(fut8Quote));
boost::shared_ptr<Quote> s2yRate(new SimpleQuote(s2yQuote));
boost::shared_ptr<Quote> s3yRate(new SimpleQuote(s3yQuote));
boost::shared_ptr<Quote> s5yRate(new SimpleQuote(s5yQuote));
boost::shared_ptr<Quote> s10yRate(new SimpleQuote(s10yQuote));
boost::shared_ptr<Quote> s15yRate(new SimpleQuote(s15yQuote));
DayCounter depositDayCounter = Actual360();
boost::shared_ptr<RateHelper> d1w(new DepositRateHelper(
Handle<Quote>(d1wRate),
1, Weeks, fixingDays,
calendar, ModifiedFollowing, depositDayCounter));
boost::shared_ptr<RateHelper> d1m(new DepositRateHelper(
Handle<Quote>(d1mRate),
1, Months, fixingDays,
calendar, ModifiedFollowing, depositDayCounter));
boost::shared_ptr<RateHelper> d3m(new DepositRateHelper(
Handle<Quote>(d3mRate),
3, Months, fixingDays,
calendar, ModifiedFollowing, depositDayCounter));
boost::shared_ptr<RateHelper> d6m(new DepositRateHelper(
Handle<Quote>(d6mRate),
6, Months, fixingDays,
calendar, ModifiedFollowing, depositDayCounter));
boost::shared_ptr<RateHelper> d9m(new DepositRateHelper(
Handle<Quote>(d9mRate),
9, Months, fixingDays,
calendar, ModifiedFollowing, depositDayCounter));
boost::shared_ptr<RateHelper> d1y(new DepositRateHelper(
Handle<Quote>(d1yRate),
1, Years, fixingDays,
calendar, ModifiedFollowing, depositDayCounter));
boost::shared_ptr<RateHelper> fra3x6(new FraRateHelper(
Handle<Quote>(fra3x6Rate),
3, 6, fixingDays, calendar, ModifiedFollowing,
depositDayCounter));
boost::shared_ptr<RateHelper> fra6x9(new FraRateHelper(
Handle<Quote>(fra6x9Rate),
6, 9, fixingDays, calendar, ModifiedFollowing,
depositDayCounter));
boost::shared_ptr<RateHelper> fra6x12(new FraRateHelper(
Handle<Quote>(fra6x12Rate),
6, 12, fixingDays, calendar, ModifiedFollowing,
depositDayCounter));
Integer futMonths = 3;
Date imm = Date::nextIMMdate(settlementDate);
boost::shared_ptr<RateHelper> fut1(new FuturesRateHelper(
Handle<Quote>(fut1Price),
imm,
futMonths, calendar, ModifiedFollowing,
depositDayCounter));
imm = Date::nextIMMdate(imm+1);
boost::shared_ptr<RateHelper> fut2(new FuturesRateHelper(
Handle<Quote>(fut1Price),
imm,
futMonths, calendar, ModifiedFollowing,
depositDayCounter));
imm = Date::nextIMMdate(imm+1);
boost::shared_ptr<RateHelper> fut3(new FuturesRateHelper(
Handle<Quote>(fut1Price),
imm,
futMonths, calendar, ModifiedFollowing,
depositDayCounter));
imm = Date::nextIMMdate(imm+1);
boost::shared_ptr<RateHelper> fut4(new FuturesRateHelper(
Handle<Quote>(fut1Price),
imm,
futMonths, calendar, ModifiedFollowing,
depositDayCounter));
imm = Date::nextIMMdate(imm+1);
boost::shared_ptr<RateHelper> fut5(new FuturesRateHelper(
Handle<Quote>(fut1Price),
imm,
futMonths, calendar, ModifiedFollowing,
depositDayCounter));
imm = Date::nextIMMdate(imm+1);
boost::shared_ptr<RateHelper> fut6(new FuturesRateHelper(
Handle<Quote>(fut1Price),
imm,
futMonths, calendar, ModifiedFollowing,
depositDayCounter));
imm = Date::nextIMMdate(imm+1);
boost::shared_ptr<RateHelper> fut7(new FuturesRateHelper(
Handle<Quote>(fut1Price),
imm,
futMonths, calendar, ModifiedFollowing,
depositDayCounter));
imm = Date::nextIMMdate(imm+1);
boost::shared_ptr<RateHelper> fut8(new FuturesRateHelper(
Handle<Quote>(fut1Price),
imm,
futMonths, calendar, ModifiedFollowing,
depositDayCounter));
Frequency swFixedLegFrequency = Annual;
BusinessDayConvention swFixedLegConvention = Unadjusted;
DayCounter swFixedLegDayCounter = Thirty360(Thirty360::European);
Frequency swFloatingLegFrequency = Semiannual;
boost::shared_ptr<RateHelper> s2y(new SwapRateHelper(
Handle<Quote>(s2yRate),
2, Years, fixingDays,
calendar, swFixedLegFrequency,
swFixedLegConvention, swFixedLegDayCounter,
swFloatingLegFrequency, ModifiedFollowing));
boost::shared_ptr<RateHelper> s3y(new SwapRateHelper(
Handle<Quote>(s3yRate),
3, Years, fixingDays,
calendar, swFixedLegFrequency,
swFixedLegConvention, swFixedLegDayCounter,
swFloatingLegFrequency, ModifiedFollowing));
boost::shared_ptr<RateHelper> s5y(new SwapRateHelper(
Handle<Quote>(s5yRate),
5, Years, fixingDays,
calendar, swFixedLegFrequency,
swFixedLegConvention, swFixedLegDayCounter,
swFloatingLegFrequency, ModifiedFollowing));
boost::shared_ptr<RateHelper> s10y(new SwapRateHelper(
Handle<Quote>(s10yRate),
10, Years, fixingDays,
calendar, swFixedLegFrequency,
swFixedLegConvention, swFixedLegDayCounter,
swFloatingLegFrequency, ModifiedFollowing));
boost::shared_ptr<RateHelper> s15y(new SwapRateHelper(
Handle<Quote>(s15yRate),
15, Years, fixingDays,
calendar, swFixedLegFrequency,
swFixedLegConvention, swFixedLegDayCounter,
swFloatingLegFrequency, ModifiedFollowing));
DayCounter termStructureDayCounter =
ActualActual(ActualActual::ISDA);
double tolerance = 1.0e-15;
std::vector<boost::shared_ptr<RateHelper> > depoSwapInstruments;
depoSwapInstruments.push_back(d1w);
depoSwapInstruments.push_back(d1m);
depoSwapInstruments.push_back(d3m);
depoSwapInstruments.push_back(d6m);
depoSwapInstruments.push_back(d9m);
depoSwapInstruments.push_back(d1y);
depoSwapInstruments.push_back(s2y);
depoSwapInstruments.push_back(s3y);
depoSwapInstruments.push_back(s5y);
depoSwapInstruments.push_back(s10y);
depoSwapInstruments.push_back(s15y);
boost::shared_ptr<YieldTermStructure> depoSwapTermStructure(new
PiecewiseFlatForward(settlementDate, depoSwapInstruments,
termStructureDayCounter, tolerance));
std::vector<boost::shared_ptr<RateHelper> > depoFutSwapInstruments;
depoFutSwapInstruments.push_back(d1w);
depoFutSwapInstruments.push_back(d1m);
depoFutSwapInstruments.push_back(fut1);
depoFutSwapInstruments.push_back(fut2);
depoFutSwapInstruments.push_back(fut3);
depoFutSwapInstruments.push_back(fut4);
depoFutSwapInstruments.push_back(fut5);
depoFutSwapInstruments.push_back(fut6);
depoFutSwapInstruments.push_back(fut7);
depoFutSwapInstruments.push_back(fut8);
depoFutSwapInstruments.push_back(s3y);
depoFutSwapInstruments.push_back(s5y);
depoFutSwapInstruments.push_back(s10y);
depoFutSwapInstruments.push_back(s15y);
boost::shared_ptr<YieldTermStructure> depoFutSwapTermStructure(new
PiecewiseFlatForward(settlementDate, depoFutSwapInstruments,
termStructureDayCounter, tolerance));
std::vector<boost::shared_ptr<RateHelper> > depoFRASwapInstruments;
depoFRASwapInstruments.push_back(d1w);
depoFRASwapInstruments.push_back(d1m);
depoFRASwapInstruments.push_back(d3m);
depoFRASwapInstruments.push_back(fra3x6);
depoFRASwapInstruments.push_back(fra6x9);
depoFRASwapInstruments.push_back(fra6x12);
depoFRASwapInstruments.push_back(s2y);
depoFRASwapInstruments.push_back(s3y);
depoFRASwapInstruments.push_back(s5y);
depoFRASwapInstruments.push_back(s10y);
depoFRASwapInstruments.push_back(s15y);
boost::shared_ptr<YieldTermStructure> depoFRASwapTermStructure(new
PiecewiseFlatForward(settlementDate, depoFRASwapInstruments,
termStructureDayCounter, tolerance));
Handle<YieldTermStructure> discountingTermStructure;
Handle<YieldTermStructure> forecastingTermStructure;
Real nominal = 1000000.0;
Frequency fixedLegFrequency = Annual;
BusinessDayConvention fixedLegConvention = Unadjusted;
BusinessDayConvention floatingLegConvention = ModifiedFollowing;
DayCounter fixedLegDayCounter = Thirty360(Thirty360::European);
Rate fixedRate = 0.04;
Frequency floatingLegFrequency = Semiannual;
boost::shared_ptr<Xibor> euriborIndex(new Euribor(6, Months,
forecastingTermStructure));
Spread spread = 0.0;
Integer lenghtInYears = 5;
bool payFixedRate = true;
Date maturity = calendar.advance(settlementDate, lenghtInYears, Years,
floatingLegConvention);
Schedule fixedSchedule(calendar, settlementDate, maturity,
fixedLegFrequency, fixedLegConvention);
Schedule floatSchedule(calendar, settlementDate, maturity,
floatingLegFrequency, floatingLegConvention);
SimpleSwap spot5YearSwap(
payFixedRate, nominal,
fixedSchedule, fixedRate, fixedLegDayCounter,
floatSchedule, euriborIndex, fixingDays, spread,
discountingTermStructure);
Date fwdStart = calendar.advance(settlementDate, 1, Years);
Date fwdMaturity = calendar.advance(fwdStart, lenghtInYears, Years,
floatingLegConvention);
Schedule fwdFixedSchedule(calendar, fwdStart, fwdMaturity,
fixedLegFrequency, fixedLegConvention);
Schedule fwdFloatSchedule(calendar, fwdStart, fwdMaturity,
floatingLegFrequency, floatingLegConvention);
SimpleSwap oneYearForward5YearSwap(
payFixedRate, nominal,
fwdFixedSchedule, fixedRate, fixedLegDayCounter,
fwdFloatSchedule, euriborIndex, fixingDays, spread,
discountingTermStructure);
std::vector<std::string> headers(4);
headers[0] = "term structure";
headers[1] = "net present value";
headers[2] = "fair spread";
headers[3] = "fair fixed rate";
std::string separator = " | ";
Size width = headers[0].size() + separator.size()
+ headers[1].size() + separator.size()
+ headers[2].size() + separator.size()
+ headers[3].size() + separator.size() - 1;
std::string rule(width, '-'), dblrule(width, '=');
std::string tab(8, ' ');
std::cout << dblrule << std::endl;
std::cout << "5-year market swap-rate = "
<< std::setprecision(2) << io::rate(s5yRate->value())
<< std::endl;
std::cout << dblrule << std::endl;
std::cout << tab << "5-years swap paying "
<< io::rate(fixedRate) << std::endl;
std::cout << headers[0] << separator
<< headers[1] << separator
<< headers[2] << separator
<< headers[3] << separator << std::endl;
std::cout << rule << std::endl;
Real NPV;
Rate fairRate;
Spread fairSpread;
forecastingTermStructure.linkTo(depoSwapTermStructure);
discountingTermStructure.linkTo(depoSwapTermStructure);
NPV = spot5YearSwap.NPV();
fairSpread = spot5YearSwap.fairSpread();
fairRate = spot5YearSwap.fairRate();
std::cout << std::setw(headers[0].size())
<< "depo-swap" << separator;
std::cout << std::setw(headers[1].size())
<< std::fixed << std::setprecision(2) << NPV << separator;
std::cout << std::setw(headers[2].size())
<< io::rate(fairSpread) << separator;
std::cout << std::setw(headers[3].size())
<< io::rate(fairRate) << separator;
std::cout << std::endl;
QL_REQUIRE(std::fabs(fairRate-s5yQuote)<1e-8,
"5-years swap mispriced by "
<< io::rate(std::fabs(fairRate-s5yQuote)));
forecastingTermStructure.linkTo(depoFutSwapTermStructure);
discountingTermStructure.linkTo(depoFutSwapTermStructure);
NPV = spot5YearSwap.NPV();
fairSpread = spot5YearSwap.fairSpread();
fairRate = spot5YearSwap.fairRate();
std::cout << std::setw(headers[0].size())
<< "depo-fut-swap" << separator;
std::cout << std::setw(headers[1].size())
<< std::fixed << std::setprecision(2) << NPV << separator;
std::cout << std::setw(headers[2].size())
<< io::rate(fairSpread) << separator;
std::cout << std::setw(headers[3].size())
<< io::rate(fairRate) << separator;
std::cout << std::endl;
QL_REQUIRE(std::fabs(fairRate-s5yQuote)<1e-8,
"5-years swap mispriced!");
forecastingTermStructure.linkTo(depoFRASwapTermStructure);
discountingTermStructure.linkTo(depoFRASwapTermStructure);
NPV = spot5YearSwap.NPV();
fairSpread = spot5YearSwap.fairSpread();
fairRate = spot5YearSwap.fairRate();
std::cout << std::setw(headers[0].size())
<< "depo-FRA-swap" << separator;
std::cout << std::setw(headers[1].size())
<< std::fixed << std::setprecision(2) << NPV << separator;
std::cout << std::setw(headers[2].size())
<< io::rate(fairSpread) << separator;
std::cout << std::setw(headers[3].size())
<< io::rate(fairRate) << separator;
std::cout << std::endl;
QL_REQUIRE(std::fabs(fairRate-s5yQuote)<1e-8,
"5-years swap mispriced!");
std::cout << rule << std::endl;
std::cout << tab << "5-years, 1-year forward swap paying "
<< io::rate(fixedRate) << std::endl;
std::cout << headers[0] << separator
<< headers[1] << separator
<< headers[2] << separator
<< headers[3] << separator << std::endl;
std::cout << rule << std::endl;
forecastingTermStructure.linkTo(depoSwapTermStructure);
discountingTermStructure.linkTo(depoSwapTermStructure);
NPV = oneYearForward5YearSwap.NPV();
fairSpread = oneYearForward5YearSwap.fairSpread();
fairRate = oneYearForward5YearSwap.fairRate();
std::cout << std::setw(headers[0].size())
<< "depo-swap" << separator;
std::cout << std::setw(headers[1].size())
<< std::fixed << std::setprecision(2) << NPV << separator;
std::cout << std::setw(headers[2].size())
<< io::rate(fairSpread) << separator;
std::cout << std::setw(headers[3].size())
<< io::rate(fairRate) << separator;
std::cout << std::endl;
forecastingTermStructure.linkTo(depoFutSwapTermStructure);
discountingTermStructure.linkTo(depoFutSwapTermStructure);
NPV = oneYearForward5YearSwap.NPV();
fairSpread = oneYearForward5YearSwap.fairSpread();
fairRate = oneYearForward5YearSwap.fairRate();
std::cout << std::setw(headers[0].size())
<< "depo-fut-swap" << separator;
std::cout << std::setw(headers[1].size())
<< std::fixed << std::setprecision(2) << NPV << separator;
std::cout << std::setw(headers[2].size())
<< io::rate(fairSpread) << separator;
std::cout << std::setw(headers[3].size())
<< io::rate(fairRate) << separator;
std::cout << std::endl;
forecastingTermStructure.linkTo(depoFRASwapTermStructure);
discountingTermStructure.linkTo(depoFRASwapTermStructure);
NPV = oneYearForward5YearSwap.NPV();
fairSpread = oneYearForward5YearSwap.fairSpread();
fairRate = oneYearForward5YearSwap.fairRate();
std::cout << std::setw(headers[0].size())
<< "depo-FRA-swap" << separator;
std::cout << std::setw(headers[1].size())
<< std::fixed << std::setprecision(2) << NPV << separator;
std::cout << std::setw(headers[2].size())
<< io::rate(fairSpread) << separator;
std::cout << std::setw(headers[3].size())
<< io::rate(fairRate) << separator;
std::cout << std::endl;
boost::shared_ptr<SimpleQuote> fiveYearsRate =
boost::dynamic_pointer_cast<SimpleQuote>(s5yRate);
fiveYearsRate->setValue(0.0460);
std::cout << dblrule << std::endl;
std::cout << "5-year market swap-rate = "
<< io::rate(s5yRate->value()) << std::endl;
std::cout << dblrule << std::endl;
std::cout << tab << "5-years swap paying "
<< io::rate(fixedRate) << std::endl;
std::cout << headers[0] << separator
<< headers[1] << separator
<< headers[2] << separator
<< headers[3] << separator << std::endl;
std::cout << rule << std::endl;
forecastingTermStructure.linkTo(depoSwapTermStructure);
discountingTermStructure.linkTo(depoSwapTermStructure);
NPV = spot5YearSwap.NPV();
fairSpread = spot5YearSwap.fairSpread();
fairRate = spot5YearSwap.fairRate();
std::cout << std::setw(headers[0].size())
<< "depo-swap" << separator;
std::cout << std::setw(headers[1].size())
<< std::fixed << std::setprecision(2) << NPV << separator;
std::cout << std::setw(headers[2].size())
<< io::rate(fairSpread) << separator;
std::cout << std::setw(headers[3].size())
<< io::rate(fairRate) << separator;
std::cout << std::endl;
QL_REQUIRE(std::fabs(fairRate-s5yRate->value())<1e-8,
"5-years swap mispriced!");
forecastingTermStructure.linkTo(depoFutSwapTermStructure);
discountingTermStructure.linkTo(depoFutSwapTermStructure);
NPV = spot5YearSwap.NPV();
fairSpread = spot5YearSwap.fairSpread();
fairRate = spot5YearSwap.fairRate();
std::cout << std::setw(headers[0].size())
<< "depo-fut-swap" << separator;
std::cout << std::setw(headers[1].size())
<< std::fixed << std::setprecision(2) << NPV << separator;
std::cout << std::setw(headers[2].size())
<< io::rate(fairSpread) << separator;
std::cout << std::setw(headers[3].size())
<< io::rate(fairRate) << separator;
std::cout << std::endl;
QL_REQUIRE(std::fabs(fairRate-s5yRate->value())<1e-8,
"5-years swap mispriced!");
forecastingTermStructure.linkTo(depoFRASwapTermStructure);
discountingTermStructure.linkTo(depoFRASwapTermStructure);
NPV = spot5YearSwap.NPV();
fairSpread = spot5YearSwap.fairSpread();
fairRate = spot5YearSwap.fairRate();
std::cout << std::setw(headers[0].size())
<< "depo-FRA-swap" << separator;
std::cout << std::setw(headers[1].size())
<< std::fixed << std::setprecision(2) << NPV << separator;
std::cout << std::setw(headers[2].size())
<< io::rate(fairSpread) << separator;
std::cout << std::setw(headers[3].size())
<< io::rate(fairRate) << separator;
std::cout << std::endl;
QL_REQUIRE(std::fabs(fairRate-s5yRate->value())<1e-8,
"5-years swap mispriced!");
std::cout << rule << std::endl;
std::cout << tab << "5-years, 1-year forward swap paying "
<< io::rate(fixedRate) << std::endl;
std::cout << headers[0] << separator
<< headers[1] << separator
<< headers[2] << separator
<< headers[3] << separator << std::endl;
std::cout << rule << std::endl;
forecastingTermStructure.linkTo(depoSwapTermStructure);
discountingTermStructure.linkTo(depoSwapTermStructure);
NPV = oneYearForward5YearSwap.NPV();
fairSpread = oneYearForward5YearSwap.fairSpread();
fairRate = oneYearForward5YearSwap.fairRate();
std::cout << std::setw(headers[0].size())
<< "depo-swap" << separator;
std::cout << std::setw(headers[1].size())
<< std::fixed << std::setprecision(2) << NPV << separator;
std::cout << std::setw(headers[2].size())
<< io::rate(fairSpread) << separator;
std::cout << std::setw(headers[3].size())
<< io::rate(fairRate) << separator;
std::cout << std::endl;
forecastingTermStructure.linkTo(depoFutSwapTermStructure);
discountingTermStructure.linkTo(depoFutSwapTermStructure);
NPV = oneYearForward5YearSwap.NPV();
fairSpread = oneYearForward5YearSwap.fairSpread();
fairRate = oneYearForward5YearSwap.fairRate();
std::cout << std::setw(headers[0].size())
<< "depo-fut-swap" << separator;
std::cout << std::setw(headers[1].size())
<< std::fixed << std::setprecision(2) << NPV << separator;
std::cout << std::setw(headers[2].size())
<< io::rate(fairSpread) << separator;
std::cout << std::setw(headers[3].size())
<< io::rate(fairRate) << separator;
std::cout << std::endl;
forecastingTermStructure.linkTo(depoFRASwapTermStructure);
discountingTermStructure.linkTo(depoFRASwapTermStructure);
NPV = oneYearForward5YearSwap.NPV();
fairSpread = oneYearForward5YearSwap.fairSpread();
fairRate = oneYearForward5YearSwap.fairRate();
std::cout << std::setw(headers[0].size())
<< "depo-FRA-swap" << separator;
std::cout << std::setw(headers[1].size())
<< std::fixed << std::setprecision(2) << NPV << separator;
std::cout << std::setw(headers[2].size())
<< io::rate(fairSpread) << separator;
std::cout << std::setw(headers[3].size())
<< io::rate(fairRate) << separator;
std::cout << std::endl;
return 0;
} catch (std::exception& e) {
std::cout << e.what() << std::endl;
return 1;
} catch (...) {
std::cout << "unknown error" << std::endl;
return 1;
}
}