Hello QL-team,
I start with a basic usage question: * suppose we have previously priced an instrument, an IRS let's say, using data from a Term Structure with reference date (let's say 2008/01/01) and that the instrument was to start after a month (2008/02/01). Today (2008/05/10) I want to know the actual market to market price of this instrument: if I define the instrument again using the parameters I got from the previous pricing, an error occurs in the invocation of the NPV method because the starting date of the instrument is before the actual Term Structure's reference date I wish to use for current pricing. How can I do market to market pricing of a previous priced instrument with quantlib? Some more questions, to which Ametrano kindly answered me in private, but I think it may be useful to discuss it in ML also with other users and developers: * Actually in QL-v0.9.0, the atm method for a Swaption is atm(void) while for a CapFloor the method is atm(TermStructure) ... in the trunk version, things are changing ... can you give us a "public" declaration or a plan about that? ;-) * Suppose I construct a vector of option instrument, each with a different kind of pricing engine. How can I query each instrument about the attached engine in use? No method is available for that ... any plan? Thank you in advance, luca -- Luca Ferraro Gruppo Scienze dei Materiali CASPUR (Consorzio per le Applicazioni di Supercalcolo Per Università e Ricerca) Via dei Tizii, 6b - 00185 ROMA Tel. +39-06-44486717 Fax: +39-06-4957083 cell: +39-339-7879898 Email: [hidden email] Web: http://www.caspur.it ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Hi Luca
> the atm method for a Swaption is atm(void) > while for a CapFloor the method is atm(TermStructure) ... in the trunk > version, things are changing ... can you give us a "public" declaration > or a plan about that? ;-) the atm methods might disappear and the atm level might be just another additional result calculated by pricing engines. This is in my opinion the cleanest solution. _If_ we want to keep the atm methods, then the signature will be atm(TermStructure) since you need to know the forecasting term structure that will be used by a simple built-in "engine" to calculate the atm level only. > Suppose I construct a vector of option instrument, each with a > different kind of pricing engine. How can I query each instrument about > the attached engine in use? No method is available for that ... any plan? I'll leave this one to our chief architect... > suppose we have previously priced an instrument, an IRS let's say, > using data from a Term Structure with reference date > [...] I see no problem at all with NPV calculation of seasoned IRS, i.e. calculating the NPV of a Swap Instrument to which a proper pricing engine has been set and with the relevant fixings available for the relevant Indexes. You might want to send more details about the issues you're facing. ciao -- Nando ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
In reply to this post by luca ferraro-2
Hi Luca,
On Mon, 2008-05-12 at 18:27 +0200, luca ferraro wrote: > * suppose we have previously priced an instrument, an IRS let's say, > using data from a Term Structure with reference date (let's say > 2008/01/01) and that the instrument was to start after a month > (2008/02/01). Today (2008/05/10) I want to know the actual market to > market price of this instrument: if I define the instrument again using > the parameters I got from the previous pricing, an error occurs in the > invocation of the NPV method because the starting date of the instrument > is before the actual Term Structure's reference date I wish to use for > current pricing. How can I do market to market pricing of a previous > priced instrument with quantlib? What is the actual error message? In the case of an IRS, it's probably looking for past index fixings---the term structure cannot forecast those. You can provide them by calling Index::addFixings() on the interest-rate index instance you're passing to the instrument. > * Suppose I construct a vector of option instrument, each with a > different kind of pricing engine. How can I query each instrument about > the attached engine in use? No method is available for that ... any plan? Not much of a plan, really. The first step would be to add a method to the Instrument class returning its pricing engine (you can do it in one line of code and recompile the library) but that would still leave us with the problem of identifying the engine---it would be returned as a shared pointer to the base PricingEngine class. We could add a method returning a description string, but I'm not overly happy about it, even though we did add such methods to a few other classes. Another way would be to use RTTI to get the type of the engine. It has the disadvantage that the type might be somewhat garbled by the compiler, but you can easily map it to a better description (with the added advantage that _you_ get to choose the displayed description; it wouldn't be hard-coded to the one _we_ chose.) Luigi -- Humphrey's Requirements Uncertainty Principle: For a new software system, the requirements will not be completely known until after the users have used it. ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
In reply to this post by Ferdinando M. Ametrano-3
Ferdinando Ametrano wrote:
> Hi Luca [SNIP] >> suppose we have previously priced an instrument, an IRS let's say, >> using data from a Term Structure with reference date [...] > > I see no problem at all with NPV calculation of seasoned IRS, i.e. > calculating the NPV of a Swap Instrument to which a proper pricing > engine has been set and with the relevant fixings available for the > relevant Indexes. You might want to send more details about the > issues you're facing. > > ciao -- Nando Dear Ferdinando, thank you again for your kind answer. Apart from the work in progress of Ballabio in "Implementing QuantLib" and the source code of corse, as of today, the QL library lacks of a user guide, even a simple introduction one to most frequent possible usage. For a new user, it is not so simple to understand what is for and how to do it if you want something that is not already in the examples. So, I hope not to bother you much asking sometimes :-) ******************************************************************** the goal: I want to do mark to market price of a capfloor that is started on 02/01/2007 and ends at 02/01/2012, using a pieacewise term structure based on market data that start from, say, 05/05/2008 (this is my evaluation date). the problem: QL asks me for many fixing rates previous to the current evaluation date (the fixings from the instrument settlement date and current evaluation date). the questions: (suppose I know previous fixings rates) 1) How do I add these fixing? 2) How do I determine automatically the correct previous dates of fixing?? (probably using the schedule or the iborInder class?? any example please?) Now, please, forgive me for I'm not a finance guru: 3) Why does QL expect all previous fixing rates?? I expected that I need just the last one (the most recent previous to my actual evaluation date) because all the other cash flows are expired, isn't it? 4) Is the volatility that is to be passed to the, say, BlackCapFloorEngine a FLAT volatility? What if I have spot ones? If I have a CAP/FLOOR volatility matrix is there any class in QL that find me the forward volatility of a cap with duration not in the matrix? ** last but not least: is there any wiki that users may fill in order to start writing a simple user guide or a "QL by examples" guide? (don't tell me there are already the examples because I stress that those example do not explain how/why iborIndex, volatilities, ... classes can/should be used and the thoughts you developers had when design such classes ;-) THANK YOU AGAIN YOU ALL FOR YOUR SUPPORT AND GREAT WORK luca ******************************************************************** I report in the following snaps of my simple code: ************* [SNIP] ************** // termStructure is a shared_ptr to the PieacewiseYieldCurve // built using instrument that start from evaluationDate Settings::instance().evaluationDate() = Date(05,May,2008); // from market_data.xls Date settlementDate(02,January,2007); Date maturityDate(02,January,2012); std::vector<Rate> strike(1,4.0); // bulding the cap/floor boost::shared_ptr<CapFloor> capfloor = makeCapFloor( CapFloor::Cap, settlementDate, maturityDate, strike, termStructure); // setting engine RelinkableHandle<YieldTermStructure> rhTermStructure(termStructure); const Volatility volatility=0.1612; Handle<Quote> vol(boost::shared_ptr<Quote>( new SimpleQuote(volatility))); boost::shared_ptr<PricingEngine> capfloorEngine( new BlackCapFloorEngine(rhTermStructure, vol)); // pricing current capfloor capfloorPricing(capfloor, capfloorEngine, termStructure); ************* [SNIP] ************** boost::shared_ptr<CapFloor> capfloor = makeCapFloor( CapFloor::Cap, settlementDate, maturityDate, strike, termStructure) { RelinkableHandle<YieldTermStructure> rhTermStructure(termStructure); /* Floating Leg */ Frequency floatingLegFrequency = Semiannual; BusinessDayConvention floatingLegConvention = ModifiedFollowing; DayCounter floatingLegDayCounter = Actual360(); boost::shared_ptr<IborIndex> iborIndex( new Euribor(Period(floatingLegFrequency), rhTermStructure)); Calendar calendar = iborIndex->fixingCalendar(); Schedule floatSchedule(settlementDate, maturityDate, Period(floatingLegFrequency), calendar, floatingLegConvention, floatingLegConvention, DateGeneration::Forward, false); IborLeg leg(floatSchedule, iborIndex); leg.withNotionals(100.0) .withPaymentDayCounter(iborIndex->dayCounter()) .withPaymentAdjustment(iborIndex->businessDayConvention()) .withFixingDays(iborIndex->fixingDays()); boost::shared_ptr<CapFloor> result; switch (type) { case CapFloor::Cap: result = boost::shared_ptr<CapFloor>( new Cap(leg, strike)); break; case CapFloor::Floor: result = boost::shared_ptr<CapFloor>( new Floor(leg, strike)); break; default: std::cout << "unknown cap/floor type" << std::endl; exit(1); } return result } void capfloorPricing(const boost::shared_ptr<CapFloor>& capfloor, const boost::shared_ptr<PricingEngine>& capfloorEngine, const boost::shared_ptr<YieldTermStructure> &discountCurve) { capfloor->setPricingEngine(capfloorEngine); Real NPV = capfloor->NPV(); // [SNIP] std::cout << "MTM: " << NPT << " atmRate: " << atmRate << std::endl; } -- Luca Ferraro Gruppo Scienze dei Materiali CASPUR (Consorzio per le Applicazioni di Supercalcolo Per Università e Ricerca) Via dei Tizii, 6b - 00185 ROMA Tel. +39-06-44486717 Fax: +39-06-4957083 cell: +39-339-7879898 Email: [hidden email] Web: http://www.caspur.it ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Hi Luca,
apologies for the delay. On Wed, 2008-05-14 at 12:50 +0200, luca ferraro wrote: > the goal: > I want to do mark to market price of a capfloor that is started on > 02/01/2007 and ends at 02/01/2012, using a pieacewise term structure > based on market data that start from, say, 05/05/2008 (this is my > evaluation date). > > the problem: > QL asks me for many fixing rates previous to the current evaluation date > (the fixings from the instrument settlement date and current evaluation > date). > > the questions: (suppose I know previous fixings rates) > 1) How do I add these fixing? You'll use the Index::addFixings method. > 2) How do I determine automatically the correct previous dates of > fixing?? (probably using the schedule or the iborInder class?? any > example please?) You might use the schedule class and work out the dates. However, I usually don't bother doing this---I load the Euribor fixing for the last year or two and forget about it. > Now, please, forgive me for I'm not a finance guru: > 3) Why does QL expect all previous fixing rates?? I expected that I need > just the last one (the most recent previous to my actual evaluation > date) because all the other cash flows are expired, isn't it? Hmm. It should only ask for the fixing of the current coupon---it should disregard previous coupons. May you send some code to reproduce the problem? (You did send some snippets, but it would help to have a compilable source file.) Also, what version are you using? > 4) Is the volatility that is to be passed to the, say, > BlackCapFloorEngine a FLAT volatility? What if I have spot ones? If I > have a CAP/FLOOR volatility matrix is there any class in QL that find me > the forward volatility of a cap with duration not in the matrix? I'll leave this to Ferdinando (our local volatility expert...) > ** last but not least: is there any wiki that users may fill in order to > start writing a simple user guide or a "QL by examples" guide? Not yet---although I've been thinking about this for some time (the name I came up with was "the QuantLib cookbook"...) The problem was technical---finding the wiki software, setting up access, this kind of issues. I had a look at the wiki facilities at Sourceforge, but for a number of reasons I didn't like them. However, I've read this morning that Google Sites is now available. I'll take a test drive and let you know. Later, Luigi -- Ninety percent of everything is crap. --- Theodore Sturgeon ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
First of all, thank you for your answer. Now, I come to details:
Luigi Ballabio wrote: >> 2) How do I determine automatically the correct previous dates of >> fixing?? (probably using the schedule or the iborInder class?? any >> example please?) > > You might use the schedule class and work out the dates. However, I > usually don't bother doing this---I load the Euribor fixing for the last > year or two and forget about it. Yes, I work it out using the Index::addFixings() and the Index::fixingDate() on the Schedule dates, if the settlement date of my instrument is before the reference date of the term-structure in use, as reported in the following (bad-programming-style) code: /* adding previous fixing */ if (refDate > settlementDate) { std::vector<Date> date = floatSchedule.dates(); for (unsigned i=0; date[i]<refDate; i++) { Date prevFixingDate = iborIndex->fixingDate(date[i]); std::cout << "Adding fixing: " << prevFixingDate << std::endl; iborIndex->addFixing(prevFixingDate, prevFixRate[i]); } } When you say, "I load the Euribor fixing for the last year or two", this means that you have access to some sort of historical market data, I'm curious how you handle these data (is it in FpML?). Since we do not currently have direct access to marked data (we are not a bank), I have provided my code with a vector of previous fixed rates (genuinely invented :-P ). But, here comes the second "problem": >> Now, please, forgive me for I'm not a finance guru: >> 3) Why does QL expect all previous fixing rates?? I expected that I need >> just the last one (the most recent previous to my actual evaluation >> date) because all the other cash flows are expired, isn't it? > > Hmm. It should only ask for the fixing of the current coupon---it should > disregard previous coupons. May you send some code to reproduce the > problem? (You did send some snippets, but it would help to have a > compilable source file.) Also, what version are you using? The problem is with CapFloor: I create a CAP starting in the past 02/01/2007 and trying to evaluate it on 05/05/2008. This is a cap with a Euribor 6M schedule, but QL asks me for the 28/12/2006 fixing, and so on. Maybe I'm doing a mistake ... I attach you a tarball with my current "learn-QL-by-doing-mistakes" program. I'm using QuantLib v0.9.0. >> 4) Is the volatility that is to be passed to the, say, >> BlackCapFloorEngine a FLAT volatility? What if I have spot ones? If I >> have a CAP/FLOOR volatility matrix is there any class in QL that find me >> the forward volatility of a cap with duration not in the matrix? > > I'll leave this to Ferdinando (our local volatility expert...) Let me recast my question - I "ufficially" ask for an example code to show how to use volatility classes in order to: * handle forward volatilities; * compute flat volatility from forward ones; * compute flat volatilties from volatility matrix (cap/floor or swaption) for periods not in matrix Believe me, maybe I'm not the smartest person, but I'm not lazy: I can study the code, but it is not straightforward to do that without a little hint on "what you thought when you design these classes" ;-) Thank you again in advance, and good work to everybody! luca -- Luca Ferraro Gruppo Scienze dei Materiali CASPUR (Consorzio per le Applicazioni di Supercalcolo Per Università e Ricerca) Via dei Tizii, 6b - 00185 ROMA Tel. +39-06-44486717 Fax: +39-06-4957083 cell: +39-339-7879898 Email: [hidden email] Web: http://www.caspur.it ============================ ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
On Mon, 2008-05-26 at 19:12 +0200, luca ferraro wrote:
> When you say, "I load the Euribor fixing for the last year or two", this > means that you have access to some sort of historical market data, I'm > curious how you handle these data (is it in FpML?). No, we have them stored into a database. > Since we do not > currently have direct access to marked data (we are not a bank), I have > provided my code with a vector of previous fixed rates (genuinely > invented :-P ). Whatever works :) However, in case you need them for some study, past Euribor fixings are available at <http://www.euribor.org/html/content/euribor_data.html> > But, here comes the second "problem": Which I'll try to address in another post... Luigi -- The purpose of abstraction is not to be vague, but to create a new semantic level in which one can be absolutely precise. -- W.E. Dijkstra ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Free forum by Nabble | Edit this page |