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:
2025-11-13 16:37:18 +01:00
parent 4570a011ec
commit 2b00a351c0

View File

@@ -51,12 +51,10 @@ server <- function(input, output) {
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])
df = data.frame(strikes = strikes, Call = vcall, Put = vput)
df = data.frame(strikes = strikes, Call = vcall)
p <- ggplot(df, aes(x = strikes)) +
geom_line(aes(y = Call, color = "Call")) +
geom_line(aes(y = Put, color = "Put")) +
labs(title = "Black-Scholes Option Pricing",
x = "Strike Price",
y = "Option Price") +
@@ -75,13 +73,11 @@ server <- function(input, output) {
dv = input$divrate
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])
df = data.frame(strikes = strikes, Call = vcall, Put = vput)
df = data.frame(strikes = strikes, Put = vput)
p <- ggplot(df, aes(x = strikes)) +
geom_line(aes(y = Put, color = "Put")) +
geom_line(aes(y = Call, color = "Call")) +
labs(title = "Black-Scholes Option Pricing",
x = "Strike Price",
y = "Option Price") +