Posted by
ziegele on
May 12, 2017; 9:19pm
URL: http://quantlib.414.s1.nabble.com/Variance-Swap-test-tp18059p18277.html
Thanks Luigi.
I tried to expand the variance swap replication example to include: non-flat volatility surface, non-flat interest rate, and non-flat discrete dividend term structure, based on the example I could find from Mick Hittesdorf's tutorial at
https://mhittesdorf.wordpress.com/2013/11/17/introducing-quantlib-american-option-pricing-with-dividends/As you can find in the attached file
main.cpp, I used boost::shared_ptr<ZeroCurve> to generate the discrete dividend term structure, and boost::shared_ptr<YieldTermStructure> with InterpolatedZeroCurve<ForwardFlat> to return the interest rate term structure.
There are some things that I'm not sure if I did correctly:
1. How do I include discrete dividend, rather than dividend yield, into the calculation? Currently I translated discreteDiv to divYield by the equation: divYield = discreteDiv / spot * yearFraction(evaluationDate, optionExpiryDate), for each exDividend date (data read from
dividend_schedule.csv file). Is it correct?
2. How do I correctly interpolate the interest rate term structure?
(1) Currently I used a flat interest rate of 5% (read from
ir_schedule.csv file, with the 1st dividend date to be the evaluationDate, otherwise PV would be wrong). Is there a way of inputting discount factor directly? If so, how do I change InterpolatedZeroCurve() to?
(2) Do I really need the <ForwardFlat> selection to interpolate the interest rate? If not, what are other choices?
3. What is the difference between <ZeroCurve> used in dividend, and <YieldTermStructure> used in interest rate term structure? Loos to be that I could also use one to replace the other;
4. Currently the volatility surface is kept the same as what's written in the example (vol=0.3~0.13, linearly dependent on strike). If I want to include a full volatility surface which can also be read from a file, can I keep the codes unchanged (lines 15-45)?
5. The size of dK impacts PV. Currently I chose dK=2.5 because it matches with calculation results from Numerix. But how do I know if dK is correctly chosen? Shouldn't PV be irrelevant to dK, in theory?
Thanks,
ziegele