Python swig calibrate Heston model

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

Python swig calibrate Heston model

Seric Chen
Dear all,

I use python swig to calibrate Heston model. And when I come to the calibrate function, the program gives me the following error. Could you give me some suggestions?


Traceback (most recent call last):
  File "D:\QL_HestonModel_test.py", line 86, in <module>
    model.calibrate(options, method, EndCriteria(1000, 250, 1e-7, 1e-7, 1e-7))
  File "D:\Progs\Python27\lib\site-packages\QuantLib\QuantLib.py", line 5431, in calibrate
    def calibrate(self, *args): return _QuantLib.CalibratedModel_calibrate(self, *args)
NotImplementedError: Wrong number or type of arguments for overloaded function 'CalibratedModel_calibrate'.
  Possible C/C++ prototypes are:
 CalibratedModel::calibrate(std::vector< boost::shared_ptr< CalibrationHelper >,std::allocator< boost::shared_ptr< CalibrationHelper > > > const &,OptimizationMethod &,EndCriteria const &,Constraint const &,std::vector< Real,std::allocator< Real > > const &)
    CalibratedModel::calibrate(std::vector< boost::shared_ptr< CalibrationHelper >,std::allocator< boost::shared_ptr< CalibrationHelper > > > const &,OptimizationMethod &,EndCriteria const &,Constraint const &)
    CalibratedModel::calibrate(std::vector< boost::shared_ptr< CalibrationHelper >,std::allocator< boost::shared_ptr< CalibrationHelper > > > const &,OptimizationMethod &,EndCriteria const &)




Code:

options=[]
..............
        options.append(HestonModelHelper(maturity,calendar,s0.value(),strike[s],
                                                           vol,riskFreeTS,dividendYield,
                                                           CalibrationHelper.ImpliedVolError))

v0=0.1
kappa=1.0
theta=0.1
sigma=0.5
rho=-0.5

process=HestonProcess(riskFreeTS,dividendYield,s0,v0, kappa, theta, sigma, rho)
model=HestonModel(process)

engine=AnalyticHestonEngine(model,64)

for option in options:
    option.setPricingEngine(engine)


om=LevenbergMarquardt(1e-8, 1e-8, 1e-8); 
model.calibrate(options, om, EndCriteria(400, 40, 1.0e-8, 1.0e-8, 1.0e-8))



--
Zach


------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

答复: Python swig calibrate Heston model

cheng li

Hi Zax,

 

On my side, your codes works fine….

 

Could I know what is your QL version?

 

Regards,

Cheng

 

 

发件人: Seric Chen [mailto:[hidden email]]
发送时间: 2015427 16:32
收件人: [hidden email]; Luigi Ballabio
主题: [Quantlib-users] Python swig calibrate Heston model

 

Dear all,

 

I use python swig to calibrate Heston model. And when I come to the calibrate function, the program gives me the following error. Could you give me some suggestions?

 

 

Traceback (most recent call last):

  File "D:\QL_HestonModel_test.py", line 86, in <module>

    model.calibrate(options, method, EndCriteria(1000, 250, 1e-7, 1e-7, 1e-7))

  File "D:\Progs\Python27\lib\site-packages\QuantLib\QuantLib.py", line 5431, in calibrate

    def calibrate(self, *args): return _QuantLib.CalibratedModel_calibrate(self, *args)

NotImplementedError: Wrong number or type of arguments for overloaded function 'CalibratedModel_calibrate'.

  Possible C/C++ prototypes are:

 CalibratedModel::calibrate(std::vector< boost::shared_ptr< CalibrationHelper >,std::allocator< boost::shared_ptr< CalibrationHelper > > > const &,OptimizationMethod &,EndCriteria const &,Constraint const &,std::vector< Real,std::allocator< Real > > const &)

    CalibratedModel::calibrate(std::vector< boost::shared_ptr< CalibrationHelper >,std::allocator< boost::shared_ptr< CalibrationHelper > > > const &,OptimizationMethod &,EndCriteria const &,Constraint const &)

    CalibratedModel::calibrate(std::vector< boost::shared_ptr< CalibrationHelper >,std::allocator< boost::shared_ptr< CalibrationHelper > > > const &,OptimizationMethod &,EndCriteria const &)

 

 

 

 

Code:

 

options=[]

..............

        options.append(HestonModelHelper(maturity,calendar,s0.value(),strike[s],

                                                           vol,riskFreeTS,dividendYield,

                                                           CalibrationHelper.ImpliedVolError))

 

v0=0.1

kappa=1.0

theta=0.1

sigma=0.5

rho=-0.5

 

process=HestonProcess(riskFreeTS,dividendYield,s0,v0, kappa, theta, sigma, rho)

model=HestonModel(process)

 

engine=AnalyticHestonEngine(model,64)

 

for option in options:

    option.setPricingEngine(engine)

 

 

om=LevenbergMarquardt(1e-8, 1e-8, 1e-8); 

model.calibrate(options, om, EndCriteria(400, 40, 1.0e-8, 1.0e-8, 1.0e-8))

 

 

 

--

Zach

 


------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users