Class implements builder design pattern supporting construction of linear instruments. More...
#include <linearInstrumentBuilder.hpp>
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< Bond > | bond_ |
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
|
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 | ( | ) |
julian::BuildLinearInstrument::operator IRS | ( | ) |
|
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
|
private |
Additive margin added to fixing.
|
private |
The bond will be passed to repo agreement.
|
private |
The calendar is needed to calculate properly dates of contract.
|
private |
|
private |
Fixing date is required by FRA contracts. It defines moment of fixing .
|
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.
|
private |
The date on which the FRA notional loan become effective.
|
private |
This number is passed to futures. Informs in which quarter of the year futures starts.
|
private |
This number is passed to futures. Informs in which year futures starts.
|
private |
fx_spot_ as of trade date must be given to properly construct FxForward.
|
private |
This value is needed to properly construct repo agreement. It is the haircut of fixed income bond.
|
private |
If this variable was initialized by the builder ( withoutExchangeOfNotional() ) the swaps will not exchange notional on start date and maturity date.
|
private |
This variable represents the payment frequency of fixed leg (in IRS) or main leg (in other swaps).
|
private |
The end date defines the settlement of the contract.
|
private |
Maturity tenor defines the end date of the contract. If maturity tenor is provided, builder must have defined calendar.
|
private |
Multiplicative margin multiplying fixing.
|
private |
This integer gives which in turn futures dates must be calculated (starting form trade date).
|
private |
Number represents notional of the contract. It is passed to all instruments. It is equal to 100.00, unless user provides other input.
|
private |
Number represents the quoting of the contract.
|
private |
Interest rate convention for main leg.This rate convention will be passed to instrument requiring only one interest rate (depos, FRAs, etc.).
|
private |
Interest rate convention for secondary leg.
|
private |
This variable represents the payment frequency of floating leg (in IRS) or spread leg (in other swaps).
|
private |
The start date is usually defined as spot lag of the contract.
|
private |
Swap points are quotings of FxForward.
|
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