Hi All, I am pricing a Mark-To-Market JPYUSD Swap. Advise please which swap class of QuantLib serves this purpose. Can I present the swap as a JPY floating bond and a USD amortizing floating rate bond (notionals vector to be calculated by the FX rate at the reset dates). Thanks Dragomir Nedeltchev, Custom House ------------------------------------------------------------------------------ Site24x7 APM Insight: Get Deep Visibility into Application Performance APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month Monitor end-to-end web transactions and take corrective actions now Troubleshoot faster and improve end-user experience. Signup Now! http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140 _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Hi Dragomir,
there is no ready-to-use class in QuantLib for this I think. But as you say, you can repesent the mtm swap as two single legs with a customized notional schedule for one of them. Beneath the bond classes you can also use the NonStandardSwap I guess (setting the fixed leg's nominals to zero and only use the floating leg for each mtm swap leg) and do the valuation of the single legs with two DiscountingSwapEngine's attaching appropriate discount curves for USD and JPY. Kind Regards Peter On 22 January 2016 at 08:47, Dragomir Nedeltchev <[hidden email]> wrote: > Hi All, > > > > I am pricing a Mark-To-Market JPYUSD Swap. > > > > Advise please which swap class of QuantLib serves this purpose. > > > > Can I present the swap as a JPY floating bond and a USD amortizing floating > rate bond (notionals vector to be calculated by the FX rate at the reset > dates). Thanks > > > > Dragomir Nedeltchev, Custom House > > > > > > TMF Custom House Fund Services (Ireland) Limited Registered Office: 3rd > Floor, Kilmore House, Park Lane, Spencer Dock, Dublin 1, Ireland; Tel: (353) > 1 878 0807; Fax: (353) 1 878 0827 Website: www.customhousegroup.com > Directors: Mark Hedderman; Kevin Walsh; Barbara Cotter Registered in Ireland > No. 147511 TMF Custom House Fund Services (Ireland) Limited is authorised by > The Central Bank of Ireland under Section 10 of the Investment > Intermediaries Act, 1995 > ************************************************************************************************************** > This e-mail and any files transmitted with it are intended to be > confidential and intended solely for the use of the individual or entity to > whom they are addressed. If you have received this e-mail in error please > notify the sender. Internet mail is a communication channel, which is not > controlled by Custom House, who cannot and do not guarantee that: any e-mail > sent from Custom House will be delivered within a reasonable timeframe, or > at all; comes from the purported sender; has not been intercepted by a third > party; or that the contents of the e-mail are unaltered from the time of > transmission. The recipient of this e-mail message should take note that > this document does not constitute a legally binding contractual obligation > of any sort unless there is a specific statement within the above message > confirming that the message contains such a legally binding contractual > obligation. > ****************************************************************************************************************** > > ------------------------------------------------------------------------------ > Site24x7 APM Insight: Get Deep Visibility into Application Performance > APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month > Monitor end-to-end web transactions and take corrective actions now > Troubleshoot faster and improve end-user experience. Signup Now! > http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140 > _______________________________________________ > QuantLib-users mailing list > [hidden email] > https://lists.sourceforge.net/lists/listinfo/quantlib-users > ------------------------------------------------------------------------------ Site24x7 APM Insight: Get Deep Visibility into Application Performance APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month Monitor end-to-end web transactions and take corrective actions now Troubleshoot faster and improve end-user experience. Signup Now! http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140 _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Hi Peter,
Thank you for the prompt feedback. This seems to meet my needs. I deal with a 1Y5Y swap. How can I tackle this feature in a NonStandardSwap? I see there is VanillaSwap oneYearForward5YeraSwap, but the Vanilla Swap class doesn't treat the floating notional reset feature of the MTM swap. Thank you in advance. Kind regards, Dragomir -----Original Message----- From: Peter Caspers [mailto:[hidden email]] Sent: Sunday, January 24, 2016 2:08 PM To: Dragomir Nedeltchev Cc: [hidden email] Subject: Re: [Quantlib-users] pricing Mark-To-Market Cross-Currency Swap Hi Dragomir, there is no ready-to-use class in QuantLib for this I think. But as you say, you can repesent the mtm swap as two single legs with a customized notional schedule for one of them. Beneath the bond classes you can also use the NonStandardSwap I guess (setting the fixed leg's nominals to zero and only use the floating leg for each mtm swap leg) and do the valuation of the single legs with two DiscountingSwapEngine's attaching appropriate discount curves for USD and JPY. Kind Regards Peter On 22 January 2016 at 08:47, Dragomir Nedeltchev <[hidden email]> wrote: > Hi All, > > > > I am pricing a Mark-To-Market JPYUSD Swap. > > > > Advise please which swap class of QuantLib serves this purpose. > > > > Can I present the swap as a JPY floating bond and a USD amortizing > floating rate bond (notionals vector to be calculated by the FX rate > at the reset dates). Thanks > > > > Dragomir Nedeltchev, Custom House > > > > > > TMF Custom House Fund Services (Ireland) Limited Registered Office: > 3rd Floor, Kilmore House, Park Lane, Spencer Dock, Dublin 1, Ireland; > Tel: (353) > 1 878 0807; Fax: (353) 1 878 0827 Website: www.customhousegroup.com > Directors: Mark Hedderman; Kevin Walsh; Barbara Cotter Registered in > Ireland No. 147511 TMF Custom House Fund Services (Ireland) Limited is > authorised by The Central Bank of Ireland under Section 10 of the > Investment Intermediaries Act, 1995 > ********************************************************************** > **************************************** > This e-mail and any files transmitted with it are intended to be > confidential and intended solely for the use of the individual or > entity to whom they are addressed. If you have received this e-mail in > error please notify the sender. Internet mail is a communication > channel, which is not controlled by Custom House, who cannot and do > not guarantee that: any e-mail sent from Custom House will be > delivered within a reasonable timeframe, or at all; comes from the > purported sender; has not been intercepted by a third party; or that > the contents of the e-mail are unaltered from the time of > transmission. The recipient of this e-mail message should take note > that this document does not constitute a legally binding contractual > obligation of any sort unless there is a specific statement within the > above message confirming that the message contains such a legally binding contractual obligation. > ********************************************************************** > ******************************************** > > ---------------------------------------------------------------------- > -------- > Site24x7 APM Insight: Get Deep Visibility into Application Performance > APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month > Monitor end-to-end web transactions and take corrective actions now > Troubleshoot faster and improve end-user experience. Signup Now! > http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140 > _______________________________________________ > QuantLib-users mailing list > [hidden email] > https://lists.sourceforge.net/lists/listinfo/quantlib-users > ------------------------------------------------------------------------------ Site24x7 APM Insight: Get Deep Visibility into Application Performance APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month Monitor end-to-end web transactions and take corrective actions now Troubleshoot faster and improve end-user experience. Signup Now! http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140 _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Hi Dragomir,
you have to create the schedules of your floating legs (which basically represent the series of their accrual periods), with effective Date = start of first accrual period (forward starting in your case), termination date = end of last accrual period. Then pass them together with the other parameters to the NonStandardSwap constructor. Note that you have to precalculate the deterministic notional schedule of the USD leg before, this is not handled in the NonstandardSwap either. The NonStandardSwaps accepts a vector of notionals corresponding to the accrual periods. You can set up the fixed schedule as equal to the floating schedule (whatever, it is not used) and with notionals zero. Then set up two DiscountingSwapEngines, assign them to your non standard swaps and extract the NPV from each one (which is in USD resp. JPY for the respective legs, because the instrument is a single currency instrument actually as well as the pricing engine). Regards Peter On 25 January 2016 at 09:44, Dragomir Nedeltchev <[hidden email]> wrote: > Hi Peter, > > Thank you for the prompt feedback. This seems to meet my needs. > > I deal with a 1Y5Y swap. How can I tackle this feature in a NonStandardSwap? > > I see there is VanillaSwap oneYearForward5YeraSwap, but the Vanilla Swap class doesn't treat the floating notional reset feature of the MTM swap. > > Thank you in advance. > > Kind regards, > > Dragomir > > -----Original Message----- > From: Peter Caspers [mailto:[hidden email]] > Sent: Sunday, January 24, 2016 2:08 PM > To: Dragomir Nedeltchev > Cc: [hidden email] > Subject: Re: [Quantlib-users] pricing Mark-To-Market Cross-Currency Swap > > Hi Dragomir, > > there is no ready-to-use class in QuantLib for this I think. > > But as you say, you can repesent the mtm swap as two single legs with a customized notional schedule for one of them. Beneath the bond classes you can also use the NonStandardSwap I guess (setting the fixed leg's nominals to zero and only use the floating leg for each mtm swap leg) and do the valuation of the single legs with two DiscountingSwapEngine's attaching appropriate discount curves for USD and JPY. > > Kind Regards > Peter > > On 22 January 2016 at 08:47, Dragomir Nedeltchev <[hidden email]> wrote: >> Hi All, >> >> >> >> I am pricing a Mark-To-Market JPYUSD Swap. >> >> >> >> Advise please which swap class of QuantLib serves this purpose. >> >> >> >> Can I present the swap as a JPY floating bond and a USD amortizing >> floating rate bond (notionals vector to be calculated by the FX rate >> at the reset dates). Thanks >> >> >> >> Dragomir Nedeltchev, Custom House >> >> >> >> >> >> TMF Custom House Fund Services (Ireland) Limited Registered Office: >> 3rd Floor, Kilmore House, Park Lane, Spencer Dock, Dublin 1, Ireland; >> Tel: (353) >> 1 878 0807; Fax: (353) 1 878 0827 Website: www.customhousegroup.com >> Directors: Mark Hedderman; Kevin Walsh; Barbara Cotter Registered in >> Ireland No. 147511 TMF Custom House Fund Services (Ireland) Limited is >> authorised by The Central Bank of Ireland under Section 10 of the >> Investment Intermediaries Act, 1995 >> ********************************************************************** >> **************************************** >> This e-mail and any files transmitted with it are intended to be >> confidential and intended solely for the use of the individual or >> entity to whom they are addressed. If you have received this e-mail in >> error please notify the sender. Internet mail is a communication >> channel, which is not controlled by Custom House, who cannot and do >> not guarantee that: any e-mail sent from Custom House will be >> delivered within a reasonable timeframe, or at all; comes from the >> purported sender; has not been intercepted by a third party; or that >> the contents of the e-mail are unaltered from the time of >> transmission. The recipient of this e-mail message should take note >> that this document does not constitute a legally binding contractual >> obligation of any sort unless there is a specific statement within the >> above message confirming that the message contains such a legally binding contractual obligation. >> ********************************************************************** >> ******************************************** >> >> ---------------------------------------------------------------------- >> -------- >> Site24x7 APM Insight: Get Deep Visibility into Application Performance >> APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month >> Monitor end-to-end web transactions and take corrective actions now >> Troubleshoot faster and improve end-user experience. Signup Now! >> http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140 >> _______________________________________________ >> QuantLib-users mailing list >> [hidden email] >> https://lists.sourceforge.net/lists/listinfo/quantlib-users >> > TMF Custom House Fund Services (Ireland) Limited Registered Office: 3rd Floor, Kilmore House, Park Lane, Spencer Dock, Dublin 1, Ireland; Tel: (353) 1 878 0807; Fax: (353) 1 878 0827 Website: www.customhousegroup.com Directors: Mark Hedderman; Kevin Walsh; Barbara Cotter Registered in Ireland No. 147511 TMF Custom House Fund Services (Ireland) Limited is authorised by The Central Bank of Ireland under Section 10 of the Investment Intermediaries Act, 1995 ************************************************************************************************************** This e-mail and any files transmitted with it are intended to be confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this e-mail in error please notify the sender. Internet mail is a communication channel, which is not controlled by Custom House, who cannot and do not guarantee that: any e-mail sent from Custom House will be delivered within a reasonable timeframe, or at all; comes from the purported sender; has not been intercepted by a third party; or that the contents of the e-mail are unaltered from the time of transmission. The recipient of this e-mail message should take note that this document does not constitute a legally binding contractual obligation of any sort unless there is a specific statement within the above message confirming that the message contains such a legally binding contractual obligation. ****************************************************************************************************************** ------------------------------------------------------------------------------ Site24x7 APM Insight: Get Deep Visibility into Application Performance APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month Monitor end-to-end web transactions and take corrective actions now Troubleshoot faster and improve end-user experience. Signup Now! http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140 _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Hi Peter,
Below you will find the code for the swap in question, if I got your point correctly. The vector of floating notional was calculated by the forward JPYUSD rate. Market data copy/paste the swapvaluation.cpp for both JPY and USD; later I will insert actual numbers Thanks, Dragomir ///////////////////////////// #include <ql/quantlib.hpp> #include <iostream> #include <iomanip> using namespace QuantLib; int main(int, char* []) { try { /********************* *** MARKET DATA *** *********************/ Calendar calendar = TARGET(); Date settlementDate(03, October, 2016); settlementDate = calendar.adjust(settlementDate); Integer fixingDays = 2; Date todaysDate(26, January, 2016); Settings::instance().evaluationDate() = todaysDate; todaysDate = Settings::instance().evaluationDate(); //USD leg Rate d1wQuoteUSD=0.0382; Rate d1mQuoteUSD=0.0372; Rate d3mQuoteUSD=0.0363; Rate d6mQuoteUSD=0.0353; Rate d9mQuoteUSD=0.0348; Rate d1yQuoteUSD=0.0345; Rate fra3x6QuoteUSD=0.037125; Rate fra6x9QuoteUSD=0.037125; Rate fra6x12QuoteUSD=0.037125; Real fut1QuoteUSD=96.2875; Real fut2QuoteUSD=96.7875; Real fut3QuoteUSD=96.9875; Real fut4QuoteUSD=96.6875; Real fut5QuoteUSD=96.4875; Real fut6QuoteUSD=96.3875; Real fut7QuoteUSD=96.2875; Real fut8QuoteUSD=96.0875; Rate s2yQuoteUSD=0.037125; Rate s3yQuoteUSD=0.0398; Rate s5yQuoteUSD=0.0443; Rate s10yQuoteUSD=0.05165; Rate s15yQuoteUSD=0.055175; //JPY leg Rate d1wQuoteJPY=0.0382; Rate d1mQuoteJPY=0.0372; Rate d3mQuoteJPY=0.0363; Rate d6mQuoteJPY=0.0353; Rate d9mQuoteJPY=0.0348; Rate d1yQuoteJPY=0.0345; Rate fra3x6QuoteJPY=0.037125; Rate fra6x9QuoteJPY=0.037125; Rate fra6x12QuoteJPY=0.037125; Real fut1QuoteJPY=96.2875; Real fut2QuoteJPY=96.7875; Real fut3QuoteJPY=96.9875; Real fut4QuoteJPY=96.6875; Real fut5QuoteJPY=96.4875; Real fut6QuoteJPY=96.3875; Real fut7QuoteJPY=96.2875; Real fut8QuoteJPY=96.0875; Rate s2yQuoteJPY=0.037125; Rate s3yQuoteJPY=0.0398; Rate s5yQuoteJPY=0.0443; Rate s10yQuoteJPY=0.05165; Rate s15yQuoteJPY=0.055175; /******************** *** QUOTES *** ********************/ //USD leg boost::shared_ptr<Quote> d1wRateUSD(new SimpleQuote(d1wQuoteUSD)); boost::shared_ptr<Quote> d1mRateUSD(new SimpleQuote(d1mQuoteUSD)); boost::shared_ptr<Quote> d3mRateUSD(new SimpleQuote(d3mQuoteUSD)); boost::shared_ptr<Quote> d6mRateUSD(new SimpleQuote(d6mQuoteUSD)); boost::shared_ptr<Quote> d9mRateUSD(new SimpleQuote(d9mQuoteUSD)); boost::shared_ptr<Quote> d1yRateUSD(new SimpleQuote(d1yQuoteUSD)); boost::shared_ptr<Quote> fra3x6RateUSD(new SimpleQuote(fra3x6QuoteUSD)); boost::shared_ptr<Quote> fra6x9RateUSD(new SimpleQuote(fra6x9QuoteUSD)); boost::shared_ptr<Quote> fra6x12RateUSD(new SimpleQuote(fra6x12QuoteUSD)); boost::shared_ptr<Quote> fut1PriceUSD(new SimpleQuote(fut1QuoteUSD)); boost::shared_ptr<Quote> fut2PriceUSD(new SimpleQuote(fut2QuoteUSD)); boost::shared_ptr<Quote> fut3PriceUSD(new SimpleQuote(fut3QuoteUSD)); boost::shared_ptr<Quote> fut4PriceUSD(new SimpleQuote(fut4QuoteUSD)); boost::shared_ptr<Quote> fut5PriceUSD(new SimpleQuote(fut5QuoteUSD)); boost::shared_ptr<Quote> fut6PriceUSD(new SimpleQuote(fut6QuoteUSD)); boost::shared_ptr<Quote> fut7PriceUSD(new SimpleQuote(fut7QuoteUSD)); boost::shared_ptr<Quote> fut8PriceUSD(new SimpleQuote(fut8QuoteUSD)); boost::shared_ptr<Quote> s2yRateUSD(new SimpleQuote(s2yQuoteUSD)); boost::shared_ptr<Quote> s3yRateUSD(new SimpleQuote(s3yQuoteUSD)); boost::shared_ptr<Quote> s5yRateUSD(new SimpleQuote(s5yQuoteUSD)); boost::shared_ptr<Quote> s10yRateUSD(new SimpleQuote(s10yQuoteUSD)); boost::shared_ptr<Quote> s15yRateUSD(new SimpleQuote(s15yQuoteUSD)); //JPY leg boost::shared_ptr<Quote> d1wRateJPY(new SimpleQuote(d1wQuoteJPY)); boost::shared_ptr<Quote> d1mRateJPY(new SimpleQuote(d1mQuoteJPY)); boost::shared_ptr<Quote> d3mRateJPY(new SimpleQuote(d3mQuoteJPY)); boost::shared_ptr<Quote> d6mRateJPY(new SimpleQuote(d6mQuoteJPY)); boost::shared_ptr<Quote> d9mRateJPY(new SimpleQuote(d9mQuoteJPY)); boost::shared_ptr<Quote> d1yRateJPY(new SimpleQuote(d1yQuoteJPY)); boost::shared_ptr<Quote> fra3x6RateJPY(new SimpleQuote(fra3x6QuoteJPY)); boost::shared_ptr<Quote> fra6x9RateJPY(new SimpleQuote(fra6x9QuoteJPY)); boost::shared_ptr<Quote> fra6x12RateJPY(new SimpleQuote(fra6x12QuoteJPY)); boost::shared_ptr<Quote> fut1PriceJPY(new SimpleQuote(fut1QuoteJPY)); boost::shared_ptr<Quote> fut2PriceJPY(new SimpleQuote(fut2QuoteJPY)); boost::shared_ptr<Quote> fut3PriceJPY(new SimpleQuote(fut3QuoteJPY)); boost::shared_ptr<Quote> fut4PriceJPY(new SimpleQuote(fut4QuoteJPY)); boost::shared_ptr<Quote> fut5PriceJPY(new SimpleQuote(fut5QuoteJPY)); boost::shared_ptr<Quote> fut6PriceJPY(new SimpleQuote(fut6QuoteJPY)); boost::shared_ptr<Quote> fut7PriceJPY(new SimpleQuote(fut7QuoteJPY)); boost::shared_ptr<Quote> fut8PriceJPY(new SimpleQuote(fut8QuoteJPY)); boost::shared_ptr<Quote> s2yRateJPY(new SimpleQuote(s2yQuoteJPY)); boost::shared_ptr<Quote> s3yRateJPY(new SimpleQuote(s3yQuoteJPY)); boost::shared_ptr<Quote> s5yRateJPY(new SimpleQuote(s5yQuoteJPY)); boost::shared_ptr<Quote> s10yRateJPY(new SimpleQuote(s10yQuoteJPY)); boost::shared_ptr<Quote> s15yRateJPY(new SimpleQuote(s15yQuoteJPY)); /********************* *** RATE HELPERS *** *********************/ //USD leg DayCounter depositDayCounterUSD = Actual360(); boost::shared_ptr<RateHelper> d1wUSD(new DepositRateHelper( Handle<Quote>(d1wRateUSD), 1*Weeks, fixingDays, calendar, ModifiedFollowing, true, depositDayCounterUSD)); boost::shared_ptr<RateHelper> d1mUSD(new DepositRateHelper( Handle<Quote>(d1mRateUSD), 1*Months, fixingDays, calendar, ModifiedFollowing, true, depositDayCounterUSD)); boost::shared_ptr<RateHelper> d3mUSD(new DepositRateHelper( Handle<Quote>(d3mRateUSD), 3*Months, fixingDays, calendar, ModifiedFollowing, true, depositDayCounterUSD)); boost::shared_ptr<RateHelper> d6mUSD(new DepositRateHelper( Handle<Quote>(d6mRateUSD), 6*Months, fixingDays, calendar, ModifiedFollowing, true, depositDayCounterUSD)); boost::shared_ptr<RateHelper> d9mUSD(new DepositRateHelper( Handle<Quote>(d9mRateUSD), 9*Months, fixingDays, calendar, ModifiedFollowing, true, depositDayCounterUSD)); boost::shared_ptr<RateHelper> d1yUSD(new DepositRateHelper( Handle<Quote>(d1yRateUSD), 1*Years, fixingDays, calendar, ModifiedFollowing, true, depositDayCounterUSD)); boost::shared_ptr<RateHelper> fra3x6USD(new FraRateHelper( Handle<Quote>(fra3x6RateUSD), 3, 6, fixingDays, calendar, ModifiedFollowing, true, depositDayCounterUSD)); boost::shared_ptr<RateHelper> fra6x9USD(new FraRateHelper( Handle<Quote>(fra6x9RateUSD), 6, 9, fixingDays, calendar, ModifiedFollowing, true, depositDayCounterUSD)); boost::shared_ptr<RateHelper> fra6x12USD(new FraRateHelper( Handle<Quote>(fra6x12RateUSD), 6, 12, fixingDays, calendar, ModifiedFollowing, true, depositDayCounterUSD)); Integer futMonthsUSD = 3; Date imm = IMM::nextDate(settlementDate); boost::shared_ptr<RateHelper> fut1USD(new FuturesRateHelper( Handle<Quote>(fut1PriceUSD), imm, futMonthsUSD, calendar, ModifiedFollowing, true, depositDayCounterUSD)); imm = IMM::nextDate(imm+1); boost::shared_ptr<RateHelper> fut2USD(new FuturesRateHelper( Handle<Quote>(fut2PriceUSD), imm, futMonthsUSD, calendar, ModifiedFollowing, true, depositDayCounterUSD)); imm = IMM::nextDate(imm+1); boost::shared_ptr<RateHelper> fut3USD(new FuturesRateHelper( Handle<Quote>(fut3PriceUSD), imm, futMonthsUSD, calendar, ModifiedFollowing, true, depositDayCounterUSD)); imm = IMM::nextDate(imm+1); boost::shared_ptr<RateHelper> fut4USD(new FuturesRateHelper( Handle<Quote>(fut4PriceUSD), imm, futMonthsUSD, calendar, ModifiedFollowing, true, depositDayCounterUSD)); imm = IMM::nextDate(imm+1); boost::shared_ptr<RateHelper> fut5USD(new FuturesRateHelper( Handle<Quote>(fut5PriceUSD), imm, futMonthsUSD, calendar, ModifiedFollowing, true, depositDayCounterUSD)); imm = IMM::nextDate(imm+1); boost::shared_ptr<RateHelper> fut6USD(new FuturesRateHelper( Handle<Quote>(fut6PriceUSD), imm, futMonthsUSD, calendar, ModifiedFollowing, true, depositDayCounterUSD)); imm = IMM::nextDate(imm+1); boost::shared_ptr<RateHelper> fut7USD(new FuturesRateHelper( Handle<Quote>(fut7PriceUSD), imm, futMonthsUSD, calendar, ModifiedFollowing, true, depositDayCounterUSD)); imm = IMM::nextDate(imm+1); boost::shared_ptr<RateHelper> fut8USD(new FuturesRateHelper( Handle<Quote>(fut8PriceUSD), imm, futMonthsUSD, calendar, ModifiedFollowing, true, depositDayCounterUSD)); Frequency frequencyUSD = Quarterly; BusinessDayConvention conventionUSD = Unadjusted; DayCounter dayCounterUSD = Thirty360(Thirty360::USA); boost::shared_ptr<IborIndex> indexUSD(new Euribor6M); boost::shared_ptr<RateHelper> s2yUSD(new SwapRateHelper( Handle<Quote>(s2yRateUSD), 2*Years, calendar, frequencyUSD, conventionUSD, dayCounterUSD, indexUSD)); boost::shared_ptr<RateHelper> s3yUSD(new SwapRateHelper( Handle<Quote>(s3yRateUSD), 3*Years, calendar, frequencyUSD, conventionUSD, dayCounterUSD, indexUSD)); boost::shared_ptr<RateHelper> s5yUSD(new SwapRateHelper( Handle<Quote>(s5yRateUSD), 5*Years, calendar, frequencyUSD, conventionUSD, dayCounterUSD, indexUSD)); boost::shared_ptr<RateHelper> s10yUSD(new SwapRateHelper( Handle<Quote>(s10yRateUSD), 10*Years, calendar, frequencyUSD, conventionUSD, dayCounterUSD, indexUSD)); boost::shared_ptr<RateHelper> s15yUSD(new SwapRateHelper( Handle<Quote>(s15yRateUSD), 15*Years, calendar, frequencyUSD, conventionUSD, dayCounterUSD, indexUSD)); //JPY leg DayCounter depositDayCounterJPY = Actual360(); boost::shared_ptr<RateHelper> d1wJPY(new DepositRateHelper( Handle<Quote>(d1wRateJPY), 1*Weeks, fixingDays, calendar, ModifiedFollowing, true, depositDayCounterJPY)); boost::shared_ptr<RateHelper> d1mJPY(new DepositRateHelper( Handle<Quote>(d1mRateJPY), 1*Months, fixingDays, calendar, ModifiedFollowing, true, depositDayCounterJPY)); boost::shared_ptr<RateHelper> d3mJPY(new DepositRateHelper( Handle<Quote>(d3mRateJPY), 3*Months, fixingDays, calendar, ModifiedFollowing, true, depositDayCounterJPY)); boost::shared_ptr<RateHelper> d6mJPY(new DepositRateHelper( Handle<Quote>(d6mRateJPY), 6*Months, fixingDays, calendar, ModifiedFollowing, true, depositDayCounterJPY)); boost::shared_ptr<RateHelper> d9mJPY(new DepositRateHelper( Handle<Quote>(d9mRateJPY), 9*Months, fixingDays, calendar, ModifiedFollowing, true, depositDayCounterJPY)); boost::shared_ptr<RateHelper> d1yJPY(new DepositRateHelper( Handle<Quote>(d1yRateJPY), 1*Years, fixingDays, calendar, ModifiedFollowing, true, depositDayCounterJPY)); boost::shared_ptr<RateHelper> fra3x6JPY(new FraRateHelper( Handle<Quote>(fra3x6RateJPY), 3, 6, fixingDays, calendar, ModifiedFollowing, true, depositDayCounterJPY)); boost::shared_ptr<RateHelper> fra6x9JPY(new FraRateHelper( Handle<Quote>(fra6x9RateJPY), 6, 9, fixingDays, calendar, ModifiedFollowing, true, depositDayCounterJPY)); boost::shared_ptr<RateHelper> fra6x12JPY(new FraRateHelper( Handle<Quote>(fra6x12RateJPY), 6, 12, fixingDays, calendar, ModifiedFollowing, true, depositDayCounterJPY)); Integer futMonthsJPY = 3; Date imm = IMM::nextDate(settlementDate); boost::shared_ptr<RateHelper> fut1JPY(new FuturesRateHelper( Handle<Quote>(fut1PriceJPY), imm, futMonthsJPY, calendar, ModifiedFollowing, true, depositDayCounterJPY)); imm = IMM::nextDate(imm+1); boost::shared_ptr<RateHelper> fut2JPY(new FuturesRateHelper( Handle<Quote>(fut2PriceJPY), imm, futMonthsJPY, calendar, ModifiedFollowing, true, depositDayCounterJPY)); imm = IMM::nextDate(imm+1); boost::shared_ptr<RateHelper> fut3JPY(new FuturesRateHelper( Handle<Quote>(fut3PriceJPY), imm, futMonthsJPY, calendar, ModifiedFollowing, true, depositDayCounterJPY)); imm = IMM::nextDate(imm+1); boost::shared_ptr<RateHelper> fut4JPY(new FuturesRateHelper( Handle<Quote>(fut4PriceJPY), imm, futMonthsJPY, calendar, ModifiedFollowing, true, depositDayCounterJPY)); imm = IMM::nextDate(imm+1); boost::shared_ptr<RateHelper> fut5JPY(new FuturesRateHelper( Handle<Quote>(fut5PriceJPY), imm, futMonthsJPY, calendar, ModifiedFollowing, true, depositDayCounterJPY)); imm = IMM::nextDate(imm+1); boost::shared_ptr<RateHelper> fut6JPY(new FuturesRateHelper( Handle<Quote>(fut6PriceJPY), imm, futMonthsJPY, calendar, ModifiedFollowing, true, depositDayCounterJPY)); imm = IMM::nextDate(imm+1); boost::shared_ptr<RateHelper> fut7JPY(new FuturesRateHelper( Handle<Quote>(fut7PriceJPY), imm, futMonthsJPY, calendar, ModifiedFollowing, true, depositDayCounterJPY)); imm = IMM::nextDate(imm+1); boost::shared_ptr<RateHelper> fut8JPY(new FuturesRateHelper( Handle<Quote>(fut8PriceJPY), imm, futMonthsJPY, calendar, ModifiedFollowing, true, depositDayCounterJPY)); Frequency frequencyJPY = Quarterly; BusinessDayConvention conventionJPY = Unadjusted; DayCounter dayCounterJPY = Thirty360(Thirty360::European); boost::shared_ptr<IborIndex> indexJPY(new Euribor6M); boost::shared_ptr<RateHelper> s2yJPY(new SwapRateHelper( Handle<Quote>(s2yRateJPY), 2*Years, calendar, frequencyJPY, conventionJPY, dayCounterJPY, indexJPY)); boost::shared_ptr<RateHelper> s3yJPY(new SwapRateHelper( Handle<Quote>(s3yRateJPY), 3*Years, calendar, frequencyJPY, conventionJPY, dayCounterJPY, indexJPY)); boost::shared_ptr<RateHelper> s5yJPY(new SwapRateHelper( Handle<Quote>(s5yRateJPY), 5*Years, calendar, frequencyJPY, conventionJPY, dayCounterJPY, indexJPY)); boost::shared_ptr<RateHelper> s10yJPY(new SwapRateHelper( Handle<Quote>(s10yRateJPY), 10*Years, calendar, frequencyJPY, conventionJPY, dayCounterJPY, indexJPY)); boost::shared_ptr<RateHelper> s15yJPY(new SwapRateHelper( Handle<Quote>(s15yRateJPY), 15*Years, calendar, frequencyJPY, conventionJPY, dayCounterJPY, indexJPY)); /********************* ** CURVEs BUILDING ** *********************/ DayCounter termStructureDayCounter = ActualActual(ActualActual::ISDA); double tolerance = 1.0e-15; std::vector<boost::shared_ptr<RateHelper> > depoSwapInstrumentsUSD; depoSwapInstrumentsUSD.push_back(d1wUSD); depoSwapInstrumentsUSD.push_back(d1mUSD); depoSwapInstrumentsUSD.push_back(d3mUSD); depoSwapInstrumentsUSD.push_back(d6mUSD); depoSwapInstrumentsUSD.push_back(d9mUSD); depoSwapInstrumentsUSD.push_back(d1yUSD); depoSwapInstrumentsUSD.push_back(s2yUSD); depoSwapInstrumentsUSD.push_back(s3yUSD); depoSwapInstrumentsUSD.push_back(s5yUSD); depoSwapInstrumentsUSD.push_back(s10yUSD); depoSwapInstrumentsUSD.push_back(s15yUSD); boost::shared_ptr<YieldTermStructure> depoSwapTermStructureUSD( new PiecewiseYieldCurve<Discount,LogLinear>( settlementDate, depoSwapInstrumentsUSD, termStructureDayCounter, tolerance)); std::vector<boost::shared_ptr<RateHelper> > depoFutSwapInstrumentsUSD; depoFutSwapInstrumentsUSD.push_back(d1wUSD); depoFutSwapInstrumentsUSD.push_back(d1mUSD); depoFutSwapInstrumentsUSD.push_back(fut1USD); depoFutSwapInstrumentsUSD.push_back(fut2USD); depoFutSwapInstrumentsUSD.push_back(fut3USD); depoFutSwapInstrumentsUSD.push_back(fut4USD); depoFutSwapInstrumentsUSD.push_back(fut5USD); depoFutSwapInstrumentsUSD.push_back(fut6USD); depoFutSwapInstrumentsUSD.push_back(fut7USD); depoFutSwapInstrumentsUSD.push_back(fut8USD); depoFutSwapInstrumentsUSD.push_back(s3yUSD); depoFutSwapInstrumentsUSD.push_back(s5yUSD); depoFutSwapInstrumentsUSD.push_back(s10yUSD); depoFutSwapInstrumentsUSD.push_back(s15yUSD); boost::shared_ptr<YieldTermStructure> depoFutSwapTermStructureUSD( new PiecewiseYieldCurve<Discount,LogLinear>( settlementDate, depoFutSwapInstrumentsUSD, termStructureDayCounter, tolerance)); std::vector<boost::shared_ptr<RateHelper> > depoFRASwapInstrumentsUSD; depoFRASwapInstrumentsUSD.push_back(d1wUSD); depoFRASwapInstrumentsUSD.push_back(d1mUSD); depoFRASwapInstrumentsUSD.push_back(d3mUSD); depoFRASwapInstrumentsUSD.push_back(fra3x6USD); depoFRASwapInstrumentsUSD.push_back(fra6x9USD); depoFRASwapInstrumentsUSD.push_back(fra6x12USD); depoFRASwapInstrumentsUSD.push_back(s2yUSD); depoFRASwapInstrumentsUSD.push_back(s3yUSD); depoFRASwapInstrumentsUSD.push_back(s5yUSD); depoFRASwapInstrumentsUSD.push_back(s10yUSD); depoFRASwapInstrumentsUSD.push_back(s15yUSD); boost::shared_ptr<YieldTermStructure> depoFRASwapTermStructureUSD( new PiecewiseYieldCurve<Discount,LogLinear>( settlementDate, depoFRASwapInstrumentsUSD, termStructureDayCounter, tolerance)); RelinkableHandle<YieldTermStructure> discountingTermStructureUSD; RelinkableHandle<YieldTermStructure> forecastingTermStructureUSD; //JPY leg std::vector<boost::shared_ptr<RateHelper> > depoSwapInstrumentsJPY; depoSwapInstrumentsJPY.push_back(d1wJPY); depoSwapInstrumentsJPY.push_back(d1mJPY); depoSwapInstrumentsJPY.push_back(d3mJPY); depoSwapInstrumentsJPY.push_back(d6mJPY); depoSwapInstrumentsJPY.push_back(d9mJPY); depoSwapInstrumentsJPY.push_back(d1yJPY); depoSwapInstrumentsJPY.push_back(s2yJPY); depoSwapInstrumentsJPY.push_back(s3yJPY); depoSwapInstrumentsJPY.push_back(s5yJPY); depoSwapInstrumentsJPY.push_back(s10yJPY); depoSwapInstrumentsJPY.push_back(s15yJPY); boost::shared_ptr<YieldTermStructure> depoSwapTermStructureJPY( new PiecewiseYieldCurve<Discount,LogLinear>( settlementDate, depoSwapInstrumentsJPY, termStructureDayCounter, tolerance)); std::vector<boost::shared_ptr<RateHelper> > depoFutSwapInstrumentsJPY; depoFutSwapInstrumentsJPY.push_back(d1wJPY); depoFutSwapInstrumentsJPY.push_back(d1mJPY); depoFutSwapInstrumentsJPY.push_back(fut1JPY); depoFutSwapInstrumentsJPY.push_back(fut2JPY); depoFutSwapInstrumentsJPY.push_back(fut3JPY); depoFutSwapInstrumentsJPY.push_back(fut4JPY); depoFutSwapInstrumentsJPY.push_back(fut5JPY); depoFutSwapInstrumentsJPY.push_back(fut6JPY); depoFutSwapInstrumentsJPY.push_back(fut7JPY); depoFutSwapInstrumentsJPY.push_back(fut8JPY); depoFutSwapInstrumentsJPY.push_back(s3yJPY); depoFutSwapInstrumentsJPY.push_back(s5yJPY); depoFutSwapInstrumentsJPY.push_back(s10yJPY); depoFutSwapInstrumentsJPY.push_back(s15yJPY); boost::shared_ptr<YieldTermStructure> depoFutSwapTermStructureJPY( new PiecewiseYieldCurve<Discount,LogLinear>( settlementDate, depoFutSwapInstrumentsJPY, termStructureDayCounter, tolerance)); std::vector<boost::shared_ptr<RateHelper> > depoFRASwapInstrumentsJPY; depoFRASwapInstrumentsJPY.push_back(d1wJPY); depoFRASwapInstrumentsJPY.push_back(d1mJPY); depoFRASwapInstrumentsJPY.push_back(d3mJPY); depoFRASwapInstrumentsJPY.push_back(fra3x6JPY); depoFRASwapInstrumentsJPY.push_back(fra6x9JPY); depoFRASwapInstrumentsJPY.push_back(fra6x12JPY); depoFRASwapInstrumentsJPY.push_back(s2yJPY); depoFRASwapInstrumentsJPY.push_back(s3yJPY); depoFRASwapInstrumentsJPY.push_back(s5yJPY); depoFRASwapInstrumentsJPY.push_back(s10yJPY); depoFRASwapInstrumentsJPY.push_back(s15yJPY); boost::shared_ptr<YieldTermStructure> depoFRASwapTermStructureJPY( new PiecewiseYieldCurve<Discount,LogLinear>( settlementDate, depoFRASwapInstrumentsJPY, termStructureDayCounter, tolerance)); RelinkableHandle<YieldTermStructure> discountingTermStructureJPY; RelinkableHandle<YieldTermStructure> forecastingTermStructureJPY; /********************* * SWAPS TO BE PRICED * **********************/ Real nominalDummy = 0.0; std::vector<Real> nominalJPY; nominalJPY.push_back(16000000000); nominalJPY.push_back(16000000000); nominalJPY.push_back(16000000000); nominalJPY.push_back(16000000000); std::vector<Real> nominalUSD; nominalUSD.push_back(20000000); nominalUSD.push_back(20500000); nominalUSD.push_back(20100000); nominalUSD.push_back(20070000); // fixed leg Frequency frequencyDummy = Quarterly; BusinessDayConvention conventionDummy = Unadjusted; DayCounter dayCounterDummy = Thirty360(Thirty360::European); Rate fixedRate = 0.0; // floating leg BusinessDayConvention conventionUSD = ModifiedFollowing; BusinessDayConvention conventionJPY = ModifiedFollowing; DayCounter dayCounterUSD = Actual360(); DayCounter dayCounterJPY = Actual360();Frequency frequencyUSD = Quarterly; Frequency frequencyJPY = Quarterly; boost::shared_ptr<IborIndex> euriborIndexUSD( new Euribor6M(forecastingTermStructureUSD)); boost::shared_ptr<IborIndex> euriborIndexJPY( new Euribor6M(forecastingTermStructureJPY)); Spread spreadUSD = 0.0; Spread spreadJPY = -0.0069; Integer lenghtInYears = 1; VanillaSwap::Type swapTypeUSD = VanillaSwap::Receiver; VanillaSwap::Type swapTypeJPY = VanillaSwap::Payer; Date maturity = settlementDate + lenghtInYears*Years; Schedule fixedSchedule(settlementDate, maturity, Period(fixedLegFrequency), calendar, fixedLegConvention, fixedLegConvention, DateGeneration::Forward, false); Schedule floatScheduleUSD(settlementDate, maturity, Period(frequencyUSD), calendar, conventionUSD, conventionUSD, DateGeneration::Forward, false); Schedule floatScheduleJPY(settlementDate, maturity, Period(frequencyJPY), calendar, conventionJPY, conventionJPY, DateGeneration::Forward, false); NonStandardSwap dummyUSDSwap(swapTypeUSD, nominalDummy, nominalUSD, floatScheduleUSD, fixedRate, dayCounterDummy, floatScheduleUSD, euriborIndexUSD, QL_EPSILON, spreadUSD, dayCounterUSD, false, false, conventionUSD) NonStandardSwap dummyJPYSwap(swapTypeJPY, nominalDummy, nominalJPY, floatScheduleJPY, fixedRate, dayCounterDummy, floatScheduleJPY, euriborIndexJPY, QL_EPSILON, spreadJPY, dayCounterJPY, false, false, conventionJPY) /*************** * SWAP PRICING * ****************/ Real NPVUSD; Real NPVJPY; Real NPVmySwap; boost::shared_ptr<PricingEngine> swapEngineUSD( new DiscountingSwapEngine(discountingTermStructureUSD)); dummyUSDSwap.setPricingEngine(swapEngineUSD); forecastingTermStructureUSD.linkTo(depoSwapTermStructureUSD); discountingTermStructureUSD.linkTo(depoSwapTermStructureUSD); NPVUSD = dummyUSDSwap.NPV(); boost::shared_ptr<PricingEngine> swapEngineJPY( new DiscountingSwapEngine(discountingTermStructureJPY)); dummyJPYSwap.setPricingEngine(swapEngineJPY); forecastingTermStructureJPY.linkTo(depoSwapTermStructureJPY); discountingTermStructureJPY.linkTo(depoSwapTermStructureJPY); NPVJPY = dummyJPYSwap.NPV(); NPVmySwap = NPVUSD - NPVJPY; return 0; } catch (std::exception& e) { std::cerr << e.what() << std::endl; return 1; } catch (...) { std::cerr << "unknown error" << std::endl; return 1; } } //////////////////////////// -----Original Message----- From: Peter Caspers [mailto:[hidden email]] Sent: Monday, January 25, 2016 10:09 PM To: Dragomir Nedeltchev Cc: [hidden email] Subject: Re: [Quantlib-users] pricing Mark-To-Market Cross-Currency Swap Hi Dragomir, you have to create the schedules of your floating legs (which basically represent the series of their accrual periods), with effective Date = start of first accrual period (forward starting in your case), termination date = end of last accrual period. Then pass them together with the other parameters to the NonStandardSwap constructor. Note that you have to precalculate the deterministic notional schedule of the USD leg before, this is not handled in the NonstandardSwap either. The NonStandardSwaps accepts a vector of notionals corresponding to the accrual periods. You can set up the fixed schedule as equal to the floating schedule (whatever, it is not used) and with notionals zero. Then set up two DiscountingSwapEngines, assign them to your non standard swaps and extract the NPV from each one (which is in USD resp. JPY for the respective legs, because the instrument is a single currency instrument actually as well as the pricing engine). Regards Peter On 25 January 2016 at 09:44, Dragomir Nedeltchev <[hidden email]> wrote: > Hi Peter, > > Thank you for the prompt feedback. This seems to meet my needs. > > I deal with a 1Y5Y swap. How can I tackle this feature in a NonStandardSwap? > > I see there is VanillaSwap oneYearForward5YeraSwap, but the Vanilla Swap class doesn't treat the floating notional reset feature of the MTM swap. > > Thank you in advance. > > Kind regards, > > Dragomir > > -----Original Message----- > From: Peter Caspers [mailto:[hidden email]] > Sent: Sunday, January 24, 2016 2:08 PM > To: Dragomir Nedeltchev > Cc: [hidden email] > Subject: Re: [Quantlib-users] pricing Mark-To-Market Cross-Currency > Swap > > Hi Dragomir, > > there is no ready-to-use class in QuantLib for this I think. > > But as you say, you can repesent the mtm swap as two single legs with a customized notional schedule for one of them. Beneath the bond classes you can also use the NonStandardSwap I guess (setting the fixed leg's nominals to zero and only use the floating leg for each mtm swap leg) and do the valuation of the single legs with two DiscountingSwapEngine's attaching appropriate discount curves for USD and JPY. > > Kind Regards > Peter > > On 22 January 2016 at 08:47, Dragomir Nedeltchev <[hidden email]> wrote: >> Hi All, >> >> >> >> I am pricing a Mark-To-Market JPYUSD Swap. >> >> >> >> Advise please which swap class of QuantLib serves this purpose. >> >> >> >> Can I present the swap as a JPY floating bond and a USD amortizing >> floating rate bond (notionals vector to be calculated by the FX rate >> at the reset dates). Thanks >> >> >> >> Dragomir Nedeltchev, Custom House >> >> >> >> >> >> TMF Custom House Fund Services (Ireland) Limited Registered Office: >> 3rd Floor, Kilmore House, Park Lane, Spencer Dock, Dublin 1, Ireland; >> Tel: (353) >> 1 878 0807; Fax: (353) 1 878 0827 Website: www.customhousegroup.com >> Directors: Mark Hedderman; Kevin Walsh; Barbara Cotter Registered in >> Ireland No. 147511 TMF Custom House Fund Services (Ireland) Limited >> is authorised by The Central Bank of Ireland under Section 10 of the >> Investment Intermediaries Act, 1995 >> ********************************************************************* >> * >> **************************************** >> This e-mail and any files transmitted with it are intended to be >> confidential and intended solely for the use of the individual or >> entity to whom they are addressed. If you have received this e-mail >> in error please notify the sender. Internet mail is a communication >> channel, which is not controlled by Custom House, who cannot and do >> not guarantee that: any e-mail sent from Custom House will be >> delivered within a reasonable timeframe, or at all; comes from the >> purported sender; has not been intercepted by a third party; or that >> the contents of the e-mail are unaltered from the time of >> transmission. The recipient of this e-mail message should take note >> that this document does not constitute a legally binding contractual >> obligation of any sort unless there is a specific statement within >> the above message confirming that the message contains such a legally binding contractual obligation. >> ********************************************************************* >> * >> ******************************************** >> >> --------------------------------------------------------------------- >> - >> -------- >> Site24x7 APM Insight: Get Deep Visibility into Application >> Performance APM + Mobile APM + RUM: Monitor 3 App instances at just >> $35/Month Monitor end-to-end web transactions and take corrective >> actions now Troubleshoot faster and improve end-user experience. Signup Now! >> http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140 >> _______________________________________________ >> QuantLib-users mailing list >> [hidden email] >> https://lists.sourceforge.net/lists/listinfo/quantlib-users >> > TMF Custom House Fund Services (Ireland) Limited Registered Office: > 3rd Floor, Kilmore House, Park Lane, Spencer Dock, Dublin 1, Ireland; > Tel: (353) 1 878 0807; Fax: (353) 1 878 0827 Website: > www.customhousegroup.com Directors: Mark Hedderman; Kevin Walsh; > Barbara Cotter Registered in Ireland No. 147511 TMF Custom House Fund > Services (Ireland) Limited is authorised by The Central Bank of > Ireland under Section 10 of the Investment Intermediaries Act, 1995 > ********************************************************************** > **************************************** This e-mail and any files > transmitted with it are intended to be confidential and intended > solely for the use of the individual or entity to whom they are > addressed. If you have received this e-mail in error please notify the > sender. Internet mail is a communication channel, which is not > controlled by Custom House, who cannot and do not guarantee that: any > e-mail sent from Custom House will be delivered within a reasonable > timeframe, or at all; comes from the purported sender; has not been > intercepted by a third party; or that the contents of the e-mail are > unaltered from the time of transmission. The recipient of this e-mail > message should take note that this document does not constitute a > legally binding contractual obligation of any sort unless there is a > specific statement within the above message confirming that the > message contains such a legally binding contractual obligation. > ********************************************************************** > ******************************************** ------------------------------------------------------------------------------ Site24x7 APM Insight: Get Deep Visibility into Application Performance APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month Monitor end-to-end web transactions and take corrective actions now Troubleshoot faster and improve end-user experience. Signup Now! http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140 _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Hi Dragomir,
yes, in that direction. Just a few thoughts. - there are Libor indices in USD and JPY you can use, no need to go for Euribor - the dummy notional has to be a vector, too (containing 0.0, that's ok) - the gearing should be 1.0 ? It is the multiplier for the ibor fixing before adding the spread. - the NPVs have to be converted to one currency before adding them I did not read every line of the code - just give it a try and if you run into problems, just write back here, ok? Do you have a reference to compare the NPV with? Regards Peter On 26 January 2016 at 14:36, Dragomir Nedeltchev <[hidden email]> wrote: > Hi Peter, > > Below you will find the code for the swap in question, if I got your point correctly. > > The vector of floating notional was calculated by the forward JPYUSD rate. Market data copy/paste the swapvaluation.cpp for both JPY and USD; later I will insert actual numbers > > Thanks, > > Dragomir > > ///////////////////////////// > #include <ql/quantlib.hpp> > > #include <iostream> > #include <iomanip> > > using namespace QuantLib; > > > int main(int, char* []) { > > try { > > > > /********************* > *** MARKET DATA *** > *********************/ > > Calendar calendar = TARGET(); > Date settlementDate(03, October, 2016); > settlementDate = calendar.adjust(settlementDate); > > Integer fixingDays = 2; > > Date todaysDate(26, January, 2016); > > Settings::instance().evaluationDate() = todaysDate; > > todaysDate = Settings::instance().evaluationDate(); > > //USD leg > Rate d1wQuoteUSD=0.0382; > Rate d1mQuoteUSD=0.0372; > Rate d3mQuoteUSD=0.0363; > Rate d6mQuoteUSD=0.0353; > Rate d9mQuoteUSD=0.0348; > Rate d1yQuoteUSD=0.0345; > > Rate fra3x6QuoteUSD=0.037125; > Rate fra6x9QuoteUSD=0.037125; > Rate fra6x12QuoteUSD=0.037125; > > Real fut1QuoteUSD=96.2875; > Real fut2QuoteUSD=96.7875; > Real fut3QuoteUSD=96.9875; > Real fut4QuoteUSD=96.6875; > Real fut5QuoteUSD=96.4875; > Real fut6QuoteUSD=96.3875; > Real fut7QuoteUSD=96.2875; > Real fut8QuoteUSD=96.0875; > > Rate s2yQuoteUSD=0.037125; > Rate s3yQuoteUSD=0.0398; > Rate s5yQuoteUSD=0.0443; > Rate s10yQuoteUSD=0.05165; > Rate s15yQuoteUSD=0.055175; > > //JPY leg > > Rate d1wQuoteJPY=0.0382; > Rate d1mQuoteJPY=0.0372; > Rate d3mQuoteJPY=0.0363; > Rate d6mQuoteJPY=0.0353; > Rate d9mQuoteJPY=0.0348; > Rate d1yQuoteJPY=0.0345; > > Rate fra3x6QuoteJPY=0.037125; > Rate fra6x9QuoteJPY=0.037125; > Rate fra6x12QuoteJPY=0.037125; > > Real fut1QuoteJPY=96.2875; > Real fut2QuoteJPY=96.7875; > Real fut3QuoteJPY=96.9875; > Real fut4QuoteJPY=96.6875; > Real fut5QuoteJPY=96.4875; > Real fut6QuoteJPY=96.3875; > Real fut7QuoteJPY=96.2875; > Real fut8QuoteJPY=96.0875; > > Rate s2yQuoteJPY=0.037125; > Rate s3yQuoteJPY=0.0398; > Rate s5yQuoteJPY=0.0443; > Rate s10yQuoteJPY=0.05165; > Rate s15yQuoteJPY=0.055175; > > > /******************** > *** QUOTES *** > ********************/ > > //USD leg > > > boost::shared_ptr<Quote> d1wRateUSD(new SimpleQuote(d1wQuoteUSD)); > boost::shared_ptr<Quote> d1mRateUSD(new SimpleQuote(d1mQuoteUSD)); > boost::shared_ptr<Quote> d3mRateUSD(new SimpleQuote(d3mQuoteUSD)); > boost::shared_ptr<Quote> d6mRateUSD(new SimpleQuote(d6mQuoteUSD)); > boost::shared_ptr<Quote> d9mRateUSD(new SimpleQuote(d9mQuoteUSD)); > boost::shared_ptr<Quote> d1yRateUSD(new SimpleQuote(d1yQuoteUSD)); > > boost::shared_ptr<Quote> fra3x6RateUSD(new SimpleQuote(fra3x6QuoteUSD)); > boost::shared_ptr<Quote> fra6x9RateUSD(new SimpleQuote(fra6x9QuoteUSD)); > boost::shared_ptr<Quote> fra6x12RateUSD(new SimpleQuote(fra6x12QuoteUSD)); > > boost::shared_ptr<Quote> fut1PriceUSD(new SimpleQuote(fut1QuoteUSD)); > boost::shared_ptr<Quote> fut2PriceUSD(new SimpleQuote(fut2QuoteUSD)); > boost::shared_ptr<Quote> fut3PriceUSD(new SimpleQuote(fut3QuoteUSD)); > boost::shared_ptr<Quote> fut4PriceUSD(new SimpleQuote(fut4QuoteUSD)); > boost::shared_ptr<Quote> fut5PriceUSD(new SimpleQuote(fut5QuoteUSD)); > boost::shared_ptr<Quote> fut6PriceUSD(new SimpleQuote(fut6QuoteUSD)); > boost::shared_ptr<Quote> fut7PriceUSD(new SimpleQuote(fut7QuoteUSD)); > boost::shared_ptr<Quote> fut8PriceUSD(new SimpleQuote(fut8QuoteUSD)); > > boost::shared_ptr<Quote> s2yRateUSD(new SimpleQuote(s2yQuoteUSD)); > boost::shared_ptr<Quote> s3yRateUSD(new SimpleQuote(s3yQuoteUSD)); > boost::shared_ptr<Quote> s5yRateUSD(new SimpleQuote(s5yQuoteUSD)); > boost::shared_ptr<Quote> s10yRateUSD(new SimpleQuote(s10yQuoteUSD)); > boost::shared_ptr<Quote> s15yRateUSD(new SimpleQuote(s15yQuoteUSD)); > > //JPY leg > > boost::shared_ptr<Quote> d1wRateJPY(new SimpleQuote(d1wQuoteJPY)); > boost::shared_ptr<Quote> d1mRateJPY(new SimpleQuote(d1mQuoteJPY)); > boost::shared_ptr<Quote> d3mRateJPY(new SimpleQuote(d3mQuoteJPY)); > boost::shared_ptr<Quote> d6mRateJPY(new SimpleQuote(d6mQuoteJPY)); > boost::shared_ptr<Quote> d9mRateJPY(new SimpleQuote(d9mQuoteJPY)); > boost::shared_ptr<Quote> d1yRateJPY(new SimpleQuote(d1yQuoteJPY)); > > boost::shared_ptr<Quote> fra3x6RateJPY(new SimpleQuote(fra3x6QuoteJPY)); > boost::shared_ptr<Quote> fra6x9RateJPY(new SimpleQuote(fra6x9QuoteJPY)); > boost::shared_ptr<Quote> fra6x12RateJPY(new SimpleQuote(fra6x12QuoteJPY)); > > boost::shared_ptr<Quote> fut1PriceJPY(new SimpleQuote(fut1QuoteJPY)); > boost::shared_ptr<Quote> fut2PriceJPY(new SimpleQuote(fut2QuoteJPY)); > boost::shared_ptr<Quote> fut3PriceJPY(new SimpleQuote(fut3QuoteJPY)); > boost::shared_ptr<Quote> fut4PriceJPY(new SimpleQuote(fut4QuoteJPY)); > boost::shared_ptr<Quote> fut5PriceJPY(new SimpleQuote(fut5QuoteJPY)); > boost::shared_ptr<Quote> fut6PriceJPY(new SimpleQuote(fut6QuoteJPY)); > boost::shared_ptr<Quote> fut7PriceJPY(new SimpleQuote(fut7QuoteJPY)); > boost::shared_ptr<Quote> fut8PriceJPY(new SimpleQuote(fut8QuoteJPY)); > > boost::shared_ptr<Quote> s2yRateJPY(new SimpleQuote(s2yQuoteJPY)); > boost::shared_ptr<Quote> s3yRateJPY(new SimpleQuote(s3yQuoteJPY)); > boost::shared_ptr<Quote> s5yRateJPY(new SimpleQuote(s5yQuoteJPY)); > boost::shared_ptr<Quote> s10yRateJPY(new SimpleQuote(s10yQuoteJPY)); > boost::shared_ptr<Quote> s15yRateJPY(new SimpleQuote(s15yQuoteJPY)); > > /********************* > *** RATE HELPERS *** > *********************/ > //USD leg > > > DayCounter depositDayCounterUSD = Actual360(); > > boost::shared_ptr<RateHelper> d1wUSD(new DepositRateHelper( > Handle<Quote>(d1wRateUSD), > 1*Weeks, fixingDays, > calendar, ModifiedFollowing, > true, depositDayCounterUSD)); > boost::shared_ptr<RateHelper> d1mUSD(new DepositRateHelper( > Handle<Quote>(d1mRateUSD), > 1*Months, fixingDays, > calendar, ModifiedFollowing, > true, depositDayCounterUSD)); > boost::shared_ptr<RateHelper> d3mUSD(new DepositRateHelper( > Handle<Quote>(d3mRateUSD), > 3*Months, fixingDays, > calendar, ModifiedFollowing, > true, depositDayCounterUSD)); > boost::shared_ptr<RateHelper> d6mUSD(new DepositRateHelper( > Handle<Quote>(d6mRateUSD), > 6*Months, fixingDays, > calendar, ModifiedFollowing, > true, depositDayCounterUSD)); > boost::shared_ptr<RateHelper> d9mUSD(new DepositRateHelper( > Handle<Quote>(d9mRateUSD), > 9*Months, fixingDays, > calendar, ModifiedFollowing, > true, depositDayCounterUSD)); > boost::shared_ptr<RateHelper> d1yUSD(new DepositRateHelper( > Handle<Quote>(d1yRateUSD), > 1*Years, fixingDays, > calendar, ModifiedFollowing, > true, depositDayCounterUSD)); > > boost::shared_ptr<RateHelper> fra3x6USD(new FraRateHelper( > Handle<Quote>(fra3x6RateUSD), > 3, 6, fixingDays, calendar, ModifiedFollowing, > true, depositDayCounterUSD)); > boost::shared_ptr<RateHelper> fra6x9USD(new FraRateHelper( > Handle<Quote>(fra6x9RateUSD), > 6, 9, fixingDays, calendar, ModifiedFollowing, > true, depositDayCounterUSD)); > boost::shared_ptr<RateHelper> fra6x12USD(new FraRateHelper( > Handle<Quote>(fra6x12RateUSD), > 6, 12, fixingDays, calendar, ModifiedFollowing, > true, depositDayCounterUSD)); > > Integer futMonthsUSD = 3; > Date imm = IMM::nextDate(settlementDate); > boost::shared_ptr<RateHelper> fut1USD(new FuturesRateHelper( > Handle<Quote>(fut1PriceUSD), > imm, > futMonthsUSD, calendar, ModifiedFollowing, > true, depositDayCounterUSD)); > imm = IMM::nextDate(imm+1); > boost::shared_ptr<RateHelper> fut2USD(new FuturesRateHelper( > Handle<Quote>(fut2PriceUSD), > imm, > futMonthsUSD, calendar, ModifiedFollowing, > true, depositDayCounterUSD)); > imm = IMM::nextDate(imm+1); > boost::shared_ptr<RateHelper> fut3USD(new FuturesRateHelper( > Handle<Quote>(fut3PriceUSD), > imm, > futMonthsUSD, calendar, ModifiedFollowing, > true, depositDayCounterUSD)); > imm = IMM::nextDate(imm+1); > boost::shared_ptr<RateHelper> fut4USD(new FuturesRateHelper( > Handle<Quote>(fut4PriceUSD), > imm, > futMonthsUSD, calendar, ModifiedFollowing, > true, depositDayCounterUSD)); > imm = IMM::nextDate(imm+1); > boost::shared_ptr<RateHelper> fut5USD(new FuturesRateHelper( > Handle<Quote>(fut5PriceUSD), > imm, > futMonthsUSD, calendar, ModifiedFollowing, > true, depositDayCounterUSD)); > imm = IMM::nextDate(imm+1); > boost::shared_ptr<RateHelper> fut6USD(new FuturesRateHelper( > Handle<Quote>(fut6PriceUSD), > imm, > futMonthsUSD, calendar, ModifiedFollowing, > true, depositDayCounterUSD)); > imm = IMM::nextDate(imm+1); > boost::shared_ptr<RateHelper> fut7USD(new FuturesRateHelper( > Handle<Quote>(fut7PriceUSD), > imm, > futMonthsUSD, calendar, ModifiedFollowing, > true, depositDayCounterUSD)); > imm = IMM::nextDate(imm+1); > boost::shared_ptr<RateHelper> fut8USD(new FuturesRateHelper( > Handle<Quote>(fut8PriceUSD), > imm, > futMonthsUSD, calendar, ModifiedFollowing, > true, depositDayCounterUSD)); > > Frequency frequencyUSD = Quarterly; > BusinessDayConvention conventionUSD = Unadjusted; > DayCounter dayCounterUSD = Thirty360(Thirty360::USA); > boost::shared_ptr<IborIndex> indexUSD(new Euribor6M); > > boost::shared_ptr<RateHelper> s2yUSD(new SwapRateHelper( > Handle<Quote>(s2yRateUSD), 2*Years, > calendar, frequencyUSD, > conventionUSD, dayCounterUSD, > indexUSD)); > boost::shared_ptr<RateHelper> s3yUSD(new SwapRateHelper( > Handle<Quote>(s3yRateUSD), 3*Years, > calendar, frequencyUSD, > conventionUSD, dayCounterUSD, > indexUSD)); > boost::shared_ptr<RateHelper> s5yUSD(new SwapRateHelper( > Handle<Quote>(s5yRateUSD), 5*Years, > calendar, frequencyUSD, > conventionUSD, dayCounterUSD, > indexUSD)); > boost::shared_ptr<RateHelper> s10yUSD(new SwapRateHelper( > Handle<Quote>(s10yRateUSD), 10*Years, > calendar, frequencyUSD, > conventionUSD, dayCounterUSD, > indexUSD)); > boost::shared_ptr<RateHelper> s15yUSD(new SwapRateHelper( > Handle<Quote>(s15yRateUSD), 15*Years, > calendar, frequencyUSD, > conventionUSD, dayCounterUSD, > indexUSD)); > > //JPY leg > > > DayCounter depositDayCounterJPY = Actual360(); > > boost::shared_ptr<RateHelper> d1wJPY(new DepositRateHelper( > Handle<Quote>(d1wRateJPY), > 1*Weeks, fixingDays, > calendar, ModifiedFollowing, > true, depositDayCounterJPY)); > boost::shared_ptr<RateHelper> d1mJPY(new DepositRateHelper( > Handle<Quote>(d1mRateJPY), > 1*Months, fixingDays, > calendar, ModifiedFollowing, > true, depositDayCounterJPY)); > boost::shared_ptr<RateHelper> d3mJPY(new DepositRateHelper( > Handle<Quote>(d3mRateJPY), > 3*Months, fixingDays, > calendar, ModifiedFollowing, > true, depositDayCounterJPY)); > boost::shared_ptr<RateHelper> d6mJPY(new DepositRateHelper( > Handle<Quote>(d6mRateJPY), > 6*Months, fixingDays, > calendar, ModifiedFollowing, > true, depositDayCounterJPY)); > boost::shared_ptr<RateHelper> d9mJPY(new DepositRateHelper( > Handle<Quote>(d9mRateJPY), > 9*Months, fixingDays, > calendar, ModifiedFollowing, > true, depositDayCounterJPY)); > boost::shared_ptr<RateHelper> d1yJPY(new DepositRateHelper( > Handle<Quote>(d1yRateJPY), > 1*Years, fixingDays, > calendar, ModifiedFollowing, > true, depositDayCounterJPY)); > > boost::shared_ptr<RateHelper> fra3x6JPY(new FraRateHelper( > Handle<Quote>(fra3x6RateJPY), > 3, 6, fixingDays, calendar, ModifiedFollowing, > true, depositDayCounterJPY)); > boost::shared_ptr<RateHelper> fra6x9JPY(new FraRateHelper( > Handle<Quote>(fra6x9RateJPY), > 6, 9, fixingDays, calendar, ModifiedFollowing, > true, depositDayCounterJPY)); > boost::shared_ptr<RateHelper> fra6x12JPY(new FraRateHelper( > Handle<Quote>(fra6x12RateJPY), > 6, 12, fixingDays, calendar, ModifiedFollowing, > true, depositDayCounterJPY)); > > Integer futMonthsJPY = 3; > Date imm = IMM::nextDate(settlementDate); > boost::shared_ptr<RateHelper> fut1JPY(new FuturesRateHelper( > Handle<Quote>(fut1PriceJPY), > imm, > futMonthsJPY, calendar, ModifiedFollowing, > true, depositDayCounterJPY)); > imm = IMM::nextDate(imm+1); > boost::shared_ptr<RateHelper> fut2JPY(new FuturesRateHelper( > Handle<Quote>(fut2PriceJPY), > imm, > futMonthsJPY, calendar, ModifiedFollowing, > true, depositDayCounterJPY)); > imm = IMM::nextDate(imm+1); > boost::shared_ptr<RateHelper> fut3JPY(new FuturesRateHelper( > Handle<Quote>(fut3PriceJPY), > imm, > futMonthsJPY, calendar, ModifiedFollowing, > true, depositDayCounterJPY)); > imm = IMM::nextDate(imm+1); > boost::shared_ptr<RateHelper> fut4JPY(new FuturesRateHelper( > Handle<Quote>(fut4PriceJPY), > imm, > futMonthsJPY, calendar, ModifiedFollowing, > true, depositDayCounterJPY)); > imm = IMM::nextDate(imm+1); > boost::shared_ptr<RateHelper> fut5JPY(new FuturesRateHelper( > Handle<Quote>(fut5PriceJPY), > imm, > futMonthsJPY, calendar, ModifiedFollowing, > true, depositDayCounterJPY)); > imm = IMM::nextDate(imm+1); > boost::shared_ptr<RateHelper> fut6JPY(new FuturesRateHelper( > Handle<Quote>(fut6PriceJPY), > imm, > futMonthsJPY, calendar, ModifiedFollowing, > true, depositDayCounterJPY)); > imm = IMM::nextDate(imm+1); > boost::shared_ptr<RateHelper> fut7JPY(new FuturesRateHelper( > Handle<Quote>(fut7PriceJPY), > imm, > futMonthsJPY, calendar, ModifiedFollowing, > true, depositDayCounterJPY)); > imm = IMM::nextDate(imm+1); > boost::shared_ptr<RateHelper> fut8JPY(new FuturesRateHelper( > Handle<Quote>(fut8PriceJPY), > imm, > futMonthsJPY, calendar, ModifiedFollowing, > true, depositDayCounterJPY)); > > Frequency frequencyJPY = Quarterly; > BusinessDayConvention conventionJPY = Unadjusted; > DayCounter dayCounterJPY = Thirty360(Thirty360::European); > boost::shared_ptr<IborIndex> indexJPY(new Euribor6M); > > boost::shared_ptr<RateHelper> s2yJPY(new SwapRateHelper( > Handle<Quote>(s2yRateJPY), 2*Years, > calendar, frequencyJPY, > conventionJPY, dayCounterJPY, > indexJPY)); > boost::shared_ptr<RateHelper> s3yJPY(new SwapRateHelper( > Handle<Quote>(s3yRateJPY), 3*Years, > calendar, frequencyJPY, > conventionJPY, dayCounterJPY, > indexJPY)); > boost::shared_ptr<RateHelper> s5yJPY(new SwapRateHelper( > Handle<Quote>(s5yRateJPY), 5*Years, > calendar, frequencyJPY, > conventionJPY, dayCounterJPY, > indexJPY)); > boost::shared_ptr<RateHelper> s10yJPY(new SwapRateHelper( > Handle<Quote>(s10yRateJPY), 10*Years, > calendar, frequencyJPY, > conventionJPY, dayCounterJPY, > indexJPY)); > boost::shared_ptr<RateHelper> s15yJPY(new SwapRateHelper( > Handle<Quote>(s15yRateJPY), 15*Years, > calendar, frequencyJPY, > conventionJPY, dayCounterJPY, > indexJPY)); > > /********************* > ** CURVEs BUILDING ** > *********************/ > > DayCounter termStructureDayCounter = > ActualActual(ActualActual::ISDA); > > double tolerance = 1.0e-15; > > std::vector<boost::shared_ptr<RateHelper> > depoSwapInstrumentsUSD; > depoSwapInstrumentsUSD.push_back(d1wUSD); > depoSwapInstrumentsUSD.push_back(d1mUSD); > depoSwapInstrumentsUSD.push_back(d3mUSD); > depoSwapInstrumentsUSD.push_back(d6mUSD); > depoSwapInstrumentsUSD.push_back(d9mUSD); > depoSwapInstrumentsUSD.push_back(d1yUSD); > depoSwapInstrumentsUSD.push_back(s2yUSD); > depoSwapInstrumentsUSD.push_back(s3yUSD); > depoSwapInstrumentsUSD.push_back(s5yUSD); > depoSwapInstrumentsUSD.push_back(s10yUSD); > depoSwapInstrumentsUSD.push_back(s15yUSD); > boost::shared_ptr<YieldTermStructure> depoSwapTermStructureUSD( > new PiecewiseYieldCurve<Discount,LogLinear>( > settlementDate, depoSwapInstrumentsUSD, > termStructureDayCounter, > tolerance)); > > std::vector<boost::shared_ptr<RateHelper> > depoFutSwapInstrumentsUSD; > depoFutSwapInstrumentsUSD.push_back(d1wUSD); > depoFutSwapInstrumentsUSD.push_back(d1mUSD); > depoFutSwapInstrumentsUSD.push_back(fut1USD); > depoFutSwapInstrumentsUSD.push_back(fut2USD); > depoFutSwapInstrumentsUSD.push_back(fut3USD); > depoFutSwapInstrumentsUSD.push_back(fut4USD); > depoFutSwapInstrumentsUSD.push_back(fut5USD); > depoFutSwapInstrumentsUSD.push_back(fut6USD); > depoFutSwapInstrumentsUSD.push_back(fut7USD); > depoFutSwapInstrumentsUSD.push_back(fut8USD); > depoFutSwapInstrumentsUSD.push_back(s3yUSD); > depoFutSwapInstrumentsUSD.push_back(s5yUSD); > depoFutSwapInstrumentsUSD.push_back(s10yUSD); > depoFutSwapInstrumentsUSD.push_back(s15yUSD); > boost::shared_ptr<YieldTermStructure> depoFutSwapTermStructureUSD( > new PiecewiseYieldCurve<Discount,LogLinear>( > settlementDate, depoFutSwapInstrumentsUSD, > termStructureDayCounter, > tolerance)); > > std::vector<boost::shared_ptr<RateHelper> > depoFRASwapInstrumentsUSD; > depoFRASwapInstrumentsUSD.push_back(d1wUSD); > depoFRASwapInstrumentsUSD.push_back(d1mUSD); > depoFRASwapInstrumentsUSD.push_back(d3mUSD); > depoFRASwapInstrumentsUSD.push_back(fra3x6USD); > depoFRASwapInstrumentsUSD.push_back(fra6x9USD); > depoFRASwapInstrumentsUSD.push_back(fra6x12USD); > depoFRASwapInstrumentsUSD.push_back(s2yUSD); > depoFRASwapInstrumentsUSD.push_back(s3yUSD); > depoFRASwapInstrumentsUSD.push_back(s5yUSD); > depoFRASwapInstrumentsUSD.push_back(s10yUSD); > depoFRASwapInstrumentsUSD.push_back(s15yUSD); > boost::shared_ptr<YieldTermStructure> depoFRASwapTermStructureUSD( > new PiecewiseYieldCurve<Discount,LogLinear>( > settlementDate, depoFRASwapInstrumentsUSD, > termStructureDayCounter, > tolerance)); > > RelinkableHandle<YieldTermStructure> discountingTermStructureUSD; > > RelinkableHandle<YieldTermStructure> forecastingTermStructureUSD; > > //JPY leg > > std::vector<boost::shared_ptr<RateHelper> > depoSwapInstrumentsJPY; > depoSwapInstrumentsJPY.push_back(d1wJPY); > depoSwapInstrumentsJPY.push_back(d1mJPY); > depoSwapInstrumentsJPY.push_back(d3mJPY); > depoSwapInstrumentsJPY.push_back(d6mJPY); > depoSwapInstrumentsJPY.push_back(d9mJPY); > depoSwapInstrumentsJPY.push_back(d1yJPY); > depoSwapInstrumentsJPY.push_back(s2yJPY); > depoSwapInstrumentsJPY.push_back(s3yJPY); > depoSwapInstrumentsJPY.push_back(s5yJPY); > depoSwapInstrumentsJPY.push_back(s10yJPY); > depoSwapInstrumentsJPY.push_back(s15yJPY); > boost::shared_ptr<YieldTermStructure> depoSwapTermStructureJPY( > new PiecewiseYieldCurve<Discount,LogLinear>( > settlementDate, depoSwapInstrumentsJPY, > termStructureDayCounter, > tolerance)); > > std::vector<boost::shared_ptr<RateHelper> > depoFutSwapInstrumentsJPY; > depoFutSwapInstrumentsJPY.push_back(d1wJPY); > depoFutSwapInstrumentsJPY.push_back(d1mJPY); > depoFutSwapInstrumentsJPY.push_back(fut1JPY); > depoFutSwapInstrumentsJPY.push_back(fut2JPY); > depoFutSwapInstrumentsJPY.push_back(fut3JPY); > depoFutSwapInstrumentsJPY.push_back(fut4JPY); > depoFutSwapInstrumentsJPY.push_back(fut5JPY); > depoFutSwapInstrumentsJPY.push_back(fut6JPY); > depoFutSwapInstrumentsJPY.push_back(fut7JPY); > depoFutSwapInstrumentsJPY.push_back(fut8JPY); > depoFutSwapInstrumentsJPY.push_back(s3yJPY); > depoFutSwapInstrumentsJPY.push_back(s5yJPY); > depoFutSwapInstrumentsJPY.push_back(s10yJPY); > depoFutSwapInstrumentsJPY.push_back(s15yJPY); > boost::shared_ptr<YieldTermStructure> depoFutSwapTermStructureJPY( > new PiecewiseYieldCurve<Discount,LogLinear>( > settlementDate, depoFutSwapInstrumentsJPY, > termStructureDayCounter, > tolerance)); > > std::vector<boost::shared_ptr<RateHelper> > depoFRASwapInstrumentsJPY; > depoFRASwapInstrumentsJPY.push_back(d1wJPY); > depoFRASwapInstrumentsJPY.push_back(d1mJPY); > depoFRASwapInstrumentsJPY.push_back(d3mJPY); > depoFRASwapInstrumentsJPY.push_back(fra3x6JPY); > depoFRASwapInstrumentsJPY.push_back(fra6x9JPY); > depoFRASwapInstrumentsJPY.push_back(fra6x12JPY); > depoFRASwapInstrumentsJPY.push_back(s2yJPY); > depoFRASwapInstrumentsJPY.push_back(s3yJPY); > depoFRASwapInstrumentsJPY.push_back(s5yJPY); > depoFRASwapInstrumentsJPY.push_back(s10yJPY); > depoFRASwapInstrumentsJPY.push_back(s15yJPY); > boost::shared_ptr<YieldTermStructure> depoFRASwapTermStructureJPY( > new PiecewiseYieldCurve<Discount,LogLinear>( > settlementDate, depoFRASwapInstrumentsJPY, > termStructureDayCounter, > tolerance)); > > RelinkableHandle<YieldTermStructure> discountingTermStructureJPY; > > RelinkableHandle<YieldTermStructure> forecastingTermStructureJPY; > > /********************* > * SWAPS TO BE PRICED * > **********************/ > > Real nominalDummy = 0.0; > > std::vector<Real> nominalJPY; > nominalJPY.push_back(16000000000); > nominalJPY.push_back(16000000000); > nominalJPY.push_back(16000000000); > nominalJPY.push_back(16000000000); > > std::vector<Real> nominalUSD; > nominalUSD.push_back(20000000); > nominalUSD.push_back(20500000); > nominalUSD.push_back(20100000); > nominalUSD.push_back(20070000); > > // fixed leg > Frequency frequencyDummy = Quarterly; > BusinessDayConvention conventionDummy = Unadjusted; > > DayCounter dayCounterDummy = Thirty360(Thirty360::European); > Rate fixedRate = 0.0; > > // floating leg > BusinessDayConvention conventionUSD = ModifiedFollowing; > BusinessDayConvention conventionJPY = ModifiedFollowing; > DayCounter dayCounterUSD = Actual360(); > DayCounter dayCounterJPY = Actual360();Frequency frequencyUSD = Quarterly; > Frequency frequencyJPY = Quarterly; > boost::shared_ptr<IborIndex> euriborIndexUSD( > new Euribor6M(forecastingTermStructureUSD)); > boost::shared_ptr<IborIndex> euriborIndexJPY( > new Euribor6M(forecastingTermStructureJPY)); > Spread spreadUSD = 0.0; > Spread spreadJPY = -0.0069; > > Integer lenghtInYears = 1; > VanillaSwap::Type swapTypeUSD = VanillaSwap::Receiver; > VanillaSwap::Type swapTypeJPY = VanillaSwap::Payer; > > Date maturity = settlementDate + lenghtInYears*Years; > Schedule fixedSchedule(settlementDate, maturity, > Period(fixedLegFrequency), > calendar, fixedLegConvention, > fixedLegConvention, > DateGeneration::Forward, false); > Schedule floatScheduleUSD(settlementDate, maturity, > Period(frequencyUSD), > calendar, conventionUSD, > conventionUSD, > DateGeneration::Forward, false); > Schedule floatScheduleJPY(settlementDate, maturity, > Period(frequencyJPY), > calendar, conventionJPY, > conventionJPY, > DateGeneration::Forward, false); > > NonStandardSwap dummyUSDSwap(swapTypeUSD, nominalDummy, nominalUSD, > floatScheduleUSD, fixedRate, > dayCounterDummy, floatScheduleUSD, > euriborIndexUSD, QL_EPSILON, spreadUSD, > dayCounterUSD, false, false, conventionUSD) > NonStandardSwap dummyJPYSwap(swapTypeJPY, nominalDummy, nominalJPY, > floatScheduleJPY, fixedRate, > dayCounterDummy, floatScheduleJPY, > euriborIndexJPY, QL_EPSILON, spreadJPY, > dayCounterJPY, false, false, conventionJPY) > > /*************** > * SWAP PRICING * > ****************/ > > Real NPVUSD; > Real NPVJPY; > Real NPVmySwap; > > boost::shared_ptr<PricingEngine> swapEngineUSD( > new DiscountingSwapEngine(discountingTermStructureUSD)); > > dummyUSDSwap.setPricingEngine(swapEngineUSD); > > forecastingTermStructureUSD.linkTo(depoSwapTermStructureUSD); > discountingTermStructureUSD.linkTo(depoSwapTermStructureUSD); > > NPVUSD = dummyUSDSwap.NPV(); > > > boost::shared_ptr<PricingEngine> swapEngineJPY( > new DiscountingSwapEngine(discountingTermStructureJPY)); > > dummyJPYSwap.setPricingEngine(swapEngineJPY); > > forecastingTermStructureJPY.linkTo(depoSwapTermStructureJPY); > discountingTermStructureJPY.linkTo(depoSwapTermStructureJPY); > > NPVJPY = dummyJPYSwap.NPV(); > > NPVmySwap = NPVUSD - NPVJPY; > > return 0; > > } catch (std::exception& e) { > std::cerr << e.what() << std::endl; > return 1; > } catch (...) { > std::cerr << "unknown error" << std::endl; > return 1; > } > } > //////////////////////////// > > -----Original Message----- > From: Peter Caspers [mailto:[hidden email]] > Sent: Monday, January 25, 2016 10:09 PM > To: Dragomir Nedeltchev > Cc: [hidden email] > Subject: Re: [Quantlib-users] pricing Mark-To-Market Cross-Currency Swap > > Hi Dragomir, > > you have to create the schedules of your floating legs (which basically represent the series of their accrual periods), with effective Date = start of first accrual period (forward starting in your case), termination date = end of last accrual period. Then pass them together with the other parameters to the NonStandardSwap constructor. Note that you have to precalculate the deterministic notional schedule of the USD leg before, this is not handled in the NonstandardSwap either. The NonStandardSwaps accepts a vector of notionals corresponding to the accrual periods. You can set up the fixed schedule as equal to the floating schedule (whatever, it is not > used) and with notionals zero. > > Then set up two DiscountingSwapEngines, assign them to your non standard swaps and extract the NPV from each one (which is in USD resp. JPY for the respective legs, because the instrument is a single currency instrument actually as well as the pricing engine). > > Regards > Peter > > On 25 January 2016 at 09:44, Dragomir Nedeltchev <[hidden email]> wrote: >> Hi Peter, >> >> Thank you for the prompt feedback. This seems to meet my needs. >> >> I deal with a 1Y5Y swap. How can I tackle this feature in a NonStandardSwap? >> >> I see there is VanillaSwap oneYearForward5YeraSwap, but the Vanilla Swap class doesn't treat the floating notional reset feature of the MTM swap. >> >> Thank you in advance. >> >> Kind regards, >> >> Dragomir >> >> -----Original Message----- >> From: Peter Caspers [mailto:[hidden email]] >> Sent: Sunday, January 24, 2016 2:08 PM >> To: Dragomir Nedeltchev >> Cc: [hidden email] >> Subject: Re: [Quantlib-users] pricing Mark-To-Market Cross-Currency >> Swap >> >> Hi Dragomir, >> >> there is no ready-to-use class in QuantLib for this I think. >> >> But as you say, you can repesent the mtm swap as two single legs with a customized notional schedule for one of them. Beneath the bond classes you can also use the NonStandardSwap I guess (setting the fixed leg's nominals to zero and only use the floating leg for each mtm swap leg) and do the valuation of the single legs with two DiscountingSwapEngine's attaching appropriate discount curves for USD and JPY. >> >> Kind Regards >> Peter >> >> On 22 January 2016 at 08:47, Dragomir Nedeltchev <[hidden email]> wrote: >>> Hi All, >>> >>> >>> >>> I am pricing a Mark-To-Market JPYUSD Swap. >>> >>> >>> >>> Advise please which swap class of QuantLib serves this purpose. >>> >>> >>> >>> Can I present the swap as a JPY floating bond and a USD amortizing >>> floating rate bond (notionals vector to be calculated by the FX rate >>> at the reset dates). Thanks >>> >>> >>> >>> Dragomir Nedeltchev, Custom House >>> >>> >>> >>> >>> >>> TMF Custom House Fund Services (Ireland) Limited Registered Office: >>> 3rd Floor, Kilmore House, Park Lane, Spencer Dock, Dublin 1, Ireland; >>> Tel: (353) >>> 1 878 0807; Fax: (353) 1 878 0827 Website: www.customhousegroup.com >>> Directors: Mark Hedderman; Kevin Walsh; Barbara Cotter Registered in >>> Ireland No. 147511 TMF Custom House Fund Services (Ireland) Limited >>> is authorised by The Central Bank of Ireland under Section 10 of the >>> Investment Intermediaries Act, 1995 >>> ********************************************************************* >>> * >>> **************************************** >>> This e-mail and any files transmitted with it are intended to be >>> confidential and intended solely for the use of the individual or >>> entity to whom they are addressed. If you have received this e-mail >>> in error please notify the sender. Internet mail is a communication >>> channel, which is not controlled by Custom House, who cannot and do >>> not guarantee that: any e-mail sent from Custom House will be >>> delivered within a reasonable timeframe, or at all; comes from the >>> purported sender; has not been intercepted by a third party; or that >>> the contents of the e-mail are unaltered from the time of >>> transmission. The recipient of this e-mail message should take note >>> that this document does not constitute a legally binding contractual >>> obligation of any sort unless there is a specific statement within >>> the above message confirming that the message contains such a legally binding contractual obligation. >>> ********************************************************************* >>> * >>> ******************************************** >>> >>> --------------------------------------------------------------------- >>> - >>> -------- >>> Site24x7 APM Insight: Get Deep Visibility into Application >>> Performance APM + Mobile APM + RUM: Monitor 3 App instances at just >>> $35/Month Monitor end-to-end web transactions and take corrective >>> actions now Troubleshoot faster and improve end-user experience. Signup Now! >>> http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140 >>> _______________________________________________ >>> QuantLib-users mailing list >>> [hidden email] >>> https://lists.sourceforge.net/lists/listinfo/quantlib-users >>> >> TMF Custom House Fund Services (Ireland) Limited Registered Office: >> 3rd Floor, Kilmore House, Park Lane, Spencer Dock, Dublin 1, Ireland; >> Tel: (353) 1 878 0807; Fax: (353) 1 878 0827 Website: >> www.customhousegroup.com Directors: Mark Hedderman; Kevin Walsh; >> Barbara Cotter Registered in Ireland No. 147511 TMF Custom House Fund >> Services (Ireland) Limited is authorised by The Central Bank of >> Ireland under Section 10 of the Investment Intermediaries Act, 1995 >> ********************************************************************** >> **************************************** This e-mail and any files >> transmitted with it are intended to be confidential and intended >> solely for the use of the individual or entity to whom they are >> addressed. If you have received this e-mail in error please notify the >> sender. Internet mail is a communication channel, which is not >> controlled by Custom House, who cannot and do not guarantee that: any >> e-mail sent from Custom House will be delivered within a reasonable >> timeframe, or at all; comes from the purported sender; has not been >> intercepted by a third party; or that the contents of the e-mail are >> unaltered from the time of transmission. The recipient of this e-mail >> message should take note that this document does not constitute a >> legally binding contractual obligation of any sort unless there is a >> specific statement within the above message confirming that the >> message contains such a legally binding contractual obligation. >> ********************************************************************** >> ******************************************** > TMF Custom House Fund Services (Ireland) Limited Registered Office: 3rd Floor, Kilmore House, Park Lane, Spencer Dock, Dublin 1, Ireland; Tel: (353) 1 878 0807; Fax: (353) 1 878 0827 Website: www.customhousegroup.com Directors: Mark Hedderman; Kevin Walsh; Barbara Cotter Registered in Ireland No. 147511 TMF Custom House Fund Services (Ireland) Limited is authorised by The Central Bank of Ireland under Section 10 of the Investment Intermediaries Act, 1995 ************************************************************************************************************** This e-mail and any files transmitted with it are intended to be confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this e-mail in error please notify the sender. Internet mail is a communication channel, which is not controlled by Custom House, who cannot and do not guarantee that: any e-mail sent from Custom House will be delivered within a reasonable timeframe, or at all; comes from the purported sender; has not been intercepted by a third party; or that the contents of the e-mail are unaltered from the time of transmission. The recipient of this e-mail message should take note that this document does not constitute a legally binding contractual obligation of any sort unless there is a specific statement within the above message confirming that the message contains such a legally binding contractual obligation. ****************************************************************************************************************** ------------------------------------------------------------------------------ Site24x7 APM Insight: Get Deep Visibility into Application Performance APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month Monitor end-to-end web transactions and take corrective actions now Troubleshoot faster and improve end-user experience. Signup Now! http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140 _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Hi Peter,
I fixed the code per your advice below. Please advise how to write the line boost::shared_ptr<IborIndex> indexJPY(new Euribor6M); so that it concerns JPY Libor I received 5 error messages for the revised code (Build Solution, Release mode): ////////////////// 4 IntelliSense: no instance of constructor "QuantLib::NonstandardSwap::NonstandardSwap" matches the argument list argument types are: (QuantLib::VanillaSwap::Type, std::vector<QuantLib::Time, std::allocator<QuantLib::Time>>, std::vector<QuantLib::Time, std::allocator<QuantLib::Time>>, QuantLib::Schedule, QuantLib::Rate, QuantLib::DayCounter, QuantLib::Schedule, boost::shared_ptr<QuantLib::IborIndex>, double, QuantLib::Spread, QuantLib::DayCounter, bool, bool, QuantLib::BusinessDayConvention) c:\local\QuantLib-1.6.2\JPYUSD MTM Swap\JPYUSD MTM Swap\Source.cpp 276 32 JPYUSD MTM Swap Error 1 error C2664: 'QuantLib::NonstandardSwap::NonstandardSwap(const QuantLib::NonstandardSwap &)' : cannot convert argument 5 from 'QuantLib::Rate' to 'const std::vector<QuantLib::Time,std::allocator<_Ty>> &' C:\local\QuantLib-1.6.2\JPYUSD MTM Swap\JPYUSD MTM Swap\Source.cpp 280 1 JPYUSD MTM Swap Error 2 error C2374: 'imm' : redefinition; multiple initialization C:\local\QuantLib-1.6.2\JPYUSD MTM Swap\JPYUSD MTM Swap\Source.cpp 389 1 JPYUSD MTM Swap 5 IntelliSense: no instance of constructor "QuantLib::NonstandardSwap::NonstandardSwap" matches the argument list argument types are: (QuantLib::VanillaSwap::Type, std::vector<QuantLib::Time, std::allocator<QuantLib::Time>>, std::vector<QuantLib::Time, std::allocator<QuantLib::Time>>, QuantLib::Schedule, QuantLib::Rate, QuantLib::DayCounter, QuantLib::Schedule, boost::shared_ptr<QuantLib::IborIndex>, double, QuantLib::Spread, QuantLib::DayCounter, bool, bool, QuantLib::BusinessDayConvention) c:\local\QuantLib-1.6.2\JPYUSD MTM Swap\JPYUSD MTM Swap\Source.cpp 487 32 JPYUSD MTM Swap Error 3 error C2664: 'QuantLib::NonstandardSwap::NonstandardSwap(const QuantLib::NonstandardSwap &)' : cannot convert argument 5 from 'QuantLib::Rate' to 'const std::vector<QuantLib::Time,std::allocator<_Ty>> &' C:\local\QuantLib-1.6.2\JPYUSD MTM Swap\JPYUSD MTM Swap\Source.cpp 491 1 JPYUSD MTM Swap ////////////////// And here is the code: /////////////////////////////////////// #include <ql/quantlib.hpp> #include <ql/instruments/nonstandardswap.hpp> #include <iostream> #include <iomanip> using namespace QuantLib; int main(int, char*[]) { try { Calendar calendar = TARGET(); Date settlementDate(03, October, 2016); settlementDate = calendar.adjust(settlementDate); Integer fixingDays = 2; Date todaysDate(26, January, 2016); Settings::instance().evaluationDate() = todaysDate; todaysDate = Settings::instance().evaluationDate(); //dummyUSD swap // curve 23 USD vs 3M LIBOR Rate d1mQuoteUSD = 0.6213; Real fut2QuoteUSD = 99.33034; Real fut3QuoteUSD = 99.30568; Real fut4QuoteUSD = 99.266; Real fut5QuoteUSD = 99.27143; Real fut6QuoteUSD = 99.24691; Real fut9QuoteUSD = 99.20304; Real fut12QuoteUSD = 99.10996; Real fut15QuoteUSD = 99.01759; Real fut18QuoteUSD = 98.92062; Real fut21QuoteUSD = 98.81907; Real fut24QuoteUSD = 98.71795; Real fut27QuoteUSD = 98.63228; Real fut30QuoteUSD = 98.54702; Real fut33QuoteUSD = 98.46717; Real fut36QuoteUSD = 98.38774; Rate s4yQuoteUSD = 1.24338; Rate s5yQuoteUSD = 1.38353; Rate s6yQuoteUSD = 1.50944; Rate s7yQuoteUSD = 1.61756; Rate s8yQuoteUSD = 1.71261; boost::shared_ptr<Quote> d1mRateUSD(new SimpleQuote(d1mQuoteUSD)); boost::shared_ptr<Quote> fut2PriceUSD(new SimpleQuote(fut2QuoteUSD)); boost::shared_ptr<Quote> fut3PriceUSD(new SimpleQuote(fut3QuoteUSD)); boost::shared_ptr<Quote> fut4PriceUSD(new SimpleQuote(fut4QuoteUSD)); boost::shared_ptr<Quote> fut5PriceUSD(new SimpleQuote(fut5QuoteUSD)); boost::shared_ptr<Quote> fut6PriceUSD(new SimpleQuote(fut6QuoteUSD)); boost::shared_ptr<Quote> fut9PriceUSD(new SimpleQuote(fut9QuoteUSD)); boost::shared_ptr<Quote> fut12PriceUSD(new SimpleQuote(fut12QuoteUSD)); boost::shared_ptr<Quote> fut15PriceUSD(new SimpleQuote(fut15QuoteUSD)); boost::shared_ptr<Quote> fut18PriceUSD(new SimpleQuote(fut18QuoteUSD)); boost::shared_ptr<Quote> fut21PriceUSD(new SimpleQuote(fut21QuoteUSD)); boost::shared_ptr<Quote> fut24PriceUSD(new SimpleQuote(fut24QuoteUSD)); boost::shared_ptr<Quote> fut27PriceUSD(new SimpleQuote(fut27QuoteUSD)); boost::shared_ptr<Quote> fut30PriceUSD(new SimpleQuote(fut30QuoteUSD)); boost::shared_ptr<Quote> fut33PriceUSD(new SimpleQuote(fut33QuoteUSD)); boost::shared_ptr<Quote> fut36PriceUSD(new SimpleQuote(fut36QuoteUSD)); boost::shared_ptr<Quote> s4yRateUSD(new SimpleQuote(s4yQuoteUSD)); boost::shared_ptr<Quote> s5yRateUSD(new SimpleQuote(s5yQuoteUSD)); boost::shared_ptr<Quote> s6yRateUSD(new SimpleQuote(s6yQuoteUSD)); boost::shared_ptr<Quote> s7yRateUSD(new SimpleQuote(s7yQuoteUSD)); boost::shared_ptr<Quote> s8yRateUSD(new SimpleQuote(s8yQuoteUSD)); DayCounter depositDayCounterUSD = Actual360(); boost::shared_ptr<RateHelper> d1mUSD(new DepositRateHelper( Handle<Quote>(d1mRateUSD), 1 * Months, fixingDays, calendar, ModifiedFollowing, true, depositDayCounterUSD)); Integer futMonthsUSD = 3; Date imm = IMM::nextDate(settlementDate); boost::shared_ptr<RateHelper> fut2USD(new FuturesRateHelper( Handle<Quote>(fut2PriceUSD), imm, futMonthsUSD, calendar, ModifiedFollowing, true, depositDayCounterUSD)); imm = IMM::nextDate(imm + 1); boost::shared_ptr<RateHelper> fut3USD(new FuturesRateHelper( Handle<Quote>(fut3PriceUSD), imm, futMonthsUSD, calendar, ModifiedFollowing, true, depositDayCounterUSD)); imm = IMM::nextDate(imm + 1); boost::shared_ptr<RateHelper> fut4USD(new FuturesRateHelper( Handle<Quote>(fut4PriceUSD), imm, futMonthsUSD, calendar, ModifiedFollowing, true, depositDayCounterUSD)); imm = IMM::nextDate(imm + 1); boost::shared_ptr<RateHelper> fut5USD(new FuturesRateHelper( Handle<Quote>(fut5PriceUSD), imm, futMonthsUSD, calendar, ModifiedFollowing, true, depositDayCounterUSD)); imm = IMM::nextDate(imm + 1); boost::shared_ptr<RateHelper> fut6USD(new FuturesRateHelper( Handle<Quote>(fut6PriceUSD), imm, futMonthsUSD, calendar, ModifiedFollowing, true, depositDayCounterUSD)); imm = IMM::nextDate(imm + 1); boost::shared_ptr<RateHelper> fut9USD(new FuturesRateHelper( Handle<Quote>(fut9PriceUSD), imm, futMonthsUSD, calendar, ModifiedFollowing, true, depositDayCounterUSD)); imm = IMM::nextDate(imm + 1); boost::shared_ptr<RateHelper> fut12USD(new FuturesRateHelper( Handle<Quote>(fut12PriceUSD), imm, futMonthsUSD, calendar, ModifiedFollowing, true, depositDayCounterUSD)); imm = IMM::nextDate(imm + 1); boost::shared_ptr<RateHelper> fut15USD(new FuturesRateHelper( Handle<Quote>(fut15PriceUSD), imm, futMonthsUSD, calendar, ModifiedFollowing, true, depositDayCounterUSD)); imm = IMM::nextDate(imm + 1); boost::shared_ptr<RateHelper> fut18USD(new FuturesRateHelper( Handle<Quote>(fut18PriceUSD), imm, futMonthsUSD, calendar, ModifiedFollowing, true, depositDayCounterUSD)); imm = IMM::nextDate(imm + 1); boost::shared_ptr<RateHelper> fut21USD(new FuturesRateHelper( Handle<Quote>(fut21PriceUSD), imm, futMonthsUSD, calendar, ModifiedFollowing, true, depositDayCounterUSD)); imm = IMM::nextDate(imm + 1); boost::shared_ptr<RateHelper> fut24USD(new FuturesRateHelper( Handle<Quote>(fut24PriceUSD), imm, futMonthsUSD, calendar, ModifiedFollowing, true, depositDayCounterUSD)); imm = IMM::nextDate(imm + 1); boost::shared_ptr<RateHelper> fut27USD(new FuturesRateHelper( Handle<Quote>(fut27PriceUSD), imm, futMonthsUSD, calendar, ModifiedFollowing, true, depositDayCounterUSD)); imm = IMM::nextDate(imm + 1); boost::shared_ptr<RateHelper> fut30USD(new FuturesRateHelper( Handle<Quote>(fut30PriceUSD), imm, futMonthsUSD, calendar, ModifiedFollowing, true, depositDayCounterUSD)); imm = IMM::nextDate(imm + 1); boost::shared_ptr<RateHelper> fut33USD(new FuturesRateHelper( Handle<Quote>(fut33PriceUSD), imm, futMonthsUSD, calendar, ModifiedFollowing, true, depositDayCounterUSD)); imm = IMM::nextDate(imm + 1); boost::shared_ptr<RateHelper> fut36USD(new FuturesRateHelper( Handle<Quote>(fut36PriceUSD), imm, futMonthsUSD, calendar, ModifiedFollowing, true, depositDayCounterUSD)); Frequency frequencyUSD = Quarterly; BusinessDayConvention conventionUSD = Unadjusted; DayCounter dayCounterUSD = Thirty360(Thirty360::USA); boost::shared_ptr<IborIndex> indexUSD(new Euribor6M); boost::shared_ptr<RateHelper> s4yUSD(new SwapRateHelper( Handle<Quote>(s4yRateUSD), 4 * Years, calendar, frequencyUSD, conventionUSD, dayCounterUSD, indexUSD)); boost::shared_ptr<RateHelper> s5yUSD(new SwapRateHelper( Handle<Quote>(s5yRateUSD), 5 * Years, calendar, frequencyUSD, conventionUSD, dayCounterUSD, indexUSD)); boost::shared_ptr<RateHelper> s6yUSD(new SwapRateHelper( Handle<Quote>(s6yRateUSD), 6 * Years, calendar, frequencyUSD, conventionUSD, dayCounterUSD, indexUSD)); boost::shared_ptr<RateHelper> s7yUSD(new SwapRateHelper( Handle<Quote>(s7yRateUSD), 7 * Years, calendar, frequencyUSD, conventionUSD, dayCounterUSD, indexUSD)); boost::shared_ptr<RateHelper> s8yUSD(new SwapRateHelper( Handle<Quote>(s8yRateUSD), 8 * Years, calendar, frequencyUSD, conventionUSD, dayCounterUSD, indexUSD)); DayCounter termStructureDayCounter = ActualActual(ActualActual::ISDA); double tolerance = 1.0e-15; std::vector<boost::shared_ptr<RateHelper> > swapInstrumentsUSD; swapInstrumentsUSD.push_back(d1mUSD); swapInstrumentsUSD.push_back(fut2USD); swapInstrumentsUSD.push_back(fut3USD); swapInstrumentsUSD.push_back(fut4USD); swapInstrumentsUSD.push_back(fut5USD); swapInstrumentsUSD.push_back(fut6USD); swapInstrumentsUSD.push_back(fut9USD); swapInstrumentsUSD.push_back(fut12USD); swapInstrumentsUSD.push_back(fut15USD); swapInstrumentsUSD.push_back(fut18USD); swapInstrumentsUSD.push_back(fut21USD); swapInstrumentsUSD.push_back(fut24USD); swapInstrumentsUSD.push_back(fut27USD); swapInstrumentsUSD.push_back(fut30USD); swapInstrumentsUSD.push_back(fut33USD); swapInstrumentsUSD.push_back(fut36USD); swapInstrumentsUSD.push_back(s4yUSD); swapInstrumentsUSD.push_back(s5yUSD); swapInstrumentsUSD.push_back(s6yUSD); swapInstrumentsUSD.push_back(s7yUSD); swapInstrumentsUSD.push_back(s8yUSD); boost::shared_ptr<YieldTermStructure> swapTermStructureUSD( new PiecewiseYieldCurve<Discount, LogLinear>( settlementDate, swapInstrumentsUSD, termStructureDayCounter, tolerance)); RelinkableHandle<YieldTermStructure> discountingTermStructureUSD; RelinkableHandle<YieldTermStructure> forecastingTermStructureUSD; // dummy leg std::vector<Real> notionalDummy; notionalDummy.push_back(0.0); notionalDummy.push_back(0.0); notionalDummy.push_back(0.0); notionalDummy.push_back(0.0); Rate fixedRate = 0.0; Integer lenghtInYears = 1; Date maturity = settlementDate + lenghtInYears*Years; // USD leg boost::shared_ptr<IborIndex> euriborIndexUSD( new Euribor6M(forecastingTermStructureUSD)); Spread spreadUSD = 0.0; std::vector<Real> notionalUSD; notionalUSD.push_back(20000000); notionalUSD.push_back(20500000); notionalUSD.push_back(20100000); notionalUSD.push_back(20070000); VanillaSwap::Type swapTypeUSD = VanillaSwap::Receiver; Schedule scheduleUSD(settlementDate, maturity, Period(frequencyUSD), calendar, conventionUSD, conventionUSD, DateGeneration::Forward, false); NonstandardSwap dummyUSDSwap(swapTypeUSD, notionalDummy, notionalUSD, scheduleUSD, fixedRate, dayCounterUSD, scheduleUSD, euriborIndexUSD, 1.0, spreadUSD, dayCounterUSD, false, false, conventionUSD); Real NPVUSD; Real USDJPYrate; USDJPYrate = 118.0; boost::shared_ptr<PricingEngine> swapEngineUSD( new DiscountingSwapEngine(discountingTermStructureUSD)); dummyUSDSwap.setPricingEngine(swapEngineUSD); forecastingTermStructureUSD.linkTo(swapTermStructureUSD); discountingTermStructureUSD.linkTo(swapTermStructureUSD); NPVUSD = dummyUSDSwap.NPV() * USDJPYrate; //dummyJPY swap // curve 308 JPY vs 3M LIBOR Rate d3mQuoteJPY = 0.08071; Rate fra1x4QuoteJPY = 0.06; Rate fra2x5QuoteJPY = 0.06; Rate fra3x6QuoteJPY = 0.055; Rate fra4x7QuoteJPY = 0.055; Rate fra5x8QuoteJPY = 0.05; Rate fra6x9QuoteJPY = 0.045; Rate fra7x10QuoteJPY = 0.0375; Rate fra8x11QuoteJPY = 0.03375; Rate fra9x12QuoteJPY = 0.035; Real fut18QuoteJPY = 99.93105; Rate s2yQuoteJPY = 0.06025; Rate s3yQuoteJPY = 0.06665; Rate s4yQuoteJPY = 0.07388; Rate s5yQuoteJPY = 0.10152; Rate s6yQuoteJPY = 0.14495; Rate s7yQuoteJPY = 0.1873; Rate s8yQuoteJPY = 0.242; boost::shared_ptr<Quote> d3mRateJPY(new SimpleQuote(d3mQuoteJPY)); boost::shared_ptr<Quote> fra1x4RateJPY(new SimpleQuote(fra1x4QuoteJPY)); boost::shared_ptr<Quote> fra2x5RateJPY(new SimpleQuote(fra2x5QuoteJPY)); boost::shared_ptr<Quote> fra3x6RateJPY(new SimpleQuote(fra3x6QuoteJPY)); boost::shared_ptr<Quote> fra4x7RateJPY(new SimpleQuote(fra4x7QuoteJPY)); boost::shared_ptr<Quote> fra5x8RateJPY(new SimpleQuote(fra5x8QuoteJPY)); boost::shared_ptr<Quote> fra6x9RateJPY(new SimpleQuote(fra6x9QuoteJPY)); boost::shared_ptr<Quote> fra7x10RateJPY(new SimpleQuote(fra7x10QuoteJPY)); boost::shared_ptr<Quote> fra8x11RateJPY(new SimpleQuote(fra8x11QuoteJPY)); boost::shared_ptr<Quote> fra9x12RateJPY(new SimpleQuote(fra9x12QuoteJPY)); boost::shared_ptr<Quote> fut18PriceJPY(new SimpleQuote(fut18QuoteJPY)); boost::shared_ptr<Quote> s2yRateJPY(new SimpleQuote(s2yQuoteJPY)); boost::shared_ptr<Quote> s3yRateJPY(new SimpleQuote(s3yQuoteJPY)); boost::shared_ptr<Quote> s4yRateJPY(new SimpleQuote(s4yQuoteJPY)); boost::shared_ptr<Quote> s5yRateJPY(new SimpleQuote(s5yQuoteJPY)); boost::shared_ptr<Quote> s6yRateJPY(new SimpleQuote(s6yQuoteJPY)); boost::shared_ptr<Quote> s7yRateJPY(new SimpleQuote(s7yQuoteJPY)); boost::shared_ptr<Quote> s8yRateJPY(new SimpleQuote(s8yQuoteJPY)); DayCounter depositDayCounterJPY = Actual360(); boost::shared_ptr<RateHelper> d3mJPY(new DepositRateHelper( Handle<Quote>(d3mRateJPY), 3 * Months, fixingDays, calendar, ModifiedFollowing, true, depositDayCounterJPY)); boost::shared_ptr<RateHelper> fra1x4JPY(new FraRateHelper( Handle<Quote>(fra1x4RateJPY), 1, 4, fixingDays, calendar, ModifiedFollowing, true, depositDayCounterJPY)); boost::shared_ptr<RateHelper> fra2x5JPY(new FraRateHelper( Handle<Quote>(fra2x5RateJPY), 2, 5, fixingDays, calendar, ModifiedFollowing, true, depositDayCounterJPY)); boost::shared_ptr<RateHelper> fra3x6JPY(new FraRateHelper( Handle<Quote>(fra3x6RateJPY), 3, 6, fixingDays, calendar, ModifiedFollowing, true, depositDayCounterJPY)); boost::shared_ptr<RateHelper> fra4x7JPY(new FraRateHelper( Handle<Quote>(fra4x7RateJPY), 4, 7, fixingDays, calendar, ModifiedFollowing, true, depositDayCounterJPY)); boost::shared_ptr<RateHelper> fra5x8JPY(new FraRateHelper( Handle<Quote>(fra5x8RateJPY), 5, 8, fixingDays, calendar, ModifiedFollowing, true, depositDayCounterJPY)); boost::shared_ptr<RateHelper> fra6x9JPY(new FraRateHelper( Handle<Quote>(fra6x9RateJPY), 6, 9, fixingDays, calendar, ModifiedFollowing, true, depositDayCounterJPY)); boost::shared_ptr<RateHelper> fra7x10JPY(new FraRateHelper( Handle<Quote>(fra7x10RateJPY), 7, 10, fixingDays, calendar, ModifiedFollowing, true, depositDayCounterJPY)); boost::shared_ptr<RateHelper> fra8x11JPY(new FraRateHelper( Handle<Quote>(fra8x11RateJPY), 8, 11, fixingDays, calendar, ModifiedFollowing, true, depositDayCounterJPY)); boost::shared_ptr<RateHelper> fra9x12JPY(new FraRateHelper( Handle<Quote>(fra9x12RateJPY), 9, 12, fixingDays, calendar, ModifiedFollowing, true, depositDayCounterJPY)); Integer futMonthsJPY = 3; Date imm = IMM::nextDate(settlementDate); boost::shared_ptr<RateHelper> fut18JPY(new FuturesRateHelper( Handle<Quote>(fut18PriceJPY), imm, futMonthsJPY, calendar, ModifiedFollowing, true, depositDayCounterJPY)); Frequency frequencyJPY = Quarterly; BusinessDayConvention conventionJPY = Unadjusted; DayCounter dayCounterJPY = Thirty360(Thirty360::European); boost::shared_ptr<IborIndex> indexJPY(new Euribor6M); boost::shared_ptr<RateHelper> s2yJPY(new SwapRateHelper( Handle<Quote>(s2yRateJPY), 2 * Years, calendar, frequencyJPY, conventionJPY, dayCounterJPY, indexJPY)); boost::shared_ptr<RateHelper> s3yJPY(new SwapRateHelper( Handle<Quote>(s3yRateJPY), 3 * Years, calendar, frequencyJPY, conventionJPY, dayCounterJPY, indexJPY)); boost::shared_ptr<RateHelper> s4yJPY(new SwapRateHelper( Handle<Quote>(s4yRateJPY), 4 * Years, calendar, frequencyJPY, conventionJPY, dayCounterJPY, indexJPY)); boost::shared_ptr<RateHelper> s5yJPY(new SwapRateHelper( Handle<Quote>(s5yRateJPY), 5 * Years, calendar, frequencyJPY, conventionJPY, dayCounterJPY, indexJPY)); boost::shared_ptr<RateHelper> s6yJPY(new SwapRateHelper( Handle<Quote>(s6yRateJPY), 6 * Years, calendar, frequencyJPY, conventionJPY, dayCounterJPY, indexJPY)); boost::shared_ptr<RateHelper> s7yJPY(new SwapRateHelper( Handle<Quote>(s7yRateJPY), 7 * Years, calendar, frequencyJPY, conventionJPY, dayCounterJPY, indexJPY)); boost::shared_ptr<RateHelper> s8yJPY(new SwapRateHelper( Handle<Quote>(s8yRateJPY), 8 * Years, calendar, frequencyJPY, conventionJPY, dayCounterJPY, indexJPY)); std::vector<boost::shared_ptr<RateHelper> > swapInstrumentsJPY; swapInstrumentsJPY.push_back(d3mJPY); swapInstrumentsJPY.push_back(fra1x4JPY); swapInstrumentsJPY.push_back(fra2x5JPY); swapInstrumentsJPY.push_back(fra3x6JPY); swapInstrumentsJPY.push_back(fra4x7JPY); swapInstrumentsJPY.push_back(fra5x8JPY); swapInstrumentsJPY.push_back(fra6x9JPY); swapInstrumentsJPY.push_back(fra7x10JPY); swapInstrumentsJPY.push_back(fra8x11JPY); swapInstrumentsJPY.push_back(fra9x12JPY); swapInstrumentsJPY.push_back(fut18JPY); swapInstrumentsJPY.push_back(s2yJPY); swapInstrumentsJPY.push_back(s3yJPY); swapInstrumentsJPY.push_back(s4yJPY); swapInstrumentsJPY.push_back(s5yJPY); swapInstrumentsJPY.push_back(s6yJPY); swapInstrumentsJPY.push_back(s7yJPY); swapInstrumentsJPY.push_back(s8yJPY); boost::shared_ptr<YieldTermStructure> swapTermStructureJPY( new PiecewiseYieldCurve<Discount, LogLinear>( settlementDate, swapInstrumentsJPY, termStructureDayCounter, tolerance)); RelinkableHandle<YieldTermStructure> discountingTermStructureJPY; RelinkableHandle<YieldTermStructure> forecastingTermStructureJPY; // JPY leg std::vector<Real> notionalJPY; notionalJPY.push_back(16000000000); notionalJPY.push_back(16000000000); notionalJPY.push_back(16000000000); notionalJPY.push_back(16000000000); boost::shared_ptr<IborIndex> euriborIndexJPY( new Euribor6M(forecastingTermStructureJPY)); Spread spreadJPY = -0.0069; VanillaSwap::Type swapTypeJPY = VanillaSwap::Payer; Schedule scheduleJPY(settlementDate, maturity, Period(frequencyJPY), calendar, conventionJPY, conventionJPY, DateGeneration::Forward, false); NonstandardSwap dummyJPYSwap(swapTypeJPY, notionalDummy, notionalJPY, scheduleJPY, fixedRate, dayCounterJPY, scheduleJPY, euriborIndexJPY, 1.0, spreadJPY, dayCounterJPY, false, false, conventionJPY); Real NPVJPY; Real NPVmySwap; boost::shared_ptr<PricingEngine> swapEngineJPY( new DiscountingSwapEngine(discountingTermStructureJPY)); dummyJPYSwap.setPricingEngine(swapEngineJPY); forecastingTermStructureJPY.linkTo(swapTermStructureJPY); discountingTermStructureJPY.linkTo(swapTermStructureJPY); NPVJPY = dummyJPYSwap.NPV(); NPVmySwap = NPVUSD - NPVJPY; return 0; } catch (std::exception& e) { std::cerr << e.what() << std::endl; return 1; } catch (...) { std::cerr << "unknown error" << std::endl; return 1; } } /////////////////////////// Thanks, Dragomir -----Original Message----- From: Peter Caspers [mailto:[hidden email]] Sent: Tuesday, January 26, 2016 9:41 PM To: Dragomir Nedeltchev Cc: [hidden email] Subject: Re: [Quantlib-users] pricing Mark-To-Market Cross-Currency Swap Hi Dragomir, yes, in that direction. Just a few thoughts. - there are Libor indices in USD and JPY you can use, no need to go for Euribor - the dummy notional has to be a vector, too (containing 0.0, that's ok) - the gearing should be 1.0 ? It is the multiplier for the ibor fixing before adding the spread. - the NPVs have to be converted to one currency before adding them I did not read every line of the code - just give it a try and if you run into problems, just write back here, ok? Do you have a reference to compare the NPV with? Regards Peter On 26 January 2016 at 14:36, Dragomir Nedeltchev <[hidden email]> wrote: > Hi Peter, > > Below you will find the code for the swap in question, if I got your point correctly. > > The vector of floating notional was calculated by the forward JPYUSD > rate. Market data copy/paste the swapvaluation.cpp for both JPY and > USD; later I will insert actual numbers > > Thanks, > > Dragomir > > ///////////////////////////// > #include <ql/quantlib.hpp> > > #include <iostream> > #include <iomanip> > > using namespace QuantLib; > > > int main(int, char* []) { > > try { > > > > /********************* > *** MARKET DATA *** > *********************/ > > Calendar calendar = TARGET(); > Date settlementDate(03, October, 2016); > settlementDate = calendar.adjust(settlementDate); > > Integer fixingDays = 2; > > Date todaysDate(26, January, 2016); > > Settings::instance().evaluationDate() = todaysDate; > > todaysDate = Settings::instance().evaluationDate(); > > //USD leg > Rate d1wQuoteUSD=0.0382; > Rate d1mQuoteUSD=0.0372; > Rate d3mQuoteUSD=0.0363; > Rate d6mQuoteUSD=0.0353; > Rate d9mQuoteUSD=0.0348; > Rate d1yQuoteUSD=0.0345; > > Rate fra3x6QuoteUSD=0.037125; > Rate fra6x9QuoteUSD=0.037125; > Rate fra6x12QuoteUSD=0.037125; > > Real fut1QuoteUSD=96.2875; > Real fut2QuoteUSD=96.7875; > Real fut3QuoteUSD=96.9875; > Real fut4QuoteUSD=96.6875; > Real fut5QuoteUSD=96.4875; > Real fut6QuoteUSD=96.3875; > Real fut7QuoteUSD=96.2875; > Real fut8QuoteUSD=96.0875; > > Rate s2yQuoteUSD=0.037125; > Rate s3yQuoteUSD=0.0398; > Rate s5yQuoteUSD=0.0443; > Rate s10yQuoteUSD=0.05165; > Rate s15yQuoteUSD=0.055175; > > //JPY leg > > Rate d1wQuoteJPY=0.0382; > Rate d1mQuoteJPY=0.0372; > Rate d3mQuoteJPY=0.0363; > Rate d6mQuoteJPY=0.0353; > Rate d9mQuoteJPY=0.0348; > Rate d1yQuoteJPY=0.0345; > > Rate fra3x6QuoteJPY=0.037125; > Rate fra6x9QuoteJPY=0.037125; > Rate fra6x12QuoteJPY=0.037125; > > Real fut1QuoteJPY=96.2875; > Real fut2QuoteJPY=96.7875; > Real fut3QuoteJPY=96.9875; > Real fut4QuoteJPY=96.6875; > Real fut5QuoteJPY=96.4875; > Real fut6QuoteJPY=96.3875; > Real fut7QuoteJPY=96.2875; > Real fut8QuoteJPY=96.0875; > > Rate s2yQuoteJPY=0.037125; > Rate s3yQuoteJPY=0.0398; > Rate s5yQuoteJPY=0.0443; > Rate s10yQuoteJPY=0.05165; > Rate s15yQuoteJPY=0.055175; > > > /******************** > *** QUOTES *** > ********************/ > > //USD leg > > > boost::shared_ptr<Quote> d1wRateUSD(new SimpleQuote(d1wQuoteUSD)); > boost::shared_ptr<Quote> d1mRateUSD(new SimpleQuote(d1mQuoteUSD)); > boost::shared_ptr<Quote> d3mRateUSD(new SimpleQuote(d3mQuoteUSD)); > boost::shared_ptr<Quote> d6mRateUSD(new SimpleQuote(d6mQuoteUSD)); > boost::shared_ptr<Quote> d9mRateUSD(new SimpleQuote(d9mQuoteUSD)); > boost::shared_ptr<Quote> d1yRateUSD(new > SimpleQuote(d1yQuoteUSD)); > > boost::shared_ptr<Quote> fra3x6RateUSD(new SimpleQuote(fra3x6QuoteUSD)); > boost::shared_ptr<Quote> fra6x9RateUSD(new SimpleQuote(fra6x9QuoteUSD)); > boost::shared_ptr<Quote> fra6x12RateUSD(new > SimpleQuote(fra6x12QuoteUSD)); > > boost::shared_ptr<Quote> fut1PriceUSD(new SimpleQuote(fut1QuoteUSD)); > boost::shared_ptr<Quote> fut2PriceUSD(new SimpleQuote(fut2QuoteUSD)); > boost::shared_ptr<Quote> fut3PriceUSD(new SimpleQuote(fut3QuoteUSD)); > boost::shared_ptr<Quote> fut4PriceUSD(new SimpleQuote(fut4QuoteUSD)); > boost::shared_ptr<Quote> fut5PriceUSD(new SimpleQuote(fut5QuoteUSD)); > boost::shared_ptr<Quote> fut6PriceUSD(new SimpleQuote(fut6QuoteUSD)); > boost::shared_ptr<Quote> fut7PriceUSD(new SimpleQuote(fut7QuoteUSD)); > boost::shared_ptr<Quote> fut8PriceUSD(new > SimpleQuote(fut8QuoteUSD)); > > boost::shared_ptr<Quote> s2yRateUSD(new SimpleQuote(s2yQuoteUSD)); > boost::shared_ptr<Quote> s3yRateUSD(new SimpleQuote(s3yQuoteUSD)); > boost::shared_ptr<Quote> s5yRateUSD(new SimpleQuote(s5yQuoteUSD)); > boost::shared_ptr<Quote> s10yRateUSD(new SimpleQuote(s10yQuoteUSD)); > boost::shared_ptr<Quote> s15yRateUSD(new > SimpleQuote(s15yQuoteUSD)); > > //JPY leg > > boost::shared_ptr<Quote> d1wRateJPY(new SimpleQuote(d1wQuoteJPY)); > boost::shared_ptr<Quote> d1mRateJPY(new SimpleQuote(d1mQuoteJPY)); > boost::shared_ptr<Quote> d3mRateJPY(new SimpleQuote(d3mQuoteJPY)); > boost::shared_ptr<Quote> d6mRateJPY(new SimpleQuote(d6mQuoteJPY)); > boost::shared_ptr<Quote> d9mRateJPY(new SimpleQuote(d9mQuoteJPY)); > boost::shared_ptr<Quote> d1yRateJPY(new > SimpleQuote(d1yQuoteJPY)); > > boost::shared_ptr<Quote> fra3x6RateJPY(new SimpleQuote(fra3x6QuoteJPY)); > boost::shared_ptr<Quote> fra6x9RateJPY(new SimpleQuote(fra6x9QuoteJPY)); > boost::shared_ptr<Quote> fra6x12RateJPY(new > SimpleQuote(fra6x12QuoteJPY)); > > boost::shared_ptr<Quote> fut1PriceJPY(new SimpleQuote(fut1QuoteJPY)); > boost::shared_ptr<Quote> fut2PriceJPY(new SimpleQuote(fut2QuoteJPY)); > boost::shared_ptr<Quote> fut3PriceJPY(new SimpleQuote(fut3QuoteJPY)); > boost::shared_ptr<Quote> fut4PriceJPY(new SimpleQuote(fut4QuoteJPY)); > boost::shared_ptr<Quote> fut5PriceJPY(new SimpleQuote(fut5QuoteJPY)); > boost::shared_ptr<Quote> fut6PriceJPY(new SimpleQuote(fut6QuoteJPY)); > boost::shared_ptr<Quote> fut7PriceJPY(new SimpleQuote(fut7QuoteJPY)); > boost::shared_ptr<Quote> fut8PriceJPY(new > SimpleQuote(fut8QuoteJPY)); > > boost::shared_ptr<Quote> s2yRateJPY(new SimpleQuote(s2yQuoteJPY)); > boost::shared_ptr<Quote> s3yRateJPY(new SimpleQuote(s3yQuoteJPY)); > boost::shared_ptr<Quote> s5yRateJPY(new SimpleQuote(s5yQuoteJPY)); > boost::shared_ptr<Quote> s10yRateJPY(new SimpleQuote(s10yQuoteJPY)); > boost::shared_ptr<Quote> s15yRateJPY(new > SimpleQuote(s15yQuoteJPY)); > > /********************* > *** RATE HELPERS *** > *********************/ > //USD leg > > > DayCounter depositDayCounterUSD = Actual360(); > > boost::shared_ptr<RateHelper> d1wUSD(new DepositRateHelper( > Handle<Quote>(d1wRateUSD), > 1*Weeks, fixingDays, > calendar, ModifiedFollowing, > true, depositDayCounterUSD)); > boost::shared_ptr<RateHelper> d1mUSD(new DepositRateHelper( > Handle<Quote>(d1mRateUSD), > 1*Months, fixingDays, > calendar, ModifiedFollowing, > true, depositDayCounterUSD)); > boost::shared_ptr<RateHelper> d3mUSD(new DepositRateHelper( > Handle<Quote>(d3mRateUSD), > 3*Months, fixingDays, > calendar, ModifiedFollowing, > true, depositDayCounterUSD)); > boost::shared_ptr<RateHelper> d6mUSD(new DepositRateHelper( > Handle<Quote>(d6mRateUSD), > 6*Months, fixingDays, > calendar, ModifiedFollowing, > true, depositDayCounterUSD)); > boost::shared_ptr<RateHelper> d9mUSD(new DepositRateHelper( > Handle<Quote>(d9mRateUSD), > 9*Months, fixingDays, > calendar, ModifiedFollowing, > true, depositDayCounterUSD)); > boost::shared_ptr<RateHelper> d1yUSD(new DepositRateHelper( > Handle<Quote>(d1yRateUSD), > 1*Years, fixingDays, > calendar, ModifiedFollowing, > true, depositDayCounterUSD)); > > boost::shared_ptr<RateHelper> fra3x6USD(new FraRateHelper( > Handle<Quote>(fra3x6RateUSD), > 3, 6, fixingDays, calendar, ModifiedFollowing, > true, depositDayCounterUSD)); > boost::shared_ptr<RateHelper> fra6x9USD(new FraRateHelper( > Handle<Quote>(fra6x9RateUSD), > 6, 9, fixingDays, calendar, ModifiedFollowing, > true, depositDayCounterUSD)); > boost::shared_ptr<RateHelper> fra6x12USD(new FraRateHelper( > Handle<Quote>(fra6x12RateUSD), > 6, 12, fixingDays, calendar, ModifiedFollowing, > true, depositDayCounterUSD)); > > Integer futMonthsUSD = 3; > Date imm = IMM::nextDate(settlementDate); > boost::shared_ptr<RateHelper> fut1USD(new FuturesRateHelper( > Handle<Quote>(fut1PriceUSD), > imm, > futMonthsUSD, calendar, ModifiedFollowing, > true, depositDayCounterUSD)); > imm = IMM::nextDate(imm+1); > boost::shared_ptr<RateHelper> fut2USD(new FuturesRateHelper( > Handle<Quote>(fut2PriceUSD), > imm, > futMonthsUSD, calendar, ModifiedFollowing, > true, depositDayCounterUSD)); > imm = IMM::nextDate(imm+1); > boost::shared_ptr<RateHelper> fut3USD(new FuturesRateHelper( > Handle<Quote>(fut3PriceUSD), > imm, > futMonthsUSD, calendar, ModifiedFollowing, > true, depositDayCounterUSD)); > imm = IMM::nextDate(imm+1); > boost::shared_ptr<RateHelper> fut4USD(new FuturesRateHelper( > Handle<Quote>(fut4PriceUSD), > imm, > futMonthsUSD, calendar, ModifiedFollowing, > true, depositDayCounterUSD)); > imm = IMM::nextDate(imm+1); > boost::shared_ptr<RateHelper> fut5USD(new FuturesRateHelper( > Handle<Quote>(fut5PriceUSD), > imm, > futMonthsUSD, calendar, ModifiedFollowing, > true, depositDayCounterUSD)); > imm = IMM::nextDate(imm+1); > boost::shared_ptr<RateHelper> fut6USD(new FuturesRateHelper( > Handle<Quote>(fut6PriceUSD), > imm, > futMonthsUSD, calendar, ModifiedFollowing, > true, depositDayCounterUSD)); > imm = IMM::nextDate(imm+1); > boost::shared_ptr<RateHelper> fut7USD(new FuturesRateHelper( > Handle<Quote>(fut7PriceUSD), > imm, > futMonthsUSD, calendar, ModifiedFollowing, > true, depositDayCounterUSD)); > imm = IMM::nextDate(imm+1); > boost::shared_ptr<RateHelper> fut8USD(new FuturesRateHelper( > Handle<Quote>(fut8PriceUSD), > imm, > futMonthsUSD, calendar, ModifiedFollowing, > true, depositDayCounterUSD)); > > Frequency frequencyUSD = Quarterly; > BusinessDayConvention conventionUSD = Unadjusted; > DayCounter dayCounterUSD = Thirty360(Thirty360::USA); > boost::shared_ptr<IborIndex> indexUSD(new Euribor6M); > > boost::shared_ptr<RateHelper> s2yUSD(new SwapRateHelper( > Handle<Quote>(s2yRateUSD), 2*Years, > calendar, frequencyUSD, > conventionUSD, dayCounterUSD, > indexUSD)); > boost::shared_ptr<RateHelper> s3yUSD(new SwapRateHelper( > Handle<Quote>(s3yRateUSD), 3*Years, > calendar, frequencyUSD, > conventionUSD, dayCounterUSD, > indexUSD)); > boost::shared_ptr<RateHelper> s5yUSD(new SwapRateHelper( > Handle<Quote>(s5yRateUSD), 5*Years, > calendar, frequencyUSD, > conventionUSD, dayCounterUSD, > indexUSD)); > boost::shared_ptr<RateHelper> s10yUSD(new SwapRateHelper( > Handle<Quote>(s10yRateUSD), 10*Years, > calendar, frequencyUSD, > conventionUSD, dayCounterUSD, > indexUSD)); > boost::shared_ptr<RateHelper> s15yUSD(new SwapRateHelper( > Handle<Quote>(s15yRateUSD), 15*Years, > calendar, frequencyUSD, > conventionUSD, dayCounterUSD, > indexUSD)); > > //JPY leg > > > DayCounter depositDayCounterJPY = Actual360(); > > boost::shared_ptr<RateHelper> d1wJPY(new DepositRateHelper( > Handle<Quote>(d1wRateJPY), > 1*Weeks, fixingDays, > calendar, ModifiedFollowing, > true, depositDayCounterJPY)); > boost::shared_ptr<RateHelper> d1mJPY(new DepositRateHelper( > Handle<Quote>(d1mRateJPY), > 1*Months, fixingDays, > calendar, ModifiedFollowing, > true, depositDayCounterJPY)); > boost::shared_ptr<RateHelper> d3mJPY(new DepositRateHelper( > Handle<Quote>(d3mRateJPY), > 3*Months, fixingDays, > calendar, ModifiedFollowing, > true, depositDayCounterJPY)); > boost::shared_ptr<RateHelper> d6mJPY(new DepositRateHelper( > Handle<Quote>(d6mRateJPY), > 6*Months, fixingDays, > calendar, ModifiedFollowing, > true, depositDayCounterJPY)); > boost::shared_ptr<RateHelper> d9mJPY(new DepositRateHelper( > Handle<Quote>(d9mRateJPY), > 9*Months, fixingDays, > calendar, ModifiedFollowing, > true, depositDayCounterJPY)); > boost::shared_ptr<RateHelper> d1yJPY(new DepositRateHelper( > Handle<Quote>(d1yRateJPY), > 1*Years, fixingDays, > calendar, ModifiedFollowing, > true, depositDayCounterJPY)); > > boost::shared_ptr<RateHelper> fra3x6JPY(new FraRateHelper( > Handle<Quote>(fra3x6RateJPY), > 3, 6, fixingDays, calendar, ModifiedFollowing, > true, depositDayCounterJPY)); > boost::shared_ptr<RateHelper> fra6x9JPY(new FraRateHelper( > Handle<Quote>(fra6x9RateJPY), > 6, 9, fixingDays, calendar, ModifiedFollowing, > true, depositDayCounterJPY)); > boost::shared_ptr<RateHelper> fra6x12JPY(new FraRateHelper( > Handle<Quote>(fra6x12RateJPY), > 6, 12, fixingDays, calendar, ModifiedFollowing, > true, depositDayCounterJPY)); > > Integer futMonthsJPY = 3; > Date imm = IMM::nextDate(settlementDate); > boost::shared_ptr<RateHelper> fut1JPY(new FuturesRateHelper( > Handle<Quote>(fut1PriceJPY), > imm, > futMonthsJPY, calendar, ModifiedFollowing, > true, depositDayCounterJPY)); > imm = IMM::nextDate(imm+1); > boost::shared_ptr<RateHelper> fut2JPY(new FuturesRateHelper( > Handle<Quote>(fut2PriceJPY), > imm, > futMonthsJPY, calendar, ModifiedFollowing, > true, depositDayCounterJPY)); > imm = IMM::nextDate(imm+1); > boost::shared_ptr<RateHelper> fut3JPY(new FuturesRateHelper( > Handle<Quote>(fut3PriceJPY), > imm, > futMonthsJPY, calendar, ModifiedFollowing, > true, depositDayCounterJPY)); > imm = IMM::nextDate(imm+1); > boost::shared_ptr<RateHelper> fut4JPY(new FuturesRateHelper( > Handle<Quote>(fut4PriceJPY), > imm, > futMonthsJPY, calendar, ModifiedFollowing, > true, depositDayCounterJPY)); > imm = IMM::nextDate(imm+1); > boost::shared_ptr<RateHelper> fut5JPY(new FuturesRateHelper( > Handle<Quote>(fut5PriceJPY), > imm, > futMonthsJPY, calendar, ModifiedFollowing, > true, depositDayCounterJPY)); > imm = IMM::nextDate(imm+1); > boost::shared_ptr<RateHelper> fut6JPY(new FuturesRateHelper( > Handle<Quote>(fut6PriceJPY), > imm, > futMonthsJPY, calendar, ModifiedFollowing, > true, depositDayCounterJPY)); > imm = IMM::nextDate(imm+1); > boost::shared_ptr<RateHelper> fut7JPY(new FuturesRateHelper( > Handle<Quote>(fut7PriceJPY), > imm, > futMonthsJPY, calendar, ModifiedFollowing, > true, depositDayCounterJPY)); > imm = IMM::nextDate(imm+1); > boost::shared_ptr<RateHelper> fut8JPY(new FuturesRateHelper( > Handle<Quote>(fut8PriceJPY), > imm, > futMonthsJPY, calendar, ModifiedFollowing, > true, depositDayCounterJPY)); > > Frequency frequencyJPY = Quarterly; > BusinessDayConvention conventionJPY = Unadjusted; > DayCounter dayCounterJPY = Thirty360(Thirty360::European); > boost::shared_ptr<IborIndex> indexJPY(new Euribor6M); > > boost::shared_ptr<RateHelper> s2yJPY(new SwapRateHelper( > Handle<Quote>(s2yRateJPY), 2*Years, > calendar, frequencyJPY, > conventionJPY, dayCounterJPY, > indexJPY)); > boost::shared_ptr<RateHelper> s3yJPY(new SwapRateHelper( > Handle<Quote>(s3yRateJPY), 3*Years, > calendar, frequencyJPY, > conventionJPY, dayCounterJPY, > indexJPY)); > boost::shared_ptr<RateHelper> s5yJPY(new SwapRateHelper( > Handle<Quote>(s5yRateJPY), 5*Years, > calendar, frequencyJPY, > conventionJPY, dayCounterJPY, > indexJPY)); > boost::shared_ptr<RateHelper> s10yJPY(new SwapRateHelper( > Handle<Quote>(s10yRateJPY), 10*Years, > calendar, frequencyJPY, > conventionJPY, dayCounterJPY, > indexJPY)); > boost::shared_ptr<RateHelper> s15yJPY(new SwapRateHelper( > Handle<Quote>(s15yRateJPY), 15*Years, > calendar, frequencyJPY, > conventionJPY, dayCounterJPY, > indexJPY)); > > /********************* > ** CURVEs BUILDING ** > *********************/ > > DayCounter termStructureDayCounter = > ActualActual(ActualActual::ISDA); > > double tolerance = 1.0e-15; > > std::vector<boost::shared_ptr<RateHelper> > depoSwapInstrumentsUSD; > depoSwapInstrumentsUSD.push_back(d1wUSD); > depoSwapInstrumentsUSD.push_back(d1mUSD); > depoSwapInstrumentsUSD.push_back(d3mUSD); > depoSwapInstrumentsUSD.push_back(d6mUSD); > depoSwapInstrumentsUSD.push_back(d9mUSD); > depoSwapInstrumentsUSD.push_back(d1yUSD); > depoSwapInstrumentsUSD.push_back(s2yUSD); > depoSwapInstrumentsUSD.push_back(s3yUSD); > depoSwapInstrumentsUSD.push_back(s5yUSD); > depoSwapInstrumentsUSD.push_back(s10yUSD); > depoSwapInstrumentsUSD.push_back(s15yUSD); > boost::shared_ptr<YieldTermStructure> depoSwapTermStructureUSD( > new PiecewiseYieldCurve<Discount,LogLinear>( > settlementDate, depoSwapInstrumentsUSD, > termStructureDayCounter, > tolerance)); > > std::vector<boost::shared_ptr<RateHelper> > depoFutSwapInstrumentsUSD; > depoFutSwapInstrumentsUSD.push_back(d1wUSD); > depoFutSwapInstrumentsUSD.push_back(d1mUSD); > depoFutSwapInstrumentsUSD.push_back(fut1USD); > depoFutSwapInstrumentsUSD.push_back(fut2USD); > depoFutSwapInstrumentsUSD.push_back(fut3USD); > depoFutSwapInstrumentsUSD.push_back(fut4USD); > depoFutSwapInstrumentsUSD.push_back(fut5USD); > depoFutSwapInstrumentsUSD.push_back(fut6USD); > depoFutSwapInstrumentsUSD.push_back(fut7USD); > depoFutSwapInstrumentsUSD.push_back(fut8USD); > depoFutSwapInstrumentsUSD.push_back(s3yUSD); > depoFutSwapInstrumentsUSD.push_back(s5yUSD); > depoFutSwapInstrumentsUSD.push_back(s10yUSD); > depoFutSwapInstrumentsUSD.push_back(s15yUSD); > boost::shared_ptr<YieldTermStructure> depoFutSwapTermStructureUSD( > new PiecewiseYieldCurve<Discount,LogLinear>( > settlementDate, depoFutSwapInstrumentsUSD, > termStructureDayCounter, > tolerance)); > > std::vector<boost::shared_ptr<RateHelper> > depoFRASwapInstrumentsUSD; > depoFRASwapInstrumentsUSD.push_back(d1wUSD); > depoFRASwapInstrumentsUSD.push_back(d1mUSD); > depoFRASwapInstrumentsUSD.push_back(d3mUSD); > depoFRASwapInstrumentsUSD.push_back(fra3x6USD); > depoFRASwapInstrumentsUSD.push_back(fra6x9USD); > depoFRASwapInstrumentsUSD.push_back(fra6x12USD); > depoFRASwapInstrumentsUSD.push_back(s2yUSD); > depoFRASwapInstrumentsUSD.push_back(s3yUSD); > depoFRASwapInstrumentsUSD.push_back(s5yUSD); > depoFRASwapInstrumentsUSD.push_back(s10yUSD); > depoFRASwapInstrumentsUSD.push_back(s15yUSD); > boost::shared_ptr<YieldTermStructure> depoFRASwapTermStructureUSD( > new PiecewiseYieldCurve<Discount,LogLinear>( > settlementDate, depoFRASwapInstrumentsUSD, > termStructureDayCounter, > tolerance)); > > RelinkableHandle<YieldTermStructure> > discountingTermStructureUSD; > > RelinkableHandle<YieldTermStructure> > forecastingTermStructureUSD; > > //JPY leg > > std::vector<boost::shared_ptr<RateHelper> > depoSwapInstrumentsJPY; > depoSwapInstrumentsJPY.push_back(d1wJPY); > depoSwapInstrumentsJPY.push_back(d1mJPY); > depoSwapInstrumentsJPY.push_back(d3mJPY); > depoSwapInstrumentsJPY.push_back(d6mJPY); > depoSwapInstrumentsJPY.push_back(d9mJPY); > depoSwapInstrumentsJPY.push_back(d1yJPY); > depoSwapInstrumentsJPY.push_back(s2yJPY); > depoSwapInstrumentsJPY.push_back(s3yJPY); > depoSwapInstrumentsJPY.push_back(s5yJPY); > depoSwapInstrumentsJPY.push_back(s10yJPY); > depoSwapInstrumentsJPY.push_back(s15yJPY); > boost::shared_ptr<YieldTermStructure> depoSwapTermStructureJPY( > new PiecewiseYieldCurve<Discount,LogLinear>( > settlementDate, depoSwapInstrumentsJPY, > termStructureDayCounter, > tolerance)); > > std::vector<boost::shared_ptr<RateHelper> > depoFutSwapInstrumentsJPY; > depoFutSwapInstrumentsJPY.push_back(d1wJPY); > depoFutSwapInstrumentsJPY.push_back(d1mJPY); > depoFutSwapInstrumentsJPY.push_back(fut1JPY); > depoFutSwapInstrumentsJPY.push_back(fut2JPY); > depoFutSwapInstrumentsJPY.push_back(fut3JPY); > depoFutSwapInstrumentsJPY.push_back(fut4JPY); > depoFutSwapInstrumentsJPY.push_back(fut5JPY); > depoFutSwapInstrumentsJPY.push_back(fut6JPY); > depoFutSwapInstrumentsJPY.push_back(fut7JPY); > depoFutSwapInstrumentsJPY.push_back(fut8JPY); > depoFutSwapInstrumentsJPY.push_back(s3yJPY); > depoFutSwapInstrumentsJPY.push_back(s5yJPY); > depoFutSwapInstrumentsJPY.push_back(s10yJPY); > depoFutSwapInstrumentsJPY.push_back(s15yJPY); > boost::shared_ptr<YieldTermStructure> depoFutSwapTermStructureJPY( > new PiecewiseYieldCurve<Discount,LogLinear>( > settlementDate, depoFutSwapInstrumentsJPY, > termStructureDayCounter, > tolerance)); > > std::vector<boost::shared_ptr<RateHelper> > depoFRASwapInstrumentsJPY; > depoFRASwapInstrumentsJPY.push_back(d1wJPY); > depoFRASwapInstrumentsJPY.push_back(d1mJPY); > depoFRASwapInstrumentsJPY.push_back(d3mJPY); > depoFRASwapInstrumentsJPY.push_back(fra3x6JPY); > depoFRASwapInstrumentsJPY.push_back(fra6x9JPY); > depoFRASwapInstrumentsJPY.push_back(fra6x12JPY); > depoFRASwapInstrumentsJPY.push_back(s2yJPY); > depoFRASwapInstrumentsJPY.push_back(s3yJPY); > depoFRASwapInstrumentsJPY.push_back(s5yJPY); > depoFRASwapInstrumentsJPY.push_back(s10yJPY); > depoFRASwapInstrumentsJPY.push_back(s15yJPY); > boost::shared_ptr<YieldTermStructure> depoFRASwapTermStructureJPY( > new PiecewiseYieldCurve<Discount,LogLinear>( > settlementDate, depoFRASwapInstrumentsJPY, > termStructureDayCounter, > tolerance)); > > RelinkableHandle<YieldTermStructure> > discountingTermStructureJPY; > > RelinkableHandle<YieldTermStructure> > forecastingTermStructureJPY; > > /********************* > * SWAPS TO BE PRICED * > **********************/ > > Real nominalDummy = 0.0; > > std::vector<Real> nominalJPY; > nominalJPY.push_back(16000000000); > nominalJPY.push_back(16000000000); > nominalJPY.push_back(16000000000); > nominalJPY.push_back(16000000000); > > std::vector<Real> nominalUSD; > nominalUSD.push_back(20000000); > nominalUSD.push_back(20500000); > nominalUSD.push_back(20100000); > nominalUSD.push_back(20070000); > > // fixed leg > Frequency frequencyDummy = Quarterly; > BusinessDayConvention conventionDummy = Unadjusted; > > DayCounter dayCounterDummy = Thirty360(Thirty360::European); > Rate fixedRate = 0.0; > > // floating leg > BusinessDayConvention conventionUSD = ModifiedFollowing; > BusinessDayConvention conventionJPY = ModifiedFollowing; > DayCounter dayCounterUSD = Actual360(); > DayCounter dayCounterJPY = Actual360();Frequency frequencyUSD = Quarterly; > Frequency frequencyJPY = Quarterly; > boost::shared_ptr<IborIndex> euriborIndexUSD( > new Euribor6M(forecastingTermStructureUSD)); > boost::shared_ptr<IborIndex> euriborIndexJPY( > new Euribor6M(forecastingTermStructureJPY)); > Spread spreadUSD = 0.0; > Spread spreadJPY = -0.0069; > > Integer lenghtInYears = 1; > VanillaSwap::Type swapTypeUSD = VanillaSwap::Receiver; > VanillaSwap::Type swapTypeJPY = VanillaSwap::Payer; > > Date maturity = settlementDate + lenghtInYears*Years; > Schedule fixedSchedule(settlementDate, maturity, > Period(fixedLegFrequency), > calendar, fixedLegConvention, > fixedLegConvention, > DateGeneration::Forward, false); > Schedule floatScheduleUSD(settlementDate, maturity, > Period(frequencyUSD), > calendar, conventionUSD, > conventionUSD, > DateGeneration::Forward, false); > Schedule floatScheduleJPY(settlementDate, maturity, > Period(frequencyJPY), > calendar, conventionJPY, > conventionJPY, > DateGeneration::Forward, false); > > NonStandardSwap dummyUSDSwap(swapTypeUSD, nominalDummy, nominalUSD, > floatScheduleUSD, fixedRate, > dayCounterDummy, floatScheduleUSD, > euriborIndexUSD, QL_EPSILON, spreadUSD, > dayCounterUSD, false, false, conventionUSD) > NonStandardSwap dummyJPYSwap(swapTypeJPY, nominalDummy, nominalJPY, > floatScheduleJPY, fixedRate, > dayCounterDummy, floatScheduleJPY, > euriborIndexJPY, QL_EPSILON, spreadJPY, > dayCounterJPY, false, false, > conventionJPY) > > /*************** > * SWAP PRICING * > ****************/ > > Real NPVUSD; > Real NPVJPY; > Real NPVmySwap; > > boost::shared_ptr<PricingEngine> swapEngineUSD( > new > DiscountingSwapEngine(discountingTermStructureUSD)); > > dummyUSDSwap.setPricingEngine(swapEngineUSD); > > forecastingTermStructureUSD.linkTo(depoSwapTermStructureUSD); > discountingTermStructureUSD.linkTo(depoSwapTermStructureUSD); > > NPVUSD = dummyUSDSwap.NPV(); > > > boost::shared_ptr<PricingEngine> swapEngineJPY( > new > DiscountingSwapEngine(discountingTermStructureJPY)); > > dummyJPYSwap.setPricingEngine(swapEngineJPY); > > forecastingTermStructureJPY.linkTo(depoSwapTermStructureJPY); > discountingTermStructureJPY.linkTo(depoSwapTermStructureJPY); > > NPVJPY = dummyJPYSwap.NPV(); > > NPVmySwap = NPVUSD - NPVJPY; > > return 0; > > } catch (std::exception& e) { > std::cerr << e.what() << std::endl; > return 1; > } catch (...) { > std::cerr << "unknown error" << std::endl; > return 1; > } > } > //////////////////////////// > > -----Original Message----- > From: Peter Caspers [mailto:[hidden email]] > Sent: Monday, January 25, 2016 10:09 PM > To: Dragomir Nedeltchev > Cc: [hidden email] > Subject: Re: [Quantlib-users] pricing Mark-To-Market Cross-Currency > Swap > > Hi Dragomir, > > you have to create the schedules of your floating legs (which > basically represent the series of their accrual periods), with > effective Date = start of first accrual period (forward starting in > your case), termination date = end of last accrual period. Then pass > them together with the other parameters to the NonStandardSwap > constructor. Note that you have to precalculate the deterministic > notional schedule of the USD leg before, this is not handled in the > NonstandardSwap either. The NonStandardSwaps accepts a vector of > notionals corresponding to the accrual periods. You can set up the > fixed schedule as equal to the floating schedule (whatever, it is not > used) and with notionals zero. > > Then set up two DiscountingSwapEngines, assign them to your non standard swaps and extract the NPV from each one (which is in USD resp. JPY for the respective legs, because the instrument is a single currency instrument actually as well as the pricing engine). > > Regards > Peter > > On 25 January 2016 at 09:44, Dragomir Nedeltchev <[hidden email]> wrote: >> Hi Peter, >> >> Thank you for the prompt feedback. This seems to meet my needs. >> >> I deal with a 1Y5Y swap. How can I tackle this feature in a NonStandardSwap? >> >> I see there is VanillaSwap oneYearForward5YeraSwap, but the Vanilla Swap class doesn't treat the floating notional reset feature of the MTM swap. >> >> Thank you in advance. >> >> Kind regards, >> >> Dragomir >> >> -----Original Message----- >> From: Peter Caspers [mailto:[hidden email]] >> Sent: Sunday, January 24, 2016 2:08 PM >> To: Dragomir Nedeltchev >> Cc: [hidden email] >> Subject: Re: [Quantlib-users] pricing Mark-To-Market Cross-Currency >> Swap >> >> Hi Dragomir, >> >> there is no ready-to-use class in QuantLib for this I think. >> >> But as you say, you can repesent the mtm swap as two single legs with a customized notional schedule for one of them. Beneath the bond classes you can also use the NonStandardSwap I guess (setting the fixed leg's nominals to zero and only use the floating leg for each mtm swap leg) and do the valuation of the single legs with two DiscountingSwapEngine's attaching appropriate discount curves for USD and JPY. >> >> Kind Regards >> Peter >> >> On 22 January 2016 at 08:47, Dragomir Nedeltchev <[hidden email]> wrote: >>> Hi All, >>> >>> >>> >>> I am pricing a Mark-To-Market JPYUSD Swap. >>> >>> >>> >>> Advise please which swap class of QuantLib serves this purpose. >>> >>> >>> >>> Can I present the swap as a JPY floating bond and a USD amortizing >>> floating rate bond (notionals vector to be calculated by the FX rate >>> at the reset dates). Thanks >>> >>> >>> >>> Dragomir Nedeltchev, Custom House >>> >>> >>> >>> >>> >>> TMF Custom House Fund Services (Ireland) Limited Registered Office: >>> 3rd Floor, Kilmore House, Park Lane, Spencer Dock, Dublin 1, >>> Ireland; >>> Tel: (353) >>> 1 878 0807; Fax: (353) 1 878 0827 Website: www.customhousegroup.com >>> Directors: Mark Hedderman; Kevin Walsh; Barbara Cotter Registered in >>> Ireland No. 147511 TMF Custom House Fund Services (Ireland) Limited >>> is authorised by The Central Bank of Ireland under Section 10 of the >>> Investment Intermediaries Act, 1995 >>> ******************************************************************** >>> * >>> * >>> **************************************** >>> This e-mail and any files transmitted with it are intended to be >>> confidential and intended solely for the use of the individual or >>> entity to whom they are addressed. If you have received this e-mail >>> in error please notify the sender. Internet mail is a communication >>> channel, which is not controlled by Custom House, who cannot and do >>> not guarantee that: any e-mail sent from Custom House will be >>> delivered within a reasonable timeframe, or at all; comes from the >>> purported sender; has not been intercepted by a third party; or that >>> the contents of the e-mail are unaltered from the time of >>> transmission. The recipient of this e-mail message should take note >>> that this document does not constitute a legally binding contractual >>> obligation of any sort unless there is a specific statement within >>> the above message confirming that the message contains such a legally binding contractual obligation. >>> ******************************************************************** >>> * >>> * >>> ******************************************** >>> >>> -------------------------------------------------------------------- >>> - >>> - >>> -------- >>> Site24x7 APM Insight: Get Deep Visibility into Application >>> Performance APM + Mobile APM + RUM: Monitor 3 App instances at just >>> $35/Month Monitor end-to-end web transactions and take corrective >>> actions now Troubleshoot faster and improve end-user experience. Signup Now! >>> http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140 >>> _______________________________________________ >>> QuantLib-users mailing list >>> [hidden email] >>> https://lists.sourceforge.net/lists/listinfo/quantlib-users >>> >> TMF Custom House Fund Services (Ireland) Limited Registered Office: >> 3rd Floor, Kilmore House, Park Lane, Spencer Dock, Dublin 1, Ireland; >> Tel: (353) 1 878 0807; Fax: (353) 1 878 0827 Website: >> www.customhousegroup.com Directors: Mark Hedderman; Kevin Walsh; >> Barbara Cotter Registered in Ireland No. 147511 TMF Custom House Fund >> Services (Ireland) Limited is authorised by The Central Bank of >> Ireland under Section 10 of the Investment Intermediaries Act, 1995 >> ********************************************************************* >> * >> **************************************** This e-mail and any files >> transmitted with it are intended to be confidential and intended >> solely for the use of the individual or entity to whom they are >> addressed. If you have received this e-mail in error please notify >> the sender. Internet mail is a communication channel, which is not >> controlled by Custom House, who cannot and do not guarantee that: any >> e-mail sent from Custom House will be delivered within a reasonable >> timeframe, or at all; comes from the purported sender; has not been >> intercepted by a third party; or that the contents of the e-mail are >> unaltered from the time of transmission. The recipient of this e-mail >> message should take note that this document does not constitute a >> legally binding contractual obligation of any sort unless there is a >> specific statement within the above message confirming that the >> message contains such a legally binding contractual obligation. >> ********************************************************************* >> * >> ******************************************** > TMF Custom House Fund Services (Ireland) Limited Registered Office: > 3rd Floor, Kilmore House, Park Lane, Spencer Dock, Dublin 1, Ireland; > Tel: (353) 1 878 0807; Fax: (353) 1 878 0827 Website: > www.customhousegroup.com Directors: Mark Hedderman; Kevin Walsh; > Barbara Cotter Registered in Ireland No. 147511 TMF Custom House Fund > Services (Ireland) Limited is authorised by The Central Bank of > Ireland under Section 10 of the Investment Intermediaries Act, 1995 > ********************************************************************** > **************************************** This e-mail and any files > transmitted with it are intended to be confidential and intended > solely for the use of the individual or entity to whom they are > addressed. If you have received this e-mail in error please notify the > sender. Internet mail is a communication channel, which is not > controlled by Custom House, who cannot and do not guarantee that: any > e-mail sent from Custom House will be delivered within a reasonable > timeframe, or at all; comes from the purported sender; has not been > intercepted by a third party; or that the contents of the e-mail are > unaltered from the time of transmission. The recipient of this e-mail > message should take note that this document does not constitute a > legally binding contractual obligation of any sort unless there is a > specific statement within the above message confirming that the > message contains such a legally binding contractual obligation. > ********************************************************************** > ******************************************** ------------------------------------------------------------------------------ Site24x7 APM Insight: Get Deep Visibility into Application Performance APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month Monitor end-to-end web transactions and take corrective actions now Troubleshoot faster and improve end-user experience. Signup Now! http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140 _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Hi Dragomir,
you can say boost::shared_ptr<IborIndex> indexJPY(new JPYLibor(6*Months)); or even cooler boost::shared_ptr<IborIndex> indexJPY = boost::make_shared<JPYLibor>(6*Months); There are no convenience classes for the maturities, you have to specify it as the first argument instead (you can do the same for Euribor by the way). The forward estimation curve can be attached via the second argument as usual. I didn't know that IntelliSense throws compilation errors now (?), but anyway, you have to make fixedRate a vector, too, whose length matches the number of periods, e.g. by std::vector<Rate> fixedRate(notionalDummy.size(), 0.0); That should fix the issue. Regards Peter On 27 January 2016 at 16:13, Dragomir Nedeltchev <[hidden email]> wrote: > Hi Peter, > > I fixed the code per your advice below. > > Please advise how to write the line > > boost::shared_ptr<IborIndex> indexJPY(new Euribor6M); > > so that it concerns JPY Libor > > I received 5 error messages for the revised code (Build Solution, Release mode): > ////////////////// > 4 IntelliSense: no instance of constructor "QuantLib::NonstandardSwap::NonstandardSwap" matches the argument list > argument types are: (QuantLib::VanillaSwap::Type, std::vector<QuantLib::Time, std::allocator<QuantLib::Time>>, std::vector<QuantLib::Time, std::allocator<QuantLib::Time>>, QuantLib::Schedule, QuantLib::Rate, QuantLib::DayCounter, QuantLib::Schedule, boost::shared_ptr<QuantLib::IborIndex>, double, QuantLib::Spread, QuantLib::DayCounter, bool, bool, QuantLib::BusinessDayConvention) c:\local\QuantLib-1.6.2\JPYUSD MTM Swap\JPYUSD MTM Swap\Source.cpp 276 32 JPYUSD MTM Swap > Error 1 error C2664: 'QuantLib::NonstandardSwap::NonstandardSwap(const QuantLib::NonstandardSwap &)' : cannot convert argument 5 from 'QuantLib::Rate' to 'const std::vector<QuantLib::Time,std::allocator<_Ty>> &' C:\local\QuantLib-1.6.2\JPYUSD MTM Swap\JPYUSD MTM Swap\Source.cpp 280 1 JPYUSD MTM Swap > Error 2 error C2374: 'imm' : redefinition; multiple initialization C:\local\QuantLib-1.6.2\JPYUSD MTM Swap\JPYUSD MTM Swap\Source.cpp 389 1 JPYUSD MTM Swap > 5 IntelliSense: no instance of constructor "QuantLib::NonstandardSwap::NonstandardSwap" matches the argument list > argument types are: (QuantLib::VanillaSwap::Type, std::vector<QuantLib::Time, std::allocator<QuantLib::Time>>, std::vector<QuantLib::Time, std::allocator<QuantLib::Time>>, QuantLib::Schedule, QuantLib::Rate, QuantLib::DayCounter, QuantLib::Schedule, boost::shared_ptr<QuantLib::IborIndex>, double, QuantLib::Spread, QuantLib::DayCounter, bool, bool, QuantLib::BusinessDayConvention) c:\local\QuantLib-1.6.2\JPYUSD MTM Swap\JPYUSD MTM Swap\Source.cpp 487 32 JPYUSD MTM Swap > Error 3 error C2664: 'QuantLib::NonstandardSwap::NonstandardSwap(const QuantLib::NonstandardSwap &)' : cannot convert argument 5 from 'QuantLib::Rate' to 'const std::vector<QuantLib::Time,std::allocator<_Ty>> &' C:\local\QuantLib-1.6.2\JPYUSD MTM Swap\JPYUSD MTM Swap\Source.cpp 491 1 JPYUSD MTM Swap > ////////////////// > > And here is the code: > /////////////////////////////////////// > #include <ql/quantlib.hpp> > #include <ql/instruments/nonstandardswap.hpp> > > #include <iostream> > #include <iomanip> > > using namespace QuantLib; > > > int main(int, char*[]) { > > try { > > Calendar calendar = TARGET(); > Date settlementDate(03, October, 2016); > settlementDate = calendar.adjust(settlementDate); > > Integer fixingDays = 2; > > Date todaysDate(26, January, 2016); > > Settings::instance().evaluationDate() = todaysDate; > > todaysDate = Settings::instance().evaluationDate(); > > //dummyUSD swap > // curve 23 USD vs 3M LIBOR > > Rate d1mQuoteUSD = 0.6213; > Real fut2QuoteUSD = 99.33034; > Real fut3QuoteUSD = 99.30568; > Real fut4QuoteUSD = 99.266; > Real fut5QuoteUSD = 99.27143; > Real fut6QuoteUSD = 99.24691; > Real fut9QuoteUSD = 99.20304; > Real fut12QuoteUSD = 99.10996; > Real fut15QuoteUSD = 99.01759; > Real fut18QuoteUSD = 98.92062; > Real fut21QuoteUSD = 98.81907; > Real fut24QuoteUSD = 98.71795; > Real fut27QuoteUSD = 98.63228; > Real fut30QuoteUSD = 98.54702; > Real fut33QuoteUSD = 98.46717; > Real fut36QuoteUSD = 98.38774; > Rate s4yQuoteUSD = 1.24338; > Rate s5yQuoteUSD = 1.38353; > Rate s6yQuoteUSD = 1.50944; > Rate s7yQuoteUSD = 1.61756; > Rate s8yQuoteUSD = 1.71261; > > boost::shared_ptr<Quote> d1mRateUSD(new SimpleQuote(d1mQuoteUSD)); > boost::shared_ptr<Quote> fut2PriceUSD(new SimpleQuote(fut2QuoteUSD)); > boost::shared_ptr<Quote> fut3PriceUSD(new SimpleQuote(fut3QuoteUSD)); > boost::shared_ptr<Quote> fut4PriceUSD(new SimpleQuote(fut4QuoteUSD)); > boost::shared_ptr<Quote> fut5PriceUSD(new SimpleQuote(fut5QuoteUSD)); > boost::shared_ptr<Quote> fut6PriceUSD(new SimpleQuote(fut6QuoteUSD)); > boost::shared_ptr<Quote> fut9PriceUSD(new SimpleQuote(fut9QuoteUSD)); > boost::shared_ptr<Quote> fut12PriceUSD(new SimpleQuote(fut12QuoteUSD)); > boost::shared_ptr<Quote> fut15PriceUSD(new SimpleQuote(fut15QuoteUSD)); > boost::shared_ptr<Quote> fut18PriceUSD(new SimpleQuote(fut18QuoteUSD)); > boost::shared_ptr<Quote> fut21PriceUSD(new SimpleQuote(fut21QuoteUSD)); > boost::shared_ptr<Quote> fut24PriceUSD(new SimpleQuote(fut24QuoteUSD)); > boost::shared_ptr<Quote> fut27PriceUSD(new SimpleQuote(fut27QuoteUSD)); > boost::shared_ptr<Quote> fut30PriceUSD(new SimpleQuote(fut30QuoteUSD)); > boost::shared_ptr<Quote> fut33PriceUSD(new SimpleQuote(fut33QuoteUSD)); > boost::shared_ptr<Quote> fut36PriceUSD(new SimpleQuote(fut36QuoteUSD)); > boost::shared_ptr<Quote> s4yRateUSD(new SimpleQuote(s4yQuoteUSD)); > boost::shared_ptr<Quote> s5yRateUSD(new SimpleQuote(s5yQuoteUSD)); > boost::shared_ptr<Quote> s6yRateUSD(new SimpleQuote(s6yQuoteUSD)); > boost::shared_ptr<Quote> s7yRateUSD(new SimpleQuote(s7yQuoteUSD)); > boost::shared_ptr<Quote> s8yRateUSD(new SimpleQuote(s8yQuoteUSD)); > > DayCounter depositDayCounterUSD = Actual360(); > > boost::shared_ptr<RateHelper> d1mUSD(new DepositRateHelper( > Handle<Quote>(d1mRateUSD), > 1 * Months, fixingDays, > calendar, ModifiedFollowing, > true, depositDayCounterUSD)); > > Integer futMonthsUSD = 3; > Date imm = IMM::nextDate(settlementDate); > boost::shared_ptr<RateHelper> fut2USD(new FuturesRateHelper( > Handle<Quote>(fut2PriceUSD), > imm, > futMonthsUSD, calendar, ModifiedFollowing, > true, depositDayCounterUSD)); > imm = IMM::nextDate(imm + 1); > boost::shared_ptr<RateHelper> fut3USD(new FuturesRateHelper( > Handle<Quote>(fut3PriceUSD), > imm, > futMonthsUSD, calendar, ModifiedFollowing, > true, depositDayCounterUSD)); > imm = IMM::nextDate(imm + 1); > boost::shared_ptr<RateHelper> fut4USD(new FuturesRateHelper( > Handle<Quote>(fut4PriceUSD), > imm, > futMonthsUSD, calendar, ModifiedFollowing, > true, depositDayCounterUSD)); > imm = IMM::nextDate(imm + 1); > boost::shared_ptr<RateHelper> fut5USD(new FuturesRateHelper( > Handle<Quote>(fut5PriceUSD), > imm, > futMonthsUSD, calendar, ModifiedFollowing, > true, depositDayCounterUSD)); > imm = IMM::nextDate(imm + 1); > boost::shared_ptr<RateHelper> fut6USD(new FuturesRateHelper( > Handle<Quote>(fut6PriceUSD), > imm, > futMonthsUSD, calendar, ModifiedFollowing, > true, depositDayCounterUSD)); > imm = IMM::nextDate(imm + 1); > boost::shared_ptr<RateHelper> fut9USD(new FuturesRateHelper( > Handle<Quote>(fut9PriceUSD), > imm, > futMonthsUSD, calendar, ModifiedFollowing, > true, depositDayCounterUSD)); > imm = IMM::nextDate(imm + 1); > boost::shared_ptr<RateHelper> fut12USD(new FuturesRateHelper( > Handle<Quote>(fut12PriceUSD), > imm, > futMonthsUSD, calendar, ModifiedFollowing, > true, depositDayCounterUSD)); > imm = IMM::nextDate(imm + 1); > boost::shared_ptr<RateHelper> fut15USD(new FuturesRateHelper( > Handle<Quote>(fut15PriceUSD), > imm, > futMonthsUSD, calendar, ModifiedFollowing, > true, depositDayCounterUSD)); > imm = IMM::nextDate(imm + 1); > boost::shared_ptr<RateHelper> fut18USD(new FuturesRateHelper( > Handle<Quote>(fut18PriceUSD), > imm, > futMonthsUSD, calendar, ModifiedFollowing, > true, depositDayCounterUSD)); > imm = IMM::nextDate(imm + 1); > boost::shared_ptr<RateHelper> fut21USD(new FuturesRateHelper( > Handle<Quote>(fut21PriceUSD), > imm, > futMonthsUSD, calendar, ModifiedFollowing, > true, depositDayCounterUSD)); > imm = IMM::nextDate(imm + 1); > boost::shared_ptr<RateHelper> fut24USD(new FuturesRateHelper( > Handle<Quote>(fut24PriceUSD), > imm, > futMonthsUSD, calendar, ModifiedFollowing, > true, depositDayCounterUSD)); > imm = IMM::nextDate(imm + 1); > boost::shared_ptr<RateHelper> fut27USD(new FuturesRateHelper( > Handle<Quote>(fut27PriceUSD), > imm, > futMonthsUSD, calendar, ModifiedFollowing, > true, depositDayCounterUSD)); > imm = IMM::nextDate(imm + 1); > boost::shared_ptr<RateHelper> fut30USD(new FuturesRateHelper( > Handle<Quote>(fut30PriceUSD), > imm, > futMonthsUSD, calendar, ModifiedFollowing, > true, depositDayCounterUSD)); > imm = IMM::nextDate(imm + 1); > boost::shared_ptr<RateHelper> fut33USD(new FuturesRateHelper( > Handle<Quote>(fut33PriceUSD), > imm, > futMonthsUSD, calendar, ModifiedFollowing, > true, depositDayCounterUSD)); > imm = IMM::nextDate(imm + 1); > boost::shared_ptr<RateHelper> fut36USD(new FuturesRateHelper( > Handle<Quote>(fut36PriceUSD), > imm, > futMonthsUSD, calendar, ModifiedFollowing, > true, depositDayCounterUSD)); > > Frequency frequencyUSD = Quarterly; > BusinessDayConvention conventionUSD = Unadjusted; > DayCounter dayCounterUSD = Thirty360(Thirty360::USA); > boost::shared_ptr<IborIndex> indexUSD(new Euribor6M); > > boost::shared_ptr<RateHelper> s4yUSD(new SwapRateHelper( > Handle<Quote>(s4yRateUSD), 4 * Years, > calendar, frequencyUSD, > conventionUSD, dayCounterUSD, > indexUSD)); > boost::shared_ptr<RateHelper> s5yUSD(new SwapRateHelper( > Handle<Quote>(s5yRateUSD), 5 * Years, > calendar, frequencyUSD, > conventionUSD, dayCounterUSD, > indexUSD)); > boost::shared_ptr<RateHelper> s6yUSD(new SwapRateHelper( > Handle<Quote>(s6yRateUSD), 6 * Years, > calendar, frequencyUSD, > conventionUSD, dayCounterUSD, > indexUSD)); > boost::shared_ptr<RateHelper> s7yUSD(new SwapRateHelper( > Handle<Quote>(s7yRateUSD), 7 * Years, > calendar, frequencyUSD, > conventionUSD, dayCounterUSD, > indexUSD)); > boost::shared_ptr<RateHelper> s8yUSD(new SwapRateHelper( > Handle<Quote>(s8yRateUSD), 8 * Years, > calendar, frequencyUSD, > conventionUSD, dayCounterUSD, > indexUSD)); > > DayCounter termStructureDayCounter = > ActualActual(ActualActual::ISDA); > > double tolerance = 1.0e-15; > > std::vector<boost::shared_ptr<RateHelper> > swapInstrumentsUSD; > swapInstrumentsUSD.push_back(d1mUSD); > swapInstrumentsUSD.push_back(fut2USD); > swapInstrumentsUSD.push_back(fut3USD); > swapInstrumentsUSD.push_back(fut4USD); > swapInstrumentsUSD.push_back(fut5USD); > swapInstrumentsUSD.push_back(fut6USD); > swapInstrumentsUSD.push_back(fut9USD); > swapInstrumentsUSD.push_back(fut12USD); > swapInstrumentsUSD.push_back(fut15USD); > swapInstrumentsUSD.push_back(fut18USD); > swapInstrumentsUSD.push_back(fut21USD); > swapInstrumentsUSD.push_back(fut24USD); > swapInstrumentsUSD.push_back(fut27USD); > swapInstrumentsUSD.push_back(fut30USD); > swapInstrumentsUSD.push_back(fut33USD); > swapInstrumentsUSD.push_back(fut36USD); > swapInstrumentsUSD.push_back(s4yUSD); > swapInstrumentsUSD.push_back(s5yUSD); > swapInstrumentsUSD.push_back(s6yUSD); > swapInstrumentsUSD.push_back(s7yUSD); > swapInstrumentsUSD.push_back(s8yUSD); > > boost::shared_ptr<YieldTermStructure> swapTermStructureUSD( > new PiecewiseYieldCurve<Discount, LogLinear>( > settlementDate, swapInstrumentsUSD, > termStructureDayCounter, > tolerance)); > > RelinkableHandle<YieldTermStructure> discountingTermStructureUSD; > > RelinkableHandle<YieldTermStructure> forecastingTermStructureUSD; > > // dummy leg > > std::vector<Real> notionalDummy; > notionalDummy.push_back(0.0); > notionalDummy.push_back(0.0); > notionalDummy.push_back(0.0); > notionalDummy.push_back(0.0); > > Rate fixedRate = 0.0; > > Integer lenghtInYears = 1; > Date maturity = settlementDate + lenghtInYears*Years; > > > // USD leg > > boost::shared_ptr<IborIndex> euriborIndexUSD( > new Euribor6M(forecastingTermStructureUSD)); > Spread spreadUSD = 0.0; > > std::vector<Real> notionalUSD; > notionalUSD.push_back(20000000); > notionalUSD.push_back(20500000); > notionalUSD.push_back(20100000); > notionalUSD.push_back(20070000); > > VanillaSwap::Type swapTypeUSD = VanillaSwap::Receiver; > > Schedule scheduleUSD(settlementDate, maturity, > Period(frequencyUSD), > calendar, conventionUSD, > conventionUSD, > DateGeneration::Forward, false); > > NonstandardSwap dummyUSDSwap(swapTypeUSD, notionalDummy, notionalUSD, > scheduleUSD, fixedRate, > dayCounterUSD, scheduleUSD, > euriborIndexUSD, 1.0, spreadUSD, > dayCounterUSD, false, false, conventionUSD); > Real NPVUSD; > Real USDJPYrate; > USDJPYrate = 118.0; > > boost::shared_ptr<PricingEngine> swapEngineUSD( > new DiscountingSwapEngine(discountingTermStructureUSD)); > > dummyUSDSwap.setPricingEngine(swapEngineUSD); > > forecastingTermStructureUSD.linkTo(swapTermStructureUSD); > discountingTermStructureUSD.linkTo(swapTermStructureUSD); > > NPVUSD = dummyUSDSwap.NPV() * USDJPYrate; > > //dummyJPY swap > > // curve 308 JPY vs 3M LIBOR > > Rate d3mQuoteJPY = 0.08071; > > Rate fra1x4QuoteJPY = 0.06; > Rate fra2x5QuoteJPY = 0.06; > Rate fra3x6QuoteJPY = 0.055; > Rate fra4x7QuoteJPY = 0.055; > Rate fra5x8QuoteJPY = 0.05; > Rate fra6x9QuoteJPY = 0.045; > Rate fra7x10QuoteJPY = 0.0375; > Rate fra8x11QuoteJPY = 0.03375; > Rate fra9x12QuoteJPY = 0.035; > > Real fut18QuoteJPY = 99.93105; > > Rate s2yQuoteJPY = 0.06025; > Rate s3yQuoteJPY = 0.06665; > Rate s4yQuoteJPY = 0.07388; > Rate s5yQuoteJPY = 0.10152; > Rate s6yQuoteJPY = 0.14495; > Rate s7yQuoteJPY = 0.1873; > Rate s8yQuoteJPY = 0.242; > > boost::shared_ptr<Quote> d3mRateJPY(new SimpleQuote(d3mQuoteJPY)); > > boost::shared_ptr<Quote> fra1x4RateJPY(new SimpleQuote(fra1x4QuoteJPY)); > boost::shared_ptr<Quote> fra2x5RateJPY(new SimpleQuote(fra2x5QuoteJPY)); > boost::shared_ptr<Quote> fra3x6RateJPY(new SimpleQuote(fra3x6QuoteJPY)); > boost::shared_ptr<Quote> fra4x7RateJPY(new SimpleQuote(fra4x7QuoteJPY)); > boost::shared_ptr<Quote> fra5x8RateJPY(new SimpleQuote(fra5x8QuoteJPY)); > boost::shared_ptr<Quote> fra6x9RateJPY(new SimpleQuote(fra6x9QuoteJPY)); > boost::shared_ptr<Quote> fra7x10RateJPY(new SimpleQuote(fra7x10QuoteJPY)); > boost::shared_ptr<Quote> fra8x11RateJPY(new SimpleQuote(fra8x11QuoteJPY)); > boost::shared_ptr<Quote> fra9x12RateJPY(new SimpleQuote(fra9x12QuoteJPY)); > > boost::shared_ptr<Quote> fut18PriceJPY(new SimpleQuote(fut18QuoteJPY)); > > boost::shared_ptr<Quote> s2yRateJPY(new SimpleQuote(s2yQuoteJPY)); > boost::shared_ptr<Quote> s3yRateJPY(new SimpleQuote(s3yQuoteJPY)); > boost::shared_ptr<Quote> s4yRateJPY(new SimpleQuote(s4yQuoteJPY)); > boost::shared_ptr<Quote> s5yRateJPY(new SimpleQuote(s5yQuoteJPY)); > boost::shared_ptr<Quote> s6yRateJPY(new SimpleQuote(s6yQuoteJPY)); > boost::shared_ptr<Quote> s7yRateJPY(new SimpleQuote(s7yQuoteJPY)); > boost::shared_ptr<Quote> s8yRateJPY(new SimpleQuote(s8yQuoteJPY)); > > DayCounter depositDayCounterJPY = Actual360(); > > boost::shared_ptr<RateHelper> d3mJPY(new DepositRateHelper( > Handle<Quote>(d3mRateJPY), > 3 * Months, fixingDays, > calendar, ModifiedFollowing, > true, depositDayCounterJPY)); > > boost::shared_ptr<RateHelper> fra1x4JPY(new FraRateHelper( > Handle<Quote>(fra1x4RateJPY), > 1, 4, fixingDays, calendar, ModifiedFollowing, > true, depositDayCounterJPY)); > boost::shared_ptr<RateHelper> fra2x5JPY(new FraRateHelper( > Handle<Quote>(fra2x5RateJPY), > 2, 5, fixingDays, calendar, ModifiedFollowing, > true, depositDayCounterJPY)); > boost::shared_ptr<RateHelper> fra3x6JPY(new FraRateHelper( > Handle<Quote>(fra3x6RateJPY), > 3, 6, fixingDays, calendar, ModifiedFollowing, > true, depositDayCounterJPY)); > boost::shared_ptr<RateHelper> fra4x7JPY(new FraRateHelper( > Handle<Quote>(fra4x7RateJPY), > 4, 7, fixingDays, calendar, ModifiedFollowing, > true, depositDayCounterJPY)); > boost::shared_ptr<RateHelper> fra5x8JPY(new FraRateHelper( > Handle<Quote>(fra5x8RateJPY), > 5, 8, fixingDays, calendar, ModifiedFollowing, > true, depositDayCounterJPY)); > boost::shared_ptr<RateHelper> fra6x9JPY(new FraRateHelper( > Handle<Quote>(fra6x9RateJPY), > 6, 9, fixingDays, calendar, ModifiedFollowing, > true, depositDayCounterJPY)); > boost::shared_ptr<RateHelper> fra7x10JPY(new FraRateHelper( > Handle<Quote>(fra7x10RateJPY), > 7, 10, fixingDays, calendar, ModifiedFollowing, > true, depositDayCounterJPY)); > boost::shared_ptr<RateHelper> fra8x11JPY(new FraRateHelper( > Handle<Quote>(fra8x11RateJPY), > 8, 11, fixingDays, calendar, ModifiedFollowing, > true, depositDayCounterJPY)); > boost::shared_ptr<RateHelper> fra9x12JPY(new FraRateHelper( > Handle<Quote>(fra9x12RateJPY), > 9, 12, fixingDays, calendar, ModifiedFollowing, > true, depositDayCounterJPY)); > > Integer futMonthsJPY = 3; > Date imm = IMM::nextDate(settlementDate); > boost::shared_ptr<RateHelper> fut18JPY(new FuturesRateHelper( > Handle<Quote>(fut18PriceJPY), > imm, > futMonthsJPY, calendar, ModifiedFollowing, > true, depositDayCounterJPY)); > > Frequency frequencyJPY = Quarterly; > BusinessDayConvention conventionJPY = Unadjusted; > DayCounter dayCounterJPY = Thirty360(Thirty360::European); > boost::shared_ptr<IborIndex> indexJPY(new Euribor6M); > > boost::shared_ptr<RateHelper> s2yJPY(new SwapRateHelper( > Handle<Quote>(s2yRateJPY), 2 * Years, > calendar, frequencyJPY, > conventionJPY, dayCounterJPY, > indexJPY)); > boost::shared_ptr<RateHelper> s3yJPY(new SwapRateHelper( > Handle<Quote>(s3yRateJPY), 3 * Years, > calendar, frequencyJPY, > conventionJPY, dayCounterJPY, > indexJPY)); > boost::shared_ptr<RateHelper> s4yJPY(new SwapRateHelper( > Handle<Quote>(s4yRateJPY), 4 * Years, > calendar, frequencyJPY, > conventionJPY, dayCounterJPY, > indexJPY)); > boost::shared_ptr<RateHelper> s5yJPY(new SwapRateHelper( > Handle<Quote>(s5yRateJPY), 5 * Years, > calendar, frequencyJPY, > conventionJPY, dayCounterJPY, > indexJPY)); > boost::shared_ptr<RateHelper> s6yJPY(new SwapRateHelper( > Handle<Quote>(s6yRateJPY), 6 * Years, > calendar, frequencyJPY, > conventionJPY, dayCounterJPY, > indexJPY)); > boost::shared_ptr<RateHelper> s7yJPY(new SwapRateHelper( > Handle<Quote>(s7yRateJPY), 7 * Years, > calendar, frequencyJPY, > conventionJPY, dayCounterJPY, > indexJPY)); > boost::shared_ptr<RateHelper> s8yJPY(new SwapRateHelper( > Handle<Quote>(s8yRateJPY), 8 * Years, > calendar, frequencyJPY, > conventionJPY, dayCounterJPY, > indexJPY)); > > std::vector<boost::shared_ptr<RateHelper> > swapInstrumentsJPY; > swapInstrumentsJPY.push_back(d3mJPY); > swapInstrumentsJPY.push_back(fra1x4JPY); > swapInstrumentsJPY.push_back(fra2x5JPY); > swapInstrumentsJPY.push_back(fra3x6JPY); > swapInstrumentsJPY.push_back(fra4x7JPY); > swapInstrumentsJPY.push_back(fra5x8JPY); > swapInstrumentsJPY.push_back(fra6x9JPY); > swapInstrumentsJPY.push_back(fra7x10JPY); > swapInstrumentsJPY.push_back(fra8x11JPY); > swapInstrumentsJPY.push_back(fra9x12JPY); > swapInstrumentsJPY.push_back(fut18JPY); > swapInstrumentsJPY.push_back(s2yJPY); > swapInstrumentsJPY.push_back(s3yJPY); > swapInstrumentsJPY.push_back(s4yJPY); > swapInstrumentsJPY.push_back(s5yJPY); > swapInstrumentsJPY.push_back(s6yJPY); > swapInstrumentsJPY.push_back(s7yJPY); > swapInstrumentsJPY.push_back(s8yJPY); > boost::shared_ptr<YieldTermStructure> swapTermStructureJPY( > new PiecewiseYieldCurve<Discount, LogLinear>( > settlementDate, swapInstrumentsJPY, > termStructureDayCounter, > tolerance)); > > RelinkableHandle<YieldTermStructure> discountingTermStructureJPY; > > RelinkableHandle<YieldTermStructure> forecastingTermStructureJPY; > > // JPY leg > > std::vector<Real> notionalJPY; > notionalJPY.push_back(16000000000); > notionalJPY.push_back(16000000000); > notionalJPY.push_back(16000000000); > notionalJPY.push_back(16000000000); > > boost::shared_ptr<IborIndex> euriborIndexJPY( > new Euribor6M(forecastingTermStructureJPY)); > > Spread spreadJPY = -0.0069; > > VanillaSwap::Type swapTypeJPY = VanillaSwap::Payer; > > Schedule scheduleJPY(settlementDate, maturity, > Period(frequencyJPY), > calendar, conventionJPY, > conventionJPY, > DateGeneration::Forward, false); > > NonstandardSwap dummyJPYSwap(swapTypeJPY, notionalDummy, notionalJPY, > scheduleJPY, fixedRate, > dayCounterJPY, scheduleJPY, > euriborIndexJPY, 1.0, spreadJPY, > dayCounterJPY, false, false, conventionJPY); > > Real NPVJPY; > Real NPVmySwap; > > boost::shared_ptr<PricingEngine> swapEngineJPY( > new DiscountingSwapEngine(discountingTermStructureJPY)); > > dummyJPYSwap.setPricingEngine(swapEngineJPY); > > forecastingTermStructureJPY.linkTo(swapTermStructureJPY); > discountingTermStructureJPY.linkTo(swapTermStructureJPY); > > NPVJPY = dummyJPYSwap.NPV(); > > NPVmySwap = NPVUSD - NPVJPY; > > return 0; > > } > catch (std::exception& e) { > std::cerr << e.what() << std::endl; > return 1; > } > catch (...) { > std::cerr << "unknown error" << std::endl; > return 1; > } > } > /////////////////////////// > > Thanks, > > Dragomir > > > > > > -----Original Message----- > From: Peter Caspers [mailto:[hidden email]] > Sent: Tuesday, January 26, 2016 9:41 PM > To: Dragomir Nedeltchev > Cc: [hidden email] > Subject: Re: [Quantlib-users] pricing Mark-To-Market Cross-Currency Swap > > Hi Dragomir, > > yes, in that direction. Just a few thoughts. > > - there are Libor indices in USD and JPY you can use, no need to go for Euribor > - the dummy notional has to be a vector, too (containing 0.0, that's ok) > - the gearing should be 1.0 ? It is the multiplier for the ibor fixing before adding the spread. > - the NPVs have to be converted to one currency before adding them > > I did not read every line of the code - just give it a try and if you run into problems, just write back here, ok? Do you have a reference to compare the NPV with? > > Regards > Peter > > > On 26 January 2016 at 14:36, Dragomir Nedeltchev <[hidden email]> wrote: >> Hi Peter, >> >> Below you will find the code for the swap in question, if I got your point correctly. >> >> The vector of floating notional was calculated by the forward JPYUSD >> rate. Market data copy/paste the swapvaluation.cpp for both JPY and >> USD; later I will insert actual numbers >> >> Thanks, >> >> Dragomir >> >> ///////////////////////////// >> #include <ql/quantlib.hpp> >> >> #include <iostream> >> #include <iomanip> >> >> using namespace QuantLib; >> >> >> int main(int, char* []) { >> >> try { >> >> >> >> /********************* >> *** MARKET DATA *** >> *********************/ >> >> Calendar calendar = TARGET(); >> Date settlementDate(03, October, 2016); >> settlementDate = calendar.adjust(settlementDate); >> >> Integer fixingDays = 2; >> >> Date todaysDate(26, January, 2016); >> >> Settings::instance().evaluationDate() = todaysDate; >> >> todaysDate = Settings::instance().evaluationDate(); >> >> //USD leg >> Rate d1wQuoteUSD=0.0382; >> Rate d1mQuoteUSD=0.0372; >> Rate d3mQuoteUSD=0.0363; >> Rate d6mQuoteUSD=0.0353; >> Rate d9mQuoteUSD=0.0348; >> Rate d1yQuoteUSD=0.0345; >> >> Rate fra3x6QuoteUSD=0.037125; >> Rate fra6x9QuoteUSD=0.037125; >> Rate fra6x12QuoteUSD=0.037125; >> >> Real fut1QuoteUSD=96.2875; >> Real fut2QuoteUSD=96.7875; >> Real fut3QuoteUSD=96.9875; >> Real fut4QuoteUSD=96.6875; >> Real fut5QuoteUSD=96.4875; >> Real fut6QuoteUSD=96.3875; >> Real fut7QuoteUSD=96.2875; >> Real fut8QuoteUSD=96.0875; >> >> Rate s2yQuoteUSD=0.037125; >> Rate s3yQuoteUSD=0.0398; >> Rate s5yQuoteUSD=0.0443; >> Rate s10yQuoteUSD=0.05165; >> Rate s15yQuoteUSD=0.055175; >> >> //JPY leg >> >> Rate d1wQuoteJPY=0.0382; >> Rate d1mQuoteJPY=0.0372; >> Rate d3mQuoteJPY=0.0363; >> Rate d6mQuoteJPY=0.0353; >> Rate d9mQuoteJPY=0.0348; >> Rate d1yQuoteJPY=0.0345; >> >> Rate fra3x6QuoteJPY=0.037125; >> Rate fra6x9QuoteJPY=0.037125; >> Rate fra6x12QuoteJPY=0.037125; >> >> Real fut1QuoteJPY=96.2875; >> Real fut2QuoteJPY=96.7875; >> Real fut3QuoteJPY=96.9875; >> Real fut4QuoteJPY=96.6875; >> Real fut5QuoteJPY=96.4875; >> Real fut6QuoteJPY=96.3875; >> Real fut7QuoteJPY=96.2875; >> Real fut8QuoteJPY=96.0875; >> >> Rate s2yQuoteJPY=0.037125; >> Rate s3yQuoteJPY=0.0398; >> Rate s5yQuoteJPY=0.0443; >> Rate s10yQuoteJPY=0.05165; >> Rate s15yQuoteJPY=0.055175; >> >> >> /******************** >> *** QUOTES *** >> ********************/ >> >> //USD leg >> >> >> boost::shared_ptr<Quote> d1wRateUSD(new SimpleQuote(d1wQuoteUSD)); >> boost::shared_ptr<Quote> d1mRateUSD(new SimpleQuote(d1mQuoteUSD)); >> boost::shared_ptr<Quote> d3mRateUSD(new SimpleQuote(d3mQuoteUSD)); >> boost::shared_ptr<Quote> d6mRateUSD(new SimpleQuote(d6mQuoteUSD)); >> boost::shared_ptr<Quote> d9mRateUSD(new SimpleQuote(d9mQuoteUSD)); >> boost::shared_ptr<Quote> d1yRateUSD(new >> SimpleQuote(d1yQuoteUSD)); >> >> boost::shared_ptr<Quote> fra3x6RateUSD(new SimpleQuote(fra3x6QuoteUSD)); >> boost::shared_ptr<Quote> fra6x9RateUSD(new SimpleQuote(fra6x9QuoteUSD)); >> boost::shared_ptr<Quote> fra6x12RateUSD(new >> SimpleQuote(fra6x12QuoteUSD)); >> >> boost::shared_ptr<Quote> fut1PriceUSD(new SimpleQuote(fut1QuoteUSD)); >> boost::shared_ptr<Quote> fut2PriceUSD(new SimpleQuote(fut2QuoteUSD)); >> boost::shared_ptr<Quote> fut3PriceUSD(new SimpleQuote(fut3QuoteUSD)); >> boost::shared_ptr<Quote> fut4PriceUSD(new SimpleQuote(fut4QuoteUSD)); >> boost::shared_ptr<Quote> fut5PriceUSD(new SimpleQuote(fut5QuoteUSD)); >> boost::shared_ptr<Quote> fut6PriceUSD(new SimpleQuote(fut6QuoteUSD)); >> boost::shared_ptr<Quote> fut7PriceUSD(new SimpleQuote(fut7QuoteUSD)); >> boost::shared_ptr<Quote> fut8PriceUSD(new >> SimpleQuote(fut8QuoteUSD)); >> >> boost::shared_ptr<Quote> s2yRateUSD(new SimpleQuote(s2yQuoteUSD)); >> boost::shared_ptr<Quote> s3yRateUSD(new SimpleQuote(s3yQuoteUSD)); >> boost::shared_ptr<Quote> s5yRateUSD(new SimpleQuote(s5yQuoteUSD)); >> boost::shared_ptr<Quote> s10yRateUSD(new SimpleQuote(s10yQuoteUSD)); >> boost::shared_ptr<Quote> s15yRateUSD(new >> SimpleQuote(s15yQuoteUSD)); >> >> //JPY leg >> >> boost::shared_ptr<Quote> d1wRateJPY(new SimpleQuote(d1wQuoteJPY)); >> boost::shared_ptr<Quote> d1mRateJPY(new SimpleQuote(d1mQuoteJPY)); >> boost::shared_ptr<Quote> d3mRateJPY(new SimpleQuote(d3mQuoteJPY)); >> boost::shared_ptr<Quote> d6mRateJPY(new SimpleQuote(d6mQuoteJPY)); >> boost::shared_ptr<Quote> d9mRateJPY(new SimpleQuote(d9mQuoteJPY)); >> boost::shared_ptr<Quote> d1yRateJPY(new >> SimpleQuote(d1yQuoteJPY)); >> >> boost::shared_ptr<Quote> fra3x6RateJPY(new SimpleQuote(fra3x6QuoteJPY)); >> boost::shared_ptr<Quote> fra6x9RateJPY(new SimpleQuote(fra6x9QuoteJPY)); >> boost::shared_ptr<Quote> fra6x12RateJPY(new >> SimpleQuote(fra6x12QuoteJPY)); >> >> boost::shared_ptr<Quote> fut1PriceJPY(new SimpleQuote(fut1QuoteJPY)); >> boost::shared_ptr<Quote> fut2PriceJPY(new SimpleQuote(fut2QuoteJPY)); >> boost::shared_ptr<Quote> fut3PriceJPY(new SimpleQuote(fut3QuoteJPY)); >> boost::shared_ptr<Quote> fut4PriceJPY(new SimpleQuote(fut4QuoteJPY)); >> boost::shared_ptr<Quote> fut5PriceJPY(new SimpleQuote(fut5QuoteJPY)); >> boost::shared_ptr<Quote> fut6PriceJPY(new SimpleQuote(fut6QuoteJPY)); >> boost::shared_ptr<Quote> fut7PriceJPY(new SimpleQuote(fut7QuoteJPY)); >> boost::shared_ptr<Quote> fut8PriceJPY(new >> SimpleQuote(fut8QuoteJPY)); >> >> boost::shared_ptr<Quote> s2yRateJPY(new SimpleQuote(s2yQuoteJPY)); >> boost::shared_ptr<Quote> s3yRateJPY(new SimpleQuote(s3yQuoteJPY)); >> boost::shared_ptr<Quote> s5yRateJPY(new SimpleQuote(s5yQuoteJPY)); >> boost::shared_ptr<Quote> s10yRateJPY(new SimpleQuote(s10yQuoteJPY)); >> boost::shared_ptr<Quote> s15yRateJPY(new >> SimpleQuote(s15yQuoteJPY)); >> >> /********************* >> *** RATE HELPERS *** >> *********************/ >> //USD leg >> >> >> DayCounter depositDayCounterUSD = Actual360(); >> >> boost::shared_ptr<RateHelper> d1wUSD(new DepositRateHelper( >> Handle<Quote>(d1wRateUSD), >> 1*Weeks, fixingDays, >> calendar, ModifiedFollowing, >> true, depositDayCounterUSD)); >> boost::shared_ptr<RateHelper> d1mUSD(new DepositRateHelper( >> Handle<Quote>(d1mRateUSD), >> 1*Months, fixingDays, >> calendar, ModifiedFollowing, >> true, depositDayCounterUSD)); >> boost::shared_ptr<RateHelper> d3mUSD(new DepositRateHelper( >> Handle<Quote>(d3mRateUSD), >> 3*Months, fixingDays, >> calendar, ModifiedFollowing, >> true, depositDayCounterUSD)); >> boost::shared_ptr<RateHelper> d6mUSD(new DepositRateHelper( >> Handle<Quote>(d6mRateUSD), >> 6*Months, fixingDays, >> calendar, ModifiedFollowing, >> true, depositDayCounterUSD)); >> boost::shared_ptr<RateHelper> d9mUSD(new DepositRateHelper( >> Handle<Quote>(d9mRateUSD), >> 9*Months, fixingDays, >> calendar, ModifiedFollowing, >> true, depositDayCounterUSD)); >> boost::shared_ptr<RateHelper> d1yUSD(new DepositRateHelper( >> Handle<Quote>(d1yRateUSD), >> 1*Years, fixingDays, >> calendar, ModifiedFollowing, >> true, depositDayCounterUSD)); >> >> boost::shared_ptr<RateHelper> fra3x6USD(new FraRateHelper( >> Handle<Quote>(fra3x6RateUSD), >> 3, 6, fixingDays, calendar, ModifiedFollowing, >> true, depositDayCounterUSD)); >> boost::shared_ptr<RateHelper> fra6x9USD(new FraRateHelper( >> Handle<Quote>(fra6x9RateUSD), >> 6, 9, fixingDays, calendar, ModifiedFollowing, >> true, depositDayCounterUSD)); >> boost::shared_ptr<RateHelper> fra6x12USD(new FraRateHelper( >> Handle<Quote>(fra6x12RateUSD), >> 6, 12, fixingDays, calendar, ModifiedFollowing, >> true, depositDayCounterUSD)); >> >> Integer futMonthsUSD = 3; >> Date imm = IMM::nextDate(settlementDate); >> boost::shared_ptr<RateHelper> fut1USD(new FuturesRateHelper( >> Handle<Quote>(fut1PriceUSD), >> imm, >> futMonthsUSD, calendar, ModifiedFollowing, >> true, depositDayCounterUSD)); >> imm = IMM::nextDate(imm+1); >> boost::shared_ptr<RateHelper> fut2USD(new FuturesRateHelper( >> Handle<Quote>(fut2PriceUSD), >> imm, >> futMonthsUSD, calendar, ModifiedFollowing, >> true, depositDayCounterUSD)); >> imm = IMM::nextDate(imm+1); >> boost::shared_ptr<RateHelper> fut3USD(new FuturesRateHelper( >> Handle<Quote>(fut3PriceUSD), >> imm, >> futMonthsUSD, calendar, ModifiedFollowing, >> true, depositDayCounterUSD)); >> imm = IMM::nextDate(imm+1); >> boost::shared_ptr<RateHelper> fut4USD(new FuturesRateHelper( >> Handle<Quote>(fut4PriceUSD), >> imm, >> futMonthsUSD, calendar, ModifiedFollowing, >> true, depositDayCounterUSD)); >> imm = IMM::nextDate(imm+1); >> boost::shared_ptr<RateHelper> fut5USD(new FuturesRateHelper( >> Handle<Quote>(fut5PriceUSD), >> imm, >> futMonthsUSD, calendar, ModifiedFollowing, >> true, depositDayCounterUSD)); >> imm = IMM::nextDate(imm+1); >> boost::shared_ptr<RateHelper> fut6USD(new FuturesRateHelper( >> Handle<Quote>(fut6PriceUSD), >> imm, >> futMonthsUSD, calendar, ModifiedFollowing, >> true, depositDayCounterUSD)); >> imm = IMM::nextDate(imm+1); >> boost::shared_ptr<RateHelper> fut7USD(new FuturesRateHelper( >> Handle<Quote>(fut7PriceUSD), >> imm, >> futMonthsUSD, calendar, ModifiedFollowing, >> true, depositDayCounterUSD)); >> imm = IMM::nextDate(imm+1); >> boost::shared_ptr<RateHelper> fut8USD(new FuturesRateHelper( >> Handle<Quote>(fut8PriceUSD), >> imm, >> futMonthsUSD, calendar, ModifiedFollowing, >> true, depositDayCounterUSD)); >> >> Frequency frequencyUSD = Quarterly; >> BusinessDayConvention conventionUSD = Unadjusted; >> DayCounter dayCounterUSD = Thirty360(Thirty360::USA); >> boost::shared_ptr<IborIndex> indexUSD(new Euribor6M); >> >> boost::shared_ptr<RateHelper> s2yUSD(new SwapRateHelper( >> Handle<Quote>(s2yRateUSD), 2*Years, >> calendar, frequencyUSD, >> conventionUSD, dayCounterUSD, >> indexUSD)); >> boost::shared_ptr<RateHelper> s3yUSD(new SwapRateHelper( >> Handle<Quote>(s3yRateUSD), 3*Years, >> calendar, frequencyUSD, >> conventionUSD, dayCounterUSD, >> indexUSD)); >> boost::shared_ptr<RateHelper> s5yUSD(new SwapRateHelper( >> Handle<Quote>(s5yRateUSD), 5*Years, >> calendar, frequencyUSD, >> conventionUSD, dayCounterUSD, >> indexUSD)); >> boost::shared_ptr<RateHelper> s10yUSD(new SwapRateHelper( >> Handle<Quote>(s10yRateUSD), 10*Years, >> calendar, frequencyUSD, >> conventionUSD, dayCounterUSD, >> indexUSD)); >> boost::shared_ptr<RateHelper> s15yUSD(new SwapRateHelper( >> Handle<Quote>(s15yRateUSD), 15*Years, >> calendar, frequencyUSD, >> conventionUSD, dayCounterUSD, >> indexUSD)); >> >> //JPY leg >> >> >> DayCounter depositDayCounterJPY = Actual360(); >> >> boost::shared_ptr<RateHelper> d1wJPY(new DepositRateHelper( >> Handle<Quote>(d1wRateJPY), >> 1*Weeks, fixingDays, >> calendar, ModifiedFollowing, >> true, depositDayCounterJPY)); >> boost::shared_ptr<RateHelper> d1mJPY(new DepositRateHelper( >> Handle<Quote>(d1mRateJPY), >> 1*Months, fixingDays, >> calendar, ModifiedFollowing, >> true, depositDayCounterJPY)); >> boost::shared_ptr<RateHelper> d3mJPY(new DepositRateHelper( >> Handle<Quote>(d3mRateJPY), >> 3*Months, fixingDays, >> calendar, ModifiedFollowing, >> true, depositDayCounterJPY)); >> boost::shared_ptr<RateHelper> d6mJPY(new DepositRateHelper( >> Handle<Quote>(d6mRateJPY), >> 6*Months, fixingDays, >> calendar, ModifiedFollowing, >> true, depositDayCounterJPY)); >> boost::shared_ptr<RateHelper> d9mJPY(new DepositRateHelper( >> Handle<Quote>(d9mRateJPY), >> 9*Months, fixingDays, >> calendar, ModifiedFollowing, >> true, depositDayCounterJPY)); >> boost::shared_ptr<RateHelper> d1yJPY(new DepositRateHelper( >> Handle<Quote>(d1yRateJPY), >> 1*Years, fixingDays, >> calendar, ModifiedFollowing, >> true, depositDayCounterJPY)); >> >> boost::shared_ptr<RateHelper> fra3x6JPY(new FraRateHelper( >> Handle<Quote>(fra3x6RateJPY), >> 3, 6, fixingDays, calendar, ModifiedFollowing, >> true, depositDayCounterJPY)); >> boost::shared_ptr<RateHelper> fra6x9JPY(new FraRateHelper( >> Handle<Quote>(fra6x9RateJPY), >> 6, 9, fixingDays, calendar, ModifiedFollowing, >> true, depositDayCounterJPY)); >> boost::shared_ptr<RateHelper> fra6x12JPY(new FraRateHelper( >> Handle<Quote>(fra6x12RateJPY), >> 6, 12, fixingDays, calendar, ModifiedFollowing, >> true, depositDayCounterJPY)); >> >> Integer futMonthsJPY = 3; >> Date imm = IMM::nextDate(settlementDate); >> boost::shared_ptr<RateHelper> fut1JPY(new FuturesRateHelper( >> Handle<Quote>(fut1PriceJPY), >> imm, >> futMonthsJPY, calendar, ModifiedFollowing, >> true, depositDayCounterJPY)); >> imm = IMM::nextDate(imm+1); >> boost::shared_ptr<RateHelper> fut2JPY(new FuturesRateHelper( >> Handle<Quote>(fut2PriceJPY), >> imm, >> futMonthsJPY, calendar, ModifiedFollowing, >> true, depositDayCounterJPY)); >> imm = IMM::nextDate(imm+1); >> boost::shared_ptr<RateHelper> fut3JPY(new FuturesRateHelper( >> Handle<Quote>(fut3PriceJPY), >> imm, >> futMonthsJPY, calendar, ModifiedFollowing, >> true, depositDayCounterJPY)); >> imm = IMM::nextDate(imm+1); >> boost::shared_ptr<RateHelper> fut4JPY(new FuturesRateHelper( >> Handle<Quote>(fut4PriceJPY), >> imm, >> futMonthsJPY, calendar, ModifiedFollowing, >> true, depositDayCounterJPY)); >> imm = IMM::nextDate(imm+1); >> boost::shared_ptr<RateHelper> fut5JPY(new FuturesRateHelper( >> Handle<Quote>(fut5PriceJPY), >> imm, >> futMonthsJPY, calendar, ModifiedFollowing, >> true, depositDayCounterJPY)); >> imm = IMM::nextDate(imm+1); >> boost::shared_ptr<RateHelper> fut6JPY(new FuturesRateHelper( >> Handle<Quote>(fut6PriceJPY), >> imm, >> futMonthsJPY, calendar, ModifiedFollowing, >> true, depositDayCounterJPY)); >> imm = IMM::nextDate(imm+1); >> boost::shared_ptr<RateHelper> fut7JPY(new FuturesRateHelper( >> Handle<Quote>(fut7PriceJPY), >> imm, >> futMonthsJPY, calendar, ModifiedFollowing, >> true, depositDayCounterJPY)); >> imm = IMM::nextDate(imm+1); >> boost::shared_ptr<RateHelper> fut8JPY(new FuturesRateHelper( >> Handle<Quote>(fut8PriceJPY), >> imm, >> futMonthsJPY, calendar, ModifiedFollowing, >> true, depositDayCounterJPY)); >> >> Frequency frequencyJPY = Quarterly; >> BusinessDayConvention conventionJPY = Unadjusted; >> DayCounter dayCounterJPY = Thirty360(Thirty360::European); >> boost::shared_ptr<IborIndex> indexJPY(new Euribor6M); >> >> boost::shared_ptr<RateHelper> s2yJPY(new SwapRateHelper( >> Handle<Quote>(s2yRateJPY), 2*Years, >> calendar, frequencyJPY, >> conventionJPY, dayCounterJPY, >> indexJPY)); >> boost::shared_ptr<RateHelper> s3yJPY(new SwapRateHelper( >> Handle<Quote>(s3yRateJPY), 3*Years, >> calendar, frequencyJPY, >> conventionJPY, dayCounterJPY, >> indexJPY)); >> boost::shared_ptr<RateHelper> s5yJPY(new SwapRateHelper( >> Handle<Quote>(s5yRateJPY), 5*Years, >> calendar, frequencyJPY, >> conventionJPY, dayCounterJPY, >> indexJPY)); >> boost::shared_ptr<RateHelper> s10yJPY(new SwapRateHelper( >> Handle<Quote>(s10yRateJPY), 10*Years, >> calendar, frequencyJPY, >> conventionJPY, dayCounterJPY, >> indexJPY)); >> boost::shared_ptr<RateHelper> s15yJPY(new SwapRateHelper( >> Handle<Quote>(s15yRateJPY), 15*Years, >> calendar, frequencyJPY, >> conventionJPY, dayCounterJPY, >> indexJPY)); >> >> /********************* >> ** CURVEs BUILDING ** >> *********************/ >> >> DayCounter termStructureDayCounter = >> ActualActual(ActualActual::ISDA); >> >> double tolerance = 1.0e-15; >> >> std::vector<boost::shared_ptr<RateHelper> > depoSwapInstrumentsUSD; >> depoSwapInstrumentsUSD.push_back(d1wUSD); >> depoSwapInstrumentsUSD.push_back(d1mUSD); >> depoSwapInstrumentsUSD.push_back(d3mUSD); >> depoSwapInstrumentsUSD.push_back(d6mUSD); >> depoSwapInstrumentsUSD.push_back(d9mUSD); >> depoSwapInstrumentsUSD.push_back(d1yUSD); >> depoSwapInstrumentsUSD.push_back(s2yUSD); >> depoSwapInstrumentsUSD.push_back(s3yUSD); >> depoSwapInstrumentsUSD.push_back(s5yUSD); >> depoSwapInstrumentsUSD.push_back(s10yUSD); >> depoSwapInstrumentsUSD.push_back(s15yUSD); >> boost::shared_ptr<YieldTermStructure> depoSwapTermStructureUSD( >> new PiecewiseYieldCurve<Discount,LogLinear>( >> settlementDate, depoSwapInstrumentsUSD, >> termStructureDayCounter, >> tolerance)); >> >> std::vector<boost::shared_ptr<RateHelper> > depoFutSwapInstrumentsUSD; >> depoFutSwapInstrumentsUSD.push_back(d1wUSD); >> depoFutSwapInstrumentsUSD.push_back(d1mUSD); >> depoFutSwapInstrumentsUSD.push_back(fut1USD); >> depoFutSwapInstrumentsUSD.push_back(fut2USD); >> depoFutSwapInstrumentsUSD.push_back(fut3USD); >> depoFutSwapInstrumentsUSD.push_back(fut4USD); >> depoFutSwapInstrumentsUSD.push_back(fut5USD); >> depoFutSwapInstrumentsUSD.push_back(fut6USD); >> depoFutSwapInstrumentsUSD.push_back(fut7USD); >> depoFutSwapInstrumentsUSD.push_back(fut8USD); >> depoFutSwapInstrumentsUSD.push_back(s3yUSD); >> depoFutSwapInstrumentsUSD.push_back(s5yUSD); >> depoFutSwapInstrumentsUSD.push_back(s10yUSD); >> depoFutSwapInstrumentsUSD.push_back(s15yUSD); >> boost::shared_ptr<YieldTermStructure> depoFutSwapTermStructureUSD( >> new PiecewiseYieldCurve<Discount,LogLinear>( >> settlementDate, depoFutSwapInstrumentsUSD, >> termStructureDayCounter, >> tolerance)); >> >> std::vector<boost::shared_ptr<RateHelper> > depoFRASwapInstrumentsUSD; >> depoFRASwapInstrumentsUSD.push_back(d1wUSD); >> depoFRASwapInstrumentsUSD.push_back(d1mUSD); >> depoFRASwapInstrumentsUSD.push_back(d3mUSD); >> depoFRASwapInstrumentsUSD.push_back(fra3x6USD); >> depoFRASwapInstrumentsUSD.push_back(fra6x9USD); >> depoFRASwapInstrumentsUSD.push_back(fra6x12USD); >> depoFRASwapInstrumentsUSD.push_back(s2yUSD); >> depoFRASwapInstrumentsUSD.push_back(s3yUSD); >> depoFRASwapInstrumentsUSD.push_back(s5yUSD); >> depoFRASwapInstrumentsUSD.push_back(s10yUSD); >> depoFRASwapInstrumentsUSD.push_back(s15yUSD); >> boost::shared_ptr<YieldTermStructure> depoFRASwapTermStructureUSD( >> new PiecewiseYieldCurve<Discount,LogLinear>( >> settlementDate, depoFRASwapInstrumentsUSD, >> termStructureDayCounter, >> tolerance)); >> >> RelinkableHandle<YieldTermStructure> >> discountingTermStructureUSD; >> >> RelinkableHandle<YieldTermStructure> >> forecastingTermStructureUSD; >> >> //JPY leg >> >> std::vector<boost::shared_ptr<RateHelper> > depoSwapInstrumentsJPY; >> depoSwapInstrumentsJPY.push_back(d1wJPY); >> depoSwapInstrumentsJPY.push_back(d1mJPY); >> depoSwapInstrumentsJPY.push_back(d3mJPY); >> depoSwapInstrumentsJPY.push_back(d6mJPY); >> depoSwapInstrumentsJPY.push_back(d9mJPY); >> depoSwapInstrumentsJPY.push_back(d1yJPY); >> depoSwapInstrumentsJPY.push_back(s2yJPY); >> depoSwapInstrumentsJPY.push_back(s3yJPY); >> depoSwapInstrumentsJPY.push_back(s5yJPY); >> depoSwapInstrumentsJPY.push_back(s10yJPY); >> depoSwapInstrumentsJPY.push_back(s15yJPY); >> boost::shared_ptr<YieldTermStructure> depoSwapTermStructureJPY( >> new PiecewiseYieldCurve<Discount,LogLinear>( >> settlementDate, depoSwapInstrumentsJPY, >> termStructureDayCounter, >> tolerance)); >> >> std::vector<boost::shared_ptr<RateHelper> > depoFutSwapInstrumentsJPY; >> depoFutSwapInstrumentsJPY.push_back(d1wJPY); >> depoFutSwapInstrumentsJPY.push_back(d1mJPY); >> depoFutSwapInstrumentsJPY.push_back(fut1JPY); >> depoFutSwapInstrumentsJPY.push_back(fut2JPY); >> depoFutSwapInstrumentsJPY.push_back(fut3JPY); >> depoFutSwapInstrumentsJPY.push_back(fut4JPY); >> depoFutSwapInstrumentsJPY.push_back(fut5JPY); >> depoFutSwapInstrumentsJPY.push_back(fut6JPY); >> depoFutSwapInstrumentsJPY.push_back(fut7JPY); >> depoFutSwapInstrumentsJPY.push_back(fut8JPY); >> depoFutSwapInstrumentsJPY.push_back(s3yJPY); >> depoFutSwapInstrumentsJPY.push_back(s5yJPY); >> depoFutSwapInstrumentsJPY.push_back(s10yJPY); >> depoFutSwapInstrumentsJPY.push_back(s15yJPY); >> boost::shared_ptr<YieldTermStructure> depoFutSwapTermStructureJPY( >> new PiecewiseYieldCurve<Discount,LogLinear>( >> settlementDate, depoFutSwapInstrumentsJPY, >> termStructureDayCounter, >> tolerance)); >> >> std::vector<boost::shared_ptr<RateHelper> > depoFRASwapInstrumentsJPY; >> depoFRASwapInstrumentsJPY.push_back(d1wJPY); >> depoFRASwapInstrumentsJPY.push_back(d1mJPY); >> depoFRASwapInstrumentsJPY.push_back(d3mJPY); >> depoFRASwapInstrumentsJPY.push_back(fra3x6JPY); >> depoFRASwapInstrumentsJPY.push_back(fra6x9JPY); >> depoFRASwapInstrumentsJPY.push_back(fra6x12JPY); >> depoFRASwapInstrumentsJPY.push_back(s2yJPY); >> depoFRASwapInstrumentsJPY.push_back(s3yJPY); >> depoFRASwapInstrumentsJPY.push_back(s5yJPY); >> depoFRASwapInstrumentsJPY.push_back(s10yJPY); >> depoFRASwapInstrumentsJPY.push_back(s15yJPY); >> boost::shared_ptr<YieldTermStructure> depoFRASwapTermStructureJPY( >> new PiecewiseYieldCurve<Discount,LogLinear>( >> settlementDate, depoFRASwapInstrumentsJPY, >> termStructureDayCounter, >> tolerance)); >> >> RelinkableHandle<YieldTermStructure> >> discountingTermStructureJPY; >> >> RelinkableHandle<YieldTermStructure> >> forecastingTermStructureJPY; >> >> /********************* >> * SWAPS TO BE PRICED * >> **********************/ >> >> Real nominalDummy = 0.0; >> >> std::vector<Real> nominalJPY; >> nominalJPY.push_back(16000000000); >> nominalJPY.push_back(16000000000); >> nominalJPY.push_back(16000000000); >> nominalJPY.push_back(16000000000); >> >> std::vector<Real> nominalUSD; >> nominalUSD.push_back(20000000); >> nominalUSD.push_back(20500000); >> nominalUSD.push_back(20100000); >> nominalUSD.push_back(20070000); >> >> // fixed leg >> Frequency frequencyDummy = Quarterly; >> BusinessDayConvention conventionDummy = Unadjusted; >> >> DayCounter dayCounterDummy = Thirty360(Thirty360::European); >> Rate fixedRate = 0.0; >> >> // floating leg >> BusinessDayConvention conventionUSD = ModifiedFollowing; >> BusinessDayConvention conventionJPY = ModifiedFollowing; >> DayCounter dayCounterUSD = Actual360(); >> DayCounter dayCounterJPY = Actual360();Frequency frequencyUSD = Quarterly; >> Frequency frequencyJPY = Quarterly; >> boost::shared_ptr<IborIndex> euriborIndexUSD( >> new Euribor6M(forecastingTermStructureUSD)); >> boost::shared_ptr<IborIndex> euriborIndexJPY( >> new Euribor6M(forecastingTermStructureJPY)); >> Spread spreadUSD = 0.0; >> Spread spreadJPY = -0.0069; >> >> Integer lenghtInYears = 1; >> VanillaSwap::Type swapTypeUSD = VanillaSwap::Receiver; >> VanillaSwap::Type swapTypeJPY = VanillaSwap::Payer; >> >> Date maturity = settlementDate + lenghtInYears*Years; >> Schedule fixedSchedule(settlementDate, maturity, >> Period(fixedLegFrequency), >> calendar, fixedLegConvention, >> fixedLegConvention, >> DateGeneration::Forward, false); >> Schedule floatScheduleUSD(settlementDate, maturity, >> Period(frequencyUSD), >> calendar, conventionUSD, >> conventionUSD, >> DateGeneration::Forward, false); >> Schedule floatScheduleJPY(settlementDate, maturity, >> Period(frequencyJPY), >> calendar, conventionJPY, >> conventionJPY, >> DateGeneration::Forward, false); >> >> NonStandardSwap dummyUSDSwap(swapTypeUSD, nominalDummy, nominalUSD, >> floatScheduleUSD, fixedRate, >> dayCounterDummy, floatScheduleUSD, >> euriborIndexUSD, QL_EPSILON, spreadUSD, >> dayCounterUSD, false, false, conventionUSD) >> NonStandardSwap dummyJPYSwap(swapTypeJPY, nominalDummy, nominalJPY, >> floatScheduleJPY, fixedRate, >> dayCounterDummy, floatScheduleJPY, >> euriborIndexJPY, QL_EPSILON, spreadJPY, >> dayCounterJPY, false, false, >> conventionJPY) >> >> /*************** >> * SWAP PRICING * >> ****************/ >> >> Real NPVUSD; >> Real NPVJPY; >> Real NPVmySwap; >> >> boost::shared_ptr<PricingEngine> swapEngineUSD( >> new >> DiscountingSwapEngine(discountingTermStructureUSD)); >> >> dummyUSDSwap.setPricingEngine(swapEngineUSD); >> >> forecastingTermStructureUSD.linkTo(depoSwapTermStructureUSD); >> discountingTermStructureUSD.linkTo(depoSwapTermStructureUSD); >> >> NPVUSD = dummyUSDSwap.NPV(); >> >> >> boost::shared_ptr<PricingEngine> swapEngineJPY( >> new >> DiscountingSwapEngine(discountingTermStructureJPY)); >> >> dummyJPYSwap.setPricingEngine(swapEngineJPY); >> >> forecastingTermStructureJPY.linkTo(depoSwapTermStructureJPY); >> discountingTermStructureJPY.linkTo(depoSwapTermStructureJPY); >> >> NPVJPY = dummyJPYSwap.NPV(); >> >> NPVmySwap = NPVUSD - NPVJPY; >> >> return 0; >> >> } catch (std::exception& e) { >> std::cerr << e.what() << std::endl; >> return 1; >> } catch (...) { >> std::cerr << "unknown error" << std::endl; >> return 1; >> } >> } >> //////////////////////////// >> >> -----Original Message----- >> From: Peter Caspers [mailto:[hidden email]] >> Sent: Monday, January 25, 2016 10:09 PM >> To: Dragomir Nedeltchev >> Cc: [hidden email] >> Subject: Re: [Quantlib-users] pricing Mark-To-Market Cross-Currency >> Swap >> >> Hi Dragomir, >> >> you have to create the schedules of your floating legs (which >> basically represent the series of their accrual periods), with >> effective Date = start of first accrual period (forward starting in >> your case), termination date = end of last accrual period. Then pass >> them together with the other parameters to the NonStandardSwap >> constructor. Note that you have to precalculate the deterministic >> notional schedule of the USD leg before, this is not handled in the >> NonstandardSwap either. The NonStandardSwaps accepts a vector of >> notionals corresponding to the accrual periods. You can set up the >> fixed schedule as equal to the floating schedule (whatever, it is not >> used) and with notionals zero. >> >> Then set up two DiscountingSwapEngines, assign them to your non standard swaps and extract the NPV from each one (which is in USD resp. JPY for the respective legs, because the instrument is a single currency instrument actually as well as the pricing engine). >> >> Regards >> Peter >> >> On 25 January 2016 at 09:44, Dragomir Nedeltchev <[hidden email]> wrote: >>> Hi Peter, >>> >>> Thank you for the prompt feedback. This seems to meet my needs. >>> >>> I deal with a 1Y5Y swap. How can I tackle this feature in a NonStandardSwap? >>> >>> I see there is VanillaSwap oneYearForward5YeraSwap, but the Vanilla Swap class doesn't treat the floating notional reset feature of the MTM swap. >>> >>> Thank you in advance. >>> >>> Kind regards, >>> >>> Dragomir >>> >>> -----Original Message----- >>> From: Peter Caspers [mailto:[hidden email]] >>> Sent: Sunday, January 24, 2016 2:08 PM >>> To: Dragomir Nedeltchev >>> Cc: [hidden email] >>> Subject: Re: [Quantlib-users] pricing Mark-To-Market Cross-Currency >>> Swap >>> >>> Hi Dragomir, >>> >>> there is no ready-to-use class in QuantLib for this I think. >>> >>> But as you say, you can repesent the mtm swap as two single legs with a customized notional schedule for one of them. Beneath the bond classes you can also use the NonStandardSwap I guess (setting the fixed leg's nominals to zero and only use the floating leg for each mtm swap leg) and do the valuation of the single legs with two DiscountingSwapEngine's attaching appropriate discount curves for USD and JPY. >>> >>> Kind Regards >>> Peter >>> >>> On 22 January 2016 at 08:47, Dragomir Nedeltchev <[hidden email]> wrote: >>>> Hi All, >>>> >>>> >>>> >>>> I am pricing a Mark-To-Market JPYUSD Swap. >>>> >>>> >>>> >>>> Advise please which swap class of QuantLib serves this purpose. >>>> >>>> >>>> >>>> Can I present the swap as a JPY floating bond and a USD amortizing >>>> floating rate bond (notionals vector to be calculated by the FX rate >>>> at the reset dates). Thanks >>>> >>>> >>>> >>>> Dragomir Nedeltchev, Custom House >>>> >>>> >>>> >>>> >>>> >>>> TMF Custom House Fund Services (Ireland) Limited Registered Office: >>>> 3rd Floor, Kilmore House, Park Lane, Spencer Dock, Dublin 1, >>>> Ireland; >>>> Tel: (353) >>>> 1 878 0807; Fax: (353) 1 878 0827 Website: www.customhousegroup.com >>>> Directors: Mark Hedderman; Kevin Walsh; Barbara Cotter Registered in >>>> Ireland No. 147511 TMF Custom House Fund Services (Ireland) Limited >>>> is authorised by The Central Bank of Ireland under Section 10 of the >>>> Investment Intermediaries Act, 1995 >>>> ******************************************************************** >>>> * >>>> * >>>> **************************************** >>>> This e-mail and any files transmitted with it are intended to be >>>> confidential and intended solely for the use of the individual or >>>> entity to whom they are addressed. If you have received this e-mail >>>> in error please notify the sender. Internet mail is a communication >>>> channel, which is not controlled by Custom House, who cannot and do >>>> not guarantee that: any e-mail sent from Custom House will be >>>> delivered within a reasonable timeframe, or at all; comes from the >>>> purported sender; has not been intercepted by a third party; or that >>>> the contents of the e-mail are unaltered from the time of >>>> transmission. The recipient of this e-mail message should take note >>>> that this document does not constitute a legally binding contractual >>>> obligation of any sort unless there is a specific statement within >>>> the above message confirming that the message contains such a legally binding contractual obligation. >>>> ******************************************************************** >>>> * >>>> * >>>> ******************************************** >>>> >>>> -------------------------------------------------------------------- >>>> - >>>> - >>>> -------- >>>> Site24x7 APM Insight: Get Deep Visibility into Application >>>> Performance APM + Mobile APM + RUM: Monitor 3 App instances at just >>>> $35/Month Monitor end-to-end web transactions and take corrective >>>> actions now Troubleshoot faster and improve end-user experience. Signup Now! >>>> http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140 >>>> _______________________________________________ >>>> QuantLib-users mailing list >>>> [hidden email] >>>> https://lists.sourceforge.net/lists/listinfo/quantlib-users >>>> >>> TMF Custom House Fund Services (Ireland) Limited Registered Office: >>> 3rd Floor, Kilmore House, Park Lane, Spencer Dock, Dublin 1, Ireland; >>> Tel: (353) 1 878 0807; Fax: (353) 1 878 0827 Website: >>> www.customhousegroup.com Directors: Mark Hedderman; Kevin Walsh; >>> Barbara Cotter Registered in Ireland No. 147511 TMF Custom House Fund >>> Services (Ireland) Limited is authorised by The Central Bank of >>> Ireland under Section 10 of the Investment Intermediaries Act, 1995 >>> ********************************************************************* >>> * >>> **************************************** This e-mail and any files >>> transmitted with it are intended to be confidential and intended >>> solely for the use of the individual or entity to whom they are >>> addressed. If you have received this e-mail in error please notify >>> the sender. Internet mail is a communication channel, which is not >>> controlled by Custom House, who cannot and do not guarantee that: any >>> e-mail sent from Custom House will be delivered within a reasonable >>> timeframe, or at all; comes from the purported sender; has not been >>> intercepted by a third party; or that the contents of the e-mail are >>> unaltered from the time of transmission. The recipient of this e-mail >>> message should take note that this document does not constitute a >>> legally binding contractual obligation of any sort unless there is a >>> specific statement within the above message confirming that the >>> message contains such a legally binding contractual obligation. >>> ********************************************************************* >>> * >>> ******************************************** >> TMF Custom House Fund Services (Ireland) Limited Registered Office: >> 3rd Floor, Kilmore House, Park Lane, Spencer Dock, Dublin 1, Ireland; >> Tel: (353) 1 878 0807; Fax: (353) 1 878 0827 Website: >> www.customhousegroup.com Directors: Mark Hedderman; Kevin Walsh; >> Barbara Cotter Registered in Ireland No. 147511 TMF Custom House Fund >> Services (Ireland) Limited is authorised by The Central Bank of >> Ireland under Section 10 of the Investment Intermediaries Act, 1995 >> ********************************************************************** >> **************************************** This e-mail and any files >> transmitted with it are intended to be confidential and intended >> solely for the use of the individual or entity to whom they are >> addressed. If you have received this e-mail in error please notify the >> sender. Internet mail is a communication channel, which is not >> controlled by Custom House, who cannot and do not guarantee that: any >> e-mail sent from Custom House will be delivered within a reasonable >> timeframe, or at all; comes from the purported sender; has not been >> intercepted by a third party; or that the contents of the e-mail are >> unaltered from the time of transmission. The recipient of this e-mail >> message should take note that this document does not constitute a >> legally binding contractual obligation of any sort unless there is a >> specific statement within the above message confirming that the >> message contains such a legally binding contractual obligation. >> ********************************************************************** >> ******************************************** > TMF Custom House Fund Services (Ireland) Limited Registered Office: 3rd Floor, Kilmore House, Park Lane, Spencer Dock, Dublin 1, Ireland; Tel: (353) 1 878 0807; Fax: (353) 1 878 0827 Website: www.customhousegroup.com Directors: Mark Hedderman; Kevin Walsh; Barbara Cotter Registered in Ireland No. 147511 TMF Custom House Fund Services (Ireland) Limited is authorised by The Central Bank of Ireland under Section 10 of the Investment Intermediaries Act, 1995 ************************************************************************************************************** This e-mail and any files transmitted with it are intended to be confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this e-mail in error please notify the sender. Internet mail is a communication channel, which is not controlled by Custom House, who cannot and do not guarantee that: any e-mail sent from Custom House will be delivered within a reasonable timeframe, or at all; comes from the purported sender; has not been intercepted by a third party; or that the contents of the e-mail are unaltered from the time of transmission. The recipient of this e-mail message should take note that this document does not constitute a legally binding contractual obligation of any sort unless there is a specific statement within the above message confirming that the message contains such a legally binding contractual obligation. ****************************************************************************************************************** ------------------------------------------------------------------------------ Site24x7 APM Insight: Get Deep Visibility into Application Performance APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month Monitor end-to-end web transactions and take corrective actions now Troubleshoot faster and improve end-user experience. Signup Now! http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140 _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Hi Dragomir,
that looks quite scary. When I compile and run the code you sent earlier I get an exception saying that a yield curve can not be bootstrapped because of a negative time given. Probably this corresponds to your output The program '[9264] JPYUSD1.exe' has exited with code 1 (0x1). but you should see the error text message somewhere (whereever std::cerr is appearing in your enviroment - maybe you should run the program from a console rather than start it from within the IDE?). The expecption is thrown because you set the reference date of the yield term structures equal to the settlement date which is 8m after the global evaluation date. This won't work, because the instruments in the curve have payments before that settlement date. You should set the reference date of the yield curves equal to todaysDate, boost::shared_ptr<YieldTermStructure> swapTermStructureUSD( new PiecewiseYieldCurve<Discount, LogLinear>( todaysDate, swapInstrumentsUSD, termStructureDayCounter, tolerance)); then at least this problem will disappear. Regards Peter On 28 January 2016 at 14:15, Dragomir Nedeltchev <[hidden email]> wrote: > Hi Peter, > > I fixed the two issues as per your advice below. > > When running Build Solution I receive the error message: > > 1 IntelliSense: no instance of constructor "QuantLib::Constraint::Constraint" matches the argument list c:\local\QuantLib-1.7.1\ql\models\model.hpp 103 48 JPYUSD1 > > > When I double-click on the line and run Build Solution again, it succeeds. > > When I press F5, I receive error messages > > 'JPYUSD1.exe' (Win32): Loaded 'C:\local\QuantLib-1.6.2\JPYUSD1\Release\JPYUSD1.exe'. Symbols loaded. > 'JPYUSD1.exe' (Win32): Loaded 'C:\Windows\System32\ntdll.dll'. Cannot find or open the PDB file. > 'JPYUSD1.exe' (Win32): Loaded 'C:\Windows\System32\kernel32.dll'. Cannot find or open the PDB file. > 'JPYUSD1.exe' (Win32): Loaded 'C:\Windows\System32\KernelBase.dll'. Cannot find or open the PDB file. > 'JPYUSD1.exe' (Win32): Loaded 'C:\Windows\System32\msvcp120.dll'. Cannot find or open the PDB file. > 'JPYUSD1.exe' (Win32): Loaded 'C:\Windows\System32\msvcr120.dll'. Cannot find or open the PDB file. > 'JPYUSD1.exe' (Win32): Loaded 'C:\Windows\System32\QIPCAP.dll'. Cannot find or open the PDB file. > First-chance exception at 0x756C812F in JPYUSD1.exe: Microsoft C++ exception: QuantLib::Error at memory location 0x0027D250. > First-chance exception at 0x756C812F in JPYUSD1.exe: Microsoft C++ exception: QuantLib::Error at memory location 0x0027DB68. > First-chance exception at 0x756C812F in JPYUSD1.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000. > First-chance exception at 0x756C812F in JPYUSD1.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000. > First-chance exception at 0x756C812F in JPYUSD1.exe: Microsoft C++ exception: QuantLib::Error at memory location 0x0027E24C. > First-chance exception at 0x756C812F in JPYUSD1.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000. > First-chance exception at 0x756C812F in JPYUSD1.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000. > The program '[9264] JPYUSD1.exe' has exited with code 1 (0x1). > > When I delete the try loop, I receive the message > > Unhandled exception at 0x756C812F in JPYUSD1.exe: Microsoft C++ exception: QuantLib::Error at memory location 0x002EE5E8. > > > and the cursor pinpoints to file actualactual.cpp > > When I select Continue (instead of Break), I receive message > > Unhandled exception at 0x013F113A in JPYUSD1.exe: 0xC0000005: Access violation writing location 0x000000A6. > > And the cursor pinpoints to file iterativebootsrap.hpp where I have to abort the debug > > Thanks, > > Dragomir > > > -----Original Message----- > From: Peter Caspers [mailto:[hidden email]] > Sent: Wednesday, January 27, 2016 8:45 PM > To: Dragomir Nedeltchev > Cc: [hidden email] > Subject: Re: [Quantlib-users] pricing Mark-To-Market Cross-Currency Swap > > Hi Dragomir, > > you can say > > boost::shared_ptr<IborIndex> indexJPY(new JPYLibor(6*Months)); > > or even cooler > > boost::shared_ptr<IborIndex> indexJPY = boost::make_shared<JPYLibor>(6*Months); > > There are no convenience classes for the maturities, you have to > specify it as the first argument instead (you can do the same for > Euribor by the way). The forward estimation curve can be attached via > the second argument as usual. > > I didn't know that IntelliSense throws compilation errors now (?), but > anyway, you have to make fixedRate a vector, too, whose length matches > the number of periods, e.g. by > > std::vector<Rate> fixedRate(notionalDummy.size(), 0.0); > > That should fix the issue. > > Regards > Peter > > > On 27 January 2016 at 16:13, Dragomir Nedeltchev > <[hidden email]> wrote: >> Hi Peter, >> >> I fixed the code per your advice below. >> >> Please advise how to write the line >> >> boost::shared_ptr<IborIndex> indexJPY(new Euribor6M); >> >> so that it concerns JPY Libor >> >> I received 5 error messages for the revised code (Build Solution, Release mode): >> ////////////////// >> 4 IntelliSense: no instance of constructor "QuantLib::NonstandardSwap::NonstandardSwap" matches the argument list >> argument types are: (QuantLib::VanillaSwap::Type, std::vector<QuantLib::Time, std::allocator<QuantLib::Time>>, std::vector<QuantLib::Time, std::allocator<QuantLib::Time>>, QuantLib::Schedule, QuantLib::Rate, QuantLib::DayCounter, QuantLib::Schedule, boost::shared_ptr<QuantLib::IborIndex>, double, QuantLib::Spread, QuantLib::DayCounter, bool, bool, QuantLib::BusinessDayConvention) c:\local\QuantLib-1.6.2\JPYUSD MTM Swap\JPYUSD MTM Swap\Source.cpp 276 32 JPYUSD MTM Swap >> Error 1 error C2664: 'QuantLib::NonstandardSwap::NonstandardSwap(const QuantLib::NonstandardSwap &)' : cannot convert argument 5 from 'QuantLib::Rate' to 'const std::vector<QuantLib::Time,std::allocator<_Ty>> &' C:\local\QuantLib-1.6.2\JPYUSD MTM Swap\JPYUSD MTM Swap\Source.cpp 280 1 JPYUSD MTM Swap >> Error 2 error C2374: 'imm' : redefinition; multiple initialization C:\local\QuantLib-1.6.2\JPYUSD MTM Swap\JPYUSD MTM Swap\Source.cpp 389 1 JPYUSD MTM Swap >> 5 IntelliSense: no instance of constructor "QuantLib::NonstandardSwap::NonstandardSwap" matches the argument list >> argument types are: (QuantLib::VanillaSwap::Type, std::vector<QuantLib::Time, std::allocator<QuantLib::Time>>, std::vector<QuantLib::Time, std::allocator<QuantLib::Time>>, QuantLib::Schedule, QuantLib::Rate, QuantLib::DayCounter, QuantLib::Schedule, boost::shared_ptr<QuantLib::IborIndex>, double, QuantLib::Spread, QuantLib::DayCounter, bool, bool, QuantLib::BusinessDayConvention) c:\local\QuantLib-1.6.2\JPYUSD MTM Swap\JPYUSD MTM Swap\Source.cpp 487 32 JPYUSD MTM Swap >> Error 3 error C2664: 'QuantLib::NonstandardSwap::NonstandardSwap(const QuantLib::NonstandardSwap &)' : cannot convert argument 5 from 'QuantLib::Rate' to 'const std::vector<QuantLib::Time,std::allocator<_Ty>> &' C:\local\QuantLib-1.6.2\JPYUSD MTM Swap\JPYUSD MTM Swap\Source.cpp 491 1 JPYUSD MTM Swap >> ////////////////// >> >> And here is the code: >> /////////////////////////////////////// >> #include <ql/quantlib.hpp> >> #include <ql/instruments/nonstandardswap.hpp> >> >> #include <iostream> >> #include <iomanip> >> >> using namespace QuantLib; >> >> >> int main(int, char*[]) { >> >> try { >> >> Calendar calendar = TARGET(); >> Date settlementDate(03, October, 2016); >> settlementDate = calendar.adjust(settlementDate); >> >> Integer fixingDays = 2; >> >> Date todaysDate(26, January, 2016); >> >> Settings::instance().evaluationDate() = todaysDate; >> >> todaysDate = Settings::instance().evaluationDate(); >> >> //dummyUSD swap >> // curve 23 USD vs 3M LIBOR >> >> Rate d1mQuoteUSD = 0.6213; >> Real fut2QuoteUSD = 99.33034; >> Real fut3QuoteUSD = 99.30568; >> Real fut4QuoteUSD = 99.266; >> Real fut5QuoteUSD = 99.27143; >> Real fut6QuoteUSD = 99.24691; >> Real fut9QuoteUSD = 99.20304; >> Real fut12QuoteUSD = 99.10996; >> Real fut15QuoteUSD = 99.01759; >> Real fut18QuoteUSD = 98.92062; >> Real fut21QuoteUSD = 98.81907; >> Real fut24QuoteUSD = 98.71795; >> Real fut27QuoteUSD = 98.63228; >> Real fut30QuoteUSD = 98.54702; >> Real fut33QuoteUSD = 98.46717; >> Real fut36QuoteUSD = 98.38774; >> Rate s4yQuoteUSD = 1.24338; >> Rate s5yQuoteUSD = 1.38353; >> Rate s6yQuoteUSD = 1.50944; >> Rate s7yQuoteUSD = 1.61756; >> Rate s8yQuoteUSD = 1.71261; >> >> boost::shared_ptr<Quote> d1mRateUSD(new SimpleQuote(d1mQuoteUSD)); >> boost::shared_ptr<Quote> fut2PriceUSD(new SimpleQuote(fut2QuoteUSD)); >> boost::shared_ptr<Quote> fut3PriceUSD(new SimpleQuote(fut3QuoteUSD)); >> boost::shared_ptr<Quote> fut4PriceUSD(new SimpleQuote(fut4QuoteUSD)); >> boost::shared_ptr<Quote> fut5PriceUSD(new SimpleQuote(fut5QuoteUSD)); >> boost::shared_ptr<Quote> fut6PriceUSD(new SimpleQuote(fut6QuoteUSD)); >> boost::shared_ptr<Quote> fut9PriceUSD(new SimpleQuote(fut9QuoteUSD)); >> boost::shared_ptr<Quote> fut12PriceUSD(new SimpleQuote(fut12QuoteUSD)); >> boost::shared_ptr<Quote> fut15PriceUSD(new SimpleQuote(fut15QuoteUSD)); >> boost::shared_ptr<Quote> fut18PriceUSD(new SimpleQuote(fut18QuoteUSD)); >> boost::shared_ptr<Quote> fut21PriceUSD(new SimpleQuote(fut21QuoteUSD)); >> boost::shared_ptr<Quote> fut24PriceUSD(new SimpleQuote(fut24QuoteUSD)); >> boost::shared_ptr<Quote> fut27PriceUSD(new SimpleQuote(fut27QuoteUSD)); >> boost::shared_ptr<Quote> fut30PriceUSD(new SimpleQuote(fut30QuoteUSD)); >> boost::shared_ptr<Quote> fut33PriceUSD(new SimpleQuote(fut33QuoteUSD)); >> boost::shared_ptr<Quote> fut36PriceUSD(new SimpleQuote(fut36QuoteUSD)); >> boost::shared_ptr<Quote> s4yRateUSD(new SimpleQuote(s4yQuoteUSD)); >> boost::shared_ptr<Quote> s5yRateUSD(new SimpleQuote(s5yQuoteUSD)); >> boost::shared_ptr<Quote> s6yRateUSD(new SimpleQuote(s6yQuoteUSD)); >> boost::shared_ptr<Quote> s7yRateUSD(new SimpleQuote(s7yQuoteUSD)); >> boost::shared_ptr<Quote> s8yRateUSD(new SimpleQuote(s8yQuoteUSD)); >> >> DayCounter depositDayCounterUSD = Actual360(); >> >> boost::shared_ptr<RateHelper> d1mUSD(new DepositRateHelper( >> Handle<Quote>(d1mRateUSD), >> 1 * Months, fixingDays, >> calendar, ModifiedFollowing, >> true, depositDayCounterUSD)); >> >> Integer futMonthsUSD = 3; >> Date imm = IMM::nextDate(settlementDate); >> boost::shared_ptr<RateHelper> fut2USD(new FuturesRateHelper( >> Handle<Quote>(fut2PriceUSD), >> imm, >> futMonthsUSD, calendar, ModifiedFollowing, >> true, depositDayCounterUSD)); >> imm = IMM::nextDate(imm + 1); >> boost::shared_ptr<RateHelper> fut3USD(new FuturesRateHelper( >> Handle<Quote>(fut3PriceUSD), >> imm, >> futMonthsUSD, calendar, ModifiedFollowing, >> true, depositDayCounterUSD)); >> imm = IMM::nextDate(imm + 1); >> boost::shared_ptr<RateHelper> fut4USD(new FuturesRateHelper( >> Handle<Quote>(fut4PriceUSD), >> imm, >> futMonthsUSD, calendar, ModifiedFollowing, >> true, depositDayCounterUSD)); >> imm = IMM::nextDate(imm + 1); >> boost::shared_ptr<RateHelper> fut5USD(new FuturesRateHelper( >> Handle<Quote>(fut5PriceUSD), >> imm, >> futMonthsUSD, calendar, ModifiedFollowing, >> true, depositDayCounterUSD)); >> imm = IMM::nextDate(imm + 1); >> boost::shared_ptr<RateHelper> fut6USD(new FuturesRateHelper( >> Handle<Quote>(fut6PriceUSD), >> imm, >> futMonthsUSD, calendar, ModifiedFollowing, >> true, depositDayCounterUSD)); >> imm = IMM::nextDate(imm + 1); >> boost::shared_ptr<RateHelper> fut9USD(new FuturesRateHelper( >> Handle<Quote>(fut9PriceUSD), >> imm, >> futMonthsUSD, calendar, ModifiedFollowing, >> true, depositDayCounterUSD)); >> imm = IMM::nextDate(imm + 1); >> boost::shared_ptr<RateHelper> fut12USD(new FuturesRateHelper( >> Handle<Quote>(fut12PriceUSD), >> imm, >> futMonthsUSD, calendar, ModifiedFollowing, >> true, depositDayCounterUSD)); >> imm = IMM::nextDate(imm + 1); >> boost::shared_ptr<RateHelper> fut15USD(new FuturesRateHelper( >> Handle<Quote>(fut15PriceUSD), >> imm, >> futMonthsUSD, calendar, ModifiedFollowing, >> true, depositDayCounterUSD)); >> imm = IMM::nextDate(imm + 1); >> boost::shared_ptr<RateHelper> fut18USD(new FuturesRateHelper( >> Handle<Quote>(fut18PriceUSD), >> imm, >> futMonthsUSD, calendar, ModifiedFollowing, >> true, depositDayCounterUSD)); >> imm = IMM::nextDate(imm + 1); >> boost::shared_ptr<RateHelper> fut21USD(new FuturesRateHelper( >> Handle<Quote>(fut21PriceUSD), >> imm, >> futMonthsUSD, calendar, ModifiedFollowing, >> true, depositDayCounterUSD)); >> imm = IMM::nextDate(imm + 1); >> boost::shared_ptr<RateHelper> fut24USD(new FuturesRateHelper( >> Handle<Quote>(fut24PriceUSD), >> imm, >> futMonthsUSD, calendar, ModifiedFollowing, >> true, depositDayCounterUSD)); >> imm = IMM::nextDate(imm + 1); >> boost::shared_ptr<RateHelper> fut27USD(new FuturesRateHelper( >> Handle<Quote>(fut27PriceUSD), >> imm, >> futMonthsUSD, calendar, ModifiedFollowing, >> true, depositDayCounterUSD)); >> imm = IMM::nextDate(imm + 1); >> boost::shared_ptr<RateHelper> fut30USD(new FuturesRateHelper( >> Handle<Quote>(fut30PriceUSD), >> imm, >> futMonthsUSD, calendar, ModifiedFollowing, >> true, depositDayCounterUSD)); >> imm = IMM::nextDate(imm + 1); >> boost::shared_ptr<RateHelper> fut33USD(new FuturesRateHelper( >> Handle<Quote>(fut33PriceUSD), >> imm, >> futMonthsUSD, calendar, ModifiedFollowing, >> true, depositDayCounterUSD)); >> imm = IMM::nextDate(imm + 1); >> boost::shared_ptr<RateHelper> fut36USD(new FuturesRateHelper( >> Handle<Quote>(fut36PriceUSD), >> imm, >> futMonthsUSD, calendar, ModifiedFollowing, >> true, depositDayCounterUSD)); >> >> Frequency frequencyUSD = Quarterly; >> BusinessDayConvention conventionUSD = Unadjusted; >> DayCounter dayCounterUSD = Thirty360(Thirty360::USA); >> boost::shared_ptr<IborIndex> indexUSD(new Euribor6M); >> >> boost::shared_ptr<RateHelper> s4yUSD(new SwapRateHelper( >> Handle<Quote>(s4yRateUSD), 4 * Years, >> calendar, frequencyUSD, >> conventionUSD, dayCounterUSD, >> indexUSD)); >> boost::shared_ptr<RateHelper> s5yUSD(new SwapRateHelper( >> Handle<Quote>(s5yRateUSD), 5 * Years, >> calendar, frequencyUSD, >> conventionUSD, dayCounterUSD, >> indexUSD)); >> boost::shared_ptr<RateHelper> s6yUSD(new SwapRateHelper( >> Handle<Quote>(s6yRateUSD), 6 * Years, >> calendar, frequencyUSD, >> conventionUSD, dayCounterUSD, >> indexUSD)); >> boost::shared_ptr<RateHelper> s7yUSD(new SwapRateHelper( >> Handle<Quote>(s7yRateUSD), 7 * Years, >> calendar, frequencyUSD, >> conventionUSD, dayCounterUSD, >> indexUSD)); >> boost::shared_ptr<RateHelper> s8yUSD(new SwapRateHelper( >> Handle<Quote>(s8yRateUSD), 8 * Years, >> calendar, frequencyUSD, >> conventionUSD, dayCounterUSD, >> indexUSD)); >> >> DayCounter termStructureDayCounter = >> ActualActual(ActualActual::ISDA); >> >> double tolerance = 1.0e-15; >> >> std::vector<boost::shared_ptr<RateHelper> > swapInstrumentsUSD; >> swapInstrumentsUSD.push_back(d1mUSD); >> swapInstrumentsUSD.push_back(fut2USD); >> swapInstrumentsUSD.push_back(fut3USD); >> swapInstrumentsUSD.push_back(fut4USD); >> swapInstrumentsUSD.push_back(fut5USD); >> swapInstrumentsUSD.push_back(fut6USD); >> swapInstrumentsUSD.push_back(fut9USD); >> swapInstrumentsUSD.push_back(fut12USD); >> swapInstrumentsUSD.push_back(fut15USD); >> swapInstrumentsUSD.push_back(fut18USD); >> swapInstrumentsUSD.push_back(fut21USD); >> swapInstrumentsUSD.push_back(fut24USD); >> swapInstrumentsUSD.push_back(fut27USD); >> swapInstrumentsUSD.push_back(fut30USD); >> swapInstrumentsUSD.push_back(fut33USD); >> swapInstrumentsUSD.push_back(fut36USD); >> swapInstrumentsUSD.push_back(s4yUSD); >> swapInstrumentsUSD.push_back(s5yUSD); >> swapInstrumentsUSD.push_back(s6yUSD); >> swapInstrumentsUSD.push_back(s7yUSD); >> swapInstrumentsUSD.push_back(s8yUSD); >> >> boost::shared_ptr<YieldTermStructure> swapTermStructureUSD( >> new PiecewiseYieldCurve<Discount, LogLinear>( >> settlementDate, swapInstrumentsUSD, >> termStructureDayCounter, >> tolerance)); >> >> RelinkableHandle<YieldTermStructure> discountingTermStructureUSD; >> >> RelinkableHandle<YieldTermStructure> forecastingTermStructureUSD; >> >> // dummy leg >> >> std::vector<Real> notionalDummy; >> notionalDummy.push_back(0.0); >> notionalDummy.push_back(0.0); >> notionalDummy.push_back(0.0); >> notionalDummy.push_back(0.0); >> >> Rate fixedRate = 0.0; >> >> Integer lenghtInYears = 1; >> Date maturity = settlementDate + lenghtInYears*Years; >> >> >> // USD leg >> >> boost::shared_ptr<IborIndex> euriborIndexUSD( >> new Euribor6M(forecastingTermStructureUSD)); >> Spread spreadUSD = 0.0; >> >> std::vector<Real> notionalUSD; >> notionalUSD.push_back(20000000); >> notionalUSD.push_back(20500000); >> notionalUSD.push_back(20100000); >> notionalUSD.push_back(20070000); >> >> VanillaSwap::Type swapTypeUSD = VanillaSwap::Receiver; >> >> Schedule scheduleUSD(settlementDate, maturity, >> Period(frequencyUSD), >> calendar, conventionUSD, >> conventionUSD, >> DateGeneration::Forward, false); >> >> NonstandardSwap dummyUSDSwap(swapTypeUSD, notionalDummy, notionalUSD, >> scheduleUSD, fixedRate, >> dayCounterUSD, scheduleUSD, >> euriborIndexUSD, 1.0, spreadUSD, >> dayCounterUSD, false, false, conventionUSD); >> Real NPVUSD; >> Real USDJPYrate; >> USDJPYrate = 118.0; >> >> boost::shared_ptr<PricingEngine> swapEngineUSD( >> new DiscountingSwapEngine(discountingTermStructureUSD)); >> >> dummyUSDSwap.setPricingEngine(swapEngineUSD); >> >> forecastingTermStructureUSD.linkTo(swapTermStructureUSD); >> discountingTermStructureUSD.linkTo(swapTermStructureUSD); >> >> NPVUSD = dummyUSDSwap.NPV() * USDJPYrate; >> >> //dummyJPY swap >> >> // curve 308 JPY vs 3M LIBOR >> >> Rate d3mQuoteJPY = 0.08071; >> >> Rate fra1x4QuoteJPY = 0.06; >> Rate fra2x5QuoteJPY = 0.06; >> Rate fra3x6QuoteJPY = 0.055; >> Rate fra4x7QuoteJPY = 0.055; >> Rate fra5x8QuoteJPY = 0.05; >> Rate fra6x9QuoteJPY = 0.045; >> Rate fra7x10QuoteJPY = 0.0375; >> Rate fra8x11QuoteJPY = 0.03375; >> Rate fra9x12QuoteJPY = 0.035; >> >> Real fut18QuoteJPY = 99.93105; >> >> Rate s2yQuoteJPY = 0.06025; >> Rate s3yQuoteJPY = 0.06665; >> Rate s4yQuoteJPY = 0.07388; >> Rate s5yQuoteJPY = 0.10152; >> Rate s6yQuoteJPY = 0.14495; >> Rate s7yQuoteJPY = 0.1873; >> Rate s8yQuoteJPY = 0.242; >> >> boost::shared_ptr<Quote> d3mRateJPY(new SimpleQuote(d3mQuoteJPY)); >> >> boost::shared_ptr<Quote> fra1x4RateJPY(new SimpleQuote(fra1x4QuoteJPY)); >> boost::shared_ptr<Quote> fra2x5RateJPY(new SimpleQuote(fra2x5QuoteJPY)); >> boost::shared_ptr<Quote> fra3x6RateJPY(new SimpleQuote(fra3x6QuoteJPY)); >> boost::shared_ptr<Quote> fra4x7RateJPY(new SimpleQuote(fra4x7QuoteJPY)); >> boost::shared_ptr<Quote> fra5x8RateJPY(new SimpleQuote(fra5x8QuoteJPY)); >> boost::shared_ptr<Quote> fra6x9RateJPY(new SimpleQuote(fra6x9QuoteJPY)); >> boost::shared_ptr<Quote> fra7x10RateJPY(new SimpleQuote(fra7x10QuoteJPY)); >> boost::shared_ptr<Quote> fra8x11RateJPY(new SimpleQuote(fra8x11QuoteJPY)); >> boost::shared_ptr<Quote> fra9x12RateJPY(new SimpleQuote(fra9x12QuoteJPY)); >> >> boost::shared_ptr<Quote> fut18PriceJPY(new SimpleQuote(fut18QuoteJPY)); >> >> boost::shared_ptr<Quote> s2yRateJPY(new SimpleQuote(s2yQuoteJPY)); >> boost::shared_ptr<Quote> s3yRateJPY(new SimpleQuote(s3yQuoteJPY)); >> boost::shared_ptr<Quote> s4yRateJPY(new SimpleQuote(s4yQuoteJPY)); >> boost::shared_ptr<Quote> s5yRateJPY(new SimpleQuote(s5yQuoteJPY)); >> boost::shared_ptr<Quote> s6yRateJPY(new SimpleQuote(s6yQuoteJPY)); >> boost::shared_ptr<Quote> s7yRateJPY(new SimpleQuote(s7yQuoteJPY)); >> boost::shared_ptr<Quote> s8yRateJPY(new SimpleQuote(s8yQuoteJPY)); >> >> DayCounter depositDayCounterJPY = Actual360(); >> >> boost::shared_ptr<RateHelper> d3mJPY(new DepositRateHelper( >> Handle<Quote>(d3mRateJPY), >> 3 * Months, fixingDays, >> calendar, ModifiedFollowing, >> true, depositDayCounterJPY)); >> >> boost::shared_ptr<RateHelper> fra1x4JPY(new FraRateHelper( >> Handle<Quote>(fra1x4RateJPY), >> 1, 4, fixingDays, calendar, ModifiedFollowing, >> true, depositDayCounterJPY)); >> boost::shared_ptr<RateHelper> fra2x5JPY(new FraRateHelper( >> Handle<Quote>(fra2x5RateJPY), >> 2, 5, fixingDays, calendar, ModifiedFollowing, >> true, depositDayCounterJPY)); >> boost::shared_ptr<RateHelper> fra3x6JPY(new FraRateHelper( >> Handle<Quote>(fra3x6RateJPY), >> 3, 6, fixingDays, calendar, ModifiedFollowing, >> true, depositDayCounterJPY)); >> boost::shared_ptr<RateHelper> fra4x7JPY(new FraRateHelper( >> Handle<Quote>(fra4x7RateJPY), >> 4, 7, fixingDays, calendar, ModifiedFollowing, >> true, depositDayCounterJPY)); >> boost::shared_ptr<RateHelper> fra5x8JPY(new FraRateHelper( >> Handle<Quote>(fra5x8RateJPY), >> 5, 8, fixingDays, calendar, ModifiedFollowing, >> true, depositDayCounterJPY)); >> boost::shared_ptr<RateHelper> fra6x9JPY(new FraRateHelper( >> Handle<Quote>(fra6x9RateJPY), >> 6, 9, fixingDays, calendar, ModifiedFollowing, >> true, depositDayCounterJPY)); >> boost::shared_ptr<RateHelper> fra7x10JPY(new FraRateHelper( >> Handle<Quote>(fra7x10RateJPY), >> 7, 10, fixingDays, calendar, ModifiedFollowing, >> true, depositDayCounterJPY)); >> boost::shared_ptr<RateHelper> fra8x11JPY(new FraRateHelper( >> Handle<Quote>(fra8x11RateJPY), >> 8, 11, fixingDays, calendar, ModifiedFollowing, >> true, depositDayCounterJPY)); >> boost::shared_ptr<RateHelper> fra9x12JPY(new FraRateHelper( >> Handle<Quote>(fra9x12RateJPY), >> 9, 12, fixingDays, calendar, ModifiedFollowing, >> true, depositDayCounterJPY)); >> >> Integer futMonthsJPY = 3; >> Date imm = IMM::nextDate(settlementDate); >> boost::shared_ptr<RateHelper> fut18JPY(new FuturesRateHelper( >> Handle<Quote>(fut18PriceJPY), >> imm, >> futMonthsJPY, calendar, ModifiedFollowing, >> true, depositDayCounterJPY)); >> >> Frequency frequencyJPY = Quarterly; >> BusinessDayConvention conventionJPY = Unadjusted; >> DayCounter dayCounterJPY = Thirty360(Thirty360::European); >> boost::shared_ptr<IborIndex> indexJPY(new Euribor6M); >> >> boost::shared_ptr<RateHelper> s2yJPY(new SwapRateHelper( >> Handle<Quote>(s2yRateJPY), 2 * Years, >> calendar, frequencyJPY, >> conventionJPY, dayCounterJPY, >> indexJPY)); >> boost::shared_ptr<RateHelper> s3yJPY(new SwapRateHelper( >> Handle<Quote>(s3yRateJPY), 3 * Years, >> calendar, frequencyJPY, >> conventionJPY, dayCounterJPY, >> indexJPY)); >> boost::shared_ptr<RateHelper> s4yJPY(new SwapRateHelper( >> Handle<Quote>(s4yRateJPY), 4 * Years, >> calendar, frequencyJPY, >> conventionJPY, dayCounterJPY, >> indexJPY)); >> boost::shared_ptr<RateHelper> s5yJPY(new SwapRateHelper( >> Handle<Quote>(s5yRateJPY), 5 * Years, >> calendar, frequencyJPY, >> conventionJPY, dayCounterJPY, >> indexJPY)); >> boost::shared_ptr<RateHelper> s6yJPY(new SwapRateHelper( >> Handle<Quote>(s6yRateJPY), 6 * Years, >> calendar, frequencyJPY, >> conventionJPY, dayCounterJPY, >> indexJPY)); >> boost::shared_ptr<RateHelper> s7yJPY(new SwapRateHelper( >> Handle<Quote>(s7yRateJPY), 7 * Years, >> calendar, frequencyJPY, >> conventionJPY, dayCounterJPY, >> indexJPY)); >> boost::shared_ptr<RateHelper> s8yJPY(new SwapRateHelper( >> Handle<Quote>(s8yRateJPY), 8 * Years, >> calendar, frequencyJPY, >> conventionJPY, dayCounterJPY, >> indexJPY)); >> >> std::vector<boost::shared_ptr<RateHelper> > swapInstrumentsJPY; >> swapInstrumentsJPY.push_back(d3mJPY); >> swapInstrumentsJPY.push_back(fra1x4JPY); >> swapInstrumentsJPY.push_back(fra2x5JPY); >> swapInstrumentsJPY.push_back(fra3x6JPY); >> swapInstrumentsJPY.push_back(fra4x7JPY); >> swapInstrumentsJPY.push_back(fra5x8JPY); >> swapInstrumentsJPY.push_back(fra6x9JPY); >> swapInstrumentsJPY.push_back(fra7x10JPY); >> swapInstrumentsJPY.push_back(fra8x11JPY); >> swapInstrumentsJPY.push_back(fra9x12JPY); >> swapInstrumentsJPY.push_back(fut18JPY); >> swapInstrumentsJPY.push_back(s2yJPY); >> swapInstrumentsJPY.push_back(s3yJPY); >> swapInstrumentsJPY.push_back(s4yJPY); >> swapInstrumentsJPY.push_back(s5yJPY); >> swapInstrumentsJPY.push_back(s6yJPY); >> swapInstrumentsJPY.push_back(s7yJPY); >> swapInstrumentsJPY.push_back(s8yJPY); >> boost::shared_ptr<YieldTermStructure> swapTermStructureJPY( >> new PiecewiseYieldCurve<Discount, LogLinear>( >> settlementDate, swapInstrumentsJPY, >> termStructureDayCounter, >> tolerance)); >> >> RelinkableHandle<YieldTermStructure> discountingTermStructureJPY; >> >> RelinkableHandle<YieldTermStructure> forecastingTermStructureJPY; >> >> // JPY leg >> >> std::vector<Real> notionalJPY; >> notionalJPY.push_back(16000000000); >> notionalJPY.push_back(16000000000); >> notionalJPY.push_back(16000000000); >> notionalJPY.push_back(16000000000); >> >> boost::shared_ptr<IborIndex> euriborIndexJPY( >> new Euribor6M(forecastingTermStructureJPY)); >> >> Spread spreadJPY = -0.0069; >> >> VanillaSwap::Type swapTypeJPY = VanillaSwap::Payer; >> >> Schedule scheduleJPY(settlementDate, maturity, >> Period(frequencyJPY), >> calendar, conventionJPY, >> conventionJPY, >> DateGeneration::Forward, false); >> >> NonstandardSwap dummyJPYSwap(swapTypeJPY, notionalDummy, notionalJPY, >> scheduleJPY, fixedRate, >> dayCounterJPY, scheduleJPY, >> euriborIndexJPY, 1.0, spreadJPY, >> dayCounterJPY, false, false, conventionJPY); >> >> Real NPVJPY; >> Real NPVmySwap; >> >> boost::shared_ptr<PricingEngine> swapEngineJPY( >> new DiscountingSwapEngine(discountingTermStructureJPY)); >> >> dummyJPYSwap.setPricingEngine(swapEngineJPY); >> >> forecastingTermStructureJPY.linkTo(swapTermStructureJPY); >> discountingTermStructureJPY.linkTo(swapTermStructureJPY); >> >> NPVJPY = dummyJPYSwap.NPV(); >> >> NPVmySwap = NPVUSD - NPVJPY; >> >> return 0; >> >> } >> catch (std::exception& e) { >> std::cerr << e.what() << std::endl; >> return 1; >> } >> catch (...) { >> std::cerr << "unknown error" << std::endl; >> return 1; >> } >> } >> /////////////////////////// >> >> Thanks, >> >> Dragomir >> >> >> >> >> >> -----Original Message----- >> From: Peter Caspers [mailto:[hidden email]] >> Sent: Tuesday, January 26, 2016 9:41 PM >> To: Dragomir Nedeltchev >> Cc: [hidden email] >> Subject: Re: [Quantlib-users] pricing Mark-To-Market Cross-Currency Swap >> >> Hi Dragomir, >> >> yes, in that direction. Just a few thoughts. >> >> - there are Libor indices in USD and JPY you can use, no need to go for Euribor >> - the dummy notional has to be a vector, too (containing 0.0, that's ok) >> - the gearing should be 1.0 ? It is the multiplier for the ibor fixing before adding the spread. >> - the NPVs have to be converted to one currency before adding them >> >> I did not read every line of the code - just give it a try and if you run into problems, just write back here, ok? Do you have a reference to compare the NPV with? >> >> Regards >> Peter >> >> >> On 26 January 2016 at 14:36, Dragomir Nedeltchev <[hidden email]> wrote: >>> Hi Peter, >>> >>> Below you will find the code for the swap in question, if I got your point correctly. >>> >>> The vector of floating notional was calculated by the forward JPYUSD >>> rate. Market data copy/paste the swapvaluation.cpp for both JPY and >>> USD; later I will insert actual numbers >>> >>> Thanks, >>> >>> Dragomir >>> >>> ///////////////////////////// >>> #include <ql/quantlib.hpp> >>> >>> #include <iostream> >>> #include <iomanip> >>> >>> using namespace QuantLib; >>> >>> >>> int main(int, char* []) { >>> >>> try { >>> >>> >>> >>> /********************* >>> *** MARKET DATA *** >>> *********************/ >>> >>> Calendar calendar = TARGET(); >>> Date settlementDate(03, October, 2016); >>> settlementDate = calendar.adjust(settlementDate); >>> >>> Integer fixingDays = 2; >>> >>> Date todaysDate(26, January, 2016); >>> >>> Settings::instance().evaluationDate() = todaysDate; >>> >>> todaysDate = Settings::instance().evaluationDate(); >>> >>> //USD leg >>> Rate d1wQuoteUSD=0.0382; >>> Rate d1mQuoteUSD=0.0372; >>> Rate d3mQuoteUSD=0.0363; >>> Rate d6mQuoteUSD=0.0353; >>> Rate d9mQuoteUSD=0.0348; >>> Rate d1yQuoteUSD=0.0345; >>> >>> Rate fra3x6QuoteUSD=0.037125; >>> Rate fra6x9QuoteUSD=0.037125; >>> Rate fra6x12QuoteUSD=0.037125; >>> >>> Real fut1QuoteUSD=96.2875; >>> Real fut2QuoteUSD=96.7875; >>> Real fut3QuoteUSD=96.9875; >>> Real fut4QuoteUSD=96.6875; >>> Real fut5QuoteUSD=96.4875; >>> Real fut6QuoteUSD=96.3875; >>> Real fut7QuoteUSD=96.2875; >>> Real fut8QuoteUSD=96.0875; >>> >>> Rate s2yQuoteUSD=0.037125; >>> Rate s3yQuoteUSD=0.0398; >>> Rate s5yQuoteUSD=0.0443; >>> Rate s10yQuoteUSD=0.05165; >>> Rate s15yQuoteUSD=0.055175; >>> >>> //JPY leg >>> >>> Rate d1wQuoteJPY=0.0382; >>> Rate d1mQuoteJPY=0.0372; >>> Rate d3mQuoteJPY=0.0363; >>> Rate d6mQuoteJPY=0.0353; >>> Rate d9mQuoteJPY=0.0348; >>> Rate d1yQuoteJPY=0.0345; >>> >>> Rate fra3x6QuoteJPY=0.037125; >>> Rate fra6x9QuoteJPY=0.037125; >>> Rate fra6x12QuoteJPY=0.037125; >>> >>> Real fut1QuoteJPY=96.2875; >>> Real fut2QuoteJPY=96.7875; >>> Real fut3QuoteJPY=96.9875; >>> Real fut4QuoteJPY=96.6875; >>> Real fut5QuoteJPY=96.4875; >>> Real fut6QuoteJPY=96.3875; >>> Real fut7QuoteJPY=96.2875; >>> Real fut8QuoteJPY=96.0875; >>> >>> Rate s2yQuoteJPY=0.037125; >>> Rate s3yQuoteJPY=0.0398; >>> Rate s5yQuoteJPY=0.0443; >>> Rate s10yQuoteJPY=0.05165; >>> Rate s15yQuoteJPY=0.055175; >>> >>> >>> /******************** >>> *** QUOTES *** >>> ********************/ >>> >>> //USD leg >>> >>> >>> boost::shared_ptr<Quote> d1wRateUSD(new SimpleQuote(d1wQuoteUSD)); >>> boost::shared_ptr<Quote> d1mRateUSD(new SimpleQuote(d1mQuoteUSD)); >>> boost::shared_ptr<Quote> d3mRateUSD(new SimpleQuote(d3mQuoteUSD)); >>> boost::shared_ptr<Quote> d6mRateUSD(new SimpleQuote(d6mQuoteUSD)); >>> boost::shared_ptr<Quote> d9mRateUSD(new SimpleQuote(d9mQuoteUSD)); >>> boost::shared_ptr<Quote> d1yRateUSD(new >>> SimpleQuote(d1yQuoteUSD)); >>> >>> boost::shared_ptr<Quote> fra3x6RateUSD(new SimpleQuote(fra3x6QuoteUSD)); >>> boost::shared_ptr<Quote> fra6x9RateUSD(new SimpleQuote(fra6x9QuoteUSD)); >>> boost::shared_ptr<Quote> fra6x12RateUSD(new >>> SimpleQuote(fra6x12QuoteUSD)); >>> >>> boost::shared_ptr<Quote> fut1PriceUSD(new SimpleQuote(fut1QuoteUSD)); >>> boost::shared_ptr<Quote> fut2PriceUSD(new SimpleQuote(fut2QuoteUSD)); >>> boost::shared_ptr<Quote> fut3PriceUSD(new SimpleQuote(fut3QuoteUSD)); >>> boost::shared_ptr<Quote> fut4PriceUSD(new SimpleQuote(fut4QuoteUSD)); >>> boost::shared_ptr<Quote> fut5PriceUSD(new SimpleQuote(fut5QuoteUSD)); >>> boost::shared_ptr<Quote> fut6PriceUSD(new SimpleQuote(fut6QuoteUSD)); >>> boost::shared_ptr<Quote> fut7PriceUSD(new SimpleQuote(fut7QuoteUSD)); >>> boost::shared_ptr<Quote> fut8PriceUSD(new >>> SimpleQuote(fut8QuoteUSD)); >>> >>> boost::shared_ptr<Quote> s2yRateUSD(new SimpleQuote(s2yQuoteUSD)); >>> boost::shared_ptr<Quote> s3yRateUSD(new SimpleQuote(s3yQuoteUSD)); >>> boost::shared_ptr<Quote> s5yRateUSD(new SimpleQuote(s5yQuoteUSD)); >>> boost::shared_ptr<Quote> s10yRateUSD(new SimpleQuote(s10yQuoteUSD)); >>> boost::shared_ptr<Quote> s15yRateUSD(new >>> SimpleQuote(s15yQuoteUSD)); >>> >>> //JPY leg >>> >>> boost::shared_ptr<Quote> d1wRateJPY(new SimpleQuote(d1wQuoteJPY)); >>> boost::shared_ptr<Quote> d1mRateJPY(new SimpleQuote(d1mQuoteJPY)); >>> boost::shared_ptr<Quote> d3mRateJPY(new SimpleQuote(d3mQuoteJPY)); >>> boost::shared_ptr<Quote> d6mRateJPY(new SimpleQuote(d6mQuoteJPY)); >>> boost::shared_ptr<Quote> d9mRateJPY(new SimpleQuote(d9mQuoteJPY)); >>> boost::shared_ptr<Quote> d1yRateJPY(new >>> SimpleQuote(d1yQuoteJPY)); >>> >>> boost::shared_ptr<Quote> fra3x6RateJPY(new SimpleQuote(fra3x6QuoteJPY)); >>> boost::shared_ptr<Quote> fra6x9RateJPY(new SimpleQuote(fra6x9QuoteJPY)); >>> boost::shared_ptr<Quote> fra6x12RateJPY(new >>> SimpleQuote(fra6x12QuoteJPY)); >>> >>> boost::shared_ptr<Quote> fut1PriceJPY(new SimpleQuote(fut1QuoteJPY)); >>> boost::shared_ptr<Quote> fut2PriceJPY(new SimpleQuote(fut2QuoteJPY)); >>> boost::shared_ptr<Quote> fut3PriceJPY(new SimpleQuote(fut3QuoteJPY)); >>> boost::shared_ptr<Quote> fut4PriceJPY(new SimpleQuote(fut4QuoteJPY)); >>> boost::shared_ptr<Quote> fut5PriceJPY(new SimpleQuote(fut5QuoteJPY)); >>> boost::shared_ptr<Quote> fut6PriceJPY(new SimpleQuote(fut6QuoteJPY)); >>> boost::shared_ptr<Quote> fut7PriceJPY(new SimpleQuote(fut7QuoteJPY)); >>> boost::shared_ptr<Quote> fut8PriceJPY(new >>> SimpleQuote(fut8QuoteJPY)); >>> >>> boost::shared_ptr<Quote> s2yRateJPY(new SimpleQuote(s2yQuoteJPY)); >>> boost::shared_ptr<Quote> s3yRateJPY(new SimpleQuote(s3yQuoteJPY)); >>> boost::shared_ptr<Quote> s5yRateJPY(new SimpleQuote(s5yQuoteJPY)); >>> boost::shared_ptr<Quote> s10yRateJPY(new SimpleQuote(s10yQuoteJPY)); >>> boost::shared_ptr<Quote> s15yRateJPY(new >>> SimpleQuote(s15yQuoteJPY)); >>> >>> /********************* >>> *** RATE HELPERS *** >>> *********************/ >>> //USD leg >>> >>> >>> DayCounter depositDayCounterUSD = Actual360(); >>> >>> boost::shared_ptr<RateHelper> d1wUSD(new DepositRateHelper( >>> Handle<Quote>(d1wRateUSD), >>> 1*Weeks, fixingDays, >>> calendar, ModifiedFollowing, >>> true, depositDayCounterUSD)); >>> boost::shared_ptr<RateHelper> d1mUSD(new DepositRateHelper( >>> Handle<Quote>(d1mRateUSD), >>> 1*Months, fixingDays, >>> calendar, ModifiedFollowing, >>> true, depositDayCounterUSD)); >>> boost::shared_ptr<RateHelper> d3mUSD(new DepositRateHelper( >>> Handle<Quote>(d3mRateUSD), >>> 3*Months, fixingDays, >>> calendar, ModifiedFollowing, >>> true, depositDayCounterUSD)); >>> boost::shared_ptr<RateHelper> d6mUSD(new DepositRateHelper( >>> Handle<Quote>(d6mRateUSD), >>> 6*Months, fixingDays, >>> calendar, ModifiedFollowing, >>> true, depositDayCounterUSD)); >>> boost::shared_ptr<RateHelper> d9mUSD(new DepositRateHelper( >>> Handle<Quote>(d9mRateUSD), >>> 9*Months, fixingDays, >>> calendar, ModifiedFollowing, >>> true, depositDayCounterUSD)); >>> boost::shared_ptr<RateHelper> d1yUSD(new DepositRateHelper( >>> Handle<Quote>(d1yRateUSD), >>> 1*Years, fixingDays, >>> calendar, ModifiedFollowing, >>> true, depositDayCounterUSD)); >>> >>> boost::shared_ptr<RateHelper> fra3x6USD(new FraRateHelper( >>> Handle<Quote>(fra3x6RateUSD), >>> 3, 6, fixingDays, calendar, ModifiedFollowing, >>> true, depositDayCounterUSD)); >>> boost::shared_ptr<RateHelper> fra6x9USD(new FraRateHelper( >>> Handle<Quote>(fra6x9RateUSD), >>> 6, 9, fixingDays, calendar, ModifiedFollowing, >>> true, depositDayCounterUSD)); >>> boost::shared_ptr<RateHelper> fra6x12USD(new FraRateHelper( >>> Handle<Quote>(fra6x12RateUSD), >>> 6, 12, fixingDays, calendar, ModifiedFollowing, >>> true, depositDayCounterUSD)); >>> >>> Integer futMonthsUSD = 3; >>> Date imm = IMM::nextDate(settlementDate); >>> boost::shared_ptr<RateHelper> fut1USD(new FuturesRateHelper( >>> Handle<Quote>(fut1PriceUSD), >>> imm, >>> futMonthsUSD, calendar, ModifiedFollowing, >>> true, depositDayCounterUSD)); >>> imm = IMM::nextDate(imm+1); >>> boost::shared_ptr<RateHelper> fut2USD(new FuturesRateHelper( >>> Handle<Quote>(fut2PriceUSD), >>> imm, >>> futMonthsUSD, calendar, ModifiedFollowing, >>> true, depositDayCounterUSD)); >>> imm = IMM::nextDate(imm+1); >>> boost::shared_ptr<RateHelper> fut3USD(new FuturesRateHelper( >>> Handle<Quote>(fut3PriceUSD), >>> imm, >>> futMonthsUSD, calendar, ModifiedFollowing, >>> true, depositDayCounterUSD)); >>> imm = IMM::nextDate(imm+1); >>> boost::shared_ptr<RateHelper> fut4USD(new FuturesRateHelper( >>> Handle<Quote>(fut4PriceUSD), >>> imm, >>> futMonthsUSD, calendar, ModifiedFollowing, >>> true, depositDayCounterUSD)); >>> imm = IMM::nextDate(imm+1); >>> boost::shared_ptr<RateHelper> fut5USD(new FuturesRateHelper( >>> Handle<Quote>(fut5PriceUSD), >>> imm, >>> futMonthsUSD, calendar, ModifiedFollowing, >>> true, depositDayCounterUSD)); >>> imm = IMM::nextDate(imm+1); >>> boost::shared_ptr<RateHelper> fut6USD(new FuturesRateHelper( >>> Handle<Quote>(fut6PriceUSD), >>> imm, >>> futMonthsUSD, calendar, ModifiedFollowing, >>> true, depositDayCounterUSD)); >>> imm = IMM::nextDate(imm+1); >>> boost::shared_ptr<RateHelper> fut7USD(new FuturesRateHelper( >>> Handle<Quote>(fut7PriceUSD), >>> imm, >>> futMonthsUSD, calendar, ModifiedFollowing, >>> true, depositDayCounterUSD)); >>> imm = IMM::nextDate(imm+1); >>> boost::shared_ptr<RateHelper> fut8USD(new FuturesRateHelper( >>> Handle<Quote>(fut8PriceUSD), >>> imm, >>> futMonthsUSD, calendar, ModifiedFollowing, >>> true, depositDayCounterUSD)); >>> >>> Frequency frequencyUSD = Quarterly; >>> BusinessDayConvention conventionUSD = Unadjusted; >>> DayCounter dayCounterUSD = Thirty360(Thirty360::USA); >>> boost::shared_ptr<IborIndex> indexUSD(new Euribor6M); >>> >>> boost::shared_ptr<RateHelper> s2yUSD(new SwapRateHelper( >>> Handle<Quote>(s2yRateUSD), 2*Years, >>> calendar, frequencyUSD, >>> conventionUSD, dayCounterUSD, >>> indexUSD)); >>> boost::shared_ptr<RateHelper> s3yUSD(new SwapRateHelper( >>> Handle<Quote>(s3yRateUSD), 3*Years, >>> calendar, frequencyUSD, >>> conventionUSD, dayCounterUSD, >>> indexUSD)); >>> boost::shared_ptr<RateHelper> s5yUSD(new SwapRateHelper( >>> Handle<Quote>(s5yRateUSD), 5*Years, >>> calendar, frequencyUSD, >>> conventionUSD, dayCounterUSD, >>> indexUSD)); >>> boost::shared_ptr<RateHelper> s10yUSD(new SwapRateHelper( >>> Handle<Quote>(s10yRateUSD), 10*Years, >>> calendar, frequencyUSD, >>> conventionUSD, dayCounterUSD, >>> indexUSD)); >>> boost::shared_ptr<RateHelper> s15yUSD(new SwapRateHelper( >>> Handle<Quote>(s15yRateUSD), 15*Years, >>> calendar, frequencyUSD, >>> conventionUSD, dayCounterUSD, >>> indexUSD)); >>> >>> //JPY leg >>> >>> >>> DayCounter depositDayCounterJPY = Actual360(); >>> >>> boost::shared_ptr<RateHelper> d1wJPY(new DepositRateHelper( >>> Handle<Quote>(d1wRateJPY), >>> 1*Weeks, fixingDays, >>> calendar, ModifiedFollowing, >>> true, depositDayCounterJPY)); >>> boost::shared_ptr<RateHelper> d1mJPY(new DepositRateHelper( >>> Handle<Quote>(d1mRateJPY), >>> 1*Months, fixingDays, >>> calendar, ModifiedFollowing, >>> true, depositDayCounterJPY)); >>> boost::shared_ptr<RateHelper> d3mJPY(new DepositRateHelper( >>> Handle<Quote>(d3mRateJPY), >>> 3*Months, fixingDays, >>> calendar, ModifiedFollowing, >>> true, depositDayCounterJPY)); >>> boost::shared_ptr<RateHelper> d6mJPY(new DepositRateHelper( >>> Handle<Quote>(d6mRateJPY), >>> 6*Months, fixingDays, >>> calendar, ModifiedFollowing, >>> true, depositDayCounterJPY)); >>> boost::shared_ptr<RateHelper> d9mJPY(new DepositRateHelper( >>> Handle<Quote>(d9mRateJPY), >>> 9*Months, fixingDays, >>> calendar, ModifiedFollowing, >>> true, depositDayCounterJPY)); >>> boost::shared_ptr<RateHelper> d1yJPY(new DepositRateHelper( >>> Handle<Quote>(d1yRateJPY), >>> 1*Years, fixingDays, >>> calendar, ModifiedFollowing, >>> true, depositDayCounterJPY)); >>> >>> boost::shared_ptr<RateHelper> fra3x6JPY(new FraRateHelper( >>> Handle<Quote>(fra3x6RateJPY), >>> 3, 6, fixingDays, calendar, ModifiedFollowing, >>> true, depositDayCounterJPY)); >>> boost::shared_ptr<RateHelper> fra6x9JPY(new FraRateHelper( >>> Handle<Quote>(fra6x9RateJPY), >>> 6, 9, fixingDays, calendar, ModifiedFollowing, >>> true, depositDayCounterJPY)); >>> boost::shared_ptr<RateHelper> fra6x12JPY(new FraRateHelper( >>> Handle<Quote>(fra6x12RateJPY), >>> 6, 12, fixingDays, calendar, ModifiedFollowing, >>> true, depositDayCounterJPY)); >>> >>> Integer futMonthsJPY = 3; >>> Date imm = IMM::nextDate(settlementDate); >>> boost::shared_ptr<RateHelper> fut1JPY(new FuturesRateHelper( >>> Handle<Quote>(fut1PriceJPY), >>> imm, >>> futMonthsJPY, calendar, ModifiedFollowing, >>> true, depositDayCounterJPY)); >>> imm = IMM::nextDate(imm+1); >>> boost::shared_ptr<RateHelper> fut2JPY(new FuturesRateHelper( >>> Handle<Quote>(fut2PriceJPY), >>> imm, >>> futMonthsJPY, calendar, ModifiedFollowing, >>> true, depositDayCounterJPY)); >>> imm = IMM::nextDate(imm+1); >>> boost::shared_ptr<RateHelper> fut3JPY(new FuturesRateHelper( >>> Handle<Quote>(fut3PriceJPY), >>> imm, >>> futMonthsJPY, calendar, ModifiedFollowing, >>> true, depositDayCounterJPY)); >>> imm = IMM::nextDate(imm+1); >>> boost::shared_ptr<RateHelper> fut4JPY(new FuturesRateHelper( >>> Handle<Quote>(fut4PriceJPY), >>> imm, >>> futMonthsJPY, calendar, ModifiedFollowing, >>> true, depositDayCounterJPY)); >>> imm = IMM::nextDate(imm+1); >>> boost::shared_ptr<RateHelper> fut5JPY(new FuturesRateHelper( >>> Handle<Quote>(fut5PriceJPY), >>> imm, >>> futMonthsJPY, calendar, ModifiedFollowing, >>> true, depositDayCounterJPY)); >>> imm = IMM::nextDate(imm+1); >>> boost::shared_ptr<RateHelper> fut6JPY(new FuturesRateHelper( >>> Handle<Quote>(fut6PriceJPY), >>> imm, >>> futMonthsJPY, calendar, ModifiedFollowing, >>> true, depositDayCounterJPY)); >>> imm = IMM::nextDate(imm+1); >>> boost::shared_ptr<RateHelper> fut7JPY(new FuturesRateHelper( >>> Handle<Quote>(fut7PriceJPY), >>> imm, >>> futMonthsJPY, calendar, ModifiedFollowing, >>> true, depositDayCounterJPY)); >>> imm = IMM::nextDate(imm+1); >>> boost::shared_ptr<RateHelper> fut8JPY(new FuturesRateHelper( >>> Handle<Quote>(fut8PriceJPY), >>> imm, >>> futMonthsJPY, calendar, ModifiedFollowing, >>> true, depositDayCounterJPY)); >>> >>> Frequency frequencyJPY = Quarterly; >>> BusinessDayConvention conventionJPY = Unadjusted; >>> DayCounter dayCounterJPY = Thirty360(Thirty360::European); >>> boost::shared_ptr<IborIndex> indexJPY(new Euribor6M); >>> >>> boost::shared_ptr<RateHelper> s2yJPY(new SwapRateHelper( >>> Handle<Quote>(s2yRateJPY), 2*Years, >>> calendar, frequencyJPY, >>> conventionJPY, dayCounterJPY, >>> indexJPY)); >>> boost::shared_ptr<RateHelper> s3yJPY(new SwapRateHelper( >>> Handle<Quote>(s3yRateJPY), 3*Years, >>> calendar, frequencyJPY, >>> conventionJPY, dayCounterJPY, >>> indexJPY)); >>> boost::shared_ptr<RateHelper> s5yJPY(new SwapRateHelper( >>> Handle<Quote>(s5yRateJPY), 5*Years, >>> calendar, frequencyJPY, >>> conventionJPY, dayCounterJPY, >>> indexJPY)); >>> boost::shared_ptr<RateHelper> s10yJPY(new SwapRateHelper( >>> Handle<Quote>(s10yRateJPY), 10*Years, >>> calendar, frequencyJPY, >>> conventionJPY, dayCounterJPY, >>> indexJPY)); >>> boost::shared_ptr<RateHelper> s15yJPY(new SwapRateHelper( >>> Handle<Quote>(s15yRateJPY), 15*Years, >>> calendar, frequencyJPY, >>> conventionJPY, dayCounterJPY, >>> indexJPY)); >>> >>> /********************* >>> ** CURVEs BUILDING ** >>> *********************/ >>> >>> DayCounter termStructureDayCounter = >>> ActualActual(ActualActual::ISDA); >>> >>> double tolerance = 1.0e-15; >>> >>> std::vector<boost::shared_ptr<RateHelper> > depoSwapInstrumentsUSD; >>> depoSwapInstrumentsUSD.push_back(d1wUSD); >>> depoSwapInstrumentsUSD.push_back(d1mUSD); >>> depoSwapInstrumentsUSD.push_back(d3mUSD); >>> depoSwapInstrumentsUSD.push_back(d6mUSD); >>> depoSwapInstrumentsUSD.push_back(d9mUSD); >>> depoSwapInstrumentsUSD.push_back(d1yUSD); >>> depoSwapInstrumentsUSD.push_back(s2yUSD); >>> depoSwapInstrumentsUSD.push_back(s3yUSD); >>> depoSwapInstrumentsUSD.push_back(s5yUSD); >>> depoSwapInstrumentsUSD.push_back(s10yUSD); >>> depoSwapInstrumentsUSD.push_back(s15yUSD); >>> boost::shared_ptr<YieldTermStructure> depoSwapTermStructureUSD( >>> new PiecewiseYieldCurve<Discount,LogLinear>( >>> settlementDate, depoSwapInstrumentsUSD, >>> termStructureDayCounter, >>> tolerance)); >>> >>> std::vector<boost::shared_ptr<RateHelper> > depoFutSwapInstrumentsUSD; >>> depoFutSwapInstrumentsUSD.push_back(d1wUSD); >>> depoFutSwapInstrumentsUSD.push_back(d1mUSD); >>> depoFutSwapInstrumentsUSD.push_back(fut1USD); >>> depoFutSwapInstrumentsUSD.push_back(fut2USD); >>> depoFutSwapInstrumentsUSD.push_back(fut3USD); >>> depoFutSwapInstrumentsUSD.push_back(fut4USD); >>> depoFutSwapInstrumentsUSD.push_back(fut5USD); >>> depoFutSwapInstrumentsUSD.push_back(fut6USD); >>> depoFutSwapInstrumentsUSD.push_back(fut7USD); >>> depoFutSwapInstrumentsUSD.push_back(fut8USD); >>> depoFutSwapInstrumentsUSD.push_back(s3yUSD); >>> depoFutSwapInstrumentsUSD.push_back(s5yUSD); >>> depoFutSwapInstrumentsUSD.push_back(s10yUSD); >>> depoFutSwapInstrumentsUSD.push_back(s15yUSD); >>> boost::shared_ptr<YieldTermStructure> depoFutSwapTermStructureUSD( >>> new PiecewiseYieldCurve<Discount,LogLinear>( >>> settlementDate, depoFutSwapInstrumentsUSD, >>> termStructureDayCounter, >>> tolerance)); >>> >>> std::vector<boost::shared_ptr<RateHelper> > depoFRASwapInstrumentsUSD; >>> depoFRASwapInstrumentsUSD.push_back(d1wUSD); >>> depoFRASwapInstrumentsUSD.push_back(d1mUSD); >>> depoFRASwapInstrumentsUSD.push_back(d3mUSD); >>> depoFRASwapInstrumentsUSD.push_back(fra3x6USD); >>> depoFRASwapInstrumentsUSD.push_back(fra6x9USD); >>> depoFRASwapInstrumentsUSD.push_back(fra6x12USD); >>> depoFRASwapInstrumentsUSD.push_back(s2yUSD); >>> depoFRASwapInstrumentsUSD.push_back(s3yUSD); >>> depoFRASwapInstrumentsUSD.push_back(s5yUSD); >>> depoFRASwapInstrumentsUSD.push_back(s10yUSD); >>> depoFRASwapInstrumentsUSD.push_back(s15yUSD); >>> boost::shared_ptr<YieldTermStructure> depoFRASwapTermStructureUSD( >>> new PiecewiseYieldCurve<Discount,LogLinear>( >>> settlementDate, depoFRASwapInstrumentsUSD, >>> termStructureDayCounter, >>> tolerance)); >>> >>> RelinkableHandle<YieldTermStructure> >>> discountingTermStructureUSD; >>> >>> RelinkableHandle<YieldTermStructure> >>> forecastingTermStructureUSD; >>> >>> //JPY leg >>> >>> std::vector<boost::shared_ptr<RateHelper> > depoSwapInstrumentsJPY; >>> depoSwapInstrumentsJPY.push_back(d1wJPY); >>> depoSwapInstrumentsJPY.push_back(d1mJPY); >>> depoSwapInstrumentsJPY.push_back(d3mJPY); >>> depoSwapInstrumentsJPY.push_back(d6mJPY); >>> depoSwapInstrumentsJPY.push_back(d9mJPY); >>> depoSwapInstrumentsJPY.push_back(d1yJPY); >>> depoSwapInstrumentsJPY.push_back(s2yJPY); >>> depoSwapInstrumentsJPY.push_back(s3yJPY); >>> depoSwapInstrumentsJPY.push_back(s5yJPY); >>> depoSwapInstrumentsJPY.push_back(s10yJPY); >>> depoSwapInstrumentsJPY.push_back(s15yJPY); >>> boost::shared_ptr<YieldTermStructure> depoSwapTermStructureJPY( >>> new PiecewiseYieldCurve<Discount,LogLinear>( >>> settlementDate, depoSwapInstrumentsJPY, >>> termStructureDayCounter, >>> tolerance)); >>> >>> std::vector<boost::shared_ptr<RateHelper> > depoFutSwapInstrumentsJPY; >>> depoFutSwapInstrumentsJPY.push_back(d1wJPY); >>> depoFutSwapInstrumentsJPY.push_back(d1mJPY); >>> depoFutSwapInstrumentsJPY.push_back(fut1JPY); >>> depoFutSwapInstrumentsJPY.push_back(fut2JPY); >>> depoFutSwapInstrumentsJPY.push_back(fut3JPY); >>> depoFutSwapInstrumentsJPY.push_back(fut4JPY); >>> depoFutSwapInstrumentsJPY.push_back(fut5JPY); >>> depoFutSwapInstrumentsJPY.push_back(fut6JPY); >>> depoFutSwapInstrumentsJPY.push_back(fut7JPY); >>> depoFutSwapInstrumentsJPY.push_back(fut8JPY); >>> depoFutSwapInstrumentsJPY.push_back(s3yJPY); >>> depoFutSwapInstrumentsJPY.push_back(s5yJPY); >>> depoFutSwapInstrumentsJPY.push_back(s10yJPY); >>> depoFutSwapInstrumentsJPY.push_back(s15yJPY); >>> boost::shared_ptr<YieldTermStructure> depoFutSwapTermStructureJPY( >>> new PiecewiseYieldCurve<Discount,LogLinear>( >>> settlementDate, depoFutSwapInstrumentsJPY, >>> termStructureDayCounter, >>> tolerance)); >>> >>> std::vector<boost::shared_ptr<RateHelper> > depoFRASwapInstrumentsJPY; >>> depoFRASwapInstrumentsJPY.push_back(d1wJPY); >>> depoFRASwapInstrumentsJPY.push_back(d1mJPY); >>> depoFRASwapInstrumentsJPY.push_back(d3mJPY); >>> depoFRASwapInstrumentsJPY.push_back(fra3x6JPY); >>> depoFRASwapInstrumentsJPY.push_back(fra6x9JPY); >>> depoFRASwapInstrumentsJPY.push_back(fra6x12JPY); >>> depoFRASwapInstrumentsJPY.push_back(s2yJPY); >>> depoFRASwapInstrumentsJPY.push_back(s3yJPY); >>> depoFRASwapInstrumentsJPY.push_back(s5yJPY); >>> depoFRASwapInstrumentsJPY.push_back(s10yJPY); >>> depoFRASwapInstrumentsJPY.push_back(s15yJPY); >>> boost::shared_ptr<YieldTermStructure> depoFRASwapTermStructureJPY( >>> new PiecewiseYieldCurve<Discount,LogLinear>( >>> settlementDate, depoFRASwapInstrumentsJPY, >>> termStructureDayCounter, >>> tolerance)); >>> >>> RelinkableHandle<YieldTermStructure> >>> discountingTermStructureJPY; >>> >>> RelinkableHandle<YieldTermStructure> >>> forecastingTermStructureJPY; >>> >>> /********************* >>> * SWAPS TO BE PRICED * >>> **********************/ >>> >>> Real nominalDummy = 0.0; >>> >>> std::vector<Real> nominalJPY; >>> nominalJPY.push_back(16000000000); >>> nominalJPY.push_back(16000000000); >>> nominalJPY.push_back(16000000000); >>> nominalJPY.push_back(16000000000); >>> >>> std::vector<Real> nominalUSD; >>> nominalUSD.push_back(20000000); >>> nominalUSD.push_back(20500000); >>> nominalUSD.push_back(20100000); >>> nominalUSD.push_back(20070000); >>> >>> // fixed leg >>> Frequency frequencyDummy = Quarterly; >>> BusinessDayConvention conventionDummy = Unadjusted; >>> >>> DayCounter dayCounterDummy = Thirty360(Thirty360::European); >>> Rate fixedRate = 0.0; >>> >>> // floating leg >>> BusinessDayConvention conventionUSD = ModifiedFollowing; >>> BusinessDayConvention conventionJPY = ModifiedFollowing; >>> DayCounter dayCounterUSD = Actual360(); >>> DayCounter dayCounterJPY = Actual360();Frequency frequencyUSD = Quarterly; >>> Frequency frequencyJPY = Quarterly; >>> boost::shared_ptr<IborIndex> euriborIndexUSD( >>> new Euribor6M(forecastingTermStructureUSD)); >>> boost::shared_ptr<IborIndex> euriborIndexJPY( >>> new Euribor6M(forecastingTermStructureJPY)); >>> Spread spreadUSD = 0.0; >>> Spread spreadJPY = -0.0069; >>> >>> Integer lenghtInYears = 1; >>> VanillaSwap::Type swapTypeUSD = VanillaSwap::Receiver; >>> VanillaSwap::Type swapTypeJPY = VanillaSwap::Payer; >>> >>> Date maturity = settlementDate + lenghtInYears*Years; >>> Schedule fixedSchedule(settlementDate, maturity, >>> Period(fixedLegFrequency), >>> calendar, fixedLegConvention, >>> fixedLegConvention, >>> DateGeneration::Forward, false); >>> Schedule floatScheduleUSD(settlementDate, maturity, >>> Period(frequencyUSD), >>> calendar, conventionUSD, >>> conventionUSD, >>> DateGeneration::Forward, false); >>> Schedule floatScheduleJPY(settlementDate, maturity, >>> Period(frequencyJPY), >>> calendar, conventionJPY, >>> conventionJPY, >>> DateGeneration::Forward, false); >>> >>> NonStandardSwap dummyUSDSwap(swapTypeUSD, nominalDummy, nominalUSD, >>> floatScheduleUSD, fixedRate, >>> dayCounterDummy, floatScheduleUSD, >>> euriborIndexUSD, QL_EPSILON, spreadUSD, >>> dayCounterUSD, false, false, conventionUSD) >>> NonStandardSwap dummyJPYSwap(swapTypeJPY, nominalDummy, nominalJPY, >>> floatScheduleJPY, fixedRate, >>> dayCounterDummy, floatScheduleJPY, >>> euriborIndexJPY, QL_EPSILON, spreadJPY, >>> dayCounterJPY, false, false, >>> conventionJPY) >>> >>> /*************** >>> * SWAP PRICING * >>> ****************/ >>> >>> Real NPVUSD; >>> Real NPVJPY; >>> Real NPVmySwap; >>> >>> boost::shared_ptr<PricingEngine> swapEngineUSD( >>> new >>> DiscountingSwapEngine(discountingTermStructureUSD)); >>> >>> dummyUSDSwap.setPricingEngine(swapEngineUSD); >>> >>> forecastingTermStructureUSD.linkTo(depoSwapTermStructureUSD); >>> discountingTermStructureUSD.linkTo(depoSwapTermStructureUSD); >>> >>> NPVUSD = dummyUSDSwap.NPV(); >>> >>> >>> boost::shared_ptr<PricingEngine> swapEngineJPY( >>> new >>> DiscountingSwapEngine(discountingTermStructureJPY)); >>> >>> dummyJPYSwap.setPricingEngine(swapEngineJPY); >>> >>> forecastingTermStructureJPY.linkTo(depoSwapTermStructureJPY); >>> discountingTermStructureJPY.linkTo(depoSwapTermStructureJPY); >>> >>> NPVJPY = dummyJPYSwap.NPV(); >>> >>> NPVmySwap = NPVUSD - NPVJPY; >>> >>> return 0; >>> >>> } catch (std::exception& e) { >>> std::cerr << e.what() << std::endl; >>> return 1; >>> } catch (...) { >>> std::cerr << "unknown error" << std::endl; >>> return 1; >>> } >>> } >>> //////////////////////////// >>> >>> -----Original Message----- >>> From: Peter Caspers [mailto:[hidden email]] >>> Sent: Monday, January 25, 2016 10:09 PM >>> To: Dragomir Nedeltchev >>> Cc: [hidden email] >>> Subject: Re: [Quantlib-users] pricing Mark-To-Market Cross-Currency >>> Swap >>> >>> Hi Dragomir, >>> >>> you have to create the schedules of your floating legs (which >>> basically represent the series of their accrual periods), with >>> effective Date = start of first accrual period (forward starting in >>> your case), termination date = end of last accrual period. Then pass >>> them together with the other parameters to the NonStandardSwap >>> constructor. Note that you have to precalculate the deterministic >>> notional schedule of the USD leg before, this is not handled in the >>> NonstandardSwap either. The NonStandardSwaps accepts a vector of >>> notionals corresponding to the accrual periods. You can set up the >>> fixed schedule as equal to the floating schedule (whatever, it is not >>> used) and with notionals zero. >>> >>> Then set up two DiscountingSwapEngines, assign them to your non standard swaps and extract the NPV from each one (which is in USD resp. JPY for the respective legs, because the instrument is a single currency instrument actually as well as the pricing engine). >>> >>> Regards >>> Peter >>> >>> On 25 January 2016 at 09:44, Dragomir Nedeltchev <[hidden email]> wrote: >>>> Hi Peter, >>>> >>>> Thank you for the prompt feedback. This seems to meet my needs. >>>> >>>> I deal with a 1Y5Y swap. How can I tackle this feature in a NonStandardSwap? >>>> >>>> I see there is VanillaSwap oneYearForward5YeraSwap, but the Vanilla Swap class doesn't treat the floating notional reset feature of the MTM swap. >>>> >>>> Thank you in advance. >>>> >>>> Kind regards, >>>> >>>> Dragomir >>>> >>>> -----Original Message----- >>>> From: Peter Caspers [mailto:[hidden email]] >>>> Sent: Sunday, January 24, 2016 2:08 PM >>>> To: Dragomir Nedeltchev >>>> Cc: [hidden email] >>>> Subject: Re: [Quantlib-users] pricing Mark-To-Market Cross-Currency >>>> Swap >>>> >>>> Hi Dragomir, >>>> >>>> there is no ready-to-use class in QuantLib for this I think. >>>> >>>> But as you say, you can repesent the mtm swap as two single legs with a customized notional schedule for one of them. Beneath the bond classes you can also use the NonStandardSwap I guess (setting the fixed leg's nominals to zero and only use the floating leg for each mtm swap leg) and do the valuation of the single legs with two DiscountingSwapEngine's attaching appropriate discount curves for USD and JPY. >>>> >>>> Kind Regards >>>> Peter >>>> >>>> On 22 January 2016 at 08:47, Dragomir Nedeltchev <[hidden email]> wrote: >>>>> Hi All, >>>>> >>>>> >>>>> >>>>> I am pricing a Mark-To-Market JPYUSD Swap. >>>>> >>>>> >>>>> >>>>> Advise please which swap class of QuantLib serves this purpose. >>>>> >>>>> >>>>> >>>>> Can I present the swap as a JPY floating bond and a USD amortizing >>>>> floating rate bond (notionals vector to be calculated by the FX rate >>>>> at the reset dates). Thanks >>>>> >>>>> >>>>> >>>>> Dragomir Nedeltchev, Custom House >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> TMF Custom House Fund Services (Ireland) Limited Registered Office: >>>>> 3rd Floor, Kilmore House, Park Lane, Spencer Dock, Dublin 1, >>>>> Ireland; >>>>> Tel: (353) >>>>> 1 878 0807; Fax: (353) 1 878 0827 Website: www.customhousegroup.com >>>>> Directors: Mark Hedderman; Kevin Walsh; Barbara Cotter Registered in >>>>> Ireland No. 147511 TMF Custom House Fund Services (Ireland) Limited >>>>> is authorised by The Central Bank of Ireland under Section 10 of the >>>>> Investment Intermediaries Act, 1995 >>>>> ******************************************************************** >>>>> * >>>>> * >>>>> **************************************** >>>>> This e-mail and any files transmitted with it are intended to be >>>>> confidential and intended solely for the use of the individual or >>>>> entity to whom they are addressed. If you have received this e-mail >>>>> in error please notify the sender. Internet mail is a communication >>>>> channel, which is not controlled by Custom House, who cannot and do >>>>> not guarantee that: any e-mail sent from Custom House will be >>>>> delivered within a reasonable timeframe, or at all; comes from the >>>>> purported sender; has not been intercepted by a third party; or that >>>>> the contents of the e-mail are unaltered from the time of >>>>> transmission. The recipient of this e-mail message should take note >>>>> that this document does not constitute a legally binding contractual >>>>> obligation of any sort unless there is a specific statement within >>>>> the above message confirming that the message contains such a legally binding contractual obligation. >>>>> ******************************************************************** >>>>> * >>>>> * >>>>> ******************************************** >>>>> >>>>> -------------------------------------------------------------------- >>>>> - >>>>> - >>>>> -------- >>>>> Site24x7 APM Insight: Get Deep Visibility into Application >>>>> Performance APM + Mobile APM + RUM: Monitor 3 App instances at just >>>>> $35/Month Monitor end-to-end web transactions and take corrective >>>>> actions now Troubleshoot faster and improve end-user experience. Signup Now! >>>>> http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140 >>>>> _______________________________________________ >>>>> QuantLib-users mailing list >>>>> [hidden email] >>>>> https://lists.sourceforge.net/lists/listinfo/quantlib-users >>>>> >>>> TMF Custom House Fund Services (Ireland) Limited Registered Office: >>>> 3rd Floor, Kilmore House, Park Lane, Spencer Dock, Dublin 1, Ireland; >>>> Tel: (353) 1 878 0807; Fax: (353) 1 878 0827 Website: >>>> www.customhousegroup.com Directors: Mark Hedderman; Kevin Walsh; >>>> Barbara Cotter Registered in Ireland No. 147511 TMF Custom House Fund >>>> Services (Ireland) Limited is authorised by The Central Bank of >>>> Ireland under Section 10 of the Investment Intermediaries Act, 1995 >>>> ********************************************************************* >>>> * >>>> **************************************** This e-mail and any files >>>> transmitted with it are intended to be confidential and intended >>>> solely for the use of the individual or entity to whom they are >>>> addressed. If you have received this e-mail in error please notify >>>> the sender. Internet mail is a communication channel, which is not >>>> controlled by Custom House, who cannot and do not guarantee that: any >>>> e-mail sent from Custom House will be delivered within a reasonable >>>> timeframe, or at all; comes from the purported sender; has not been >>>> intercepted by a third party; or that the contents of the e-mail are >>>> unaltered from the time of transmission. The recipient of this e-mail >>>> message should take note that this document does not constitute a >>>> legally binding contractual obligation of any sort unless there is a >>>> specific statement within the above message confirming that the >>>> message contains such a legally binding contractual obligation. >>>> ********************************************************************* >>>> * >>>> ******************************************** >>> TMF Custom House Fund Services (Ireland) Limited Registered Office: >>> 3rd Floor, Kilmore House, Park Lane, Spencer Dock, Dublin 1, Ireland; >>> Tel: (353) 1 878 0807; Fax: (353) 1 878 0827 Website: >>> www.customhousegroup.com Directors: Mark Hedderman; Kevin Walsh; >>> Barbara Cotter Registered in Ireland No. 147511 TMF Custom House Fund >>> Services (Ireland) Limited is authorised by The Central Bank of >>> Ireland under Section 10 of the Investment Intermediaries Act, 1995 >>> ********************************************************************** >>> **************************************** This e-mail and any files >>> transmitted with it are intended to be confidential and intended >>> solely for the use of the individual or entity to whom they are >>> addressed. If you have received this e-mail in error please notify the >>> sender. Internet mail is a communication channel, which is not >>> controlled by Custom House, who cannot and do not guarantee that: any >>> e-mail sent from Custom House will be delivered within a reasonable >>> timeframe, or at all; comes from the purported sender; has not been >>> intercepted by a third party; or that the contents of the e-mail are >>> unaltered from the time of transmission. The recipient of this e-mail >>> message should take note that this document does not constitute a >>> legally binding contractual obligation of any sort unless there is a >>> specific statement within the above message confirming that the >>> message contains such a legally binding contractual obligation. >>> ********************************************************************** >>> ******************************************** >> TMF Custom House Fund Services (Ireland) Limited Registered Office: 3rd Floor, Kilmore House, Park Lane, Spencer Dock, Dublin 1, Ireland; Tel: (353) 1 878 0807; Fax: (353) 1 878 0827 Website: www.customhousegroup.com Directors: Mark Hedderman; Kevin Walsh; Barbara Cotter Registered in Ireland No. 147511 TMF Custom House Fund Services (Ireland) Limited is authorised by The Central Bank of Ireland under Section 10 of the Investment Intermediaries Act, 1995 ************************************************************************************************************** This e-mail and any files transmitted with it are intended to be confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this e-mail in error please notify the sender. Internet mail is a communication channel, which is not controlled by Custom House, who cannot and do not guarantee that: any e-mail sent from Custom House will be delivered within a reasonable timeframe, or at all; comes from the purported sender; has not been intercepted by a third party; or that the contents of the e-mail are unaltered from the time of transmission. The recipient of this e-mail message should take note that this document does not constitute a legally binding contractual obligation of any sort unless there is a specific statement within the above message confirming that the message contains such a legally binding contractual obligation. ****************************************************************************************************************** > TMF Custom House Fund Services (Ireland) Limited Registered Office: 3rd Floor, Kilmore House, Park Lane, Spencer Dock, Dublin 1, Ireland; Tel: (353) 1 878 0807; Fax: (353) 1 878 0827 Website: www.customhousegroup.com Directors: Mark Hedderman; Kevin Walsh; Barbara Cotter Registered in Ireland No. 147511 TMF Custom House Fund Services (Ireland) Limited is authorised by The Central Bank of Ireland under Section 10 of the Investment Intermediaries Act, 1995 ************************************************************************************************************** This e-mail and any files transmitted with it are intended to be confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this e-mail in error please notify the sender. Internet mail is a communication channel, which is not controlled by Custom House, who cannot and do not guarantee that: any e-mail sent from Custom House will be delivered within a reasonable timeframe, or at all; comes from the purported sender; has not been intercepted by a third party; or that the contents of the e-mail are unaltered from the time of transmission. The recipient of this e-mail message should take note that this document does not constitute a legally binding contractual obligation of any sort unless there is a specific statement within the above message confirming that the message contains such a legally binding contractual obligation. ****************************************************************************************************************** ------------------------------------------------------------------------------ Site24x7 APM Insight: Get Deep Visibility into Application Performance APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month Monitor end-to-end web transactions and take corrective actions now Troubleshoot faster and improve end-user experience. Signup Now! http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140 _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Hi, seems that the message got too big due to the code you sent. Below
is just my last response therefore. Regards, Peter ---------- Forwarded message ---------- From: Peter Caspers <[hidden email]> Date: 28 January 2016 at 21:38 Subject: Re: [Quantlib-users] pricing Mark-To-Market Cross-Currency Swap To: dragomir nedeltchev <[hidden email]> Cc: QuantLib Mailing Lists <[hidden email]> Hi Dragomir, the problem is that you do not see the actual error message that QuantLib gives you. That would help a lot: Actually it changed to another message now saying that the bootstrap fails because of a non-bracketed root. This is because you use swap quotes like 1.23 for 1.23% but QuantLib expects 0.0123. The same for deposits. Try to amend this. But first try to get the error message, otherwise you are flying blindly. Also you are still doing things like NPVmySwap = NPVUSD - NPVJPY; where you have to convert the NPVs to a common base currency to get a sensible result. Therefore, check every intermediate result first, the discount factors of the curves, the single leg NPVs, maybe even the single cashlows of each leg.. Regards Peter ------------------------------------------------------------------------------ Site24x7 APM Insight: Get Deep Visibility into Application Performance APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month Monitor end-to-end web transactions and take corrective actions now Troubleshoot faster and improve end-user experience. Signup Now! http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140 _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Free forum by Nabble | Edit this page |