Last active
October 18, 2020 16:12
-
-
Save addiversitas/adebff6ad441f720cb954ac19fb0ba2b to your computer and use it in GitHub Desktop.
example of implied volatility surface plot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(plotly) | |
xaxx <- list( | |
gridcolor='rgb(255, 255, 255)', | |
zerolinecolor='rgb(255, 255, 255)', | |
showbackground=TRUE, | |
backgroundcolor='rgb(230, 230,230)', | |
title = "Moneyness" | |
) | |
yaxx <- list( | |
gridcolor='rgb(255, 255, 255)', | |
zerolinecolor='rgb(255, 255, 255)', | |
showbackground=TRUE, | |
backgroundcolor='rgb(230, 230,230)', | |
title = "Time To Maturity" | |
) | |
zaxx <- list( | |
gridcolor='rgb(255, 255, 255)', | |
zerolinecolor='rgb(255, 255, 255)', | |
showbackground=TRUE, | |
backgroundcolor='rgb(230, 230,230)', | |
tickformat = "%", | |
title = "Implied Volatility" | |
) | |
fig <- plot_ly(x = colnames(ivGridCalls), y = rownames(ivGridCalls), z = ivGridCalls) | |
fig <- fig %>% add_surface() | |
fig <- fig %>% layout(scene = list(xaxis=xaxx, yaxis=yaxx, zaxis = zaxx)) | |
fig <- fig %>% plotly::colorbar(title = "", x = 0.9, y = 0.75, tickformat = "%") | |
fig |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment