I am trying to get my hands on Options. I am trying to use the QuantLib C# code for calculating Options (single and multiple) and also to evaluate Greeks and Marginal Values. In the solution I have seen an example of calculating options but the values there is not matching with www.asx.com.au calculator. Also, I have been trying to print GREEKS by using the code in quant lib but could not do it so far. I am little confused by the programming structure of quantlib and I need some help. An example program which I can use to get the Greeks for Eurpean/American Call/Put options will be a great help.
Regards, Sumit Gupta ------------------------------------------------------------------------------ Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are powering Web 2.0 with engaging, cross-platform capabilities. Quickly and easily build your RIAs with Flex Builder, the Eclipse(TM)based development software that enables intelligent coding and step-through debugging. Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
On Thu, 2009-03-19 at 13:21 +1100, Sumit Gupta wrote:
> I am trying to get my hands on Options. I am trying to use the > QuantLib C# code for calculating Options (single and multiple) and > also to evaluate Greeks and Marginal Values. In the solution I have > seen an example of calculating options but the values there is not > matching with www.asx.com.au calculator. Do you have an example of values not matching (and the inputs you used)? Luigi -- A debugged program is one for which you have not yet found the conditions that make it fail. -- Jerry Ogdin ------------------------------------------------------------------------------ Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are powering Web 2.0 with engaging, cross-platform capabilities. Quickly and easily build your RIAs with Flex Builder, the Eclipse(TM)based development software that enables intelligent coding and step-through debugging. Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Sumit,
I was able to figure out the Greeks yesterday, as well as Black-Scholes options valuations. I've pasted a function below that will create a EuropeanOption based on some simple parameters. Then you can call the NPV(), delta(), gamma(), etc methods on the resulting object. Some caveats: (1) this code is C#, using the SWIG-wrapped release, but I think you can figure out how to redo it in C++ (2) it's using the plain old BlackScholes stochastic process (3) it's using the SimpleDayCounter, which is for theoretical computation (see the docs). If you pass in todaysDate=01Jan2009 and maturityDate=01Jul2009, then the time-to-maturity will be exactly 0.5. This might not be the best code example, but I'm new to both QuantLib and this subject area. -Grant private EuropeanOption CreateEuropeanOption( double underlyingPrice, double strikePrice, double riskFreeRate, Date todaysDate, Date maturityDate, double volatility, Option.Type optionType) { Date settlementDate = todaysDate; Settings.instance().setEvaluationDate(todaysDate); Calendar calendar = new NullCalendar(); DayCounter dayCounter = new SimpleDayCounter(); QuoteHandle underlyingQuoteH = new QuoteHandle(new SimpleQuote(underlyingPrice)); EuropeanExercise europeanExercise = new EuropeanExercise(maturityDate); YieldTermStructureHandle flatRateTSH = new YieldTermStructureHandle( new FlatForward(settlementDate, riskFreeRate, dayCounter)); BlackVolTermStructureHandle flatVolTSH = new BlackVolTermStructureHandle( new BlackConstantVol(settlementDate, calendar, volatility, dayCounter)); BlackScholesProcess stochasticProcess = new BlackScholesProcess(underlyingQuoteH, flatRateTSH, flatVolTSH); PlainVanillaPayoff payoff = new PlainVanillaPayoff(optionType, strikePrice); EuropeanOption europeanOption = new EuropeanOption(payoff, europeanExercise); europeanOption.setPricingEngine(new AnalyticEuropeanEngine(stochasticProcess)); return europeanOption; } On Fri, Mar 20, 2009 at 5:00 AM, Luigi Ballabio <[hidden email]> wrote: > On Thu, 2009-03-19 at 13:21 +1100, Sumit Gupta wrote: >> I am trying to get my hands on Options. I am trying to use the >> QuantLib C# code for calculating Options (single and multiple) and >> also to evaluate Greeks and Marginal Values. In the solution I have >> seen an example of calculating options but the values there is not >> matching with www.asx.com.au calculator. > > Do you have an example of values not matching (and the inputs you used)? > > Luigi > > > -- > > A debugged program is one for which you have not yet found the > conditions that make it fail. > -- Jerry Ogdin > > > > ------------------------------------------------------------------------------ > Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are > powering Web 2.0 with engaging, cross-platform capabilities. Quickly and > easily build your RIAs with Flex Builder, the Eclipse(TM)based development > software that enables intelligent coding and step-through debugging. > Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com > _______________________________________________ > QuantLib-users mailing list > [hidden email] > https://lists.sourceforge.net/lists/listinfo/quantlib-users > ------------------------------------------------------------------------------ Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are powering Web 2.0 with engaging, cross-platform capabilities. Quickly and easily build your RIAs with Flex Builder, the Eclipse(TM)based development software that enables intelligent coding and step-through debugging. Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
In reply to this post by Luigi Ballabio
The values for Eurpoean (BlackScholes) options and greeks being calculated perfectly and matching to the 4th decimal point with ASX. Also for bionomial (American) the value of option is matching perfectly too. BUT Greeks are not matching at all and not even with close approximation. I am using the same input as provided to ASX options in the example EquityOption.cs.
Also, FYI, the EquityOption I changed variable settlementDate with todayDate variable in the code as it was bug there and once i did tht I started getting the perfect values.
ASX calculator can be accessed with the link below. Select the option you want to calculate:
Thanks for your help in advance.
Regards,
Sumit Gupta
On Fri, Mar 20, 2009 at 9:00 PM, Luigi Ballabio <[hidden email]> wrote:
------------------------------------------------------------------------------ Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are powering Web 2.0 with engaging, cross-platform capabilities. Quickly and easily build your RIAs with Flex Builder, the Eclipse(TM)based development software that enables intelligent coding and step-through debugging. Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Also, I am having problems with GREEKS only for american (Bionomial-CRR) option pricing only and also do not know how to calculate Rho and Vega there. They were not implemented there in the QuantLib for Bionomial-CRR model. Please advice.
Regards,
Sumit
On Sat, Mar 21, 2009 at 3:30 PM, Sumit Gupta <[hidden email]> wrote:
------------------------------------------------------------------------------ Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are powering Web 2.0 with engaging, cross-platform capabilities. Quickly and easily build your RIAs with Flex Builder, the Eclipse(TM)based development software that enables intelligent coding and step-through debugging. Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
On Sat, 2009-03-21 at 15:34 +1100, Sumit Gupta wrote:
> Also, I am having problems with GREEKS only for american > (Bionomial-CRR) option pricing only and also do not know how to > calculate Rho and Vega there. They were not implemented there in the > QuantLib for Bionomial-CRR model. Please advice. You have to calculate rho and vega numerically. For rho: price your option, modify the risk-free rate a tiny bit, and reprice. For vega, do the same for the volatility. Luigi -- Don't let school get in the way of your education. -- Mark Twain ------------------------------------------------------------------------------ Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are powering Web 2.0 with engaging, cross-platform capabilities. Quickly and easily build your RIAs with Flex Builder, the Eclipse(TM)based development software that enables intelligent coding and step-through debugging. Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
In reply to this post by Sumit Gupta-5
On Sat, 2009-03-21 at 15:30 +1100, Sumit Gupta wrote:
> The values for Eurpoean (BlackScholes) options and greeks being > calculated perfectly and matching to the 4th decimal point with ASX. > Also for bionomial (American) the value of option is matching > perfectly too. BUT Greeks are not matching at all and not even with > close approximation. They don't match as closely as the price, but I wouldn't say "not matching at all". For the option I've tried, I get for instance a 0.786 delta vs 0.793 from ASX; that might be due to the way Greeks are calculated on the tree. Also, if I calculate the delta numerically by modifying the underlying value and recalculating, I get 0.789, which seems to mean the we and ASX are making comparable errors on opposite sides of the true value. Perhaps you may post the set of inputs that you used, so we can do some analysis on them? Luigi -- So little done, so much to do. -- Cecil Rhodes ------------------------------------------------------------------------------ Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are powering Web 2.0 with engaging, cross-platform capabilities. Quickly and easily build your RIAs with Flex Builder, the Eclipse(TM)based development software that enables intelligent coding and step-through debugging. Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Free forum by Nabble | Edit this page |