Closed abysmon closed 8 years ago
I am sorry but
The whole date calculation is imperfect as it assumes whole days, so we get rounding artefacts. Until QuantLib switch to intra-daily time and calculations there is little we can do.
Sorry for the incomplete report. I was talking about this line https://github.com/eddelbuettel/rquantlib/blob/master/src/implieds.cpp#L39, and a similar line in the code later on. Why the maturity is being converted as int(maturity*360 + 0.5)
instead of int(maturity*365)
? I'm sure this will give better date retrieval than the previous one.
Both are approximations, and both suffer from non-smooth rounding cutoffs. Using 12 months of 30 days is frequently used, sometimes 365 is preferred, others even use 365.25. That's why fixed income is full of settlement conventions.
This is meant to be an example toolkit provided as source: if you think you really need it differently, just build it locally. But this is not a case of one being demonstrably right or wrong so I do not think I was to change this: what we really want much better date arithmetic in QuantLib itself.
You may like what is now in the master branch -- intra-day time for options too. Requires QuantLin 1.7 configured with --enable-intraday
.
I actually changed to 365 when testing that, but reverted. Many of the reference values used in the unit tests would come out wrong. So 360 it is I am am afraid, at least as the default.
The days calculation is now being
int(maturity*360 + 0.5)
which for some time periods make a difference of 1 day when being used in European option implied volatility calculation. Hence subsequently all the option greeks also diverge.