Hi, All
I am trying to use QuantLib to calculate american options premium using trinomial trees. Unfortunately, I could now find any code snippet that shows this technique. Could u please tell me if it is overall possible at the moment ? Also, would be really cool if u drop me some lines of code showing proper API usage.
I am new to QuantLib and C++ is not my main language, I write mostly in C# so could help in porting this library afterwards. Thanks in advance.
------------------------------------------------------------------------------ Sell apps to millions through the Intel(R) Atom(Tm) Developer Program Be part of this innovative community and reach millions of netbook users worldwide. Take advantage of special opportunities to increase revenue and speed time-to-market. Join now, and jumpstart your future. http://p.sf.net/sfu/intel-atom-d2d _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
On Fri, 2010-08-27 at 22:10 +0200, Alexander Ratnikov wrote:
> I am trying to use QuantLib to calculate american options premium > using trinomial trees. > Unfortunately, I could now find any code snippet that shows this > technique. If you mean American equity options, there's no trinomial-tree implementation. Pricing using binomial trees, however, is shown in Examples/EquityOption. The latter is also available in C# if you download the QuantLib-SWIG bindings too. Luigi -- Zawinski's Law: Every program attempts to expand until it can read mail. Those programs which cannot so expand are replaced by ones which can. ------------------------------------------------------------------------------ This SF.net Dev2Dev email is sponsored by: Show off your parallel programming skills. Enter the Intel(R) Threading Challenge 2010. http://p.sf.net/sfu/intel-thread-sfd _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
As far as I know, JQuantLib doesn't support discrete dividends for American Options.
Does the C# version support discrete dividends for American Options? -----Original Message----- From: Luigi Ballabio [mailto:[hidden email]] Sent: Tuesday, August 31, 2010 10:07 AM To: Alexander Ratnikov Cc: [hidden email] Subject: Re: [Quantlib-users] american options via trinomial trees On Fri, 2010-08-27 at 22:10 +0200, Alexander Ratnikov wrote: > I am trying to use QuantLib to calculate american options premium > using trinomial trees. > Unfortunately, I could now find any code snippet that shows this > technique. If you mean American equity options, there's no trinomial-tree implementation. Pricing using binomial trees, however, is shown in Examples/EquityOption. The latter is also available in C# if you download the QuantLib-SWIG bindings too. Luigi -- Zawinski's Law: Every program attempts to expand until it can read mail. Those programs which cannot so expand are replaced by ones which can. ------------------------------------------------------------------------------ This SF.net Dev2Dev email is sponsored by: Show off your parallel programming skills. Enter the Intel(R) Threading Challenge 2010. http://p.sf.net/sfu/intel-thread-sfd _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users The information contained in this electronic message is confidential and does not constitute investment advice or an offer to sell or the solicitation of an offer to purchase any security or investment product. Offers may only be made by means of delivery of an approved confidential offering memorandum, may be legally privileged and confidential under applicable law, and are intended only for the use of the individual or entity named above. We do not, and will not, effect or attempt to effect transactions in securities, or render personalized investment advice for compensation, through this email. All materials within this email have been provided to you for information purposes only and may not be relied upon by you in evaluating the merits of investing in any securities referenced herein. Any review, retransmission, dissemination, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer. Email transmissions are not secure, and we accept no liability for errors in transmission, delayed transmission, or other transmission-related issues. This message may contain confidential, proprietary or legally privileged information. Neither confidentiality nor any privilege is intended to be waived or lost by any error in transmission. Emails are subject to review and will be archived. ------------------------------------------------------------------------------ This SF.net Dev2Dev email is sponsored by: Show off your parallel programming skills. Enter the Intel(R) Threading Challenge 2010. http://p.sf.net/sfu/intel-thread-sfd _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
On Tue, 2010-08-31 at 10:39 -0400, Jeff Yan wrote:
> As far as I know, JQuantLib doesn't support discrete dividends for American Options. > > Does the C# version support discrete dividends for American Options? The SWIG bindings do---they export the finite-difference engine available in the C++ library. Look for the DividendVanillaOption and FDDividendAmericanEngine classes. As for the native C# port at QLNet, I have no idea. Luigi -- Things should be made as simple as possible, but no simpler. -- Albert Einstein ------------------------------------------------------------------------------ This SF.net Dev2Dev email is sponsored by: Show off your parallel programming skills. Enter the Intel(R) Threading Challenge 2010. http://p.sf.net/sfu/intel-thread-sfd _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Hey
I am trying to price American Options with discrete dividends in Java, through SWIG, JNI, to QuantLib (C++ version). Everything goes well until the last step: calling option.NPV() method crashes with JNI error. I believe my Swig/JNI bridge works because I am able to price American Option with continuous dividend yield successfully. I think the problem is my code calling handling discrete dividends that goes wrong Please see the following Java code. Any suggestion is greatly appreciated! // our option Option.Type type = Option.Type.Put; double strike = 40.0; double underlying = 36.0; double riskFreeRate = 0.06; double dividendYield = 0.00; double volatility = 0.2; Date todaysDate = new Date(15, Month.May, 1998); Date settlementDate = new Date(17, Month.May, 1998); Settings.instance().setEvaluationDate(todaysDate); Date maturity = new Date(17, Month.May, 1999); DayCounter dayCounter = new Actual365Fixed(); Calendar calendar = new TARGET(); Exercise americanExercise = new AmericanExercise(settlementDate, maturity); // define the underlying asset and the yield/dividend/volatility curves QuoteHandle underlyingH = new QuoteHandle(new SimpleQuote(underlying)); YieldTermStructureHandle flatTermStructure = new YieldTermStructureHandle(new FlatForward( settlementDate, riskFreeRate, dayCounter)); YieldTermStructureHandle flatDividendYield = new YieldTermStructureHandle(new FlatForward( settlementDate, dividendYield, dayCounter)); BlackVolTermStructureHandle flatVolatility = new BlackVolTermStructureHandle(new BlackConstantVol( settlementDate, calendar, volatility, dayCounter)); BlackScholesMertonProcess process = new BlackScholesMertonProcess(underlyingH, flatDividendYield, flatTermStructure, flatVolatility); // options Payoff payoff = new PlainVanillaPayoff(type, strike); DateVector divDates = new DateVector(); DoubleVector divs = new DoubleVector(); divs.add(0.5); divDates.add(new Date(1, Month.October, 2010)); DividendVanillaOption americanOption = new DividendVanillaOption(payoff, americanExercise, divDates, divs); FDDividendAmericanEngine engine = new FDDividendAmericanEngine(process); americanOption.setPricingEngine(engine ); // Binomial method int timeSteps = 801; americanOption.setPricingEngine(new BinomialVanillaEngine(process, "CoxRossRubinstein", timeSteps)); System.out.println("before calling npv"); crashes here System.out.println("npv=" + americanOption.NPV() ); The information contained in this electronic message is confidential and does not constitute investment advice or an offer to sell or the solicitation of an offer to purchase any security or investment product. Offers may only be made by means of delivery of an approved confidential offering memorandum, may be legally privileged and confidential under applicable law, and are intended only for the use of the individual or entity named above. We do not, and will not, effect or attempt to effect transactions in securities, or render personalized investment advice for compensation, through this email. All materials within this email have been provided to you for information purposes only and may not be relied upon by you in evaluating the merits of investing in any securities referenced herein. Any review, retransmission, dissemination, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer. Email transmissions are not secure, and we accept no liability for errors in transmission, delayed transmission, or other transmission-related issues. This message may contain confidential, proprietary or legally privileged information. Neither confidentiality nor any privilege is intended to be waived or lost by any error in transmission. Emails are subject to review and will be archived. ------------------------------------------------------------------------------ This SF.net Dev2Dev email is sponsored by: Show off your parallel programming skills. Enter the Intel(R) Threading Challenge 2010. http://p.sf.net/sfu/intel-thread-sfd _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
On Tue, 2010-08-31 at 11:31 -0400, Jeff Yan wrote:
> I am trying to price American Options with discrete dividends in Java, > through SWIG, JNI, to QuantLib (C++ version). Everything goes well > until the last step: calling option.NPV() method crashes with JNI > error. > DividendVanillaOption americanOption = new DividendVanillaOption(payoff, americanExercise, divDates, divs); > > FDDividendAmericanEngine engine = new FDDividendAmericanEngine(process); > > americanOption.setPricingEngine(engine ); This is OK. If you call NPV here, you should get a price. > // Binomial method > int timeSteps = 801; > > americanOption.setPricingEngine(new BinomialVanillaEngine(process, "CoxRossRubinstein", timeSteps)); This can't work. The BinomialVanillaEngine is not compatible with the DividendVanillaOption. You'll have to stick to FD. Luigi -- Every solution breeds new problems. -- unknown ------------------------------------------------------------------------------ This SF.net Dev2Dev email is sponsored by: Show off your parallel programming skills. Enter the Intel(R) Threading Challenge 2010. http://p.sf.net/sfu/intel-thread-sfd _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Thanks for suggestion. I changed it (see below) and it still gives the same error. Any ideas?
Thanks again. // our option Option.Type type = Option.Type.Put; double strike = 40.0; double underlying = 36.0; double riskFreeRate = 0.06; double dividendYield = 0.00; double volatility = 0.2; Date todaysDate = new Date(15, Month.May, 1998); Date settlementDate = new Date(17, Month.May, 1998); Settings.instance().setEvaluationDate(todaysDate); Date maturity = new Date(17, Month.May, 1999); DayCounter dayCounter = new Actual365Fixed(); Calendar calendar = new TARGET(); Exercise americanExercise = new AmericanExercise(settlementDate, maturity); // define the underlying asset and the yield/dividend/volatility curves QuoteHandle underlyingH = new QuoteHandle(new SimpleQuote(underlying)); YieldTermStructureHandle flatTermStructure = new YieldTermStructureHandle(new FlatForward( settlementDate, riskFreeRate, dayCounter)); YieldTermStructureHandle flatDividendYield = new YieldTermStructureHandle(new FlatForward( settlementDate, dividendYield, dayCounter)); BlackVolTermStructureHandle flatVolatility = new BlackVolTermStructureHandle(new BlackConstantVol( settlementDate, calendar, volatility, dayCounter)); BlackScholesMertonProcess process = new BlackScholesMertonProcess(underlyingH, flatDividendYield, flatTermStructure, flatVolatility); // options Payoff payoff = new PlainVanillaPayoff(type, strike); DateVector divDates = new DateVector(); DoubleVector divs = new DoubleVector(); divs.add(0.5); divDates.add(new Date(1, Month.October, 2010)); // VanillaOption americanOption = new VanillaOption(payoff, americanExercise); DividendVanillaOption americanOption = new DividendVanillaOption(payoff, americanExercise, divDates, divs); FDDividendAmericanEngine engine = new FDDividendAmericanEngine(process); americanOption.setPricingEngine(engine ); System.out.println("before calling npv"); double npv = americanOption.NPV(); System.out.println("npv=" + npv ); -----Original Message----- From: Luigi Ballabio [mailto:[hidden email]] Sent: Tuesday, August 31, 2010 11:40 AM To: Jeff Yan Cc: [hidden email] Subject: Re: [Quantlib-users] American options with discrete dividends - why it crashes? On Tue, 2010-08-31 at 11:31 -0400, Jeff Yan wrote: > I am trying to price American Options with discrete dividends in Java, > through SWIG, JNI, to QuantLib (C++ version). Everything goes well > until the last step: calling option.NPV() method crashes with JNI > error. > DividendVanillaOption americanOption = new DividendVanillaOption(payoff, americanExercise, divDates, divs); > > FDDividendAmericanEngine engine = new FDDividendAmericanEngine(process); > > americanOption.setPricingEngine(engine ); This is OK. If you call NPV here, you should get a price. > // Binomial method > int timeSteps = 801; > > americanOption.setPricingEngine(new BinomialVanillaEngine(process, "CoxRossRubinstein", timeSteps)); This can't work. The BinomialVanillaEngine is not compatible with the DividendVanillaOption. You'll have to stick to FD. Luigi -- Every solution breeds new problems. -- unknown The information contained in this electronic message is confidential and does not constitute investment advice or an offer to sell or the solicitation of an offer to purchase any security or investment product. Offers may only be made by means of delivery of an approved confidential offering memorandum, may be legally privileged and confidential under applicable law, and are intended only for the use of the individual or entity named above. We do not, and will not, effect or attempt to effect transactions in securities, or render personalized investment advice for compensation, through this email. All materials within this email have been provided to you for information purposes only and may not be relied upon by you in evaluating the merits of investing in any securities referenced herein. Any review, retransmission, dissemination, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer. Email transmissions are not secure, and we accept no liability for errors in transmission, delayed transmission, or other transmission-related issues. This message may contain confidential, proprietary or legally privileged information. Neither confidentiality nor any privilege is intended to be waived or lost by any error in transmission. Emails are subject to review and will be archived. ------------------------------------------------------------------------------ This SF.net Dev2Dev email is sponsored by: Show off your parallel programming skills. Enter the Intel(R) Threading Challenge 2010. http://p.sf.net/sfu/intel-thread-sfd _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
On Tue, 2010-08-31 at 11:55 -0400, Jeff Yan wrote:
> Thanks for suggestion. I changed it (see below) and it still gives the > same error. Any ideas? Can you catch the error and see what error message is contains? Luigi -- For every problem there is one solution which is simple, neat, and wrong. -- H. L. Mencken ------------------------------------------------------------------------------ This SF.net Dev2Dev email is sponsored by: Show off your parallel programming skills. Enter the Intel(R) Threading Challenge 2010. http://p.sf.net/sfu/intel-thread-sfd _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Good point. Will do
-----Original Message----- From: Luigi Ballabio [mailto:[hidden email]] Sent: Tuesday, August 31, 2010 12:06 PM To: Jeff Yan Cc: [hidden email] Subject: RE: [Quantlib-users] American options with discrete dividends - why it crashes? On Tue, 2010-08-31 at 11:55 -0400, Jeff Yan wrote: > Thanks for suggestion. I changed it (see below) and it still gives the > same error. Any ideas? Can you catch the error and see what error message is contains? Luigi -- For every problem there is one solution which is simple, neat, and wrong. -- H. L. Mencken The information contained in this electronic message is confidential and does not constitute investment advice or an offer to sell or the solicitation of an offer to purchase any security or investment product. Offers may only be made by means of delivery of an approved confidential offering memorandum, may be legally privileged and confidential under applicable law, and are intended only for the use of the individual or entity named above. We do not, and will not, effect or attempt to effect transactions in securities, or render personalized investment advice for compensation, through this email. All materials within this email have been provided to you for information purposes only and may not be relied upon by you in evaluating the merits of investing in any securities referenced herein. Any review, retransmission, dissemination, or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer. Email transmissions are not secure, and we accept no liability for errors in transmission, delayed transmission, or other transmission-related issues. This message may contain confidential, proprietary or legally privileged information. Neither confidentiality nor any privilege is intended to be waived or lost by any error in transmission. Emails are subject to review and will be archived. ------------------------------------------------------------------------------ This SF.net Dev2Dev email is sponsored by: Show off your parallel programming skills. Enter the Intel(R) Threading Challenge 2010. http://p.sf.net/sfu/intel-thread-sfd _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Error came from the DivDate? 2010 1st Oct?
Date todaysDate = new Date(15, Month.May, 1998); Date settlementDate = new Date(17, Month.May, 1998); Date maturity = new Date(17, Month.May, 1999); divDates.add(new Date(1, Month.October, 2010)); |
Free forum by Nabble | Edit this page |