Closed tleitch closed 8 years ago
Sounds reasonable. While I tend to lean against interface changes, the Bermudan code is so old, and has seen so little love since DS initially put it in a decade ago that I can hardly object.
One question, though: do we have 'reference' examples from either QL tests, or QL examples, or some other places? That would be good for demos or examples --- and even more importantly for unit tests.
I rewrote bermudanSwaption but decided to create a parallel affineSwaption model that does both a European and a Bermudan. Default is European. I did not want to call it EuropeanSwaption as I am reserving that for the fit and valuation routines based on SABR and I thought an overloaded version would confuse the initiate. The code is in my repository and I will do a pull as soon as I have finished a unit test for the swaption models that includes some yield curve tests.
I preserved the flat yield curve option in bermudanSwaption but I abandoned it in affineSwaption as DiscountCurve provides a flat yield curve option and I think the model process should be 1) strip curve, 2) value instrument using DiscountCurve object. Intertwining the curve stripping and valuation creates a lot of redundant code that has to be maintained or restructured. This is simple for swaps/bonds, but when you get to options life is getting very complex very fast.
Thoughts?
Sounds good!
If anything though, and given the birthing problems we had previously, it may prudent to start small with limited changes, get those booked and reconciled and then move on from there.
Addressed in #43
Currently, BermudanSwaption has an input for rate quotes, tsQuotes. It would be more efficient to pass in a DiscountCurve object when you are valuing multiple options. It is also more ih line with the current form for bond function FixedBondWithRebiltCurve:
Bonds.cpp:
The current model takes a tsQuotes in Bermudan.R and it is called tslist in Bermudan.Cpp:
Unfortunately, while tslist is used to create a curve, it is never used because at line 131, a hard coded flat rate is used to generate a separate valuation curve.
So, I propose removing the tsQuotes argument, since it cannot actually be used anywhere anyway, and replace it with a DiscountCurve object, and a flat term structure option similar to that handled by Bond.R:
This would brind Bermudan in line with the bond functions with a single yield option or a yield curve (pre-stripped).
The other option is to have a single arguement and split on class("Discount Curve") with a check for a valid numeric value if the class fails.