A continuación, mostraremos la ejecución correspondiente en R-Studio para establecer el uso adecuado de una inversión 10.000 dólares, además de la cobertura en opciones de acciones financieras.
PARTE 1: Creación del portafolio óptimo.
library(tidyquant)
library(plotly)
library(timetk)
library(tidyr)
library(dplyr)
library(forcats)
library(ggplot2)
library(tidyverse)
library(timetk)
library(knitr)
library(conflicted)
tick <- c('TXN', 'FTNT', 'DLTR')
price_data <- tq_get(tick,
from = '2013-01-01',
to = '2023-06-01',
get = 'stock.prices')
log_ret_tidy <- price_data %>%
group_by(symbol) %>%
tq_transmute(select = adjusted,
mutate_fun = periodReturn,
period = 'daily',
col_rename = 'ret',
type = 'log')
#Miramos las primeras filas
head(log_ret_tidy)
## # A tibble: 6 × 3
## # Groups: symbol [1]
## symbol date ret
## <chr> <date> <dbl>
## 1 TXN 2013-01-02 0
## 2 TXN 2013-01-03 -0.0131
## 3 TXN 2013-01-04 -0.00220
## 4 TXN 2013-01-07 0.00314
## 5 TXN 2013-01-08 -0.0117
## 6 TXN 2013-01-09 0.0142
log_ret_xts <- log_ret_tidy %>%
spread(symbol, value = ret) %>%
tk_xts()
head(log_ret_xts)
## DLTR FTNT TXN
## 2013-01-02 0.000000000 0.000000000 0.000000000
## 2013-01-03 -0.010582159 -0.091871076 -0.013084082
## 2013-01-04 0.003539811 -0.001035183 -0.002197462
## 2013-01-07 0.008544917 -0.013031186 0.003137709
## 2013-01-08 -0.024060950 0.001572750 -0.011659229
## 2013-01-09 -0.021506154 0.004703402 0.014162214
mean_ret <- colMeans(log_ret_xts)
print(round(mean_ret, 5))
## DLTR FTNT TXN
## 0.00046 0.00106 0.00075
cov_mat <- cov(log_ret_xts) * 252
print(round(cov_mat,4))
## DLTR FTNT TXN
## DLTR 0.1024 0.0296 0.0264
## FTNT 0.0296 0.1526 0.0482
## TXN 0.0264 0.0482 0.0736
wts <- runif(n = length(tick))
print(wts)
## [1] 0.2335760 0.6683211 0.7687749
print(sum(wts))
## [1] 1.670672
#Ajustamos a que sumen el 100%
wts <- wts/sum(wts)
print(wts)
## [1] 0.1398096 0.4000313 0.4601591
sum(wts)
## [1] 1
port_returns <- (sum(wts * mean_ret) + 1)^252 - 1
port_returns
## [1] 0.2338122
port_risk <- sqrt(t(wts) %*% (cov_mat %*% wts))
print(port_risk)
## [,1]
## [1,] 0.2577855
sharpe_ratio <- port_returns/port_risk
print(sharpe_ratio)
## [,1]
## [1,] 0.907003
wts <- runif(n = length(tick))
wts <- wts/sum(wts)
port_returns <- (sum(wts * mean_ret) + 1)^252 - 1
port_risk <- sqrt(t(wts) %*% (cov_mat %*% wts))
sharpe_ratio <- port_returns/port_risk
print(wts)
## [1] 0.3106901 0.3437227 0.3455871
print(port_returns)
## [1] 0.2134253
print(port_risk)
## [,1]
## [1,] 0.2452461
print(sharpe_ratio)
## [,1]
## [1,] 0.8702496
SIMULACIÓN PARA LA OPTIMIZACIÓN.
num_port <- 5000
#Creamos una matriz para almacenar los pesos aleatorios
all_wts <- matrix(nrow = num_port,
ncol = length(tick))
#Creamos el vector para almacenar la rentabilidad de la cartera
port_returns <- vector('numeric', length = num_port)
#Creamos el vector para almacenar la Desviacion Estandar
port_risk <- vector('numeric', length = num_port)
#Creamos el vector para almacenar el indice de Sharpe
sharpe_ratio <- vector('numeric', length = num_port)
#Ejecutamos el bucle 5000 veces
for (i in seq_along(port_returns)) {
wts <- runif(length(tick))
wts <- wts/sum(wts)
#Almacenamiento de peso en la matriz
all_wts[i,] <- wts
#Rentabilidad de la cartera
port_ret <- sum(wts * mean_ret)
port_ret <- ((port_ret + 1)^252) - 1
#Almacenamiento rentabilidad de la cartera
port_returns[i] <- port_ret
#Crear y almacenar el riesgo de la cartera
port_sd <- sqrt(t(wts) %*% (cov_mat %*% wts))
port_risk[i] <- port_sd
#Creación y almacenamiento de Ratios Sharpe de
#cartera asumiendo una tasa libre de riesgo del 0%
sr <- port_ret/port_sd
sharpe_ratio[i] <- sr
}
portfolio_values <- tibble(Return = port_returns,
Risk = port_risk,
SharpeRatio = sharpe_ratio)
#Convertir una matriz en un tibble y cambiar los nombres de las columnas
all_wts <- tk_tbl(all_wts)
colnames(all_wts) <- colnames(log_ret_xts)
#Combinando todos los valores juntos
portfolio_values <- tk_tbl(cbind(all_wts, portfolio_values))
head(portfolio_values)
## # A tibble: 6 × 6
## DLTR FTNT TXN Return Risk SharpeRatio
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 0.646 0.131 0.223 0.165 0.254 0.650
## 2 0.465 0.239 0.296 0.190 0.241 0.790
## 3 0.251 0.380 0.368 0.222 0.250 0.888
## 4 0.444 0.418 0.139 0.209 0.261 0.801
## 5 0.317 0.347 0.336 0.213 0.246 0.868
## 6 0.0791 0.143 0.777 0.214 0.251 0.855
View(portfolio_values)
min_var <- portfolio_values[which.min(portfolio_values$Risk),]
min_var
## # A tibble: 1 × 6
## DLTR FTNT TXN Return Risk SharpeRatio
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 0.357 0.112 0.532 0.188 0.232 0.809
max_sr <- portfolio_values[which.max(portfolio_values$SharpeRatio),]
max_sr
## # A tibble: 1 × 6
## DLTR FTNT TXN Return Risk SharpeRatio
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 0.0856 0.394 0.521 0.238 0.262 0.910
p <- min_var %>%
gather(DLTR:TXN, key = Asset,
value = Weights) %>%
mutate(Asset = as.factor(Asset)) %>%
ggplot(aes(x = fct_reorder(Asset,Weights), y = Weights, fill = Asset)) +
geom_bar(stat = 'identity') +
theme_minimal() +
labs(x = 'Assets', y = 'Pesos', title = "Pesos del portafolio de varianza mínima") +
scale_y_continuous(labels = scales::percent)
#veamos la cartera de tangencia o la cartera con el índice de
#nitidez más alto
p <- max_sr %>%
gather(DLTR:TXN, key = Asset,
value = Weights) %>%
mutate(Asset = as.factor(Asset)) %>%
ggplot(aes(x = fct_reorder(Asset,Weights), y = Weights, fill = Asset)) +
geom_bar(stat = 'identity') +
theme_minimal() +
labs(x = 'Accion', y = 'Pesos optimos', title = "Distribución Óptima del Portafolio") +
scale_y_continuous(labels = scales::percent) +
# Agregar etiquetas de texto para los pesos
geom_text(aes(label = paste("Peso:", scales::percent(Weights,2))),
position = position_stack(vjust = 0.5), color = "white")
p
p <- portfolio_values %>%
ggplot(aes(x = Risk, y = Return, color = SharpeRatio)) +
geom_point() +
theme_classic() +
scale_y_continuous(labels = scales::percent) +
scale_x_continuous(labels = scales::percent) +
labs(x = 'Annualized Risk',
y = 'Annualized Returns',
title = "Optimización del portafolio y Frontera Eficiente") +
geom_point(aes(x = Risk,
y = Return), data = min_var, color = 'red') +
geom_point(aes(x = Risk,
y = Return), data = max_sr, color = 'red') +
annotate('text', x = 0.20, y = 0.42, label = "Portafolio de Tangencia") +
annotate('text', x = 0.18, y = 0.01, label = "Portafolio de varianza mínima") +
annotate(geom = 'segment', x = 0.14, xend = 0.135, y = 0.01,
yend = 0.06, color = 'red', arrow = arrow(type = "open")) +
annotate(geom = 'segment', x = 0.22, xend = 0.2275, y = 0.405,
yend = 0.365, color = 'red', arrow = arrow(type = "open"))
p
PREGUNTAS PARTE 1.
El valor del riesgo del portafolio es 0.2753271.Este valor representa la volatilidad del portafolio, es decir, cuánto fluctúa el valor del portafolio en relación con su media. Un valor más alto indica un mayor nivel de riesgo, lo que significa que el portafolio experimenta fluctuaciones más amplias en su valor. Para interpretar este valor, es importante considerar la tolerancia del inversionistaal riesgo. Si es más conservador, es posible que desee un riesgo más bajo, mientras que si es más tolerante al riesgo, podría aceptar un riesgo más alto en busca de mayores rendimientos.
El valor del índice de Sharpe es 0.8289797.El índice de Sharpe mide la relación entre el rendimiento adicional obtenido por unidad de riesgo asumido. Un valor más alto indica un mejor rendimiento ajustado por riesgo. Este valor te proporciona una medida de la eficiencia del portafolio en términos de cómo está generando rendimientos en relación con el nivel de riesgo asumido. Un Sharpe Ratio por encima de 1 es considerado bueno, mientras que por encima de 2 es excelente.
Para invertir los 10.000 USD, podríamos ajustar la asignación de fondos entre los activos para equilibrar el rendimiento potencial con el nivel de riesgo que se está dispuesto a asumir como inversionista.
El rendimiento del portafolio es de 0.2282406 y la volatilidad de 0.2753271, por lo tanto, para obtener este portafolio los pesos se tienen que distribuir de la siguiente forma: 8% aproximadamente en DLTR, 40% en FTNT, 0% en ISA y 52% en TXN.
El Sharpe Óptimo de la cartera de inversión es 0.8189793. Este valor indica que por cada unidad de riesgo asumida en el portafolio, se está obteniendo un rendimiento de aproximadamente 0.8189793 unidades.Este Sharpe Ratio de 0.8189793 puede considerarse “óptimo” en relación con el nivel de riesgo asumido en el portafolio y las condiciones del mercado. El valor de varianza histórica de cada activo es el siguiente: TXN=0.523: los rendimientos de TXN han experimentado una mayor dispersión en el pasado en comparación con los otros dos activos. FTNT=0.394: tiene una varianza histórica de 0.394, que es menor que la de TXN pero mayor que la de DLTR. Esto sugiere que FTNT ha experimentado una dispersión moderada en sus rendimientos en el pasado. DLTR=0.0826:DLTR tiene la varianza histórica más baja de 0.0826, lo que indica que los rendimientos de DLTR han sido relativamente menos volátiles en comparación con TXN y FTNT.
PARTE 2: Creación de Arboles binomiales a través del modelo Cox-Ross-Rubinstein (CRR).
library(ggplot2)
library(derivmkts)
library(options)
library(Deriv)
library(quantmod)
library(OptionPricing)
# Especificación de los símbolos bursátiles y el período de tiempo
symbols <- c('TXN', 'FTNT', 'DLTR')
start_date <- "2023-06-01"
end_date <- "2024-04-17"
# Obtenemos los precios históricos de acciones
getSymbols(symbols, src = "yahoo", from = "2023-06-01", to = "2024-04-17")
## [1] "TXN" "FTNT" "DLTR"
# Ver las filas más recientes de los datos descargados
tail(TXN)
## TXN.Open TXN.High TXN.Low TXN.Close TXN.Volume TXN.Adjusted
## 2024-04-09 171.00 173.52 170.13 173.46 4830700 173.46
## 2024-04-10 169.87 170.41 167.90 168.92 5662800 168.92
## 2024-04-11 169.90 171.85 168.13 171.20 4352100 171.20
## 2024-04-12 168.42 169.43 165.77 166.33 5472400 166.33
## 2024-04-15 168.29 169.34 165.32 166.35 4739500 166.35
## 2024-04-16 167.48 168.52 166.82 167.59 3389000 167.59
tail(FTNT)
## FTNT.Open FTNT.High FTNT.Low FTNT.Close FTNT.Volume FTNT.Adjusted
## 2024-04-09 69.14 69.14 67.80 68.22 2799600 68.22
## 2024-04-10 67.08 68.50 67.08 68.13 3641300 68.13
## 2024-04-11 68.61 68.86 67.44 68.22 2917900 68.22
## 2024-04-12 67.47 67.72 65.93 66.45 5132600 66.45
## 2024-04-15 67.08 67.19 64.58 64.73 4911100 64.73
## 2024-04-16 64.62 65.57 64.26 64.48 3015000 64.48
tail(DLTR)
## DLTR.Open DLTR.High DLTR.Low DLTR.Close DLTR.Volume DLTR.Adjusted
## 2024-04-09 128.01 128.93 126.58 127.33 2093600 127.33
## 2024-04-10 125.46 129.26 124.91 128.73 2436800 128.73
## 2024-04-11 130.00 131.42 128.72 130.25 2005600 130.25
## 2024-04-12 129.15 129.63 124.98 125.19 3462800 125.19
## 2024-04-15 127.19 128.00 125.32 125.36 2201900 125.36
## 2024-04-16 124.81 125.72 123.34 124.06 1936700 124.06
#Crear la columna de precio de cierre ajustado
TXN= Ad(TXN)
FTNT= Ad(FTNT)
DLTR= Ad(DLTR)
s_txn = tail(TXN,1)
s_ftnt = tail(FTNT,1)
s_dltr = tail(DLTR,1)
s_txn = as.numeric(s_txn)
s_ftnt = as.numeric(s_ftnt)
s_dltr = as.numeric(s_dltr)
s_txn
## [1] 167.59
s_ftnt
## [1] 64.48
s_dltr
## [1] 124.06
media_precios_txn <- mean(TXN)
media_precios_ftnt <- mean(FTNT)
media_precios_dltr <- mean(DLTR)
v_hist=0.2496516
bs_option_price_quantmod <- function(type, underlying, strike, expire, rate, volatility, div = 0) {
T <- expire
S <- underlying
K <- strike
r <- rate
sigma <- v_hist
D <- div
d1 <- (log(S / K) + (r - D + 0.5 * sigma^2) * T) / (sigma * sqrt(T))
d2 <- d1 - sigma * sqrt(T)
if (type == "call") {
option_price <- S * exp(-D * T) * pnorm(d1) - K * exp(-r * T) * pnorm(d2)
} else if (type == "put") {
option_price <- K * exp(-r * T) * pnorm(-d2) - S * exp(-D * T) * pnorm(-d1)
} else {
stop("Invalid option type. Use 'call' or 'put'.")
}
return(option_price)
}
underlying_price <- s_txn # Precio actual de la accion
strike_price <- 175 # Precio strike
time_to_expiry <- 0.25 # Tiempo vencimiento en a?os (son 90 dias)
risk_free_rate <- 0.0112584 # Tasa libre de riesgo
dividend_yield <- 0.0293 # Dividendos de la accion (2.93%)Los dividendos de TXN se pagan trimestralmente.
volatility <- v_hist # Volatilidad Histórica
# Calculamos el precio de la opción de compra de Black-Scholes para TXN
txn_bs_call_price <- bs_option_price_quantmod(type = "call",
underlying = underlying_price,
strike = strike_price,
expire = time_to_expiry,
rate = risk_free_rate,
volatility = v_hist,
div = dividend_yield)
# Imprimimos el resultado
print(paste("TXN Precio de opción de compra (con quantmod):", txn_bs_call_price))
## [1] "TXN Precio de opción de compra (con quantmod): 5.0242106746722"
black_scholes_with_rate_change <- function(S, K, T, r, r_new, sigma, type = "call") {
d1 <- (log(S / K) + ((r_new + (sigma^2) / 2) * T)) / (sigma * sqrt(T))
d2 <- d1 - sigma * sqrt(T)
if (type == "call") {
option_price <- S * pnorm(d1) - K * exp(-r_new * T) * pnorm(d2)
} else {
option_price <- K * exp(-r_new * T) * pnorm(-d2) - S * pnorm(-d1)
}
return(option_price)
}
# Establecer parámetros
S <- s_txn # Precio actual de TXN
K <- 175 # Precio Strike
r <- 0.0112584 # Tasa libre de riesgo inicial
sigma <- v_hist #Volatilidad Histórica
# Definir un rango de puntos de tiempo (por ejemplo, de 0 a 1 con incrementos de 0,1)
T <- seq(0, 1, 0.1)
# Calcule los precios de las opciones en diferentes momentos con la tasa de interés inicial
option_prices_initial_rate <- sapply(T, function(t) black_scholes_with_rate_change(S, K, t, r, r, sigma))
# Nueva tasa de interés (caída de 25 puntos básicos)
r_new <- r - 0.0025 # Ajuste por ca?da de 25 puntos b?sicos
# Calcular los precios de las opciones en diferentes momentos con la nueva tasa de interés
option_prices_new_rate <- sapply(T, function(t) black_scholes_with_rate_change(S, K, t, r, r_new, sigma))
# Crear un nuevo data frames para trazar
df_initial_rate <- data.frame(Time = T, OptionPrice = option_prices_initial_rate, RateType = "Initial Rate")
df_new_rate <- data.frame(Time = T, OptionPrice = option_prices_new_rate, RateType = "New Rate")
# Combinar los data frames
df_combined <- rbind(df_initial_rate, df_new_rate)
ggplot(df_combined, aes(x = Time, y = OptionPrice, color = RateType)) +
geom_line() +
labs(title = "Evolución del precio de la opción TXN a lo largo del tiempo con cambio de tasa de interés.",
x = "Tiempo hasta el vencimiento (años)",
y = "Precio de la opción") +
theme_minimal() +
scale_color_manual(values = c("blue", "red"))
underlying_price <- s_ftnt # Precio actual de la accion
strike_price <- 64 # Precio strike
time_to_expiry <- 0.25 # Tiempo vencimiento en años (son 90 dias)
risk_free_rate <- 0.0112584 # Tasa libre de riesgo
dividend_yield <- 0 # Dividendos de la accion - NO PAGA DIVIDENDOS A SUS ACCIONISTAS
volatility <- v_hist # Volatilidad Histórica
# Calculamos el precio de la opción de compra de Black-Scholes para FTNT
ftnt_bs_call_price <- bs_option_price_quantmod(type = "call",
underlying = underlying_price,
strike = strike_price,
expire = time_to_expiry,
rate = risk_free_rate,
volatility = v_hist,
div = dividend_yield)
# Imprimimos el resultado
print(paste("FTNT Precio de opción de compra (con quantmod):", ftnt_bs_call_price))
## [1] "FTNT Precio de opción de compra (con quantmod): 3.53325272180764"
black_scholes_with_rate_change <- function(S, K, T, r, r_new, sigma, type = "call") {
d1 <- (log(S / K) + ((r_new + (sigma^2) / 2) * T)) / (sigma * sqrt(T))
d2 <- d1 - sigma * sqrt(T)
if (type == "call") {
option_price <- S * pnorm(d1) - K * exp(-r_new * T) * pnorm(d2)
} else {
option_price <- K * exp(-r_new * T) * pnorm(-d2) - S * pnorm(-d1)
}
return(option_price)
}
# Establecer parámetros
S <- s_ftnt # Precio actual de FTNT
K <- 64 # Precio Strike
r <- 0.0112584 # Tasa libre de riesgo inicial
sigma <- v_hist #Volatilidad Histórica
# Definir un rango de puntos de tiempo (por ejemplo, de 0 a 1 con incrementos de 0,1)
T <- seq(0, 1, 0.1)
# Calcule los precios de las opciones en diferentes momentos con la tasa de inter?s inicial
option_prices_initial_rate <- sapply(T, function(t) black_scholes_with_rate_change(S, K, t, r, r, sigma))
# Nueva tasa de interés (caída de 25 puntos básicos)
r_new <- r - 0.0025 # Ajuste por caída de 25 puntos básicos
# Calcular los precios de las opciones en diferentes momentos con la nueva tasa de interés
option_prices_new_rate <- sapply(T, function(t) black_scholes_with_rate_change(S, K, t, r, r_new, sigma))
# Crear un nuevo data frames para trazar
df_initial_rate <- data.frame(Time = T, OptionPrice = option_prices_initial_rate, RateType = "Initial Rate")
df_new_rate <- data.frame(Time = T, OptionPrice = option_prices_new_rate, RateType = "New Rate")
# Combinar los data frames
df_combined <- rbind(df_initial_rate, df_new_rate)
ggplot(df_combined, aes(x = Time, y = OptionPrice, color = RateType)) +
geom_line() +
labs(title = "Evolución del precio de la opción FTNT a lo largo del tiempo con cambio de tasa de interés.",
x = "Tiempo hasta el vencimiento (a?os)",
y = "Precio de la opci?n") +
theme_minimal() +
scale_color_manual(values = c("blue", "red"))
underlying_price <- s_dltr # Precio actual de la accion
strike_price <- 120 # Precio strike
time_to_expiry <- 0.25 # Tiempo vencimiento en a?os (son 90 dias)
risk_free_rate <- 0.0112584 # Tasa libre de riesgo
dividend_yield <- 0 # Dividendos de la accion - NO PAGA DIVIDENDOS A SUS ACCIONISTAS
volatility <- v_hist # Volatilidad Histórica
# Calculamos el precio de la opción de compra de Black-Scholes para DLTR
dltr_bs_call_price <- bs_option_price_quantmod(type = "call",
underlying = underlying_price,
strike = strike_price,
expire = time_to_expiry,
rate = risk_free_rate,
volatility = v_hist,
div = dividend_yield)
# Imprimimos el resultado
print(paste("DLTR Precio de opción de compra:", dltr_bs_call_price))
## [1] "DLTR Precio de opción de compra: 8.51452389650376"
# Función para calcular el precio de la opción Black-Scholes con tasa de interés variable
black_scholes_with_rate_change <- function(S, K, T, r, r_new, sigma, type = "call") {
d1 <- (log(S / K) + ((r_new + (sigma^2) / 2) * T)) / (sigma * sqrt(T))
d2 <- d1 - sigma * sqrt(T)
if (type == "call") {
option_price <- S * pnorm(d1) - K * exp(-r_new * T) * pnorm(d2)
} else {
option_price <- K * exp(-r_new * T) * pnorm(-d2) - S * pnorm(-d1)
}
return(option_price)
}
# Establecer parámetros
S <- s_dltr # Precio actual de DLTR
K <- 120 # Precio Strike
r <- 0.0112584 # Tasa libre de riesgo inicial
sigma <- v_hist #Volatilidad Histórica
# Definir un rango de puntos de tiempo (por ejemplo, de 0 a 1 con incrementos de 0,1)
T <- seq(0, 1, 0.1)
# Calcule los precios de las opciones en diferentes momentos con la tasa de inter?s inicial
option_prices_initial_rate <- sapply(T, function(t) black_scholes_with_rate_change(S, K, t, r, r, sigma))
# Nueva tasa de interés (caída de 25 puntos básicos)
r_new <- r - 0.0025 # Ajuste por caída de 25 puntos básicos
# Calcular los precios de las opciones en diferentes momentos con la nueva tasa de inter?s
option_prices_new_rate <- sapply(T, function(t) black_scholes_with_rate_change(S, K, t, r, r_new, sigma))
# Crear un nuevo data frames para trazar
df_initial_rate <- data.frame(Time = T, OptionPrice = option_prices_initial_rate, RateType = "Initial Rate")
df_new_rate <- data.frame(Time = T, OptionPrice = option_prices_new_rate, RateType = "New Rate")
# Combinar los data frames
df_combined <- rbind(df_initial_rate, df_new_rate)
ggplot(df_combined, aes(x = Time, y = OptionPrice, color = RateType)) +
geom_line() +
labs(title = "Evolución del precio de la opción DLTR a lo largo del tiempo con cambio de tasa de interés.",
x = "Tiempo hasta el vencimiento (años)",
y = "Precio de la opción") +
theme_minimal() +
scale_color_manual(values = c("blue", "red"))
crr_option_price <- function(S0, X, T, r, sigma, n, type = "call") {
delta_t <- T / n
u <- exp(sigma * sqrt(delta_t))
d <- 1 / u
p <- (exp(r * delta_t) - d) / (u - d)
# Generar precios de acciones al vencimiento
ST <- S0 * u^(n:0) * d^(0:n)
# Calcular los pagos de las opciones al vencimiento
payoff <- pmax(ST - X, 0) # Para una opcion call
# Inducción hacia atrás para calcular el precio de la opción en t=0
for (i in (n - 1):0) {
payoff <- exp(-r * delta_t) * (p * payoff[2:(i + 2)] + (1 - p) * payoff[1:(i + 1)])
}
return(payoff[1])
}
underlying_price_txn <- s_txn
strike_price_txn <- 175
time_to_expiry_txn <- 0.25
risk_free_rate_txn <- 0.0112584
dividend_yield_txn <- 0.0293/0.25
volatility_txn <- v_hist
n_txn <- 3 # Numero de periodos
# Calcular el precio de la opción de compra de TXN utilizando un modelo similar al CRR
txn_crr_price <- crr_option_price(underlying_price_txn,
strike_price_txn, time_to_expiry_txn,
risk_free_rate_txn, volatility_txn, n_txn)
# Imprimir el resultado
print(txn_crr_price)
## [1] 6.364303
s <- s_txn # Precio actual de las acciones
k <- 175 # Precio Strike
tt <- 0.25 # Tiempo de vencimiento (Años)
r <- 0.0112584 # Tasa de riesgo
d <- 0.0293/0.25 # Tasa yield
v <- v_hist # Volatilidad
nstep <- 3 # Número de pasos en el árbol binomial
# Calcular el precio de la opción y la información asociada.
result <- binomopt(s, k, v, r, tt, d, nstep, american = FALSE, putopt = FALSE, returntrees = TRUE, returnparams = TRUE)
# Calcular el precio de la opción de compra Europea
europea_call_option_price <- binomopt(s, k, v, r, tt, d, nstep, american = FALSE, putopt = FALSE, returntrees = TRUE, returnparams = TRUE)[[1]]
# Acceder a los parámetros devueltos
oppricretree <- result$oppricretree
delta <- result$delta
bond <- result$bond
# Imprima o use estos parámetros según sea necesario (tiempo de retorno 0 delta, gamma y theta en los vectores griegos)
print(oppricretree)
## NULL
print(delta)
## [,1] [,2] [,3]
## [1,] 0.2689476 0.516139606 0.99028087
## [2,] 0.0000000 0.008759696 0.01707627
## [3,] 0.0000000 0.000000000 0.00000000
# Imprimir precios de opciones
cat("Precio opcion Call Europea", europea_call_option_price, "\n")
## Precio opcion Call Europea 3.228092
binomplot(s, k, v, r, tt, d, nstep, putopt = FALSE, american = FALSE,
plotvalues= TRUE, plotarrows= TRUE, drawstrike= TRUE, pointsize= 3, ylimval=c(0,0),
saveplot= FALSE, saveplotfn='TXN CRR Plots.png',
crr= TRUE, jarrowrudd= FALSE, titles = TRUE, specifyupdn = FALSE,
returnprice = TRUE, logy = FALSE)
## [1] 4.02971
# Creando un modelo de árbol binomial opcion PUT CRR para TXN
s <- s_txn # Precio actual de las acciones
k <- 177.5 # Precio Strike
tt <- 0.25 # Tiempo de vencimiento (Años)
r <- 0.0112584 # Tasa libre de riesgo
d <- 0.0293/0.25 # Tasa yield
v <- v_hist # Volatilidad
nstep <- 3 # Número de pasos en el árbol binomial
# Calcular el precio de la opción y la información asociada.
result <- binomopt(s, k, v, r, tt, d, nstep, american = FALSE,
putopt = FALSE, returntrees = TRUE,
returnparams = TRUE)
# Calcular el precio de la opción de venta Europea
europea_put_option_price <- binomopt(s, k, v, r, tt, d, nstep,
american = FALSE, putopt = TRUE,
returntrees = TRUE, returnparams = TRUE)[[1]]
# Accediendo a los parámetros devueltos
oppricretree <- result$oppricretree
delta <- result$delta
bond <- result$bond
# Parámetros según sea necesario
print(oppricretree)
## NULL
print(delta)
## [,1] [,2] [,3]
## [1,] 0.2405208 0.4688745 0.9140306
## [2,] 0.0000000 0.0000000 0.0000000
## [3,] 0.0000000 0.0000000 0.0000000
print(bond)
## [,1] [,2] [,3]
## [1,] -37.50609 -77.88801 -161.7482
## [2,] 0.00000 0.00000 0.0000
## [3,] 0.00000 0.00000 0.0000
# Imprimir precios de opciones
cat("Precio opcion PUT Europea:", europea_put_option_price, "\n")
## Precio opcion PUT Europea: 17.05304
binomplot(s, k, v, r, tt, d, nstep, putopt = TRUE, american = FALSE,
plotvalues= TRUE, plotarrows= TRUE, drawstrike= TRUE, pointsize= 3, ylimval=c(0,0),
saveplot= FALSE, saveplotfn='TXN CRR Plots.png',
crr= TRUE, jarrowrudd= FALSE, titles = TRUE, specifyupdn = FALSE,
returnprice = TRUE, logy = FALSE)
## [1] 17.32622
crr_option_price <- function(S0, X, T, r, sigma, n, type = "call") {
delta_t <- T / n
u <- exp(sigma * sqrt(delta_t))
d <- 1 / u
p <- (exp(r * delta_t) - d) / (u - d)
# Generar precios de acciones al vencimiento
ST <- S0 * u^(n:0) * d^(0:n)
# Calcular los pagos de las opciones al vencimiento
payoff <- pmax(ST - X, 0) # Para una opcion call
# Inducción hacia atrás para calcular el precio de la opción en t=0
for (i in (n - 1):0) {
payoff <- exp(-r * delta_t) * (p * payoff[2:(i + 2)] + (1 - p) * payoff[1:(i + 1)])
}
return(payoff[1])
}
underlying_price_ftnt <- s_ftnt
strike_price_ftnt <- 64
time_to_expiry_ftnt <- 0.25
risk_free_rate_ftnt <- 0.0112584
dividend_yield_ftnt <- 0
volatility_ftnt <- v_hist
n_ftnt <- 3 # Numero de periodos
# Calcular el precio de la opción de compra de FTNT utilizando un modelo similar al CRR
ftnt_crr_price <- crr_option_price(underlying_price_txn,
strike_price_ftnt, time_to_expiry_ftnt,
risk_free_rate_ftnt, volatility_ftnt, n_ftnt)
# Imprimir el resultado
print(ftnt_crr_price)
## [1] 105.4424
s <- s_ftnt # Precio actual de las acciones
k <- 64 # Precio Strike
tt <- 0.25 # Tiempo de vencimiento (Años)
r <- 0.0112584 # Tasa de riesgo
d <- 0 # Tasa yield
v <- v_hist # Volatilidad
nstep <- 3 # Número de pasos en el árbol binomial
# Calcular el precio de la opción y la información asociada.
result <- binomopt(s, k, v, r, tt, d, nstep, american = FALSE, putopt = FALSE, returntrees = TRUE, returnparams = TRUE)
# Calcular el precio de la opción de compra Europea
europea_call_option_price <- binomopt(s, k, v, r, tt, d, nstep, american = FALSE, putopt = FALSE, returntrees = TRUE, returnparams = TRUE)[[1]]
# Acceder a los parámetros devueltos
oppricretree <- result$oppricretree
delta <- result$delta
bond <- result$bond
# Imprima o use estos par?metros según sea necesario (tiempo de retorno 0 delta, gamma y theta en los vectores griegos)
print(oppricretree)
## NULL
print(delta)
## [,1] [,2] [,3]
## [1,] 0.5624264 0.8018775 1.0000000
## [2,] 0.0000000 0.3050813 0.5889496
## [3,] 0.0000000 0.0000000 0.0000000
# Imprimir precios de opciones
cat("Precio opcion Call Europea", europea_call_option_price, "\n")
## Precio opcion Call Europea 3.794328
binomplot(s, k, v, r, tt, d, nstep, putopt = FALSE, american = FALSE,
plotvalues= TRUE, plotarrows= TRUE, drawstrike= TRUE, pointsize= 3, ylimval=c(0,0),
saveplot= FALSE, saveplotfn='FTNT CRR Plots.png',
crr= TRUE, jarrowrudd= FALSE, titles = TRUE, specifyupdn = FALSE,
returnprice = TRUE, logy = FALSE)
## [1] 3.799584
s <- s_ftnt # Precio actual de las acciones
k <- 65 # Precio Strike
tt <- 0.25 # Tiempo de vencimiento (Años)
r <- 0.0112584 # Tasa libre de riesgo
d <- 0 # Tasa yield
v <- v_hist # Volatilidad
nstep <- 3 # Número de pasos en el ?rbol binomial
# Calcular el precio de la opción y la información asociada.
result <- binomopt(s, k, v, r, tt, d, nstep, american = FALSE,
putopt = FALSE, returntrees = TRUE,
returnparams = TRUE)
# Calcular el precio de la opción de venta Europea
europea_put_option_price <- binomopt(s, k, v, r, tt, d, nstep,
american = FALSE, putopt = TRUE,
returntrees = TRUE, returnparams = TRUE)[[1]]
# Accediendo a los parámetros devueltos
oppricretree <- result$oppricretree
delta <- result$delta
bond <- result$bond
# Par?metros según sea necesario
print(oppricretree)
## NULL
print(delta)
## [,1] [,2] [,3]
## [1,] 0.5088949 0.7502071 1.0000000
## [2,] 0.0000000 0.2495497 0.4817476
## [3,] 0.0000000 0.0000000 0.0000000
print(bond)
## [,1] [,2] [,3]
## [1,] -29.49088 -46.25684 -64.93905
## [2,] 0.00000 -13.94415 -28.95747
## [3,] 0.00000 0.00000 0.00000
# Imprimir precios de opciones
cat("Precio opcion PUT Europea:", europea_put_option_price, "\n")
## Precio opcion PUT Europea: 3.659965
binomplot(s, k, v, r, tt, d, nstep, putopt = TRUE, american = FALSE,
plotvalues= TRUE, plotarrows= TRUE, drawstrike= TRUE, pointsize= 3, ylimval=c(0,0),
saveplot= FALSE, saveplotfn='FTNT CRR Plots.png',
crr= TRUE, jarrowrudd= FALSE, titles = TRUE, specifyupdn = FALSE,
returnprice = TRUE, logy = FALSE)
## [1] 3.655497
crr_option_price <- function(S0, X, T, r, sigma, n, type = "call") {
delta_t <- T / n
u <- exp(sigma * sqrt(delta_t))
d <- 1 / u
p <- (exp(r * delta_t) - d) / (u - d)
# Generar precios de acciones al vencimiento
ST <- S0 * u^(n:0) * d^(0:n)
# Calcular los pagos de las opciones al vencimiento
payoff <- pmax(ST - X, 0) # Para una opcion call
# Inducción hacia atrás para calcular el precio de la opción en t=0
for (i in (n - 1):0) {
payoff <- exp(-r * delta_t) * (p * payoff[2:(i + 2)] + (1 - p) * payoff[1:(i + 1)])
}
return(payoff[1])
}
underlying_price_dltr <- s_dltr
strike_price_dltr <- 120
time_to_expiry_dltr <- 0.25
risk_free_rate_dltr <- 0.0112584
dividend_yield_dltr <- 0
volatility_dltr <- v_hist
n_dltr <- 3 # Numero de periodos
# Calcular el precio de la opción de compra de FTNT utilizando un modelo similar al CRR
dltr_crr_price <- crr_option_price(underlying_price_dltr,
strike_price_dltr, time_to_expiry_dltr,
risk_free_rate_dltr, volatility_dltr, n_dltr)
# Imprimir el resultado
print(dltr_crr_price)
## [1] 9.634682
s <- s_dltr # Precio actual de las acciones
k <- 120 # Precio Strike
tt <- 0.25 # Tiempo de vencimiento (Años)
r <- 0.0112584 # Tasa de riesgo
d <- 0 # Tasa yield
v <- v_hist # Volatilidad
nstep <- 3 # Número de pasos en el ?rbol binomial
# Calcular el precio de la opción y la información asociada.
result <- binomopt(s, k, v, r, tt, d, nstep, american = FALSE, putopt = FALSE, returntrees = TRUE, returnparams = TRUE)
# Calcular el precio de la opción de compra Europea
europea_call_option_price <- binomopt(s, k, v, r, tt, d, nstep, american = FALSE, putopt = FALSE, returntrees = TRUE, returnparams = TRUE)[[1]]
# Acceder a los parámetros devueltos
oppricretree <- result$oppricretree
delta <- result$delta
bond <- result$bond
# Imprima o use estos par?metros según sea necesario (tiempo de retorno 0 delta, gamma y theta en los vectores griegos)
print(oppricretree)
## NULL
print(delta)
## [,1] [,2] [,3]
## [1,] 0.649692 0.8861093 1.0000000
## [2,] 0.000000 0.3956076 0.7637076
## [3,] 0.000000 0.0000000 0.0000000
# Imprimir precios de opciones
cat("Precio opcion Call Europea", europea_call_option_price, "\n")
## Precio opcion Call Europea 8.779688
binomplot(s, k, v, r, tt, d, nstep, putopt = FALSE, american = FALSE,
plotvalues= TRUE, plotarrows= TRUE, drawstrike= TRUE, pointsize= 3, ylimval=c(0,0),
saveplot= FALSE, saveplotfn='DLTR CRR Plots.png',
crr= TRUE, jarrowrudd= FALSE, titles = TRUE, specifyupdn = FALSE,
returnprice = TRUE, logy = FALSE)
## [1] 8.820299
# Creando un modelo de árbol binomial opcion PUT CRR para DLTR
s <- s_dltr # Precio actual de las acciones
k <- 122 # Precio Strike
tt <- 0.25 # Tiempo de vencimiento (Años)
r <- 0.0112584 # Tasa libre de riesgo
d <- 0 # Tasa yield
v <- v_hist # Volatilidad
nstep <- 3 # Número de pasos en el árbol binomial
# Calcular el precio de la opción y la información asociada.
result <- binomopt(s, k, v, r, tt, d, nstep, american = FALSE,
putopt = FALSE, returntrees = TRUE,
returnparams = TRUE)
# Calcular el precio de la opción de venta Europea
europea_put_option_price <- binomopt(s, k, v, r, tt, d, nstep,
american = FALSE, putopt = TRUE,
returntrees = TRUE, returnparams = TRUE)[[1]]
# Accediendo a los parámetros devueltos
oppricretree <- result$oppricretree
delta <- result$delta
bond <- result$bond
# Parámetros según sea necesario
print(oppricretree)
## NULL
print(delta)
## [,1] [,2] [,3]
## [1,] 0.5940462 0.8323980 1.0000000
## [2,] 0.0000000 0.3378826 0.6522714
## [3,] 0.0000000 0.0000000 0.0000000
print(bond)
## [,1] [,2] [,3]
## [1,] -65.86102 -97.73232 -121.88559
## [2,] 0.00000 -36.32515 -75.43557
## [3,] 0.00000 0.00000 0.00000
# Imprimir precios de opciones
cat("Precio opcion PUT Europea:", europea_put_option_price, "\n")
## Precio opcion PUT Europea: 5.433456
binomplot(s, k, v, r, tt, d, nstep, putopt = TRUE, american = FALSE,
plotvalues= TRUE, plotarrows= TRUE, drawstrike= TRUE, pointsize= 3, ylimval=c(0,0),
saveplot= FALSE, saveplotfn='DLTR CRR Plots.png',
crr= TRUE, jarrowrudd= FALSE, titles = TRUE, specifyupdn = FALSE,
returnprice = TRUE, logy = FALSE)
## [1] 5.454619
crr_option_price <- function(S0, X, T, r, sigma, n, type = "call") {
delta_t <- T / n
u <- exp(sigma * sqrt(delta_t))
d <- 1 / u
p <- (exp(r * delta_t) - d) / (u - d)
# Generar precios de acciones al vencimiento
ST <- S0 * u^(n:0) * d^(0:n)
# Calcular los pagos de las opciones al vencimiento
payoff <- pmax(ST - X, 0) # Para una opcion call
# Inducción hacia atrás para calcular el precio de la opción en t=0
for (i in (n - 1):0) {
payoff <- exp(-r * delta_t) * (p * payoff[2:(i + 2)] + (1 - p) * payoff[1:(i + 1)])
}
return(payoff[1])
}
underlying_price_txn <- s_txn
strike_price_txn <- 175
time_to_expiry_txn <- 0.25
risk_free_rate_txn <- 0.0112584
dividend_yield_txn <- 0.0293/0.25
volatility_txn <- 0.2697/0.25
n_txn <- 3 # Numero de periodos
# Calcular el precio de la opción de compra de TXN utilizando un modelo similar al CRR
txn_crr_price <- crr_option_price(underlying_price_txn,
strike_price_txn, time_to_expiry_txn,
risk_free_rate_txn, volatility_txn, n_txn)
# Imprimir el resultado
print(txn_crr_price)
## [1] 70.52277
s <- s_txn # Precio actual de las acciones
k <- 175 # Precio Strike
tt <- 0.25 # Tiempo de vencimiento (Años)
r <- 0.0112584 # Tasa de riesgo
d <- 0.0293/0.25 # Tasa yield
v <- 0.2697/0.25 # Volatilidad implicita
nstep <- 3 # Número de pasos en el árbol binomial
# Calcular el precio de la opción y la información asociada.
result <- binomopt(s, k, v, r, tt, d, nstep, american = FALSE, putopt = FALSE, returntrees = TRUE, returnparams = TRUE)
# Calcular el precio de la opción de compra Europea
europea_call_option_price <- binomopt(s, k, v, r, tt, d, nstep, american = FALSE, putopt = FALSE, returntrees = TRUE, returnparams = TRUE)[[1]]
# Acceder a los parámetros devueltos
oppricretree <- result$oppricretree
delta <- result$delta
bond <- result$bond
# Imprima o use estos parámetros según sea necesario (tiempo de retorno 0 delta, gamma y theta en los vectores griegos)
print(oppricretree)
## NULL
print(delta)
## [,1] [,2] [,3]
## [1,] 0.5430756 0.7580634 0.9902809
## [2,] 0.0000000 0.2621459 0.4585999
## [3,] 0.0000000 0.0000000 0.0000000
# Imprimir precios de opciones
cat("Precio opcion Call Europea", europea_call_option_price, "\n")
## Precio opcion Call Europea 32.88165
binomplot(s, k, v, r, tt, d, nstep, putopt = FALSE, american = FALSE,
plotvalues= TRUE, plotarrows= TRUE, drawstrike= TRUE, pointsize= 3, ylimval=c(0,0),
saveplot= FALSE, saveplotfn='TXN CRR Plots.png',
crr= TRUE, jarrowrudd= FALSE, titles = TRUE, specifyupdn = FALSE,
returnprice = TRUE, logy = FALSE)
## [1] 33.06093
# Creando un modelo de árbol binomial opcion PUT CRR para TXN
s <- s_txn # Precio actual de las acciones
k <- 177.5 # Precio Strike
tt <- 0.25 # Tiempo de vencimiento (Años)
r <- 0.0112584 # Tasa libre de riesgo
d <- 0.0293/0.25 # Tasa yield
v <- 0.2621/0.25 # Volatilidad implicita
nstep <- 3 # Número de pasos en el árbol binomial
# Calcular el precio de la opción y la información asociada.
result <- binomopt(s, k, v, r, tt, d, nstep, american = FALSE,
putopt = FALSE, returntrees = TRUE,
returnparams = TRUE)
# Calcular el precio de la opción de venta Europea
europea_put_option_price <- binomopt(s, k, v, r, tt, d, nstep,
american = FALSE, putopt = TRUE,
returntrees = TRUE, returnparams = TRUE)[[1]]
# Accediendo a los parámetros devueltos
oppricretree <- result$oppricretree
delta <- result$delta
bond <- result$bond
# Parámetros según sea necesario
print(oppricretree)
## NULL
print(delta)
## [,1] [,2] [,3]
## [1,] 0.5265043 0.7442338 0.9902809
## [2,] 0.0000000 0.2439823 0.4284148
## [3,] 0.0000000 0.0000000 0.0000000
print(bond)
## [,1] [,2] [,3]
## [1,] -57.38198 -105.22592 -177.33355
## [2,] 0.00000 -22.12567 -52.12023
## [3,] 0.00000 0.00000 0.00000
# Imprimir precios de opciones
cat("Precio opcion PUT Europea:", europea_put_option_price, "\n")
## Precio opcion PUT Europea: 45.10513
binomplot(s, k, v, r, tt, d, nstep, putopt = TRUE, american = FALSE,
plotvalues= TRUE, plotarrows= TRUE, drawstrike= TRUE, pointsize= 3, ylimval=c(0,0),
saveplot= FALSE, saveplotfn='TXN CRR Plots.png',
crr= TRUE, jarrowrudd= FALSE, titles = TRUE, specifyupdn = FALSE,
returnprice = TRUE, logy = FALSE)
## [1] 45.34205
crr_option_price <- function(S0, X, T, r, sigma, n, type = "call") {
delta_t <- T / n
u <- exp(sigma * sqrt(delta_t))
d <- 1 / u
p <- (exp(r * delta_t) - d) / (u - d)
# Generar precios de acciones al vencimiento
ST <- S0 * u^(n:0) * d^(0:n)
# Calcular los pagos de las opciones al vencimiento
payoff <- pmax(ST - X, 0) # Para una opcion call
# Inducción hacia atrás para calcular el precio de la opción en t=0
for (i in (n - 1):0) {
payoff <- exp(-r * delta_t) * (p * payoff[2:(i + 2)] + (1 - p) * payoff[1:(i + 1)])
}
return(payoff[1])
}
underlying_price_ftnt <- s_ftnt
strike_price_ftnt <- 64
time_to_expiry_ftnt <- 0.25
risk_free_rate_ftnt <- 0.0112584
dividend_yield_ftnt <- 0
volatility_ftnt <- 0.9990/0.25
n_ftnt <- 3 # Numero de periodos
# Calcular el precio de la opción de compra de FTNT utilizando un modelo similar al CRR
ftnt_crr_price <- crr_option_price(underlying_price_txn,
strike_price_ftnt, time_to_expiry_ftnt,
risk_free_rate_ftnt, volatility_ftnt, n_ftnt)
# Imprimir el resultado
print(ftnt_crr_price)
## [1] 2499.833
s <- s_ftnt # Precio actual de las acciones
k <- 64 # Precio Strike
tt <- 0.25 # Tiempo de vencimiento (Años)
r <- 0.0112584 # Tasa de riesgo
d <- 0 # Tasa yield
v <- 0.9990/0.25 # Volatilidad implicita
nstep <- 3 # Número de pasos en el ?rbol binomial
# Calcular el precio de la opción y la información asociada.
result <- binomopt(s, k, v, r, tt, d, nstep, american = FALSE, putopt = FALSE, returntrees = TRUE, returnparams = TRUE)
# Calcular el precio de la opción de compra Europea
europea_call_option_price <- binomopt(s, k, v, r, tt, d, nstep, american = FALSE, putopt = FALSE, returntrees = TRUE, returnparams = TRUE)[[1]]
# Acceder a los parámetros devueltos
oppricretree <- result$oppricretree
delta <- result$delta
bond <- result$bond
# Imprima o use estos parámetros según sea necesario (tiempo de retorno 0 delta, gamma y theta en los vectores griegos)
print(oppricretree)
## NULL
print(delta)
## [,1] [,2] [,3]
## [1,] 0.8563284 0.9433359 1.0000000
## [2,] 0.0000000 0.5805661 0.7637439
## [3,] 0.0000000 0.0000000 0.0000000
# Imprimir precios de opciones
cat("Precio opcion Call Europea", europea_call_option_price, "\n")
## Precio opcion Call Europea 45.87916
binomplot(s, k, v, r, tt, d, nstep, putopt = FALSE, american = FALSE,
plotvalues= TRUE, plotarrows= TRUE, drawstrike= TRUE, pointsize= 3, ylimval=c(0,0),
saveplot= FALSE, saveplotfn='TXN CRR Plots.png',
crr= TRUE, jarrowrudd= FALSE, titles = TRUE, specifyupdn = FALSE,
returnprice = TRUE, logy = FALSE)
## [1] 45.87936
# Creando un modelo de ?rbol binomial opcion PUT CRR para FTNT
s <- s_ftnt # Precio actual de las acciones
k <- 65 # Precio Strike
tt <- 0.25 # Tiempo de vencimiento (A?os)
r <- 0.0112584 # Tasa libre de riesgo
d <- 0 # Tasa yield
v <- 1.0010/0.25 # Volatilidad implicita
nstep <- 3 # N?mero de pasos en el ?rbol binomial
# Calcular el precio de la opción y la información asociada.
result <- binomopt(s, k, v, r, tt, d, nstep, american = FALSE,
putopt = FALSE, returntrees = TRUE,
returnparams = TRUE)
# Calcular el precio de la opción de venta Europea
europea_put_option_price <- binomopt(s, k, v, r, tt, d, nstep,
american = FALSE, putopt = TRUE,
returntrees = TRUE, returnparams = TRUE)[[1]]
# Accediendo a los par?metros devueltos
oppricretree <- result$oppricretree
delta <- result$delta
bond <- result$bond
# Parámetros según sea necesario
print(oppricretree)
## NULL
print(delta)
## [,1] [,2] [,3]
## [1,] 0.8548152 0.9422399 1.0000000
## [2,] 0.0000000 0.5770899 0.7587509
## [3,] 0.0000000 0.0000000 0.0000000
print(bond)
## [,1] [,2] [,3]
## [1,] -9.324416 -27.257708 -64.93905
## [2,] 0.000000 -3.690735 -15.42971
## [3,] 0.000000 0.000000 0.00000
# Imprimir precios de opciones
cat("Precio opcion PUT Europea:", europea_put_option_price, "\n")
## Precio opcion PUT Europea: 46.13138
binomplot(s, k, v, r, tt, d, nstep, putopt = TRUE, american = FALSE,
plotvalues= TRUE, plotarrows= TRUE, drawstrike= TRUE, pointsize= 3, ylimval=c(0,0),
saveplot= FALSE, saveplotfn='FTNT CRR Plots.png',
crr= TRUE, jarrowrudd= FALSE, titles = TRUE, specifyupdn = FALSE,
returnprice = TRUE, logy = FALSE)
## [1] 46.13121
crr_option_price <- function(S0, X, T, r, sigma, n, type = "call") {
delta_t <- T / n
u <- exp(sigma * sqrt(delta_t))
d <- 1 / u
p <- (exp(r * delta_t) - d) / (u - d)
# Generar precios de acciones al vencimiento
ST <- S0 * u^(n:0) * d^(0:n)
# Calcular los pagos de las opciones al vencimiento
payoff <- pmax(ST - X, 0) # Para una opcion call
# Inducción hacia atrás para calcular el precio de la opción en t=0
for (i in (n - 1):0) {
payoff <- exp(-r * delta_t) * (p * payoff[2:(i + 2)] + (1 - p) * payoff[1:(i + 1)])
}
return(payoff[1])
}
underlying_price_dltr <- s_dltr
strike_price_dltr <- 120
time_to_expiry_dltr <- 0.25
risk_free_rate_dltr <- 0.0112584
dividend_yield_dltr <- 0
volatility_dltr <- 0.2788/0.25
n_dltr <- 3 # Numero de periodos
# Calcular el precio de la opci?n de compra de FTNT utilizando un modelo similar al CRR
dltr_crr_price <- crr_option_price(underlying_price_dltr,
strike_price_dltr, time_to_expiry_dltr,
risk_free_rate_dltr, volatility_dltr, n_dltr)
# Imprimir el resultado
print(dltr_crr_price)
## [1] 61.31284
s <- s_dltr # Precio actual de las acciones
k <- 120 # Precio Strike
tt <- 0.25 # Tiempo de vencimiento (A?os)
r <- 0.0112584 # Tasa de riesgo
d <- 0 # Tasa yield
v <- 0.2788/0.25 # Volatilidad implicita
nstep <- 3 # N?mero de pasos en el ?rbol binomial
# Calcular el precio de la opción y la información asociada.
result <- binomopt(s, k, v, r, tt, d, nstep, american = FALSE, putopt = FALSE, returntrees = TRUE, returnparams = TRUE)
# Calcular el precio de la opci?n de compra Europea
europea_call_option_price <- binomopt(s, k, v, r, tt, d, nstep, american = FALSE, putopt = FALSE, returntrees = TRUE, returnparams = TRUE)[[1]]
# Acceder a los par?metros devueltos
oppricretree <- result$oppricretree
delta <- result$delta
bond <- result$bond
# Imprima o use estos parámetros según sea necesario (tiempo de retorno 0 delta, gamma y theta en los vectores griegos)
print(oppricretree)
## NULL
print(delta)
## [,1] [,2] [,3]
## [1,] 0.6450422 0.8461651 1.0000000
## [2,] 0.0000000 0.3675350 0.6339054
## [3,] 0.0000000 0.0000000 0.0000000
# Imprimir precios de opciones
cat("Precio opcion Call Europea", europea_call_option_price, "\n")
## Precio opcion Call Europea 31.12264
binomplot(s, k, v, r, tt, d, nstep, putopt = FALSE, american = FALSE,
plotvalues= TRUE, plotarrows= TRUE, drawstrike= TRUE, pointsize= 3, ylimval=c(0,0),
saveplot= FALSE, saveplotfn='DLTR CRR Plots.png',
crr= TRUE, jarrowrudd= FALSE, titles = TRUE, specifyupdn = FALSE,
returnprice = TRUE, logy = FALSE)
## [1] 31.13137
# Creando un modelo de ?rbol binomial opcion PUT CRR para DLTR
s <- s_dltr # Precio actual de las acciones
k <- 122 # Precio Strike
tt <- 0.25 # Tiempo de vencimiento (A?os)
r <- 0.0112584 # Tasa libre de riesgo
d <- 0 # Tasa yield
v <- 0.2578/0.25 # Volatilidad implicita
nstep <- 3 # N?mero de pasos en el ?rbol binomial
# Calcular el precio de la opción y la información asociada.
result <- binomopt(s, k, v, r, tt, d, nstep, american = FALSE,
putopt = FALSE, returntrees = TRUE,
returnparams = TRUE)
# Calcular el precio de la opci?n de venta Europea
europea_put_option_price <- binomopt(s, k, v, r, tt, d, nstep,
american = FALSE, putopt = TRUE,
returntrees = TRUE, returnparams = TRUE)[[1]]
# Accediendo a los parámetros devueltos
oppricretree <- result$oppricretree
delta <- result$delta
bond <- result$bond
# Parámetros según sea necesario
print(oppricretree)
## NULL
print(delta)
## [,1] [,2] [,3]
## [1,] 0.6256859 0.8320784 1.0000000
## [2,] 0.0000000 0.3477302 0.6059329
## [3,] 0.0000000 0.0000000 0.0000000
print(bond)
## [,1] [,2] [,3]
## [1,] -49.39049 -83.95240 -121.8856
## [2,] 0.00000 -23.80776 -55.9229
## [3,] 0.00000 0.00000 0.0000
# Imprimir precios de opciones
cat("Precio opcion PUT Europea:", europea_put_option_price, "\n")
## Precio opcion PUT Europea: 25.8292
binomplot(s, k, v, r, tt, d, nstep, putopt = TRUE, american = FALSE,
plotvalues= TRUE, plotarrows= TRUE, drawstrike= TRUE, pointsize= 3, ylimval=c(0,0),
saveplot= FALSE, saveplotfn='DLTR CRR Plots.png',
crr= TRUE, jarrowrudd= FALSE, titles = TRUE, specifyupdn = FALSE,
returnprice = TRUE, logy = FALSE)
## [1] 25.83415
Se evidencia que la valuación con volatilidad implícita para CALL y PUT es mucho mayor que la valuación con volatilidad histórica de la serie.
crr_option_price <- function(S0, X, T, r, sigma, n, type = "call") {
delta_t <- T / n
u <- exp(sigma * sqrt(delta_t))
d <- 1 / u
p <- (exp(r * delta_t) - d) / (u - d)
# Generar precios de acciones al vencimiento
ST <- S0 * u^(n:0) * d^(0:n)
# Calcular los pagos de las opciones al vencimiento
payoff <- pmax(ST - X, 0) # Para una opcion call
# Inducción hacia atrás para calcular el precio de la opción en t=0
for (i in (n - 1):0) {
payoff <- exp(-r * delta_t) * (p * payoff[2:(i + 2)] + (1 - p) * payoff[1:(i + 1)])
}
return(payoff[1])
}
underlying_price_txn <- s_txn
strike_price_txn <- 150
time_to_expiry_txn <- 0.25
risk_free_rate_txn <- 0.0112584
dividend_yield_txn <- 0.0293/0.25
volatility_txn <- 1.0210/0.25
n_txn <- 3 # Numero de periodos
# Calcular el precio de la opci?n de compra de TXN utilizando un modelo similar al CRR
txn_crr_price <- crr_option_price(underlying_price_txn,
strike_price_txn, time_to_expiry_txn,
risk_free_rate_txn, volatility_txn, n_txn)
# Imprimir el resultado
print(txn_crr_price)
## [1] 2660.783
s <- s_txn # Precio actual de las acciones
k <- 150 # Precio Strike
tt <- 0.25 # Tiempo de vencimiento (A?os)
r <- 0.0112584 # Tasa de riesgo
d <- 0.0293/0.25 # Tasa yield
v <- 1.0210/0.25 # Volatilidad implicita
nstep <- 3 # N?mero de pasos en el ?rbol binomial
# Calcular el precio de la opci?n y la informaci?n asociada.
result <- binomopt(s, k, v, r, tt, d, nstep, american = FALSE, putopt = FALSE, returntrees = TRUE, returnparams = TRUE)
# Calcular el precio de la opci?n de compra Europea
europea_call_option_price <- binomopt(s, k, v, r, tt, d, nstep, american = FALSE, putopt = FALSE, returntrees = TRUE, returnparams = TRUE)[[1]]
# Acceder a los par?metros devueltos
oppricretree <- result$oppricretree
delta <- result$delta
bond <- result$bond
# Imprima o use estos par?metros seg?n sea necesario (tiempo de retorno 0 delta, gamma y theta en los vectores griegos)
print(oppricretree)
## NULL
print(delta)
## [,1] [,2] [,3]
## [1,] 0.8447957 0.9327318 0.9902809
## [2,] 0.0000000 0.5941652 0.7845567
## [3,] 0.0000000 0.0000000 0.0000000
# Imprimir precios de opciones
cat("Precio opcion Call Europea", europea_call_option_price, "\n")
## Precio opcion Call Europea 119.0312
binomplot(s, k, v, r, tt, d, nstep, putopt = FALSE, american = FALSE,
plotvalues= TRUE, plotarrows= TRUE, drawstrike= TRUE, pointsize= 3, ylimval=c(0,0),
saveplot= FALSE, saveplotfn='TXN CRR Plots.png',
crr= TRUE, jarrowrudd= FALSE, titles = TRUE, specifyupdn = FALSE,
returnprice = TRUE, logy = FALSE)
## [1] 118.9796
# Creando un modelo de ?rbol binomial opcion PUT CRR para TXN
s <- s_txn # Precio actual de las acciones
k <- 115 # Precio Strike
tt <- 0.25 # Tiempo de vencimiento (A?os)
r <- 0.0112584 # Tasa libre de riesgo
d <- 0.0293/0.25 # Tasa yield
v <- 1.3164/0.25 # Volatilidad implicita
nstep <- 3 # N?mero de pasos en el ?rbol binomial
# Calcular el precio de la opci?n y la informaci?n asociada.
result <- binomopt(s, k, v, r, tt, d, nstep, american = FALSE,
putopt = FALSE, returntrees = TRUE,
returnparams = TRUE)
# Calcular el precio de la opci?n de venta Europea
europea_put_option_price <- binomopt(s, k, v, r, tt, d, nstep,
american = FALSE, putopt = TRUE,
returntrees = TRUE, returnparams = TRUE)[[1]]
# Accediendo a los par?metros devueltos
oppricretree <- result$oppricretree
delta <- result$delta
bond <- result$bond
# Par?metros seg?n sea necesario
print(oppricretree)
## NULL
print(delta)
## [,1] [,2] [,3]
## [1,] 0.9079313 0.9610150 0.9902809
## [2,] 0.0000000 0.7148648 0.8797572
## [3,] 0.0000000 0.0000000 0.0000000
print(bond)
## [,1] [,2] [,3]
## [1,] -13.00554 -46.569627 -114.89216
## [2,] 0.00000 -5.679906 -31.68066
## [3,] 0.00000 0.000000 0.00000
# Imprimir precios de opciones
cat("Precio opcion PUT Europea:", europea_put_option_price, "\n")
## Precio opcion PUT Europea: 91.0806
binomplot(s, k, v, r, tt, d, nstep, putopt = TRUE, american = FALSE,
plotvalues= TRUE, plotarrows= TRUE, drawstrike= TRUE, pointsize= 3, ylimval=c(0,0),
saveplot= FALSE, saveplotfn='TXN CRR Plots.png',
crr= TRUE, jarrowrudd= FALSE, titles = TRUE, specifyupdn = FALSE,
returnprice = TRUE, logy = FALSE)
## [1] 90.99008
crr_option_price <- function(S0, X, T, r, sigma, n, type = "call") {
delta_t <- T / n
u <- exp(sigma * sqrt(delta_t))
d <- 1 / u
p <- (exp(r * delta_t) - d) / (u - d)
# Generar precios de acciones al vencimiento
ST <- S0 * u^(n:0) * d^(0:n)
# Calcular los pagos de las opciones al vencimiento
payoff <- pmax(ST - X, 0) # Para una opcion call
# Inducción hacia atrás para calcular el precio de la opción en t=0
for (i in (n - 1):0) {
payoff <- exp(-r * delta_t) * (p * payoff[2:(i + 2)] + (1 - p) * payoff[1:(i + 1)])
}
return(payoff[1])
}
underlying_price_ftnt <- s_ftnt
strike_price_ftnt <- 45
time_to_expiry_ftnt <- 0.25
risk_free_rate_ftnt <- 0.0112584
dividend_yield_ftnt <- 0
volatility_ftnt <- 1.9766/0.25
n_ftnt <- 3 # Numero de periodos
# Calcular el precio de la opción de compra de FTNT utilizando un modelo similar al CRR
ftnt_crr_price <- crr_option_price(underlying_price_txn,
strike_price_ftnt, time_to_expiry_ftnt,
risk_free_rate_ftnt, volatility_ftnt, n_ftnt)
# Imprimir el resultado
print(ftnt_crr_price)
## [1] 117812.8
s <- s_ftnt # Precio actual de las acciones
k <- 45 # Precio Strike
tt <- 0.25 # Tiempo de vencimiento (A?os)
r <- 0.0112584 # Tasa de riesgo
d <- 0 # Tasa yield
v <- 1.9766/0.25 # Volatilidad implicita
nstep <- 3 # N?mero de pasos en el ?rbol binomial
# Calcular el precio de la opci?n y la informaci?n asociada.
result <- binomopt(s, k, v, r, tt, d, nstep, american = FALSE, putopt = FALSE, returntrees = TRUE, returnparams = TRUE)
# Calcular el precio de la opci?n de compra Europea
europea_call_option_price <- binomopt(s, k, v, r, tt, d, nstep, american = FALSE, putopt = FALSE, returntrees = TRUE, returnparams = TRUE)[[1]]
# Acceder a los par?metros devueltos
oppricretree <- result$oppricretree
delta <- result$delta
bond <- result$bond
# Imprima o use estos par?metros seg?n sea necesario (tiempo de retorno 0 delta, gamma y theta en los vectores griegos)
print(oppricretree)
## NULL
print(delta)
## [,1] [,2] [,3]
## [1,] 0.9811361 0.9943298 1.0000000
## [2,] 0.0000000 0.8518390 0.9387614
## [3,] 0.0000000 0.0000000 0.0000000
# Imprimir precios de opciones
cat("Precio opcion Call Europea", europea_call_option_price, "\n")
## Precio opcion Call Europea 61.84102
binomplot(s, k, v, r, tt, d, nstep, putopt = FALSE, american = FALSE,
plotvalues= TRUE, plotarrows= TRUE, drawstrike= TRUE, pointsize= 3, ylimval=c(0,0),
saveplot= FALSE, saveplotfn='TXN CRR Plots.png',
crr= TRUE, jarrowrudd= FALSE, titles = TRUE, specifyupdn = FALSE,
returnprice = TRUE, logy = FALSE)
## [1] 61.84197
# Creando un modelo de ?rbol binomial opcion PUT CRR para FTNT
s <- s_ftnt # Precio actual de las acciones
k <- 35 # Precio Strike
tt <- 0.25 # Tiempo de vencimiento (A?os)
r <- 0.0112584 # Tasa libre de riesgo
d <- 0 # Tasa yield
v <- 1.5938/0.25 # Volatilidad implicita
nstep <- 3 # N?mero de pasos en el ?rbol binomial
# Calcular el precio de la opci?n y la informaci?n asociada.
result <- binomopt(s, k, v, r, tt, d, nstep, american = FALSE,
putopt = FALSE, returntrees = TRUE,
returnparams = TRUE)
# Calcular el precio de la opción de venta Europea
europea_put_option_price <- binomopt(s, k, v, r, tt, d, nstep,
american = FALSE, putopt = TRUE,
returntrees = TRUE, returnparams = TRUE)[[1]]
# Accediendo a los par?metros devueltos
oppricretree <- result$oppricretree
delta <- result$delta
bond <- result$bond
# Parámetros según sea necesario
print(oppricretree)
## NULL
print(delta)
## [,1] [,2] [,3]
## [1,] 0.9664966 0.9914645 1.0000000
## [2,] 0.0000000 0.8092281 0.9377012
## [3,] 0.0000000 0.0000000 0.0000000
print(bond)
## [,1] [,2] [,3]
## [1,] -2.925092 -13.078027 -34.96718
## [2,] 0.000000 -1.316393 -9.61713
## [3,] 0.000000 0.000000 0.00000
# Imprimir precios de opciones
cat("Precio opcion PUT Europea:", europea_put_option_price, "\n")
## Precio opcion PUT Europea: 29.81624
binomplot(s, k, v, r, tt, d, nstep, putopt = TRUE, american = FALSE,
plotvalues= TRUE, plotarrows= TRUE, drawstrike= TRUE, pointsize= 3, ylimval=c(0,0),
saveplot= FALSE, saveplotfn='FTNT CRR Plots.png',
crr= TRUE, jarrowrudd= FALSE, titles = TRUE, specifyupdn = FALSE,
returnprice = TRUE, logy = FALSE)
## [1] 29.81943
crr_option_price <- function(S0, X, T, r, sigma, n, type = "call") {
delta_t <- T / n
u <- exp(sigma * sqrt(delta_t))
d <- 1 / u
p <- (exp(r * delta_t) - d) / (u - d)
# Generar precios de acciones al vencimiento
ST <- S0 * u^(n:0) * d^(0:n)
# Calcular los pagos de las opciones al vencimiento
payoff <- pmax(ST - X, 0) # Para una opcion call
# Inducción hacia atrás para calcular el precio de la opción en t=0
for (i in (n - 1):0) {
payoff <- exp(-r * delta_t) * (p * payoff[2:(i + 2)] + (1 - p) * payoff[1:(i + 1)])
}
return(payoff[1])
}
underlying_price_dltr <- s_dltr
strike_price_dltr <- 100
time_to_expiry_dltr <- 0.25
risk_free_rate_dltr <- 0.0112584
dividend_yield_dltr <- 0
volatility_dltr <- 0.9131/0.25
n_dltr <- 3 # Numero de periodos
# Calcular el precio de la opci?n de compra de FTNT utilizando un modelo similar al CRR
dltr_crr_price <- crr_option_price(underlying_price_dltr,
strike_price_dltr, time_to_expiry_dltr,
risk_free_rate_dltr, volatility_dltr, n_dltr)
# Imprimir el resultado
print(dltr_crr_price)
## [1] 1259.507
s <- s_dltr # Precio actual de las acciones
k <- 100 # Precio Strike
tt <- 0.25 # Tiempo de vencimiento (Años)
r <- 0.0112584 # Tasa de riesgo
d <- 0 # Tasa yield
v <- 0.9131/0.25 # Volatilidad implicita
nstep <- 3 # Número de pasos en el árbol binomial
# Calcular el precio de la opción y la información asociada.
result <- binomopt(s, k, v, r, tt, d, nstep, american = FALSE, putopt = FALSE, returntrees = TRUE, returnparams = TRUE)
# Calcular el precio de la opción de compra Europea
europea_call_option_price <- binomopt(s, k, v, r, tt, d, nstep, american = FALSE, putopt = FALSE, returntrees = TRUE, returnparams = TRUE)[[1]]
# Acceder a los parámetros devueltos
oppricretree <- result$oppricretree
delta <- result$delta
bond <- result$bond
# Imprima o use estos parámetros según sea necesario (tiempo de retorno 0 delta, gamma y theta en los vectores griegos)
print(oppricretree)
## NULL
print(delta)
## [,1] [,2] [,3]
## [1,] 0.8640266 0.9533392 1.0000000
## [2,] 0.0000000 0.6076881 0.8194165
## [3,] 0.0000000 0.0000000 0.0000000
# Imprimir precios de opciones
cat("Precio opcion Call Europea", europea_call_option_price, "\n")
## Precio opcion Call Europea 86.95916
binomplot(s, k, v, r, tt, d, nstep, putopt = FALSE, american = FALSE,
plotvalues= TRUE, plotarrows= TRUE, drawstrike= TRUE, pointsize= 3, ylimval=c(0,0),
saveplot= FALSE, saveplotfn='DLTR CRR Plots.png',
crr= TRUE, jarrowrudd= FALSE, titles = TRUE, specifyupdn = FALSE,
returnprice = TRUE, logy = FALSE)
## [1] 86.96948
# Creando un modelo de árbol binomial opcion PUT CRR para DLTR
s <- s_dltr # Precio actual de las acciones
k <- 105 # Precio Strike
tt <- 0.25 # Tiempo de vencimiento (A?os)
r <- 0.0112584 # Tasa libre de riesgo
d <- 0 # Tasa yield
v <- 0.8398/0.25 # Volatilidad implicita
nstep <- 3 # N?mero de pasos en el ?rbol binomial
# Calcular el precio de la opción y la información asociada.
result <- binomopt(s, k, v, r, tt, d, nstep, american = FALSE,
putopt = FALSE, returntrees = TRUE,
returnparams = TRUE)
# Calcular el precio de la opción de venta Europea
europea_put_option_price <- binomopt(s, k, v, r, tt, d, nstep,
american = FALSE, putopt = TRUE,
returntrees = TRUE, returnparams = TRUE)[[1]]
# Accediendo a los parámetros devueltos
oppricretree <- result$oppricretree
delta <- result$delta
bond <- result$bond
# Parámetros según sea necesario
print(oppricretree)
## NULL
print(delta)
## [,1] [,2] [,3]
## [1,] 0.8423415 0.9434061 1.0000000
## [2,] 0.0000000 0.5758139 0.7941569
## [3,] 0.0000000 0.0000000 0.0000000
print(bond)
## [,1] [,2] [,3]
## [1,] -22.80944 -55.9273 -104.90154
## [2,] 0.00000 -10.2810 -37.42915
## [3,] 0.00000 0.0000 0.00000
# Imprimir precios de opciones
cat("Precio opcion PUT Europea:", europea_put_option_price, "\n")
## Precio opcion PUT Europea: 62.33633
binomplot(s, k, v, r, tt, d, nstep, putopt = TRUE, american = FALSE,
plotvalues= TRUE, plotarrows= TRUE, drawstrike= TRUE, pointsize= 3, ylimval=c(0,0),
saveplot= FALSE, saveplotfn='DLTR CRR Plots.png',
crr= TRUE, jarrowrudd= FALSE, titles = TRUE, specifyupdn = FALSE,
returnprice = TRUE, logy = FALSE)
## [1] 62.34584
PARTE 3: Creación de coberturas.
prices_txn <- seq(150,215,1) # Vector de precios
strike_txn <- 175 # Precio strike
premium_call_txn <- 3.8 # Precio opcion call
premium_put_txn <- 4.05 # Precio opcion put
# payoff al vencimiento opcion call
intrinsicValuesCall_txn <- prices_txn - strike_txn - premium_call_txn
payoffLongCall_txn <- pmax(-premium_call_txn,intrinsicValuesCall_txn)
# payoff al vencimiento opcion put
intrinsicValuesPut_txn <- strike_txn - prices_txn - premium_put_txn
payoffLongPut_txn <- pmax(-premium_put_txn,intrinsicValuesPut_txn)
# El payoff de la estrategia es la suma de las opciones call y put
# Se necesita la suma elemento por elemento
payoff_txn <- rowSums(cbind(payoffLongCall_txn,payoffLongPut_txn))
results_txn <- data.frame(cbind(prices_txn,payoffLongCall_txn,payoffLongPut_txn,payoff_txn))
ggplot(results_txn, aes(x=prices_txn)) +
geom_line(aes(y = payoffLongCall_txn, color = "LongCall")) +
geom_line(aes(y = payoffLongPut_txn, color="LongPut"))+
geom_line(aes(y=payoff_txn, color = 'Payoff')) +
scale_colour_manual("",
breaks = c("LongCall", "LongPut", "Payoff"),
values = c("darkred", "darkblue", "darkgreen")) + ylab("Payoff")+
ggtitle("Long Straddle Payoff TXN")
prices_ftnt <- seq(35,95,1) # Vector de precios
strike_ftnt <- 64 # Precio strike
premium_call_ftnt <- 3.55 # Precio opcion call
premium_put_ftnt <- 3.7 # Precio opcion put
# payoff al vencimiento opcion call
intrinsicValuesCall_ftnt <- prices_ftnt - strike_ftnt - premium_call_ftnt
payoffLongCall_ftnt <- pmax(-premium_call_ftnt,intrinsicValuesCall_ftnt)
# payoff al vencimiento opcion put
intrinsicValuesPut_ftnt <- strike_ftnt - prices_ftnt - premium_put_ftnt
payoffLongPut_ftnt <- pmax(-premium_put_ftnt,intrinsicValuesPut_ftnt)
# El payoff de la estrategia es la suma de las opciones call y put
# Se necesita la suma elemento por elemento
payoff_ftnt <- rowSums(cbind(payoffLongCall_ftnt,payoffLongPut_ftnt))
results_ftnt <- data.frame(cbind(prices_ftnt,payoffLongCall_ftnt,payoffLongPut_ftnt,payoff_ftnt))
ggplot(results_ftnt, aes(x=prices_ftnt)) +
geom_line(aes(y = payoffLongCall_ftnt, color = "LongCall")) +
geom_line(aes(y = payoffLongPut_ftnt, color="LongPut"))+
geom_line(aes(y=payoff_ftnt, color = 'Payoff')) +
scale_colour_manual("",
breaks = c("LongCall", "LongPut", "Payoff"),
values = c("darkred", "darkblue", "darkgreen")) + ylab("Payoff")+
ggtitle("Long Straddle Payoff FTNT")
prices_dltr <- seq(100,165,1) # Vector de precios
strike_dltr <- 120 # Precio strike
premium_call_dltr <- 2.62 # Precio opcion call
premium_put_dltr <- 2.86 # Precio opcion put
# payoff al vencimiento opcion call
intrinsicValuesCall_dltr <- prices_dltr - strike_dltr - premium_call_dltr
payoffLongCall_dltr <- pmax(-premium_call_dltr,intrinsicValuesCall_dltr)
# payoff al vencimiento opcion put
intrinsicValuesPut_dltr <- strike_dltr - prices_dltr - premium_put_dltr
payoffLongPut_dltr <- pmax(-premium_put_dltr,intrinsicValuesPut_dltr)
# El payoff de la estrategia es la suma de las opciones call y put
# Se necesita la suma elemento por elemento
payoff_dltr <- rowSums(cbind(payoffLongCall_dltr,payoffLongPut_dltr))
payoff_dltr
## [1] 14.52 13.52 12.52 11.52 10.52 9.52 8.52 7.52 6.52 5.52 4.52 3.52
## [13] 2.52 1.52 0.52 -0.48 -1.48 -2.48 -3.48 -4.48 -5.48 -4.48 -3.48 -2.48
## [25] -1.48 -0.48 0.52 1.52 2.52 3.52 4.52 5.52 6.52 7.52 8.52 9.52
## [37] 10.52 11.52 12.52 13.52 14.52 15.52 16.52 17.52 18.52 19.52 20.52 21.52
## [49] 22.52 23.52 24.52 25.52 26.52 27.52 28.52 29.52 30.52 31.52 32.52 33.52
## [61] 34.52 35.52 36.52 37.52 38.52 39.52
results_dltr <- data.frame(cbind(prices_dltr,payoffLongCall_dltr,payoffLongPut_dltr,payoff_dltr))
ggplot(results_dltr, aes(x=prices_dltr)) +
geom_line(aes(y = payoffLongCall_dltr, color = "LongCall")) +
geom_line(aes(y = payoffLongPut_dltr, color="LongPut"))+
geom_line(aes(y=payoff_dltr, color = 'Payoff')) +
scale_colour_manual("",
breaks = c("LongCall", "LongPut", "Payoff"),
values = c("darkred", "darkblue", "darkgreen")) + ylab("Payoff")+
ggtitle("Long Straddle Payoff DLTR")
Los beneficios que nos brinda esta estrategia de cobertura es que es neutral en cuanto a la dirección del movimiento del precio del activo subyacente. Esto significa que podemos obtener ganancias independientemente de si el precio del activo subyacente aumenta o disminuye, siempre y cuando el movimiento sea lo suficientemente significativo para superar el costo de ambas opciones.
La estrategia de Straddle ofrece flexibilidad en cuanto a la duración de la posición.
La estrategia de Straddle se beneficia de un aumento en la volatilidad del activo subyacente y es por esta razón, ante unas volatilidades extremas, podemos cubrirnos mejor.