linearInstrumentBuilder.hpp
Go to the documentation of this file.
1 #ifndef JULIAN_LINEARINSTRUMENTBUILDER_HPP
2 #define JULIAN_LINEARINSTRUMENTBUILDER_HPP
3 
4 #include <dates/_all_dates.hpp>
9 #include <map>
10 
11 namespace julian {
12 
34  public:
37 
40 
42 
43  BuildLinearInstrument& startingInQuarter(const int&,const int&);
45 
51 
52  BuildLinearInstrument& withTradeDate(int y,int m,int d);
53  BuildLinearInstrument& withStartDate(int y,int m,int d);
54  BuildLinearInstrument& withFixingDate(int y,int m,int d);
55  BuildLinearInstrument& withMaturityDate(int y,int m,int d);
56 
61 
67 
68  BuildLinearInstrument& withNotional(const double);
69  BuildLinearInstrument& withQuote(const double);
72  BuildLinearInstrument& withHaircut(const double);
74  BuildLinearInstrument& withFixing(const double, const Date );
76 
77  BuildLinearInstrument& withFxSpot(const double);
79 
81 
83 
84  operator Deposit();
85  operator FRA();
86  operator IRS();
87 
88  private:
89  void reset();
90  void datesCalculation();
91 
95 
111 
122 
126  double notional_;
127  double quote_;
128  double convexity_;
131  std::map<Date,double> fixings_;
132 
133 
134  double fx_spot_;
135  double swap_points_;
136  double haircut_;
139  };
140 }
141 #endif
BuildLinearInstrument & withInterestRateForSpreadLeg(const InterestRate &)
provides interest rate for spread leg
Definition: linearInstrumentBuilder.cpp:241
double additive_margin_
Additive margin added to fixing.
Definition: linearInstrumentBuilder.hpp:129
BuildLinearInstrument & withSwapPoints(const double)
provides swap points
Definition: linearInstrumentBuilder.cpp:356
BuildLinearInstrument & withFraSettlementDate(const Date &)
provides maturity date
Definition: linearInstrumentBuilder.cpp:131
BuildLinearInstrument()
Default constructor.
Definition: linearInstrumentBuilder.cpp:15
Date trade_date_
Trade date is the date when agreement was set. It must be provided.
Definition: linearInstrumentBuilder.hpp:101
File contains definition of deposit.
Contains headers of all files with definitions of classes gathered in dates calendar and holidays mod...
BuildLinearInstrument & withMainLegFrequency(const Frequency &)
provides main leg frequency
Definition: linearInstrumentBuilder.cpp:250
BuildLinearInstrument & withStartDate(const Date &)
provides start date
Definition: linearInstrumentBuilder.cpp:113
BuildLinearInstrument & withForwardTenors(const Tenor &, const Tenor &)
provides two tenors for FRA
Definition: linearInstrumentBuilder.cpp:94
BuildLinearInstrument & withBond(const SmartPointer< Bond > &)
provides bond
Definition: linearInstrumentBuilder.cpp:274
BuildLinearInstrument & withFixedLegFrequency(const Frequency &)
provides fixed leg frequency
Definition: linearInstrumentBuilder.cpp:214
TimeUnit
Definition: timeUnit.hpp:21
double haircut_
This value is needed to properly construct repo agreement. It is the haircut of fixed income bond...
Definition: linearInstrumentBuilder.hpp:136
BuildLinearInstrument & withBasisPoints(const double)
provides basis points
Definition: linearInstrumentBuilder.cpp:301
BuildLinearInstrument & withInterestRateForFloatingLeg(const InterestRate &)
provides interest rate for floating leg of IRS
Definition: linearInstrumentBuilder.cpp:205
Calendar calendar_
The calendar is needed to calculate properly dates of contract.
Definition: linearInstrumentBuilder.hpp:96
BuildLinearInstrument & withTradeDate(const Date &)
provides trade date
Definition: linearInstrumentBuilder.cpp:104
Class implements builder design pattern supporting construction of linear instruments.
Definition: linearInstrumentBuilder.hpp:33
Definition: cadHoliday.cpp:3
Tenor maturity_tenor_
Maturity tenor defines the end date of the contract. If maturity tenor is provided, builder must have defined calendar.
Definition: linearInstrumentBuilder.hpp:99
void datesCalculation()
calculates date
Definition: linearInstrumentBuilder.cpp:479
double quote_
Number represents the quoting of the contract.
Definition: linearInstrumentBuilder.hpp:127
bool is_notional_exchanged_
If this variable was initialized by the builder ( withoutExchangeOfNotional() ) the swaps will not ex...
Definition: linearInstrumentBuilder.hpp:120
Class implements calendar object.
Definition: calendar.hpp:30
BuildLinearInstrument & withConvexityAdjustment(const double)
provides convexity
Definition: linearInstrumentBuilder.cpp:283
BuildLinearInstrument & withInterestRateForFixedLeg(const InterestRate &)
provides interest rate for fixed leg of IRS
Definition: linearInstrumentBuilder.cpp:196
Template of deep-coping smart pointer.
Definition: smartPointer.hpp:14
BuildLinearInstrument & withFloatingLegFrequency(const Frequency &)
provides floating leg frequency
Definition: linearInstrumentBuilder.cpp:223
BuildLinearInstrument & withMultiplicativeMargin(const double)
provides multiplicative margin
Definition: linearInstrumentBuilder.cpp:338
Class implements a deposit contract.
Definition: deposit.hpp:22
Frequency main_leg_frequency_
This variable represents the payment frequency of fixed leg (in IRS) or main leg (in other swaps)...
Definition: linearInstrumentBuilder.hpp:118
BuildLinearInstrument & withFixing(const double, const Date)
provides fixing
Definition: linearInstrumentBuilder.cpp:365
Class implements a Forward Rate Agreement.
Definition: FRA.hpp:27
double convexity_
Convexity is passed to Futures contract. For more information see convexity adjustment for futures in...
Definition: linearInstrumentBuilder.hpp:128
SmartPointer< Bond > bond_
The bond will be passed to repo agreement.
Definition: linearInstrumentBuilder.hpp:137
Date start_date_
The start date is usually defined as spot lag of the contract.
Definition: linearInstrumentBuilder.hpp:102
Date fra_value_date_
The date on which the FRA notional loan become effective.
Definition: linearInstrumentBuilder.hpp:104
double swap_points_
Swap points are quotings of FxForward.
Definition: linearInstrumentBuilder.hpp:135
BuildLinearInstrument & withHaircut(const double)
provides haircut
Definition: linearInstrumentBuilder.cpp:292
File contains definition of FRA contract.
int next_futures_date_
This integer gives which in turn futures dates must be calculated (starting form trade date)...
Definition: linearInstrumentBuilder.hpp:107
double multiplicative_margin_
Multiplicative margin multiplying fixing.
Definition: linearInstrumentBuilder.hpp:130
BuildLinearInstrument & usingCalendar(const Calendar &)
provides calendar
Definition: linearInstrumentBuilder.cpp:29
File contains function EasterForAGivenYear.
Frequency second_leg_frequency_
This variable represents the payment frequency of floating leg (in IRS) or spread leg (in other swaps...
Definition: linearInstrumentBuilder.hpp:119
BuildLinearInstrument & withTenor(const Tenor &)
provides maturity Tenor
Definition: linearInstrumentBuilder.cpp:76
BuildLinearInstrument & nextFuturesDate(const int &)
sets futures dates
Definition: linearInstrumentBuilder.cpp:160
BuildLinearInstrument & withQuote(const double)
provides quote
Definition: linearInstrumentBuilder.cpp:319
BuildLinearInstrument & withFxSpot(const double)
provides FX spot
Definition: linearInstrumentBuilder.cpp:347
Class implements an plain vanilla (flo/fix) interest rate swap contract.
Definition: IRS.hpp:28
BuildLinearInstrument & isExchangeOfNotional(bool)
If exchange of notional is off, the first and last cashflow of instrument will not include notional...
Definition: linearInstrumentBuilder.cpp:187
double fx_spot_
fx_spot_ as of trade date must be given to properly construct FxForward.
Definition: linearInstrumentBuilder.hpp:134
BuildLinearInstrument & withSpreadLegFrequency(const Frequency &)
provides spread leg frequency
Definition: linearInstrumentBuilder.cpp:259
InterestRate rate_for_second_leg_
Interest rate convention for secondary leg.
Definition: linearInstrumentBuilder.hpp:116
void reset()
resets builder
Definition: linearInstrumentBuilder.cpp:457
BuildLinearInstrument & startingInQuarter(const int &, const int &)
provides starting date to futures
Definition: linearInstrumentBuilder.cpp:149
InterestRate rate_for_main_leg_
Interest rate convention for main leg.This rate convention will be passed to instrument requiring onl...
Definition: linearInstrumentBuilder.hpp:115
Class implements a date object.
Definition: date.hpp:27
BuildLinearInstrument & withInterestRateForMainLeg(const InterestRate &)
provides interest rate for main leg
Definition: linearInstrumentBuilder.cpp:232
int futures_year_start_
This number is passed to futures. Informs in which year futures starts.
Definition: linearInstrumentBuilder.hpp:109
BuildLinearInstrument & withAdditiveMargin(const double)
provides additive margin
Definition: linearInstrumentBuilder.cpp:329
Date fixing_date_
Fixing date is required by FRA contracts. It defines moment of fixing .
Definition: linearInstrumentBuilder.hpp:103
File contains definition of IRS contract.
BuildLinearInstrument & withFixingDate(const Date &)
provides fixing date
Definition: linearInstrumentBuilder.cpp:122
Class implements a tenor object.
Definition: tenor.hpp:23
double notional_
Number represents notional of the contract. It is passed to all instruments. It is equal to 100...
Definition: linearInstrumentBuilder.hpp:126
BuildLinearInstrument & withInterestRate(const InterestRate &)
provides interest rate
Definition: linearInstrumentBuilder.cpp:177
Date maturity_date_
The end date defines the settlement of the contract.
Definition: linearInstrumentBuilder.hpp:105
The class implements the concept of interest rate.
Definition: interestRate.hpp:25
Tenor fixing_tenor_
Fixing tenor is needed by FRA argument. It defines start date of accrual period. If fixing tenor is p...
Definition: linearInstrumentBuilder.hpp:98
Frequency
Definition: timeUnit.hpp:68
BuildLinearInstrument & withMaturityDate(const Date &)
provides maturity date
Definition: linearInstrumentBuilder.cpp:140
BuildLinearInstrument & withNotional(const double)
provides notional
Definition: linearInstrumentBuilder.cpp:310
int futures_quarter_start_
This number is passed to futures. Informs in which quarter of the year futures starts.
Definition: linearInstrumentBuilder.hpp:108