mirror of
https://github.com/ArthurDanjou/ArtStudies.git
synced 2026-01-14 13:54:06 +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)
|
||||
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")) +
|
||||
geom_line(aes(y = Put, color = "Put")) +
|
||||
labs(title = "Black-Scholes Option Pricing",
|
||||
x = "Strike Price",
|
||||
y = "Option Price") +
|
||||
|
||||
Reference in New Issue
Block a user