julian::BuildLinearInstrument Class Reference

Class implements builder design pattern supporting construction of linear instruments. More...

#include <linearInstrumentBuilder.hpp>

Public Member Functions

Constructors
 BuildLinearInstrument ()
 Default constructor. More...
 
Date and calendar issues
BuildLinearInstrumentusingCalendar (const Calendar &)
 provides calendar More...
 
BuildLinearInstrumentwithTenor (const Tenor &)
 provides maturity Tenor More...
 
BuildLinearInstrumentwithTenor (const TimeUnit &)
 provides TimeUnit More...
 
BuildLinearInstrumentwithForwardTenors (const Tenor &, const Tenor &)
 provides two tenors for FRA More...
 
BuildLinearInstrumentstartingInQuarter (const int &, const int &)
 provides starting date to futures More...
 
BuildLinearInstrumentnextFuturesDate (const int &)
 sets futures dates More...
 
BuildLinearInstrumentwithTradeDate (const Date &)
 provides trade date More...
 
BuildLinearInstrumentwithStartDate (const Date &)
 provides start date More...
 
BuildLinearInstrumentwithFixingDate (const Date &)
 provides fixing date More...
 
BuildLinearInstrumentwithFraSettlementDate (const Date &)
 provides maturity date More...
 
BuildLinearInstrumentwithMaturityDate (const Date &)
 provides maturity date More...
 
BuildLinearInstrumentwithTradeDate (int y, int m, int d)
 provides the trade date More...
 
BuildLinearInstrumentwithStartDate (int y, int m, int d)
 provides the start date More...
 
BuildLinearInstrumentwithFixingDate (int y, int m, int d)
 provides fixing date More...
 
BuildLinearInstrumentwithMaturityDate (int y, int m, int d)
 provides maturity date More...
 
Mechanics of instrument
BuildLinearInstrumentwithFixedLegFrequency (const Frequency &)
 provides fixed leg frequency More...
 
BuildLinearInstrumentwithFloatingLegFrequency (const Frequency &)
 provides floating leg frequency More...
 
BuildLinearInstrumentwithMainLegFrequency (const Frequency &)
 provides main leg frequency More...
 
BuildLinearInstrumentwithSpreadLegFrequency (const Frequency &)
 provides spread leg frequency More...
 
BuildLinearInstrumentwithInterestRate (const InterestRate &)
 provides interest rate More...
 
BuildLinearInstrumentwithInterestRateForFixedLeg (const InterestRate &)
 provides interest rate for fixed leg of IRS More...
 
BuildLinearInstrumentwithInterestRateForFloatingLeg (const InterestRate &)
 provides interest rate for floating leg of IRS More...
 
BuildLinearInstrumentwithInterestRateForMainLeg (const InterestRate &)
 provides interest rate for main leg More...
 
BuildLinearInstrumentwithInterestRateForSpreadLeg (const InterestRate &)
 provides interest rate for spread leg More...
 
BuildLinearInstrumentisExchangeOfNotional (bool)
 If exchange of notional is off, the first and last cashflow of instrument will not include notional. More...
 
Quoting
BuildLinearInstrumentwithNotional (const double)
 provides notional More...
 
BuildLinearInstrumentwithQuote (const double)
 provides quote More...
 
BuildLinearInstrumentwithAdditiveMargin (const double)
 provides additive margin More...
 
BuildLinearInstrumentwithMultiplicativeMargin (const double)
 provides multiplicative margin More...
 
BuildLinearInstrumentwithHaircut (const double)
 provides haircut More...
 
BuildLinearInstrumentwithBasisPoints (const double)
 provides basis points More...
 
BuildLinearInstrumentwithFixing (const double, const Date)
 provides fixing More...
 
BuildLinearInstrumentwithConvexityAdjustment (const double)
 provides convexity More...
 
BuildLinearInstrumentwithFxSpot (const double)
 provides FX spot More...
 
BuildLinearInstrumentwithSwapPoints (const double)
 provides swap points More...
 
BuildLinearInstrumentwithBond (const SmartPointer< Bond > &)
 provides bond More...
 

Private Attributes

Time and date settings
Calendar calendar_
 The calendar is needed to calculate properly dates of contract. More...
 
Tenor fixing_tenor_
 Fixing tenor is needed by FRA argument. It defines start date of accrual period. If fixing tenor is provided, builder must have calendar defined. More...
 
Tenor maturity_tenor_
 Maturity tenor defines the end date of the contract. If maturity tenor is provided, builder must have defined calendar. More...
 
Date trade_date_
 Trade date is the date when agreement was set. It must be provided. More...
 
Date start_date_
 The start date is usually defined as spot lag of the contract. More...
 
Date fixing_date_
 Fixing date is required by FRA contracts. It defines moment of fixing . More...
 
Date fra_value_date_
 The date on which the FRA notional loan become effective. More...
 
Date maturity_date_
 The end date defines the settlement of the contract. More...
 
int next_futures_date_
 This integer gives which in turn futures dates must be calculated (starting form trade date). More...
 
int futures_quarter_start_
 This number is passed to futures. Informs in which quarter of the year futures starts. More...
 
int futures_year_start_
 This number is passed to futures. Informs in which year futures starts. More...
 
Mechanics of instrument
InterestRate rate_for_main_leg_
 Interest rate convention for main leg.This rate convention will be passed to instrument requiring only one interest rate (depos, FRAs, etc.). More...
 
InterestRate rate_for_second_leg_
 Interest rate convention for secondary leg. More...
 
Frequency main_leg_frequency_
 This variable represents the payment frequency of fixed leg (in IRS) or main leg (in other swaps). More...
 
Frequency second_leg_frequency_
 This variable represents the payment frequency of floating leg (in IRS) or spread leg (in other swaps). More...
 
bool is_notional_exchanged_
 If this variable was initialized by the builder ( withoutExchangeOfNotional() ) the swaps will not exchange notional on start date and maturity date. More...
 
Quoting of instrument
double notional_
 Number represents notional of the contract. It is passed to all instruments. It is equal to 100.00, unless user provides other input. More...
 
double quote_
 Number represents the quoting of the contract. More...
 
double convexity_
 Convexity is passed to Futures contract. For more information see convexity adjustment for futures in [16] [20] . More...
 
double additive_margin_
 Additive margin added to fixing. More...
 
double multiplicative_margin_
 Multiplicative margin multiplying fixing. More...
 
std::map< Date, double > fixings_
 
double fx_spot_
 fx_spot_ as of trade date must be given to properly construct FxForward. More...
 
double swap_points_
 Swap points are quotings of FxForward. More...
 
double haircut_
 This value is needed to properly construct repo agreement. It is the haircut of fixed income bond. More...
 
SmartPointer< Bondbond_
 The bond will be passed to repo agreement. More...
 

Casting operators

 operator Deposit ()
 builds deposit More...
 
 operator FRA ()
 builds FRA More...
 
 operator IRS ()
 builds IRS More...
 
void reset ()
 resets builder More...
 
void datesCalculation ()
 calculates date More...
 

Detailed Description

Class implements builder design pattern supporting construction of linear instruments.

The builder class is an implementation of creational design pattern called Builder. The aim of creating this class was to provide robust, readable and flexible method of constructing object representing linear instruments. The class contains setting methods that provides inputs to the construction process, and casting operator that transform builder into required instrument.

The class establishes some default inputs, that will be used if their are not provided by the user. These are:

  • Notional = 100.00;
  • additive margin = 0.0, multiplicative margin = 1.0
  • haircut = 0.00 (for repo's bond), convexity = 0.0 (for futures), established fixing = 0.0 (for FRAs), Swap points = 0.0 (for fxForward), basis points (for Basis swaps).

Trade date must be provided. Other dates of the contract may not be defined if the calendar and adequate tenors are given.

Examples:
bootstrapperComparison.cpp, and DepositExample.cpp.

Constructor & Destructor Documentation

julian::BuildLinearInstrument::BuildLinearInstrument ( )

Default constructor.

Default constructor calls the method reset() to initialize itself.

Member Function Documentation

void julian::BuildLinearInstrument::datesCalculation ( )
private

calculates date

this method calculates date on the basis of given inputs.

BuildLinearInstrument & julian::BuildLinearInstrument::isExchangeOfNotional ( bool  input)

If exchange of notional is off, the first and last cashflow of instrument will not include notional.

BuildLinearInstrument & julian::BuildLinearInstrument::nextFuturesDate ( const int &  input)

sets futures dates

This method calculates upcoming futures starting dates (counting from today). If 0 is provided the builder will generate futures for the nearest futures date.

julian::BuildLinearInstrument::operator Deposit ( )

builds deposit

The method builds deposit on the basis of provided inputs.

julian::BuildLinearInstrument::operator FRA ( )

builds FRA

The method builds FRA on the basis of provided inputs.

julian::BuildLinearInstrument::operator IRS ( )

builds IRS

The method builds IRS on the basis of provided inputs.

void julian::BuildLinearInstrument::reset ( )
private

resets builder

Reset function restores default settings, which are:

  • notional = 100
  • multiplicative margin = 1.0
  • additive margin = 0.0
  • haircut = 0.0
  • convexity = 0.0
  • swap points = 0.0
  • resetting all dates
BuildLinearInstrument & julian::BuildLinearInstrument::startingInQuarter ( const int &  quarter,
const int &  year 
)

provides starting date to futures

Futures starts on 3rd Wednesday of March, June,September and December. To correctly establish the starting day of futures, one need to provide the year and the quarter in which futures starts.

BuildLinearInstrument & julian::BuildLinearInstrument::usingCalendar ( const Calendar input)

provides calendar

This method sets up the calendar that is need if user wants to create object with tenors provided.

Examples:
bootstrapperComparison.cpp, and DepositExample.cpp.
BuildLinearInstrument & julian::BuildLinearInstrument::withAdditiveMargin ( const double  input)

provides additive margin

Additive margin is added to given quote. This method simplify and make more efficient stress testing the curve. To calculate the shift of the curve caused by market quotes movement, one doesn't have to change quoting of all instruments. He or she will need only to provide additive margine to builder.

BuildLinearInstrument & julian::BuildLinearInstrument::withBasisPoints ( const double  input)

provides basis points

This method sets up haircut applied to bond that is used in repo construction.

BuildLinearInstrument & julian::BuildLinearInstrument::withBond ( const SmartPointer< Bond > &  input)

provides bond

By this method bond needed to construct repo agreement is provided.

BuildLinearInstrument & julian::BuildLinearInstrument::withConvexityAdjustment ( const double  input)

provides convexity

By this method convexity of futures contract is provided.

BuildLinearInstrument & julian::BuildLinearInstrument::withFixedLegFrequency ( const Frequency input)

provides fixed leg frequency

On the basis of this input, the builder will generate the correct schedule for fixed leg.

Examples:
bootstrapperComparison.cpp.
BuildLinearInstrument & julian::BuildLinearInstrument::withFixing ( const double  input1,
const Date  input2 
)

provides fixing

Future cash flows of contract may be calculated on the basis of past quoting (for example FRA). This method is used to provided this past quoting to correctly price the instrument.

BuildLinearInstrument & julian::BuildLinearInstrument::withFixingDate ( const Date input)

provides fixing date

The fixing date is required by FRA contract. It defines the start date of accrual period. If not provided, it will be calculated by calendar on the basis of forward tenors.

BuildLinearInstrument & julian::BuildLinearInstrument::withFixingDate ( int  y,
int  m,
int  d 
)

provides fixing date

The fixing date is required by FRA contract. It defines the start date of accrual period. If not provided, it will be calculated by calendar on the basis of forward tenors.

BuildLinearInstrument & julian::BuildLinearInstrument::withFloatingLegFrequency ( const Frequency input)

provides floating leg frequency

On the basis of this input, the builder will generate the correct schedule for floating leg.

Examples:
bootstrapperComparison.cpp.
BuildLinearInstrument & julian::BuildLinearInstrument::withForwardTenors ( const Tenor input1,
const Tenor input2 
)

provides two tenors for FRA

This method provides tenors for FRA calculation. To correctly construct FRA instrument two tenors should be provide:the fixing tenor and maturity tenor.

Examples:
bootstrapperComparison.cpp.
BuildLinearInstrument & julian::BuildLinearInstrument::withFraSettlementDate ( const Date input)

provides maturity date

Day when FRA underlying loan becomes effective

BuildLinearInstrument & julian::BuildLinearInstrument::withFxSpot ( const double  input)

provides FX spot

With this method FX spot from trade date of Fx forward is provided. Fx Spot is required to calculate the future cash flow from fx forward.

BuildLinearInstrument & julian::BuildLinearInstrument::withHaircut ( const double  input)

provides haircut

This method sets up haircut applied to bond that is used in repo construction.

BuildLinearInstrument & julian::BuildLinearInstrument::withInterestRate ( const InterestRate input)

provides interest rate

Most of contracts are quoted by the number representing annualized interest rate. The convention of compounding and calculating year fraction must be provided. Some contracts (like swaps) require two interest rate conventions: for first and second leg. If those interest rate are not provided separately it is assumed that both are equal to interest rate provided by this method.

Examples:
bootstrapperComparison.cpp, and DepositExample.cpp.
BuildLinearInstrument & julian::BuildLinearInstrument::withInterestRateForFixedLeg ( const InterestRate input)

provides interest rate for fixed leg of IRS

This method provides interest rate convention (compounding and year fraction) for fixed leg of IRS.

Examples:
bootstrapperComparison.cpp.
BuildLinearInstrument & julian::BuildLinearInstrument::withInterestRateForFloatingLeg ( const InterestRate input)

provides interest rate for floating leg of IRS

This method provides interest rate convention (compounding and year fraction) for floating leg of IRS.

Examples:
bootstrapperComparison.cpp.
BuildLinearInstrument & julian::BuildLinearInstrument::withInterestRateForMainLeg ( const InterestRate input)

provides interest rate for main leg

This method provides the interest rate convention (year fraction and compounding) for main leg of basis swap and CIRS. This leg is received if contract is long.

BuildLinearInstrument & julian::BuildLinearInstrument::withInterestRateForSpreadLeg ( const InterestRate input)

provides interest rate for spread leg

This method provides the interest rate convention (year fraction and compounding) for spread leg of basis swap and CIRS. This leg is received if contract is short.

BuildLinearInstrument & julian::BuildLinearInstrument::withMainLegFrequency ( const Frequency input)

provides main leg frequency

On the basis of this input, the builder will generate the correct schedule for main leg.

BuildLinearInstrument & julian::BuildLinearInstrument::withMaturityDate ( const Date input)

provides maturity date

Maturity is the day on which contract is settle. End date is required by all contracts. It can be directly provided by this method, or by passing calendar and tenor.

Examples:
DepositExample.cpp.
BuildLinearInstrument & julian::BuildLinearInstrument::withMaturityDate ( int  y,
int  m,
int  d 
)

provides maturity date

Maturity is the day on which contract is settle. End date is required by all contracts. It can be directly provided by this method, or by passing calendar and tenor.

BuildLinearInstrument & julian::BuildLinearInstrument::withMultiplicativeMargin ( const double  input)

provides multiplicative margin

Multiplicative margin allows to change quoting by relative value. This method simplify and make more efficient stress testing the curve. To calculate the shift of the curve caused by market quotes movement, one doesn't have to change quoting of all instruments. He or she will need only to provide multiplicative margine to builder.

BuildLinearInstrument & julian::BuildLinearInstrument::withNotional ( const double  input)

provides notional

If notional of the contract is not provided, the default value of 1.0 will be assigned.

Examples:
DepositExample.cpp.
BuildLinearInstrument & julian::BuildLinearInstrument::withQuote ( const double  input)

provides quote

All contract (except FxForward) need quoting. The quote represents the price of contract.

Examples:
bootstrapperComparison.cpp, and DepositExample.cpp.
BuildLinearInstrument & julian::BuildLinearInstrument::withSpreadLegFrequency ( const Frequency input)

provides spread leg frequency

On the basis of this input, the builder will generate the correct schedule for spread leg.

BuildLinearInstrument & julian::BuildLinearInstrument::withStartDate ( const Date input)

provides start date

Start date represents the commence date of the contract. It is usually two business day from trade date (so called spot date). If start date is not provided, it is calculated by calendar (the spot date of trade date).

Examples:
DepositExample.cpp.
BuildLinearInstrument & julian::BuildLinearInstrument::withStartDate ( int  y,
int  m,
int  d 
)

provides the start date

Start date represents the commence date of the contract. It is usually two business day from trade date (so called spot date). If start date is not provided, it is calculated by calendar (the spot date of trade date).

BuildLinearInstrument & julian::BuildLinearInstrument::withSwapPoints ( const double  input)

provides swap points

Swap points are added to Fx spot to obtain the forward price of Fx forward.

BuildLinearInstrument & julian::BuildLinearInstrument::withTenor ( const Tenor input)

provides maturity Tenor

This method method defines maturity of tenor. The maturity date is calculated using: calendar (working days, settlement convention), trade date and tenor.

Examples:
bootstrapperComparison.cpp, and DepositExample.cpp.
BuildLinearInstrument & julian::BuildLinearInstrument::withTenor ( const TimeUnit input)

provides TimeUnit

On the basis of time unit tenor is constructed. This method is defined to handle pseudo-tenors (see TimeUnit description)

BuildLinearInstrument & julian::BuildLinearInstrument::withTradeDate ( const Date input)

provides trade date

The trade date is always required. It informs at which date the contract was concluded.

Examples:
bootstrapperComparison.cpp, and DepositExample.cpp.
BuildLinearInstrument & julian::BuildLinearInstrument::withTradeDate ( int  y,
int  m,
int  d 
)

provides the trade date

This method must be called for every instrument. It defines the trade date of contract.

Member Data Documentation

double julian::BuildLinearInstrument::additive_margin_
private

Additive margin added to fixing.

SmartPointer<Bond> julian::BuildLinearInstrument::bond_
private

The bond will be passed to repo agreement.

Calendar julian::BuildLinearInstrument::calendar_
private

The calendar is needed to calculate properly dates of contract.

double julian::BuildLinearInstrument::convexity_
private

Convexity is passed to Futures contract. For more information see convexity adjustment for futures in [16] [20] .

Date julian::BuildLinearInstrument::fixing_date_
private

Fixing date is required by FRA contracts. It defines moment of fixing .

Tenor julian::BuildLinearInstrument::fixing_tenor_
private

Fixing tenor is needed by FRA argument. It defines start date of accrual period. If fixing tenor is provided, builder must have calendar defined.

Date julian::BuildLinearInstrument::fra_value_date_
private

The date on which the FRA notional loan become effective.

int julian::BuildLinearInstrument::futures_quarter_start_
private

This number is passed to futures. Informs in which quarter of the year futures starts.

int julian::BuildLinearInstrument::futures_year_start_
private

This number is passed to futures. Informs in which year futures starts.

double julian::BuildLinearInstrument::fx_spot_
private

fx_spot_ as of trade date must be given to properly construct FxForward.

double julian::BuildLinearInstrument::haircut_
private

This value is needed to properly construct repo agreement. It is the haircut of fixed income bond.

bool julian::BuildLinearInstrument::is_notional_exchanged_
private

If this variable was initialized by the builder ( withoutExchangeOfNotional() ) the swaps will not exchange notional on start date and maturity date.

Frequency julian::BuildLinearInstrument::main_leg_frequency_
private

This variable represents the payment frequency of fixed leg (in IRS) or main leg (in other swaps).

Date julian::BuildLinearInstrument::maturity_date_
private

The end date defines the settlement of the contract.

Tenor julian::BuildLinearInstrument::maturity_tenor_
private

Maturity tenor defines the end date of the contract. If maturity tenor is provided, builder must have defined calendar.

double julian::BuildLinearInstrument::multiplicative_margin_
private

Multiplicative margin multiplying fixing.

int julian::BuildLinearInstrument::next_futures_date_
private

This integer gives which in turn futures dates must be calculated (starting form trade date).

double julian::BuildLinearInstrument::notional_
private

Number represents notional of the contract. It is passed to all instruments. It is equal to 100.00, unless user provides other input.

double julian::BuildLinearInstrument::quote_
private

Number represents the quoting of the contract.

InterestRate julian::BuildLinearInstrument::rate_for_main_leg_
private

Interest rate convention for main leg.This rate convention will be passed to instrument requiring only one interest rate (depos, FRAs, etc.).

InterestRate julian::BuildLinearInstrument::rate_for_second_leg_
private

Interest rate convention for secondary leg.

Frequency julian::BuildLinearInstrument::second_leg_frequency_
private

This variable represents the payment frequency of floating leg (in IRS) or spread leg (in other swaps).

Date julian::BuildLinearInstrument::start_date_
private

The start date is usually defined as spot lag of the contract.

double julian::BuildLinearInstrument::swap_points_
private

Swap points are quotings of FxForward.

Date julian::BuildLinearInstrument::trade_date_
private

Trade date is the date when agreement was set. It must be provided.


The documentation for this class was generated from the following files:
  • C:/Unix/home/OEM/jULIAN/src/instruments/linear/linearInstrumentBuilder.hpp
  • C:/Unix/home/OEM/jULIAN/src/instruments/linear/linearInstrumentBuilder.cpp