MyNixOS website logo
Description

Sensitivities of Prices of Financial Options and Implied Volatilities.

Methods to calculate sensitivities of financial option prices for European, geometric and arithmetic Asian, and American options, with various payoff functions in the Black Scholes model, and in more general jump diffusion models. A shiny app to interactively plot the results is included. Furthermore, methods to compute implied volatilities are provided for a wide range of option types and custom payoff functions. Classical formulas are implemented for European options in the Black Scholes Model, as is presented in Hull, J. C. (2017), Options, Futures, and Other Derivatives. In the case of Asian options, Malliavin Monte Carlo Greeks are implemented, see Hudde, A. & Rüschendorf, L. (2023). European and Asian Greeks for exponential Lévy processes. <doi:10.1007/s11009-023-10014-5>. For American options, the Binomial Tree Method is implemented, as is presented in Hull, J. C. (2017).

greeks

R-CMD-check status Codecov test coverage

The package greeks provides functions to compute financial option prices and sensitivities of financial option prices for European, American, Asian, and Digital options in the Black Scholes model, and in more general jump diffusion models. Furthermore, based on the implementations of Vega, efficient functions for calculating implied volatilities not just for European options, but also for American, Asian, and digital options are provided.

Classical formulas are implemented for European options in the Black Scholes Model. Furthermore, functions to calculate Malliavin Monte Carlo Greeks are given, as presented e.g., in Hudde, A. & Rüschendorf, L. (2016). European and Asian Greeks for exponential Lévy processes (https://link.springer.com/article/10.1007/s11009-023-10014-5). These functions work for classical payoff functions, as well as for any custom square integrable function provided by the user. Additionally, these calculations are not restricted to the Black Scholes model, but work for more general Lévy Jump diffusion model, which is also customizable by the user.

greeks on CRAN

You can view the documentation of this package on CRAN.R-project.org/package=greeks/greeks.pdf and the vignette on CRAN.R-project.org/package=greeks/vignettes/using_greeks.html.

Installation

# The cran version can be installed by 
install.packages("greeks")
# The development version can be installed by
install.packages("devtools")
library("devtools")
devtools::install_github("ahudde/greeks")

Computing option prices and Greeks in the shiny app

The option prices and volatilities for European options can be displayed with the interactive shiny app by calling

library(greeks)
Greeks_UI()

or online on anselmhudde.shinyapps.io/greeks/

Greeks_UI

The function Greeks

Most of the options prices and Greeks can easily be calculated with the function Greeks.

# Load package

library(greeks)

# Option price and most common Greeks of a European call option on a share with
# price 100 and volatility of 30%, where the exercise price is 120, the time to
# maturity of 5 years, and the riskless interest rate of 1%.

Greeks(initial_price = 100,
       exercise_price = 120,
       r = 0.01,
       time_to_maturity = 5,
       volatility = 0.30,
       payoff = "call")

##    fair_value         delta          vega         theta           rho 
##  21.577149923   0.554941778  88.358901748  -2.989937331 169.585139380 
##         gamma 
##   0.005890593

# Option price and most common Greeks of an American put option on a share with
# price 100 and volatility of 25%, where the exercise price is 100, the time to
# maturity of 1 year, and the riskless interest rate of -0.5%.

Greeks(initial_price = 100,
       exercise_price = 100,
       r = -0.005,
       time_to_maturity = 1,
       volatility = 0.30,
       payoff = "put",
       option_type = "American")

##  fair_value       delta        vega       theta         rho       gamma 
##  12.2027075  -0.4469782  39.5313017  -6.2141979 -56.9005269  -0.1275472

Computing implied volatilities

The package greeks also provides a function to compute implied volatilities for a wide range of option types and payoff functions:

# Implied volatility of an Asian call option with on an option price of 15, a
# share price of 100, an exercise_price of 100, a risk-free interest rate of
# 0.05 and a time to maturity of 1.

Implied_Volatility(option_price = 15, initial_price = 100,
             exercise_price = 100, r = 0.05, time_to_maturity = 1,
             option_type = "Asian", payoff = "call")

## [1] 0.6330451

Contributions, bug reports or support

Bug reports and contributions are very welcome. Also, if you need assistance, please open an issue on github.com/ahudde/greeks/issues.

Metadata

Version

1.4.2

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows