Re: QuantLib::Bond::cleanPriceFromZSpread

Posted by Luigi Ballabio on
URL: http://quantlib.414.s1.nabble.com/QuantLib-Bond-cleanPriceFromZSpread-tp7310p7315.html

On Thu, 2009-03-05 at 22:09 -0500, Guowen Han wrote:
> Well, I tend to agree with your comment. But that will break original
> design

Not the design, it's just implementation (it's a helper function in an
anonymous namespace.)

> and maintain the quote won't be a simple task.

instead of the current

Real dirtyPriceFromZSpreadFunction(..., Spread zSpread, ...) {
    - create the quote
    - create the spreaded curve
    - discount the coupons
    - return the price
}

you'll have:

class dirtyPriceFromZSpreadFunction {
    shared_ptr<SimpleQuote> quote_;
    ...
  public:
    dirtyPriceFromZSpreadFunction(... arguments except spread ...) {
        - create the quote
        - create the spreaded curve
    }
    Real operator()(Spread zSpread) {
        quote_->setValue(zSpread);
        - discount the coupons (or better yet, call CashFlows::npv)
        - return the price
    }
};


Luigi


--

feature, n:
A surprising property of a program. Occasionally documented.
To call a property a feature sometimes means the author did not
consider that case, and the program makes an unexpected, though
not necessarily wrong response. See BUG. "That's not a bug,
it's a feature!" A bug can be changed to a feature by
documenting it.



------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users