Login  Register

Re: Asset swap test error

Posted by Luigi Ballabio on Oct 03, 2011; 3:45pm
URL: http://quantlib.414.s1.nabble.com/Asset-swap-test-error-tp9280p9282.html

On Mon, 2011-10-03 at 09:36 -0600, Matt Fair wrote:
> It doesn't look like anyone is addressing this failure in the tests.

True.  Last week I reported it to the author, but he's busy with his
real work at the moment so it will be a few days before the test is
fixed.  I'm afraid it happens in the best families...

Later,
        Luigi


> The test failure was introduced in revision 18001.  It alters the way
> the price values are computed and therefore doesn't pass the test that
> existed.  If the test is wrong, then fix it so the tests pass,
> otherwise the asset swap code needs to be fixed.
> I don't know too much about this code, so I don't know what is right
> or wrong, just know when the test that existed started to fail.
>
> Index: ql/instruments/assetswap.cpp
> ===================================================================
> --- ql/instruments/assetswap.cpp (revision 18000)
> +++ ql/instruments/assetswap.cpp (revision 18001)
> @@ -243,12 +243,12 @@
>              // backpayment on the floating leg
>              // (accounts for non-par redemption, if any)
>              Real backPayment = notional;
> -            shared_ptr<CashFlow> backPaymentCashFlow (new
> +            shared_ptr<CashFlow> backPaymentCashFlow(new
>                  SimpleCashFlow(backPayment, finalDate));
>              legs_[1].push_back(backPaymentCashFlow);
>          } else {
>              // final notional exchange
> -            shared_ptr<CashFlow> finalCashFlow (new
> +            shared_ptr<CashFlow> finalCashFlow(new
>                  SimpleCashFlow(notional, finalDate));
>              legs_[1].push_back(finalCashFlow);
>          }
> @@ -349,12 +349,12 @@
>                         "fair clean price not available for seasoned deal");
>              Real notional = bond_->notional(upfrontDate_);
>              if (parSwap_) {
> -                fairCleanPrice_ = bondCleanPrice_ -
> +                fairCleanPrice_ = bondCleanPrice_ - payer_[0] *
>                      NPV_*npvDateDiscount_/startDiscounts_[1]/(notional/100.0);
>              } else {
>                  Real accruedAmount = bond_->accruedAmount(upfrontDate_);
>                  Real dirtyPrice = bondCleanPrice_ + accruedAmount;
> -                Real fairDirtyPrice = - legNPV_[0]/legNPV_[1] * dirtyPrice;
> +                Real fairDirtyPrice = - payer_[0] *
> legNPV_[0]/legNPV_[1] * dirtyPrice;
>                  fairCleanPrice_ = fairDirtyPrice - accruedAmount;
>              }
>
> @@ -370,7 +370,7 @@
>              QL_REQUIRE(endDiscounts_[1]!=Null<DiscountFactor>(),
>                         "fair non par repayment not available for expired leg");
>              Real notional = bond_->notional(upfrontDate_);
> -            fairNonParRepayment_ = nonParRepayment_ -
> +            fairNonParRepayment_ = nonParRepayment_ + payer_[0] *
>                  NPV_*npvDateDiscount_/endDiscounts_[1]/(notional/100.0);
>              return fairNonParRepayment_;
>          }
>
>
> On Sat, Sep 17, 2011 at 3:49 PM, Matt Fair <[hidden email]> wrote:
> > I noticed this in the tests:
> >
> > Testing consistency between fair price and fair spread...
> > assetswap.cpp(181): fatal error in
> > "QuantLib::detail::quantlib_test_case(&AssetSwapTest::testConsistency)":
> > par asset swap fair clean price doesn't zero the NPV:
> >   clean price:      95.0000
> >   fair clean price: 107.0805
> >   NPV:              24.1511
> >   tolerance:        0.0000
> >
> > This is the only test that fails.
> >
> > Matt
>
> ------------------------------------------------------------------------------
> All the data continuously generated in your IT infrastructure contains a
> definitive record of customers, application performance, security
> threats, fraudulent activity and more. Splunk takes this data and makes
> sense of it. Business sense. IT sense. Common sense.
> http://p.sf.net/sfu/splunk-d2dcopy1
> _______________________________________________
> QuantLib-dev mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-dev

--

Present to inform, not to impress; if you inform, you will impress.
-- Fred Brooks



------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev