Hi, I am now studying QuantLib and port QuantLibXL samples to standalone C++ code. I began with VanillaSwap.xls in StandaloneExamples, but I could not find the definition of EURIBOR6M and EUR_YC referred in "Vanilla Swap" sheet. Attached is the code I'm working on. I used FlatForward as a yield curve for DiscountingSwapEngine and Euribor6M index. The NPV is different from that in sample. (my code outputs 16,303.57 whereas VanillaSwap.xls outputs 36,106.58) That means that the sample code doesn't use FlatForward. I searched the whole source code, QuantLib, QuantLibAddin, QuantLibXL, for "EURIBOR6M" and "EUR_YC" in vain. Thanks in advance. --- Kentaro KAWAMOTO mailto:[hidden email] ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Oops, I forgot to attach my code. On Wed, 30 Jul 2008 16:14:17 +0900 () Kentaro KAWAMOTO <[hidden email]> wrote: > > Hi, > > I am now studying QuantLib and > port QuantLibXL samples to standalone C++ code. > > I began with VanillaSwap.xls in StandaloneExamples, > but I could not find the definition of > EURIBOR6M and EUR_YC referred in "Vanilla Swap" sheet. > > Attached is the code I'm working on. > I used FlatForward as a yield curve for > DiscountingSwapEngine and Euribor6M index. > > The NPV is different from that in sample. > (my code outputs 16,303.57 whereas VanillaSwap.xls > outputs 36,106.58) > That means that the sample code doesn't use FlatForward. > > I searched the whole source code, QuantLib, QuantLibAddin, > QuantLibXL, for "EURIBOR6M" and "EUR_YC" in vain. > > > Thanks in advance. > > --- > Kentaro KAWAMOTO > mailto:[hidden email] #include <stdio.h> #include <stdlib.h> #include <ql/quantlib.hpp> using namespace QuantLib; int main() { Date today(5, December, 2008); Date effectiveDate(today + 2); Date terminateDate(27, February, 2017); Rate forward(0.044); boost::shared_ptr<YieldTermStructure> flatForward(new FlatForward( 0, Japan(), forward, SimpleDayCounter())); Handle<YieldTermStructure> hFlatForward(flatForward); boost::shared_ptr<DiscountingSwapEngine> dsEngine(new DiscountingSwapEngine(hFlatForward)); Schedule fixedSchedule(effectiveDate, terminateDate, Period(Annual), static_cast<Calendar>(TARGET()), Unadjusted, ModifiedFollowing, DateGeneration::Backward, false); Schedule floatSchedule(effectiveDate, terminateDate, Period(Semiannual), static_cast<Calendar>(TARGET()), ModifiedFollowing, ModifiedFollowing, DateGeneration::Backward, false); #if 0 boost::shared_ptr<IborIndex> floatIndex(new Euribor6M()); #else boost::shared_ptr<IborIndex> floatIndex(new Euribor6M(hFlatForward)); #endif boost::shared_ptr<Swap> swap(new VanillaSwap( VanillaSwap::Payer, 1000000.00, fixedSchedule, // fixed schedule 0.042490, // fixed rate Thirty360(), // fixed day count floatSchedule, // float schedule floatIndex, // float index 0.0, // float spread Actual360() // float day count )); swap->setPricingEngine(dsEngine); Real npv = swap->NPV(); printf("npv = %10.10le\n", npv); exit(EXIT_SUCCESS); } ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Hello,
On Wed, July 30, 2008 08:22, Kentaro KAWAMOTO wrote: > > Oops, I forgot to attach my code. > > On Wed, 30 Jul 2008 16:14:17 +0900 () > Kentaro KAWAMOTO <[hidden email]> wrote: > >> >> Hi, >> >> I am now studying QuantLib and >> port QuantLibXL samples to standalone C++ code. >> >> I began with VanillaSwap.xls in StandaloneExamples, >> but I could not find the definition of >> EURIBOR6M and EUR_YC referred in "Vanilla Swap" sheet. You can use the function ohObjectCallerAddress() to identify the host cells of those objects. >> Attached is the code I'm working on. >> I used FlatForward as a yield curve for >> DiscountingSwapEngine and Euribor6M index. I see that you are writing a QuantLib C++ program to mimic the behavior of a QuantLibXL workbook. QuantLibXL uses the QuantLibAddin interface, which imposes an additional layer of abstraction. You could implement your C++ program using the QuantLibAddin interface, this is less convenient than the QuantLib interface but it would more closely match the behavior of the Excel environment. An introduction to this idea can be found at the link below. http://quantlib.org/quantlibaddin/serialization.html Regards, Eric ------------------------- Eric Ehlers nazcatech sprl | Brussels | http://www.nazcatech.be Distributed computing for pricing analytics - Use Microsoft Excel as a client to the Grid ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Eric, Sorry for my late reply. On Thu, 31 Jul 2008 12:16:37 +0100 (BST) "Eric Ehlers" <[hidden email]> wrote: > You could implement your C++ program using the > QuantLibAddin interface, this is less convenient than the > QuantLib interface but it would more closely match the behavior > of the Excel environment. An introduction to this idea can be > found at the link below. > > http://quantlib.org/quantlibaddin/serialization.html That sounds easier to mimic QuantLibXL. I'll try. Thanks. > >> I began with VanillaSwap.xls in StandaloneExamples, > >> but I could not find the definition of > >> EURIBOR6M and EUR_YC referred in "Vanilla Swap" sheet. > > You can use the function ohObjectCallerAddress() to identify > the host cells of those objects. Using ohObjectCallerAddress(), I found that EURIBOR6M is defined in EURIBOR sheet in MarketData.xls, and that it refers to an yield curve defined in the same sheet as "qlRelinkableHandleYieldTermStructure(B2)". The document says that no term structure is linked to this handle if the second argument is omitted. http://quantlib.org/quantlibxl/auto/termstructures.html#qlRelinkableHandleYieldTermStructure So my current question is why the example in VanillaSwap.xls works even though no term structure is linked to index (EURIBOR6M). Do I misunderstand something? Regards. --- Kentaro KAWAMOTO mailto:[hidden email] ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Free forum by Nabble | Edit this page |