Swap Price QuantLib vs. Bloomberg

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Swap Price QuantLib vs. Bloomberg

dhoorens
Hi
I'm trying to replicate a Swap price I can see on my Bloomberg page


I 'm not using the Quantlib xl code, because some people in my company are not yet ready to use objects in Excel (pfff) => I have created my own interface with Excel
Here is the code

double  vanillaSwapPrice(int todaysDate_,
                        int tenorInYears,
                        double fixRate,
                        int forwardTenorInMonths,
                        int fltFrequency_,
                        xloper* yieldTermStructure,
                        double nominal,
                        char* type,
                        int settlementDays,
                        int fixFrequency_,
                        char* calendar_,
                        char* dayCounter_,
                        char* fixDayCounter_,
                        char* fltDayCounter_,
                        double spread,
                        char* results){


        try{

                QuantLib::Calendar calendar = toCalendar(calendar_, QuantLib::TARGET());
                QuantLib::Calendar fixCalendar = calendar;
                QuantLib::Calendar fltCalendar = calendar;

                QuantLib::RelinkableHandle<QuantLib::YieldTermStructure> yTS;

                QuantLib::Frequency fixFrequency = toFrequency(fixFrequency_);
                QuantLib::Frequency fltFrequency = toFrequency(fltFrequency_, QuantLib::Semiannual);

                QuantLib::DayCounter dayCounter = toDayCounter(dayCounter_, QuantLib::Actual360());
                QuantLib::DayCounter fixDayCounter = toDayCounter(fixDayCounter_, QuantLib::Thirty360(QuantLib::Thirty360::BondBasis));
                QuantLib::DayCounter fltDayCounter = toDayCounter(fltDayCounter_, QuantLib::Actual360());

                boost::shared_ptr<QuantLib::IborIndex> index =
                        makeIborIndex(QuantLib::Period(fltFrequency),yTS)
                                .withSettlementDays(settlementDays)
                                .withCalendar(calendar)
                                .withDayCounter(fltDayCounter);


                QuantLib::Date todaysDate = toDate(todaysDate_);
                QuantLib::Settings::instance().evaluationDate() = todaysDate;
                QuantLib::Date settlement = calendar.advance(todaysDate,settlementDays,QuantLib::Days);
                yTS.linkTo(toYieldTermStructure(settlement, calendar, dayCounter, yieldTermStructure));
 
                QuantLib::VanillaSwap::Type typ;
                std::string type_ = std::string(type);
                if (type_ == "R")
                        typ = QuantLib::VanillaSwap::Receiver;
                else if (type_ == "P")
                        typ = QuantLib::VanillaSwap::Payer;
                else
                        throw (std::string("unknwown type of Swap"));

                if (nominal ==0.0)
                        nominal = 1.0;

                boost::shared_ptr<QuantLib::VanillaSwap> sw =
                        makeVSwap(QuantLib::Period(tenorInYears,QuantLib::Years),
                                          index,
                                          fixRate,
                                          QuantLib::Period(forwardTenorInMonths,QuantLib::Months))
                                .withType(typ)
                                .withNominal(nominal)
                                .withFixedLegTenor(QuantLib::Period(fixFrequency))
                                .withFixedLegCalendar(fixCalendar)
                                .withFixedLegDayCount(fixDayCounter)
                                .withFloatingLegTenor(QuantLib::Period(fltFrequency))
                                .withFloatingLegSpread(QuantLib::Spread(spread))
                                .withFloatingLegCalendar(fltCalendar)
                                .withFloatingLegDayCount(fltDayCounter);



                //Depending on what I want as results i can choose between
                         return sw->NPV();
                         //return sw->fixedLegNPV();
                         //return sw->fixedLegBPS();
                         //return sw->floatingLegNPV();
                         //return sw->floatingLegBPS();
                         //return sw->fairRate();
        }
        catch (...) {
                errMsg += "[" + functionCall->functionName() + "]" + "Unknown Error";
             }
    //not the real return but adapted here to say somthg :-/
    return -1;

}





The toXXX functions (i.e. toFrequency, toDayCounter, etc) are converter of the inputs into QuantLib types. The (optionnal) second input is the default value, if the first value is not right


Here is the toYieldTermStructure function
boost::shared_ptr<YieldTermStructure> toYieldTermStructure (Date settlement,
                                                        Calendar calendar,
                                                        DayCounter dayCounter,
                                                        xloper* input,
                                                        Compounding comp= QuantLib::Continuous,
                                                        Frequency freq== QuantLib::Annual,
                                                        bool endOfMonth= true){
       
        std::vector<std::vector<double> >m = ObjectHandler::operToMatrix<double>(*input ,"Input");
        unsigned int rows, cols, sizeInput;
        rows = m.size();
        cols = m[0].size();
        sizeInput = __max(rows,cols);
       
        boost::shared_ptr<YieldTermStructure> curve;

        if (sizeInput==1)
                curve = boost::shared_ptr<YieldTermStructure>(
                new FlatForward(settlement, m[0][0], dayCounter, comp, freq));
        else{
                std::vector<Date> vDate;
                std::vector<Real> vPrice;
                bool isDate = (m[0][0] >=367); //the first X-value of the curve is greater than 1/1/1901 => it's a date
                if (rows ==2 && cols > 2){  //horizontal data
                        int j_init = 0;
                        if (m[1][0] != 1.0){
                                vDate.push_back(settlement);
                                vPrice.push_back(1.0);
                                j_init++;
                        }
                        else {
                                if ((isDate && toDate((long)m[0][0]) != settlement) || (!isDate && m[0][0] != 0.0))
                                        throw (std::string("[toYieldTermStructure] Invalid first term value"));
                        }

                        for (unsigned int j = j_init; j< cols; j++){
                                if (isDate)
                                        vDate.push_back(toDate((long)m[0][j]));
                                else
                                        //It is not a date => we assume the value is in Months and we add it to the settlement
                                        vDate.push_back(calendar.advance(settlement, (long)m[0][j], Months, QuantLib::Unadjusted, endOfMonth));
                                vPrice.push_back(m[1][j]);
                        }
                }
                else if (cols ==2 && rows > 2){  //vertical data
                        int i_init = 0;
                        if (m[0][1] != 1.0){
                                vDate.push_back(settlement);
                                vPrice.push_back(1.0);
                                i_init ++;
                        }
                        else {
                                if ((isDate && toDate((long)m[0][0]) != settlement) || (!isDate && m[0][0] != 0.0))
                                        throw (std::string("[toYieldTermStructure] Invalid first term value"));
                        }
                        for (unsigned int i = i_init; i< rows; i++){
                                if (isDate)
                                        vDate.push_back(toDate((long)m[i][0]));
                                else
                                        //It is not a date => we assume the value is in Months and we add it to the settlement
                                        vDate.push_back(calendar.advance(settlement, (long)m[i][0], Months, QuantLib::Unadjusted, endOfMonth));
                                vPrice.push_back(m[i][1]);
                        }
                }
                else
                        throw (std::string("[toYieldTermStructure] data has too much either cols or rows"));
               
                curve = boost::shared_ptr<YieldTermStructure>(
                        new InterpolatedDiscountCurve<Cubic>(
                                        vDate,
                                        vPrice,
                                        dayCounter,
                                        calendar,
                                        Cubic(CubicInterpolation::Spline,
                                                  false,
                                                  CubicInterpolation::SecondDerivative,
                                                  0.0,
                                                  CubicInterpolation::SecondDerivative,
                                                  0.0)));
        }

        return curve;
}



Finally in attach you can find the makeVSwap and makeIborIndex classes





When I enter in Excel as inputs:
int todaysDate_ = 40261 (ie 24/3/2010)
int tenorInYears = 5
double fixRate = 2.21207%
int forwardTenorInMonths = 0
int fltFrequency_ = 2
xloper* yieldTermStructure = the curve given by the the second gif file
double nominal = 10000000
char* type = R
int settlementDays = 0
int fixFrequency_ = 1
char* calendar_ = TARGET
char* dayCounter_ =THIRTY360
char* fixDayCounter_ = THIRTY360
char* fltDayCounter_ = ACTUAL360
double spread = 0

it returns a value for
NPV = -9252218
FixLegNPV = 1042594.49
FixLegBps = 4713.22
FltLegNPV = -1135118.66
FltLegBps = -4809.48
FairRate = 2.40837


Here are the questions
Why do I have differences with Bloomberg.
Is QuantLib coherent with Blmbg?
Why the market value of each leg is so different (Blmg vs QuantLib)? (example QuantLIb FixLegNPV = 1042596.49   and Blmbg FixLegNPV = 9904395.99)

Tks
David
QL_Blmbg.zip
Reply | Threaded
Open this post in threaded view
|

Re: Swap Price QuantLib vs. Bloomberg

dhoorens
Hi  
the zip file seems not to work.
Here is another version
David


-----Original Message-----
From: dhoorens [mailto:[hidden email]]
Sent: mercredi 24 mars 2010 13:04
To: [hidden email]
Subject: [Quantlib-users] Swap Price QuantLib vs. Bloomberg


Hi
I'm trying to replicate a Swap price I can see on my Bloomberg page


I 'm not using the Quantlib xl code, because some people in my company
are
not yet ready to use objects in Excel (pfff) => I have created my own
interface with Excel
Here is the code

double  vanillaSwapPrice(int todaysDate_,
                        int tenorInYears,
                        double fixRate,
                        int forwardTenorInMonths,
                        int fltFrequency_,
                        xloper* yieldTermStructure,
                        double nominal,
                        char* type,
                        int settlementDays,
                        int fixFrequency_,
                        char* calendar_,
                        char* dayCounter_,
                        char* fixDayCounter_,
                        char* fltDayCounter_,
                        double spread,
                        char* results){


        try{

                QuantLib::Calendar calendar = toCalendar(calendar_,
QuantLib::TARGET());
                QuantLib::Calendar fixCalendar = calendar;
                QuantLib::Calendar fltCalendar = calendar;

                QuantLib::RelinkableHandle<QuantLib::YieldTermStructure>
yTS;

                QuantLib::Frequency fixFrequency =
toFrequency(fixFrequency_);
                QuantLib::Frequency fltFrequency =
toFrequency(fltFrequency_, QuantLib::Semiannual);

                QuantLib::DayCounter dayCounter =
toDayCounter(dayCounter_,
QuantLib::Actual360());
                QuantLib::DayCounter fixDayCounter =
toDayCounter(fixDayCounter_,
QuantLib::Thirty360(QuantLib::Thirty360::BondBasis));
                QuantLib::DayCounter fltDayCounter =
toDayCounter(fltDayCounter_, QuantLib::Actual360());

                boost::shared_ptr<QuantLib::IborIndex> index =
 
makeIborIndex(QuantLib::Period(fltFrequency),yTS)
                                .withSettlementDays(settlementDays)
                                .withCalendar(calendar)
                                .withDayCounter(fltDayCounter);


                QuantLib::Date todaysDate = toDate(todaysDate_);
                QuantLib::Settings::instance().evaluationDate() =
todaysDate;
                QuantLib::Date settlement =
calendar.advance(todaysDate,settlementDays,QuantLib::Days);
                yTS.linkTo(toYieldTermStructure(settlement, calendar,
dayCounter, yieldTermStructure));
 
                QuantLib::VanillaSwap::Type typ;
                std::string type_ = std::string(type);
                if (type_ == "R")
                        typ = QuantLib::VanillaSwap::Receiver;
                else if (type_ == "P")
                        typ = QuantLib::VanillaSwap::Payer;
                else
                        throw (std::string("unknwown type of Swap"));

                if (nominal ==0.0)
                        nominal = 1.0;

                boost::shared_ptr<QuantLib::VanillaSwap> sw =
                       
makeVSwap(QuantLib::Period(tenorInYears,QuantLib::Years),
                                          index,
                                          fixRate,
                                         
QuantLib::Period(forwardTenorInMonths,QuantLib::Months))
                                .withType(typ)
                                .withNominal(nominal)
                               
.withFixedLegTenor(QuantLib::Period(fixFrequency))
                                .withFixedLegCalendar(fixCalendar)
                                .withFixedLegDayCount(fixDayCounter)
                               
.withFloatingLegTenor(QuantLib::Period(fltFrequency))
                               
.withFloatingLegSpread(QuantLib::Spread(spread))
                                .withFloatingLegCalendar(fltCalendar)
                                .withFloatingLegDayCount(fltDayCounter);




                //Depending on what I want as results i can choose
between
                         return sw->NPV();
                         //return sw->fixedLegNPV();
                         //return sw->fixedLegBPS();
                         //return sw->floatingLegNPV();
                         //return sw->floatingLegBPS();
                         //return sw->fairRate();
        }
        catch (...) {
                errMsg += "[" + functionCall->functionName() + "]" +
"Unknown Error";
             }
    //not the real return but adapted here to say somthg :-/
    return -1;

}





The toXXX functions (i.e. toFrequency, toDayCounter, etc) are converter
of
the inputs into QuantLib types. The (optionnal) second input is the
default
value, if the first value is not right


Here is the toYieldTermStructure function
boost::shared_ptr<YieldTermStructure> toYieldTermStructure (Date
settlement,
                                                        Calendar
calendar,
                                                        DayCounter
dayCounter,
                                                        xloper* input,
                                                        Compounding
comp=
QuantLib::Continuous,
                                                        Frequency freq==
QuantLib::Annual,
                                                        bool endOfMonth=
true){
       
        std::vector<std::vector<double> >m =
ObjectHandler::operToMatrix<double>(*input ,"Input");
        unsigned int rows, cols, sizeInput;
        rows = m.size();
        cols = m[0].size();
        sizeInput = __max(rows,cols);
       
        boost::shared_ptr<YieldTermStructure> curve;

        if (sizeInput==1)
                curve = boost::shared_ptr<YieldTermStructure>(
                new FlatForward(settlement, m[0][0], dayCounter, comp,
freq));
        else{
                std::vector<Date> vDate;
                std::vector<Real> vPrice;
                bool isDate = (m[0][0] >=367); //the first X-value of
the
curve is greater than 1/1/1901 => it's a date
                if (rows ==2 && cols > 2){  //horizontal data
                        int j_init = 0;
                        if (m[1][0] != 1.0){
                                vDate.push_back(settlement);
                                vPrice.push_back(1.0);
                                j_init++;
                        }
                        else {
                                if ((isDate && toDate((long)m[0][0]) !=
settlement) || (!isDate && m[0][0] != 0.0))
                                        throw
(std::string("[toYieldTermStructure] Invalid first term value"));
                        }

                        for (unsigned int j = j_init; j< cols; j++){
                                if (isDate)
                                       
vDate.push_back(toDate((long)m[0][j]));
                                else
                                        //It is not a date => we assume
the
value is in Months and we add it to the settlement
                                       
vDate.push_back(calendar.advance(settlement, (long)m[0][j], Months,
QuantLib::Unadjusted, endOfMonth));
                                vPrice.push_back(m[1][j]);
                        }
                }
                else if (cols ==2 && rows > 2){  //vertical data
                        int i_init = 0;
                        if (m[0][1] != 1.0){
                                vDate.push_back(settlement);
                                vPrice.push_back(1.0);
                                i_init ++;
                        }
                        else {
                                if ((isDate && toDate((long)m[0][0]) !=
settlement) || (!isDate && m[0][0] != 0.0))
                                        throw
(std::string("[toYieldTermStructure] Invalid first term value"));
                        }
                        for (unsigned int i = i_init; i< rows; i++){
                                if (isDate)
                                       
vDate.push_back(toDate((long)m[i][0]));
                                else
                                        //It is not a date => we assume
the
value is in Months and we add it to the settlement
                                       
vDate.push_back(calendar.advance(settlement, (long)m[i][0], Months,
QuantLib::Unadjusted, endOfMonth));
                                vPrice.push_back(m[i][1]);
                        }
                }
                else
                        throw (std::string("[toYieldTermStructure] data
has
too much either cols or rows"));
               
                curve = boost::shared_ptr<YieldTermStructure>(
                        new InterpolatedDiscountCurve<Cubic>(
                                        vDate,
                                        vPrice,
                                        dayCounter,
                                        calendar,
 
Cubic(CubicInterpolation::Spline,
                                                  false,
                                                 
CubicInterpolation::SecondDerivative,
                                                  0.0,
                                                 
CubicInterpolation::SecondDerivative,
                                                  0.0)));
        }

        return curve;
}



Finally in attach you can find the makeVSwap and makeIborIndex classes





When I enter in Excel as inputs:
int todaysDate_ = 40261 (ie 24/3/2010)
int tenorInYears = 5
double fixRate = 2.21207%
int forwardTenorInMonths = 0
int fltFrequency_ = 2
xloper* yieldTermStructure = the curve given by the the second gif file
double nominal = 10000000
char* type = R
int settlementDays = 0
int fixFrequency_ = 1
char* calendar_ = TARGET
char* dayCounter_ =THIRTY360
char* fixDayCounter_ = THIRTY360
char* fltDayCounter_ = ACTUAL360
double spread = 0

it returns a value for
NPV = -9252218
FixLegNPV = 1042594.49
FixLegBps = 4713.22
FltLegNPV = -1135118.66
FltLegBps = -4809.48
FairRate = 2.40837


Here are the questions
Why do I have differences with Bloomberg.
Is QuantLib coherent with Blmbg?
Why the market value of each leg is so different (Blmg vs QuantLib)?
(example QuantLIb FixLegNPV = 1042596.49   and Blmbg FixLegNPV =
9904395.99)

Tks
David
http://old.nabble.com/file/p28014072/QL_Blmbg.zip QL_Blmbg.zip
--
View this message in context:
http://old.nabble.com/Swap-Price-QuantLib-vs.-Bloomberg-tp28014072p28014
072.html
Sent from the quantlib-users mailing list archive at Nabble.com.


------------------------------------------------------------------------
------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users



-----Disclaimer-----

This message may contain confidential information intended solely for the use of the named addressee. If you are not
the intended recipient, you should not read, use, disclose or reproduce the content of this message. If you have
received this message by mistake, please notify the sender immediately. Any views or opinions presented in this
message are solely those of the author and do not necessarily represent those of AXA Belgium, AXA Bank Europe,
AXA Tech Belgium GIE - ESV or any other entity of the AXA Group, unless otherwise stated by the sender and duly
authorized by the said companies.

---------------------

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users

QL_Blmbg.zip (71K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Swap Price QuantLib vs. Bloomberg

Kim Kuen Tang
In reply to this post by dhoorens

Hi David,

without going into detail of your code i would say that this is related
in the way how you created the yc in quantlib.
You should get the same result from blmbg if the discountfactors
together with the maturities are correctly passed to ql.
I would say just double check your yc in ql again and the leg you
created. ( Better dont take the discountfactors from blmbg, take the
swap quotes from blmbg and bootstrap a yc in ql, then compare the
discountfactors between blmbg and ql)


dhoorens schrieb:
>
> Here are the questions
> Why do I have differences with Bloomberg.
> Is QuantLib coherent with Blmbg?
>  
This has nothing to do with ql. A yc is uniquely determined by its
calibration instruments ( bonds, futures, swap,..) and other conventions
( interpolations, daycounter,...)
If everythings are equivalent then the resulting ycs should be the same
and as a consequence the pricing should also be the same.

Cheers,
Kim

> Why the market value of each leg is so different (Blmg vs QuantLib)?
> (example QuantLIb FixLegNPV = 1042596.49   and Blmbg FixLegNPV = 9904395.99)
>
> Tks
> David
> http://old.nabble.com/file/p28014072/QL_Blmbg.zip QL_Blmbg.zip
>  


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Swap Price QuantLib vs. Bloomberg

dhoorens
So if I understand you well, you tell me that by changing the yieldCurve
I will obtain exactly what Bloomberg gives me
If it is the case, I can believe you :-)

But I have a problem with the fixed and floating leg values. Why are
they so different
FixLeg: QL = ~1MM
FixLeg: Blmbg: = ~10MM
??

Tks
David


-----Original Message-----
From: Kim Kuen Tang [mailto:[hidden email]]
Sent: mercredi 24 mars 2010 14:21
To: HOORENS David
Cc: [hidden email]
Subject: Re: [Quantlib-users] Swap Price QuantLib vs. Bloomberg


Hi David,

without going into detail of your code i would say that this is related
in the way how you created the yc in quantlib.
You should get the same result from blmbg if the discountfactors
together with the maturities are correctly passed to ql.
I would say just double check your yc in ql again and the leg you
created. ( Better dont take the discountfactors from blmbg, take the
swap quotes from blmbg and bootstrap a yc in ql, then compare the
discountfactors between blmbg and ql)


dhoorens schrieb:
>
> Here are the questions
> Why do I have differences with Bloomberg.
> Is QuantLib coherent with Blmbg?
>  
This has nothing to do with ql. A yc is uniquely determined by its
calibration instruments ( bonds, futures, swap,..) and other conventions

( interpolations, daycounter,...)
If everythings are equivalent then the resulting ycs should be the same
and as a consequence the pricing should also be the same.

Cheers,
Kim

> Why the market value of each leg is so different (Blmg vs QuantLib)?
> (example QuantLIb FixLegNPV = 1042596.49   and Blmbg FixLegNPV =
9904395.99)
>
> Tks
> David
> http://old.nabble.com/file/p28014072/QL_Blmbg.zip QL_Blmbg.zip
>  




-----Disclaimer-----

This message may contain confidential information intended solely for the use of the named addressee. If you are not
the intended recipient, you should not read, use, disclose or reproduce the content of this message. If you have
received this message by mistake, please notify the sender immediately. Any views or opinions presented in this
message are solely those of the author and do not necessarily represent those of AXA Belgium, AXA Bank Europe,
AXA Tech Belgium GIE - ESV or any other entity of the AXA Group, unless otherwise stated by the sender and duly
authorized by the said companies.

---------------------


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Swap Price QuantLib vs. Bloomberg

Kim Kuen Tang

Hi David,

HOORENS David schrieb:
> So if I understand you well, you tell me that by changing the yieldCurve
> I will obtain exactly what Bloomberg gives me
> If it is the case, I can believe you :-)
>  
What i mean is that a fixleg is very trivial. It is only a sum over
fixed * dcf * df.
dcf = daycountfraction, df = discountfactor
 So u should get the same as from bloomberg. Did you double check ur
fixedleg ?  And did you really pass the yc correctly to ql?

> But I have a problem with the fixed and floating leg values. Why are
> they so different
> FixLeg: QL = ~1MM
> FixLeg: Blmbg: = ~10MM
> ??
>
> Tks
> David
>
>
> -----Original Message-----
> From: Kim Kuen Tang [mailto:[hidden email]]
> Sent: mercredi 24 mars 2010 14:21
> To: HOORENS David
> Cc: [hidden email]
> Subject: Re: [Quantlib-users] Swap Price QuantLib vs. Bloomberg
>
>
> Hi David,
>
> without going into detail of your code i would say that this is related
> in the way how you created the yc in quantlib.
> You should get the same result from blmbg if the discountfactors
> together with the maturities are correctly passed to ql.
> I would say just double check your yc in ql again and the leg you
> created. ( Better dont take the discountfactors from blmbg, take the
> swap quotes from blmbg and bootstrap a yc in ql, then compare the
> discountfactors between blmbg and ql)
>
>
> dhoorens schrieb:
>  


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Swap Price QuantLib vs. Bloomberg

dhoorens
Hi Kim
Except that I have used the blmbg prices instead of the rates, and that
I have quasi the same value for the Swap (fixed minus float)...
(difference of 8bps => so ok..)

So I guess it's quasi good, but I don't understand the ten factor for
the fixed Leg value.
Indeed I expected a value near the nominal for the fixed leg but with QL
I have ten times less...(1MM instead of 10 MM)???
I have used the function sw->fixedLegNPV()
Tks
David



-----Original Message-----
From: Kim Kuen Tang [mailto:[hidden email]]
Sent: jeudi 25 mars 2010 10:14
To: HOORENS David
Cc: [hidden email]
Subject: Re: [Quantlib-users] Swap Price QuantLib vs. Bloomberg


Hi David,

HOORENS David schrieb:
> So if I understand you well, you tell me that by changing the
yieldCurve
> I will obtain exactly what Bloomberg gives me
> If it is the case, I can believe you :-)
>  
What i mean is that a fixleg is very trivial. It is only a sum over
fixed * dcf * df.
dcf = daycountfraction, df = discountfactor
 So u should get the same as from bloomberg. Did you double check ur
fixedleg ?  And did you really pass the yc correctly to ql?

> But I have a problem with the fixed and floating leg values. Why are
> they so different
> FixLeg: QL = ~1MM
> FixLeg: Blmbg: = ~10MM
> ??
>
> Tks
> David
>
>
> -----Original Message-----
> From: Kim Kuen Tang [mailto:[hidden email]]
> Sent: mercredi 24 mars 2010 14:21
> To: HOORENS David
> Cc: [hidden email]
> Subject: Re: [Quantlib-users] Swap Price QuantLib vs. Bloomberg
>
>
> Hi David,
>
> without going into detail of your code i would say that this is
related

> in the way how you created the yc in quantlib.
> You should get the same result from blmbg if the discountfactors
> together with the maturities are correctly passed to ql.
> I would say just double check your yc in ql again and the leg you
> created. ( Better dont take the discountfactors from blmbg, take the
> swap quotes from blmbg and bootstrap a yc in ql, then compare the
> discountfactors between blmbg and ql)
>
>
> dhoorens schrieb:
>  




-----Disclaimer-----

This message may contain confidential information intended solely for the use of the named addressee. If you are not
the intended recipient, you should not read, use, disclose or reproduce the content of this message. If you have
received this message by mistake, please notify the sender immediately. Any views or opinions presented in this
message are solely those of the author and do not necessarily represent those of AXA Belgium, AXA Bank Europe,
AXA Tech Belgium GIE - ESV or any other entity of the AXA Group, unless otherwise stated by the sender and duly
authorized by the said companies.

---------------------


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Swap Price QuantLib vs. Bloomberg

Luigi Ballabio
Hi David,

On Thu, 2010-03-25 at 10:48 +0100, HOORENS David wrote:
> Except that I have used the blmbg prices instead of the rates, and that
> I have quasi the same value for the Swap (fixed minus float)...
> (difference of 8bps => so ok..)

Maybe not so ok---I would have expected something more accurate, since
it's a fairly simple calculation.  I see you're using a cubic
interpolation on the discount factors. What is Bloomberg using? I see
"Piecewise Linear" on the gif you included, but is it on discounts or
rates?

> So I guess it's quasi good, but I don't understand the ten factor for
> the fixed Leg value.
> Indeed I expected a value near the nominal for the fixed leg but with QL
> I have ten times less...(1MM instead of 10 MM)???

do you expect the NPV of the legs to include the final exchange of
notionals? In QuantLib, it doesn't.

Luigi




--

A programming language is low-level when its programs require attention
to the irrelevant.
-- Alan Perlis



------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users