Re: Making SpreadCdsHelper available in QuantLibXL

Posted by Bhavna J on
URL: http://quantlib.414.s1.nabble.com/Making-SpreadCdsHelper-available-in-QuantLibXL-tp7131p7146.html

Hi Everyone,

I was able to get below function to qlXL. Can someone provide me with an example for displaying QL errors using vba?
I am writing to logfile using below:
Application.Run("ohLogSetFile", FilePath)
Application.Run("ohRepositoryLogAllObjects")

But every time the log file grows in size, i tried using the FileSystemObject function from VBA to delete file and recreate new one, but it does not seem to work. When ql writes to file it cannot be deleted another time giving permission denied error.

    Dim fso As Scripting.FileSystemObject
    Set fso = New Scripting.FileSystemObject
    Dim FilePath As String
    Dim filetxt As TextStream

    FilePath = "C:\Desktop\QL Log2.txt"
    If fso.FileExists(FilePath) Then
        fso.DeleteFile FilePath
    End If

    Set filetxt = fso.CreateTextFile(FilePath, True)
    'filetxt.Write (" ")
    filetxt.Close


Anyone come across this before?

Thanks,
Bhavna

Bhavna J wrote
Thanks for the quick response, but how do I expose CreditDefaultSwap::coupons() method to quantlibXL?
I tried adding below code to qlo\credit.cpp similar to bond cashflows, but did not work...what am I doing wrong here?

vector<vector<ObjectHandler::property_t> > CreditDefaultSwap::flowAnalysis()
    {
        shared_ptr<QuantLib::CreditDefaultSwap> temp;
        getLibraryObject(temp);
        const QuantLib::Leg& coupon = temp->coupons();

        return QuantLibAddin::flowAnalysis(coupon);
    }

1>.\qlo\credit.cpp(43) : error C2143: syntax error : missing ';' before '<'
1>.\qlo\credit.cpp(43) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>.\qlo\credit.cpp(43) : error C2143: syntax error : missing ';' before '{'
1>.\qlo\credit.cpp(43) : error C2447: '{' : missing function header (old-style formal list?)


Thanks,
Bhavna

Luigi Ballabio wrote
On Thu, 2011-09-15 at 02:26 -0700, Bhavna J wrote:
> Is there a way to view the CDS cashflows in quantlib? For example when
> pricing a 2 year CDS with semiannual payment frequency, if I want to view
> the cashflows and hazard rates etc every 6 months, is there any function
> available for that currently?

In C++, you can use the CreditDefaultSwap::coupons() method to extract
the cashflows as a vector of CashFlow objects; you can then ask each of
them for its date and amount.  Once you have the dates, you can retrieve
the hazard rates from the default-probability curve you used to price
the CDS.

If we're talking about QuantLibXL instead, I'm not sure that the methods
above are all exposed.  You might have to do it before you can use them.

Luigi


--

The doctrine of human equality reposes on this: that there is no man
really clever who has not found that he is stupid.
-- Gilbert K. Chesterson



------------------------------------------------------------------------------
BlackBerry® DevCon Americas, Oct. 18-20, San Francisco, CA
http://p.sf.net/sfu/rim-devcon-copy2
_______________________________________________
QuantLib-users mailing list
QuantLib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/quantlib-users