|
From: Max <ma...@gm...> - 2008-07-21 08:15:16
|
Hi,
I try to create a volatility term structures (ATM) using class
BlackVarianceCurve.
Below is a simple program. But it fails to compile due to the access the
protected member function blackVarianceImpl().
#include <ql/quantlib.hpp>
#include <iostream>
using namespace QuantLib;
int main() {
DayCounter dc = Actual365Fixed();
Date today(25, Feb, 2008);
std::vector<Date> dates;
dates.push_back(Date(25, Aug, 2008));
dates.push_back(Date(25, Feb, 2009));
std::vector<Volatility> vols;
vols.push_back(24.9358/100); // 25 Aug 2008
vols.push_back(21.4448/100); // 25 Aug 2009
// volatility term structures
boost::shared_ptr<BlackVolTermStructure> volTS(
new BlackVarianceCurve(today, dates, vols, dc, false));
Real result_vol = volTS->blackVarianceImpl((Time)0.49863, (Real)0);
std::cout << "result_vol = " << result_vol << std::endl;
}
Here is the compilation error message (using GCC):
main.cpp: In function `int main()':
/usr/local/include/ql/termstructures/volatility/equityfx/blackvoltermstructure.hpp:120:
error: `virtual QuantLib::Real
QuantLib::BlackVolTermStructure::blackVarianceImpl(QuantLib::Time,
QuantLib::Real) const' is protected
main.cpp:23: error: within this context
May I know why the blackVarianceImpl() cannot be accessed in this way?
Also I wonder what is the proper way to create ATM volatility term structure
using QuantLib.
Thanks!
Best regards,
Max
|