SABRInterpolation excel vs linux differences‏‏

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

SABRInterpolation excel vs linux differences‏‏

piers august
Hi All

I'm getting significant differences (about 0.2 vol in some places) between the
SABR interpolation in excel and linux for release 0.9.7.

For the same input data below, I'm finding alpha, rho and nu have
small differences giving about a 0.2% difference between the interpolated
curves at the money and elsewhere. Beta is fixed at 1.  They should be
bang on identical right?

I'm probably doing something wrong - could anyone make any suggestions
as where to go from here to nail it?

The windows computer is a 64bit athlon and the linux is 64 bit intel btw.

cheers,
Piers


ql version 0.9.7



=qlSABRInterpolation(,G11:G25,H11:H25,C9,D9,,1,,,,TRUE)



obj_00000#0300







sabr excel outputted params linux outputted params

alpha 0.207442 alpha=0.205598

beta 1.000 beta=1

rho -0.389061 rho=-0.394466

nu 4.0176907 nu=4.16071

tau 0.0305936 tau=0.0305936

fwd 3826.25 forward=3826.25





input strikes input vols sabr excel sabr linux linux sabr – excel sabr
3400 0.368624622242282 0.354604292668933 0.359178 0.46%
3500 0.321037653604485 0.318275231545040 0.321538 0.33%
3550 0.299501682381891 0.300303657851484 0.302877 0.26%
3600 0.279643985001476 0.282569848982833 0.284426 0.19%
3650 0.261615469316373 0.265235824583730 0.266342 0.11%
3700 0.245580215704548 0.248582585887819 0.248912 0.03%
3750 0.231712426785790 0.233087499691996 0.232633 -0.05%
3800 0.220204595933114 0.219519711494862 0.218336 -0.12%
3850 0.211257342746155 0.208967123228945 0.207239 -0.17%
3900 0.205096538218055 0.202578259521284 0.200651 -0.19%
3950 0.201943526100016 0.200931625388894 0.199217 -0.17%
4000 0.202049566014993 0.203604828891783 0.202397 -0.12%
4050 0.205673850628091 0.209520147602468 0.208939 -0.06%
4100 0.213089315877449 0.217573188533236 0.217628 0.01%
4200 0.240440352051281 0.237060304926802 0.238270 0.12%




#include <ql/quantlib.hpp>
#include <iostream>
#include <vector>

using namespace QuantLib;
using namespace std;


int main(int argc, char *argv[])
{
    Real forward = 3826.25;
    Time tau = 0.0305936;

    vector<double> strikes;
    vector<double> vols;
   
    strikes.push_back(3400); vols.push_back(0.368624622242282);
    strikes.push_back(3500); vols.push_back(0.321037653604485);
    strikes.push_back(3550); vols.push_back(0.299501682381891);
    strikes.push_back(3600); vols.push_back(0.279643985001476);
    strikes.push_back(3650); vols.push_back(0.261615469316373);
    strikes.push_back(3700); vols.push_back(0.245580215704548);
    strikes.push_back(3750); vols.push_back(0.231712426785790);
    strikes.push_back(3800); vols.push_back(0.220204595933114);
    strikes.push_back(3850); vols.push_back(0.211257342746155);
    strikes.push_back(3900); vols.push_back(0.205096538218055);
    strikes.push_back(3950); vols.push_back(0.201943526100016);
    strikes.push_back(4000); vols.push_back(0.202049566014993);
    strikes.push_back(4050); vols.push_back(0.205673850628091);
    strikes.push_back(4100); vols.push_back(0.213089315877449);
    strikes.push_back(4200); vols.push_back(0.240440352051281);
   
   
   
    SABRInterpolation sabr(    strikes.begin(),
                strikes.end(),
                vols.begin(),
                tau,
                forward,
                Null<Real>(),
                1,
                Null<Real>(),
                Null<Real>(),
                false,
                true,
                false,
                false ) ;
   
    sabr.update();
   
    cout << "forward=" <<sabr.forward() << endl;   
    cout << "expiry=" << sabr.expiry() << endl;   
    cout << "alpha=" << sabr.alpha() << endl;   
    cout << "beta=" << sabr.beta() << endl;   
    cout << "nu=" << sabr.nu() << endl;   
    cout << "rho=" << sabr.rho() << endl;
    cout << "rmsError=" << sabr.rmsError() << endl;   
    cout << "atmVol=" << sabr(forward) << endl;
    cout << "endCriteria=" << sabr.endCriteria() << endl;
   
    for( unsigned int i = 0; i < strikes.size(); ++i )
        cout << strikes[i] << " " << vols[i] << " " << sabr( strikes[i] ) <<  endl;
   
       
    return 0;
}





New! Receive and respond to mail from other email accounts from within Hotmail Find out how.
------------------------------------------------------------------------------
Join us December 9, 2009 for the Red Hat Virtual Experience,
a free event focused on virtualization and cloud computing.
Attend in-depth sessions from your desk. Your couch. Anywhere.
http://p.sf.net/sfu/redhat-sfdev2dev
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: SABRInterpolation excel vs linux differences‏‏

piers august
Thanks for your suggestion Joe, the problem was due to the differing default value for the vegaWeightings arg across the c++ and excel versions! 

Piers



Excel
Parameters:

ObjectId id of object to be created

XArray x array.

YArray y array.

Expiry expiry time in years.

Forward forward.

Alpha alpha (fixed value or guess). Default value = QuantLib::Null<QuantLib::Real>().

Beta beta (fixed value or guess). Default value = QuantLib::Null<QuantLib::Real>().

Nu nu (fixed value or guess). Default value = QuantLib::Null<QuantLib::Real>().

Rho rho (fixed value or guess). Default value = QuantLib::Null<QuantLib::Real>().

AlphaIsFixed TRUE if the alpha value provided is to be kept fixed, FALSE if it is just a guess. Default value = false.

BetaIsFixed TRUE if the beta value provided is to be kept fixed, FALSE if it is just a guess. Default value = false.

NuIsFixed TRUE if the nu value provided is to be kept fixed, FALSE if it is just a guess. Default value = false.

RhoIsFixed TRUE if the rho value provided is to be kept fixed, FALSE if it is just a guess. Default value = false.

VegaWeighted TRUE if the interpolation is weighted using options Vega. Default value = true.

EndCriteria EndCriteria object ID. Default value = .

OptimizationMethod OptimizationMethod object ID. Default value = .

Permanent object permanent/nonpermanent

Trigger dependency tracking trigger

Overwrite overwrite flag

c++
SABRInterpolation (const I1 &xBegin, const I1 &xEnd, const I2 &yBegin, Time t, const Real &forward, Real alpha, Real beta, Real nu, Real rho, bool alphaIsFixed, bool betaIsFixed, bool nuIsFixed, bool rhoIsFixed, bool vegaWeighted=false, const boost::shared_ptr< EndCriteria > &endCriteria=boost::shared_ptr< EndCriteria >(), const boost::shared_ptr< OptimizationMethod > &optMethod=boost::shared_ptr< OptimizationMethod >())


Date: Mon, 7 Dec 2009 16:41:13 -0500
Subject: Re: [Quantlib-users] SABRInterpolation excel vs linux differences‏‏
From: [hidden email]
To: [hidden email]

The floating point rounding mode (fegetround()/fesetround()) and math optimization differences
(gcc -mieee-fp and cl.exe /Op) are some usual suspects.

2009/12/7 piers august <[hidden email]>
Hi All

I'm getting significant differences (about 0.2 vol in some places) between the
SABR interpolation in excel and linux for release 0.9.7.

For the same input data below, I'm finding alpha, rho and nu have
small differences giving about a 0.2% difference between the interpolated
curves at the money and elsewhere. Beta is fixed at 1.  They should be
bang on identical right?

I'm probably doing something wrong - could anyone make any suggestions
as where to go from here to nail it?

The windows computer is a 64bit athlon and the linux is 64 bit intel btw.

cheers,
Piers


ql version 0.9.7



=qlSABRInterpolation(,G11:G25,H11:H25,C9,D9,,1,,,,TRUE)



obj_00000#0300







sabr excel outputted params linux outputted params

alpha 0.207442 alpha=0.205598

beta 1.000 beta=1

rho -0.389061 rho=-0.394466

nu 4.0176907 nu=4.16071

tau 0.0305936 tau=0.0305936

fwd 3826.25 forward=3826.25





input strikes input vols sabr excel sabr linux linux sabr – excel sabr
3400 0.368624622242282 0.354604292668933 0.359178 0.46%
3500 0.321037653604485 0.318275231545040 0.321538 0.33%
3550 0.299501682381891 0.300303657851484 0.302877 0.26%
3600 0.279643985001476 0.282569848982833 0.284426 0.19%
3650 0.261615469316373 0.265235824583730 0.266342 0.11%
3700 0.245580215704548 0.248582585887819 0.248912 0.03%
3750 0.231712426785790 0.233087499691996 0.232633 -0.05%
3800 0.220204595933114 0.219519711494862 0.218336 -0.12%
3850 0.211257342746155 0.208967123228945 0.207239 -0.17%
3900 0.205096538218055 0.202578259521284 0.200651 -0.19%
3950 0.201943526100016 0.200931625388894 0.199217 -0.17%
4000 0.202049566014993 0.203604828891783 0.202397 -0.12%
4050 0.205673850628091 0.209520147602468 0.208939 -0.06%
4100 0.213089315877449 0.217573188533236 0.217628 0.01%
4200 0.240440352051281 0.237060304926802 0.238270 0.12%




#include <ql/quantlib.hpp>
#include <iostream>
#include <vector>

using namespace QuantLib;
using namespace std;


int main(int argc, char *argv[])
{
    Real forward = 3826.25;
    Time tau = 0.0305936;

    vector<double> strikes;
    vector<double> vols;
   
    strikes.push_back(3400); vols.push_back(0.368624622242282);
    strikes.push_back(3500); vols.push_back(0.321037653604485);
    strikes.push_back(3550); vols.push_back(0.299501682381891);
    strikes.push_back(3600); vols.push_back(0.279643985001476);
    strikes.push_back(3650); vols.push_back(0.261615469316373);
    strikes.push_back(3700); vols.push_back(0.245580215704548);
    strikes.push_back(3750); vols.push_back(0.231712426785790);
    strikes.push_back(3800); vols.push_back(0.220204595933114);
    strikes.push_back(3850); vols.push_back(0.211257342746155);
    strikes.push_back(3900); vols.push_back(0.205096538218055);
    strikes.push_back(3950); vols.push_back(0.201943526100016);
    strikes.push_back(4000); vols.push_back(0.202049566014993);
    strikes.push_back(4050); vols.push_back(0.205673850628091);
    strikes.push_back(4100); vols.push_back(0.213089315877449);
    strikes.push_back(4200); vols.push_back(0.240440352051281);
   
   
   
    SABRInterpolation sabr(    strikes.begin(),
                strikes.end(),
                vols.begin(),
                tau,
                forward,
                Null<Real>(),
                1,
                Null<Real>(),
                Null<Real>(),
                false,
                true,
                false,
                false ) ;
   
    sabr.update();
   
    cout << "forward=" <<sabr.forward() << endl;   
    cout << "expiry=" << sabr.expiry() << endl;   
    cout << "alpha=" << sabr.alpha() << endl;   
    cout << "beta=" << sabr.beta() << endl;   
    cout << "nu=" << sabr.nu() << endl;   
    cout << "rho=" << sabr.rho() << endl;
    cout << "rmsError=" << sabr.rmsError() << endl;   
    cout << "atmVol=" << sabr(forward) << endl;
    cout << "endCriteria=" << sabr.endCriteria() << endl;
   
    for( unsigned int i = 0; i < strikes.size(); ++i )
        cout << strikes[i] << " " << vols[i] << " " << sabr( strikes[i] ) <<  endl;
   
       
    return 0;
}





New! Receive and respond to mail from other email accounts from within Hotmail Find out how.

------------------------------------------------------------------------------
Join us December 9, 2009 for the Red Hat Virtual Experience,
a free event focused on virtualization and cloud computing.
Attend in-depth sessions from your desk. Your couch. Anywhere.
http://p.sf.net/sfu/redhat-sfdev2dev
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users




New! Receive and respond to mail from other email accounts from within Hotmail Find out how.
------------------------------------------------------------------------------
Return on Information:
Google Enterprise Search pays you back
Get the facts.
http://p.sf.net/sfu/google-dev2dev

_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users