Posted by
Alex Cicco on
URL: http://quantlib.414.s1.nabble.com/BLS-IV-calculated-by-QuantLib-is-different-from-Hull-s-tp213.html
Hi All,
I am new to quant lib. So, please forgive my newbie question.
My System Quantlib + boost + Java Swig interface.
I am using a Java testing code adapted from the work by Richard Gomes and Tito Ingargiola on Equity Options.
The testing code is enclosed at the end of this email.
My trouble is:
I cannot get BLS European IV calculated by QuantLib tied out with the value generated by Hull's DerivativeGem
------------------------------------------------------------------------------------------------------------------------------
Here is my input for the computation of an equity option IV
Trading Date: 2008-12-01,
Underlying stock price: 55.08,
Option Strike: 42.5,
Option Type: Put
Option Price: 0.215,
riskFreeRate = 0.03;
dividendYield = 0.00;
Option Expiration Date: 2008-12-20 ( the Saturday following the third Friday of the month)
--> Option Time to Expiration: 15 days (when counting trading days, I include 12/01/2008 as the option trading takes place at 9:30 of 12/01/2008)
--------------------------------------------------------------------------------------------------------------------------------------
Using the above input, and Hull's DerivativeGem Excel worksheet, I got an IV of 0.6897
-----------------------------------------------
Using QuantLib, I set
Try 1:
TodaysDate = 12/01/2008
SettlementDate =12/01/2008,
Maturity Date = 12/20/2008.
I got an IV of 0.7398648108461248
Try 2:
TodaysDate = 12/01/2008
SettlementDate =12/03/2008,
Maturity Date = 12/20/2008.
I got an IV of 0.7817627320081257
------------------------------------------------------------------------------------------------------------------------------------------------------
Could you advise on which parameter I set wrong in using QuantLib?
Thank you very much
Best regards,
Alex
------------------------------------------------------------------------------------------------------------------------------------------------------
My Java Testing Code goes here
package com.alexCicco.test.quantLibTest;
/*
Copyright (C) 2007 Richard Gomes
Copyright (C) 2007 Tito Ingargiola
This file is part of QuantLib, a free-software/open-source library
for financial quantitative analysts and developers -
http://quantlib.org/
QuantLib is free software: you can redistribute it and/or modify it
under the terms of the QuantLib license. You should have received a
copy of the license along with this program; if not, please email
<
[hidden email]>. The license is also available online at
<
http://quantlib.org/license.shtml>.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the license for more details.
*/
//package examples;
import org.quantlib.Actual365Fixed;
import org.quantlib.AmericanExercise;
import org.quantlib.BlackConstantVol;
import org.quantlib.BlackScholesMertonProcess;
import org.quantlib.AnalyticEuropeanEngine;
import org.quantlib.BlackVolTermStructureHandle;
import org.quantlib.Calendar;
import org.quantlib.Date;
import org.quantlib.DayCounter;
import org.quantlib.EuropeanExercise;
import org.quantlib.Exercise;
import org.quantlib.FlatForward;
import org.quantlib.Month;
import org.quantlib.Option;
import org.quantlib.Payoff;
import org.quantlib.PlainVanillaPayoff;
import org.quantlib.QuoteHandle;
import org.quantlib.Settings;
import org.quantlib.SimpleQuote;
import org.quantlib.TARGET;
import org.quantlib.VanillaOption;
import org.quantlib.YieldTermStructureHandle;
/**
* Test Implied volatility of European options
* @author Alex Cicco
*/
public class EuropeanIV {
static {
try {
System.loadLibrary("QuantLibJNI");
} catch (RuntimeException e) {
e.printStackTrace();
}
}
public static void main(String[] args) throws Exception {
long beginTime = System.currentTimeMillis();
// our option
Option.Type type = Option.Type.Put;
double strike = 42.5;
double underlying = 55.08;
double riskFreeRate = 0.03;
double dividendYield = 0.00;
double volatility = 0.01;
Date todaysDate = new Date(1, Month.December, 2008);
Date settlementDate = new Date(1, Month.December, 2008);
Settings.instance().setEvaluationDate(todaysDate);
Date maturity = new Date(20, Month.December, 2008);
DayCounter dayCounter = new Actual365Fixed();
Calendar calendar = new TARGET();
Exercise europeanExercise = new EuropeanExercise(maturity);
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 stochasticProcess =
new BlackScholesMertonProcess(underlyingH,
flatDividendYield,
flatTermStructure,
flatVolatility);
// options
Payoff payoff = new PlainVanillaPayoff(type, strike);
VanillaOption europeanOption =
new VanillaOption(payoff, europeanExercise);
VanillaOption americanOption =
new VanillaOption(payoff, americanExercise);
double optionPrice = 0.215;
europeanOption.setPricingEngine(
new AnalyticEuropeanEngine(stochasticProcess));
double iv_european = europeanOption.impliedVolatility(optionPrice, stochasticProcess);
double iv_american = americanOption.impliedVolatility(optionPrice, stochasticProcess);
String fmt = "\n%-35s %-35s %-35s\n";
System.out.printf(fmt, "Method", "European_IV", "American_IV");
System.out.println("=====================================================================================");
// Black-Scholes for European
String method = "Black-Scholes";
System.out.printf(fmt, new Object[] { method,
iv_european,
Double.NaN } );
// Bjerksund and Stensland approximation for American
method = "American: Bjerksund/Stensland";
System.out.printf(fmt, new Object[] { method,
Double.NaN,
iv_american } );
long msecs = (System.currentTimeMillis()-beginTime);
System.out.println("Run completed in "+msecs+" ms.");
}
}
------------------------------------------------------------------------------
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