This function evaluations an Barrier option on a common stock using a closed-form solution. The option value as well as the common first derivatives ("Greeks") are returned.
# S3 method for default
BarrierOption(barrType, type, underlying, strike,
dividendYield, riskFreeRate, maturity,
volatility, barrier, rebate=0.0)
A string with one of the values downin
,
downout
, upin
or upout
A string with one of the values call
or put
Current price of the underlying stock
Strike price of the option
Continuous dividend yield (as a fraction) of the stock
Risk-free rate
Time to maturity (in fractional years)
Volatility of the underlying stock
Option barrier value
Optional option rebate, defaults to 0.0
An object of class BarrierOption
(which inherits from class
Option
) is returned. It contains a list with the
following components:
Value of option
Sensitivity of the option value for a change in the underlying
Sensitivity of the option delta for a change in the underlying
Sensitivity of the option value for a change in the underlying's volatility
Sensitivity of the option value for a change in t, the remaining time to maturity
Sensitivity of the option value for a change in the risk-free interest rate
Sensitivity of the option value for a change in the dividend yield
Note that under the new pricing framework used in QuantLib, binary pricers do not provide analytics for 'Greeks'. This is expected to be addressed in future releases of QuantLib.
A closed-form solution is used to value the Barrier Option. In the case of Barrier options, the calculations are from Haug's "Option pricing formulas" book (McGraw-Hill).
Please see any decent Finance textbook for background reading, and
the QuantLib
documentation for details on the QuantLib
implementation.
http://quantlib.org for details on QuantLib
.
# NOT RUN {
BarrierOption(barrType="downin", type="call", underlying=100,
strike=100, dividendYield=0.02, riskFreeRate=0.03,
maturity=0.5, volatility=0.4, barrier=90)
# }
Run the code above in your browser using DataCamp Workspace