mirror of
https://github.com/ArthurDanjou/ArtStudies.git
synced 2026-02-01 04:29:37 +01:00
Limit plots to single series: show only Call in first plot and only Put in second; remove unused series and adjust data frames.
This commit is contained in:
@@ -51,12 +51,10 @@ server <- function(input, output) {
|
|||||||
|
|
||||||
strikes = seq(K - 30, K + 30)
|
strikes = seq(K - 30, K + 30)
|
||||||
vcall = sapply(strikes, function(k) BS(S, k, T, v, rf, dv)[1])
|
vcall = sapply(strikes, function(k) BS(S, k, T, v, rf, dv)[1])
|
||||||
vput = sapply(strikes, function(k) BS(S, k, T, v, rf, dv)[2])
|
|
||||||
|
|
||||||
df = data.frame(strikes = strikes, Call = vcall, Put = vput)
|
df = data.frame(strikes = strikes, Call = vcall)
|
||||||
p <- ggplot(df, aes(x = strikes)) +
|
p <- ggplot(df, aes(x = strikes)) +
|
||||||
geom_line(aes(y = Call, color = "Call")) +
|
geom_line(aes(y = Call, color = "Call")) +
|
||||||
geom_line(aes(y = Put, color = "Put")) +
|
|
||||||
labs(title = "Black-Scholes Option Pricing",
|
labs(title = "Black-Scholes Option Pricing",
|
||||||
x = "Strike Price",
|
x = "Strike Price",
|
||||||
y = "Option Price") +
|
y = "Option Price") +
|
||||||
@@ -75,13 +73,11 @@ server <- function(input, output) {
|
|||||||
dv = input$divrate
|
dv = input$divrate
|
||||||
|
|
||||||
strikes = seq(K - 30, K + 30)
|
strikes = seq(K - 30, K + 30)
|
||||||
vcall = sapply(strikes, function(k) BS(S, k, T, v, rf, dv)[1])
|
|
||||||
vput = sapply(strikes, function(k) BS(S, k, T, v, rf, dv)[2])
|
vput = sapply(strikes, function(k) BS(S, k, T, v, rf, dv)[2])
|
||||||
|
|
||||||
df = data.frame(strikes = strikes, Call = vcall, Put = vput)
|
df = data.frame(strikes = strikes, Put = vput)
|
||||||
p <- ggplot(df, aes(x = strikes)) +
|
p <- ggplot(df, aes(x = strikes)) +
|
||||||
geom_line(aes(y = Put, color = "Put")) +
|
geom_line(aes(y = Put, color = "Put")) +
|
||||||
geom_line(aes(y = Call, color = "Call")) +
|
|
||||||
labs(title = "Black-Scholes Option Pricing",
|
labs(title = "Black-Scholes Option Pricing",
|
||||||
x = "Strike Price",
|
x = "Strike Price",
|
||||||
y = "Option Price") +
|
y = "Option Price") +
|
||||||
|
|||||||
Reference in New Issue
Block a user