tickers <- c("NFLX", "AAPL", "LLY")
start_date <- as.Date("2023-10-01")
end_date <- as.Date("2025-11-05")
getSymbols(tickers, src = "yahoo", from = start_date, to = end_date)
## [1] "NFLX" "AAPL" "LLY"
prices <- merge(Ad(NFLX), Ad(AAPL), Ad(LLY))
colnames(prices) <- c("Netflix", "Apple", "Eli_Lilly")
prices_df <- data.frame(Date = index(prices), coredata(prices))
prices_melt <- melt(prices_df, id.vars = "Date")
ggplot(prices_melt, aes(x = Date, y = value, color = variable)) +
geom_line(size = 1) +
labs(title = "Histórico de precios (NFLX, AAPL, LLY)",
x = "Fecha", y = "Precio ajustado (USD)",
color = "Acción") +
theme_minimal()
prices <- merge(Ad(NFLX), Ad(AAPL), Ad(LLY))
colnames(prices) <- c("Netflix", "Apple", "Eli_Lilly")
returns <- na.omit(Return.calculate(prices))
mean_returns <- colMeans(returns)
cov_matrix <- cov(returns)
Dmat <- 2 * cov_matrix
dvec <- rep(0, length(mean_returns))
Amat <- cbind(rep(1, length(mean_returns)), diag(length(mean_returns)))
bvec <- c(1, rep(0, length(mean_returns))) # suma de pesos = 1, pesos >= 0
solution <- solve.QP(Dmat, dvec, Amat, bvec, meq = 1)
weights <- solution$solution
names(weights) <- colnames(prices)
weights
## Netflix Apple Eli_Lilly
## 0.2700488 0.4567437 0.2732075
total_investment <- 10000000
allocation <- weights * total_investment
allocation
## Netflix Apple Eli_Lilly
## 2700488 4567437 2732075
# Función para calcular riesgo y retorno dado un vector de pesos
portfolio_stats <- function(weights, mean_returns, cov_matrix) {
ret <- sum(weights * mean_returns)
risk <- sqrt(t(weights) %*% cov_matrix %*% weights)
return(c(risk, ret))
}
# Generar combinaciones de pesos para la frontera eficiente
n_points <- 100
weights_list <- matrix(NA, nrow = n_points, ncol = length(mean_returns))
returns_list <- numeric(n_points)
risk_list <- numeric(n_points)
for (i in 1:n_points) {
# Restricción: suma de pesos = 1, pesos >= 0
target_return <- min(mean_returns) + (max(mean_returns) - min(mean_returns)) * (i / n_points)
Dmat <- 2 * cov_matrix
dvec <- rep(0, length(mean_returns))
Amat <- cbind(rep(1, length(mean_returns)), mean_returns, diag(length(mean_returns)))
bvec <- c(1, target_return, rep(0, length(mean_returns)))
result <- solve.QP(Dmat, dvec, Amat, bvec, meq = 2)
weights_list[i, ] <- result$solution
stats <- portfolio_stats(result$solution, mean_returns, cov_matrix)
risk_list[i] <- stats[1]
returns_list[i] <- stats[2]
}
# Data frame para graficar
frontier_df <- data.frame(Risk = risk_list, Return = returns_list)
# Portafolio actual (mínima varianza)
current_stats <- portfolio_stats(weights, mean_returns, cov_matrix)
# Gráfico
ggplot(frontier_df, aes(x = Risk, y = Return)) +
geom_line(color = "blue", linewidth = 1.2) +
geom_point(aes(x = current_stats[1], y = current_stats[2]), color = "red", size = 3) +
labs(title = "Frontera Eficiente y Portafolio Actual",
x = "Riesgo (Desviación Estándar)",
y = "Retorno Esperado") +
theme_minimal()
###La curva azul representa todos los portafolios eficientes posibles combinando los tres activos (NFLX, AAPL, LLY), El eje X es el riesgo (desviación estándar), y el eje Y es el retorno esperado.La curva tiene forma convexa, lo que indica que a medida que se buscas más retorno, se debe aceptar más riesgo.
# Parámetros de simulación GBM
set.seed(123)
n_sim <- 500 # número de trayectorias
n_days <- 252 * 2 # dos años
dt <- 1/252
# Últimos precios y volatilidades
S0 <- as.numeric(last(prices))
mu <- colMeans(returns)
sigma <- apply(returns, 2, sd)
# Función de simulación MGB
sim_prices <- function(S0, mu, sigma, n_days, n_sim) {
matrix(S0 * exp(cumsum((mu - 0.5 * sigma^2) * dt +
sigma * sqrt(dt) * matrix(rnorm(n_days * n_sim), nrow = n_days))),
nrow = n_days, ncol = n_sim)
}
# Simular precios para cada acción
sim_list <- lapply(1:3, function(i) sim_prices(S0[i], mu[i], sigma[i], n_days, n_sim))
names(sim_list) <- c("NFLX", "AAPL", "LLY")
# Visualizar trayectorias simuladas
plot_sim <- function(sim_matrix, name) {
matplot(sim_matrix[, 1:20], type = "l", lty = 1, col = rainbow(20),
main = paste("Simulación de precios futuros -", name),
xlab = "Días", ylab = "Precio simulado")
}
par(mfrow = c(1, 3))
plot_sim(sim_list$NFLX, "NFLX")
plot_sim(sim_list$AAPL, "AAPL")
plot_sim(sim_list$LLY, "LLY")
###La simulación confirma que el riesgo del portafolio depende de la volatilidad individual y la correlación, Apple aporta estabilidad, mientras que Netflix y Eli Lilly añaden más incertidumbre, a medida que el horizonte aumenta, la dispersión se amplía, lo que implica mayor riesgo a largo plazo.
# Calcular valor del portafolio en cada simulación
# Usamos los pesos del portafolio (weights) y las simulaciones de cada acción
portfolio_values <- matrix(NA, nrow = n_days, ncol = n_sim)
for (i in 1:n_sim) {
for (t in 1:n_days) {
portfolio_values[t, i] <- sum(c(sim_list$NFLX[t, i],
sim_list$AAPL[t, i],
sim_list$LLY[t, i]) * weights)
}
}
# Verificar
dim(portfolio_values) # Debe ser 504 x 500 (2 años x simulaciones)
## [1] 504 500
head(portfolio_values)
## [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
## [1,] 665.9180 675.5868 676.5089 690.2358 701.5328 678.4693 685.1507 681.6674
## [2,] 665.2818 676.1351 676.9069 690.6569 701.7624 679.3918 684.9539 682.6076
## [3,] 666.1464 676.0891 677.8667 690.4222 701.3279 678.7901 683.8560 682.7963
## [4,] 665.8545 675.1068 679.2108 690.3777 702.0064 679.2384 682.7672 682.3389
## [5,] 665.9485 674.6308 679.1990 690.8990 702.5527 679.0680 682.8183 683.3740
## [6,] 667.0498 674.8277 679.1386 690.9357 703.2172 678.2747 683.5939 682.7816
## [,9] [,10] [,11] [,12] [,13] [,14] [,15] [,16]
## [1,] 668.8585 673.5345 658.1898 670.2570 676.9923 679.3324 668.9774 661.5284
## [2,] 668.0702 674.6342 657.9263 671.0291 676.2388 679.0103 669.7152 660.5470
## [3,] 667.8424 675.0317 658.2282 671.2154 676.8068 679.4811 670.2173 661.0988
## [4,] 666.8509 675.3260 659.0227 670.6821 676.1214 680.1873 670.0985 661.0838
## [5,] 667.6065 674.9667 658.3731 671.1006 675.6908 679.5955 669.8522 662.0349
## [6,] 667.4336 675.2384 658.0675 671.7442 675.8080 680.2611 670.3716 661.5964
## [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24]
## [1,] 655.2996 675.5222 672.8713 671.1767 669.7750 684.4021 666.1309 695.3554
## [2,] 655.0462 676.0623 671.8010 671.5577 670.0553 685.7129 666.6440 695.4365
## [3,] 655.7865 676.9667 672.1221 671.4679 670.5514 685.8148 666.9703 696.5224
## [4,] 655.4786 676.6406 672.7834 671.5972 670.5378 686.1714 666.3280 697.2945
## [5,] 655.0504 675.7284 673.1398 671.2636 669.7898 686.1410 665.8308 697.2003
## [6,] 654.3044 675.3427 672.9401 670.9529 669.9844 686.4645 665.7859 696.1573
## [,25] [,26] [,27] [,28] [,29] [,30] [,31] [,32]
## [1,] 690.9162 685.2141 690.1482 694.3205 701.8495 712.2713 723.2666 756.6171
## [2,] 691.0818 685.0587 689.5282 694.5373 702.1750 712.6218 722.8937 756.8806
## [3,] 691.7836 685.1238 689.7835 694.6750 702.0008 712.6463 722.5680 756.5608
## [4,] 692.4809 685.1447 689.9549 694.0236 702.4440 712.9168 722.4214 755.9961
## [5,] 693.2024 684.9456 689.8829 694.0166 702.2863 713.4944 721.8568 755.9294
## [6,] 692.6165 684.6695 688.8556 693.2953 702.7217 712.5964 722.6255 756.5148
## [,33] [,34] [,35] [,36] [,37] [,38] [,39] [,40]
## [1,] 766.8997 744.8493 731.5287 715.0133 730.4731 719.9512 718.7462 711.0856
## [2,] 767.2914 744.3401 730.9338 714.6566 731.8362 721.0470 719.3167 711.0879
## [3,] 767.4783 744.6765 730.8937 714.6031 731.9920 721.0213 719.5623 711.2995
## [4,] 767.1087 744.3077 731.1650 715.0913 731.9283 720.6169 718.8389 710.6317
## [5,] 767.7588 743.8843 731.6940 715.9698 731.4392 719.8788 718.2686 710.5233
## [6,] 768.2237 743.8440 730.9582 716.8144 730.5141 719.9081 717.0400 711.2651
## [,41] [,42] [,43] [,44] [,45] [,46] [,47] [,48]
## [1,] 716.7307 716.1612 742.2003 727.9902 736.0540 733.4248 702.5455 717.5253
## [2,] 716.7532 715.3599 742.9514 728.1648 736.3257 734.1557 702.8029 716.8918
## [3,] 716.0582 715.8239 742.1915 729.1186 736.3005 734.5381 703.4611 716.5391
## [4,] 715.7432 715.7323 743.0849 728.3511 736.0150 734.2613 704.8915 716.3839
## [5,] 716.6364 715.3158 741.6758 727.9540 735.5508 734.3682 704.9620 716.5750
## [6,] 716.8843 714.8746 740.8080 726.7547 734.4725 734.8905 704.8579 718.3024
## [,49] [,50] [,51] [,52] [,53] [,54] [,55] [,56]
## [1,] 733.2453 723.1467 736.0400 745.7659 772.7052 749.0677 761.8583 757.3899
## [2,] 733.0515 723.4437 735.9596 745.5168 771.9427 749.7657 762.1673 758.4795
## [3,] 732.8862 724.3503 735.0877 746.0894 771.3329 749.9417 761.3388 759.0557
## [4,] 733.9305 724.9548 735.6082 747.6995 772.0775 749.8695 760.2000 760.2149
## [5,] 734.2345 724.5076 736.1675 749.0215 771.1435 749.8265 761.6159 760.5584
## [6,] 734.9475 725.1612 736.0109 749.1547 771.0709 750.6787 761.8536 762.2487
## [,57] [,58] [,59] [,60] [,61] [,62] [,63] [,64]
## [1,] 778.5785 788.1906 781.1663 804.2130 823.4192 816.2351 824.9233 832.3362
## [2,] 779.5682 787.5277 781.4239 804.4715 822.9471 816.1894 826.1815 832.9050
## [3,] 780.2153 787.5455 780.2457 804.3022 822.5034 815.8672 825.9209 831.5964
## [4,] 778.9016 787.6763 781.0946 803.5998 822.3987 815.6659 827.0011 831.8475
## [5,] 778.8066 788.1726 780.6469 804.4310 822.8872 816.9357 827.7921 831.7160
## [6,] 778.5960 788.9660 781.5132 804.8642 822.8037 817.0318 828.5491 831.2950
## [,65] [,66] [,67] [,68] [,69] [,70] [,71] [,72]
## [1,] 818.0581 810.1893 802.0125 812.7487 813.5594 817.4222 817.2775 796.8233
## [2,] 817.3783 810.7258 800.6299 812.2708 812.5629 818.2294 817.2148 796.2100
## [3,] 818.3317 811.0357 800.1055 811.3563 812.0329 818.7230 817.7992 795.5198
## [4,] 819.0945 810.8705 799.9322 811.3339 812.2609 819.1028 816.5885 794.6926
## [5,] 819.3888 810.4546 799.5875 811.2368 812.5456 818.3432 816.4376 793.6678
## [6,] 818.1485 811.1272 800.0577 811.1330 813.1166 818.3408 816.6423 792.7254
## [,73] [,74] [,75] [,76] [,77] [,78] [,79] [,80]
## [1,] 785.2935 779.4494 786.0107 808.6736 802.9788 800.5973 802.7583 796.2060
## [2,] 784.6759 779.2191 786.4873 808.5685 802.5554 801.5869 801.7539 796.6558
## [3,] 785.1511 779.1774 787.2166 808.0714 802.1588 801.9273 801.5964 796.5789
## [4,] 784.9049 778.9825 787.1384 807.7030 802.9673 801.6585 802.1975 795.7166
## [5,] 783.7818 779.7602 787.7105 807.9827 801.9996 801.8684 802.6537 794.9497
## [6,] 783.6255 779.4571 787.3554 807.1291 801.8359 803.4158 803.0071 793.5813
## [,81] [,82] [,83] [,84] [,85] [,86] [,87] [,88]
## [1,] 798.9559 785.2021 785.3031 792.5873 784.4664 774.9387 786.6972 802.4942
## [2,] 798.1926 785.7335 784.4361 792.2888 783.3655 775.1931 787.0126 802.9754
## [3,] 799.1194 786.6629 784.9011 792.8764 782.6688 774.7974 786.8243 803.2866
## [4,] 798.8395 785.9239 785.3359 793.1203 781.4871 774.9946 787.4459 803.5523
## [5,] 799.4223 784.6962 785.3079 793.0770 781.0834 774.4326 787.2792 803.1898
## [6,] 799.9186 785.0616 785.2068 792.5873 781.2578 773.9890 786.3326 803.8920
## [,89] [,90] [,91] [,92] [,93] [,94] [,95] [,96]
## [1,] 798.6448 810.0762 826.0500 824.4458 804.5603 849.7294 872.4562 893.4827
## [2,] 799.1861 810.6513 826.1281 825.3773 804.4058 850.5226 873.1539 894.0816
## [3,] 799.0367 810.7891 825.7601 825.3279 805.5842 850.4198 872.6394 894.1327
## [4,] 799.0472 810.2317 825.9594 824.6845 806.1340 850.3522 873.1850 894.1198
## [5,] 798.6316 808.5965 826.3574 824.5603 806.4927 849.4893 874.1525 893.5338
## [6,] 798.4449 808.3597 825.6863 823.8712 807.7828 851.0247 874.8268 892.8765
## [,97] [,98] [,99] [,100] [,101] [,102] [,103] [,104]
## [1,] 892.1629 918.4419 936.7609 942.2401 975.6412 996.3562 972.4943 991.2573
## [2,] 893.4729 919.0429 937.0621 941.7254 974.6517 994.6158 974.1828 991.5730
## [3,] 893.4741 918.3015 937.5513 942.8619 975.3030 994.8150 974.4442 991.2170
## [4,] 891.6048 918.8925 936.3271 941.9047 977.7699 995.2490 971.9044 993.0486
## [5,] 890.7631 919.3996 937.0066 942.4127 978.2736 994.4159 971.0952 993.5048
## [6,] 890.8398 917.7431 935.8612 943.0163 977.1719 993.5293 971.2909 993.3513
## [,105] [,106] [,107] [,108] [,109] [,110] [,111] [,112]
## [1,] 987.5756 993.0222 1014.595 1045.049 1044.990 1052.413 1066.882 1060.774
## [2,] 987.7645 993.6096 1014.395 1043.537 1044.081 1053.275 1065.934 1060.806
## [3,] 987.6414 993.7109 1013.519 1044.408 1042.713 1054.793 1065.460 1061.914
## [4,] 987.4606 993.6133 1012.947 1043.794 1042.485 1055.549 1066.709 1061.011
## [5,] 989.2403 994.4687 1012.501 1044.133 1041.922 1055.330 1066.239 1062.237
## [6,] 989.8324 993.1424 1011.435 1043.972 1041.825 1054.444 1066.377 1061.523
## [,113] [,114] [,115] [,116] [,117] [,118] [,119] [,120]
## [1,] 1064.420 1050.275 1038.167 1075.790 1124.313 1124.455 1143.027 1157.350
## [2,] 1063.283 1050.263 1039.222 1075.603 1125.482 1123.800 1143.823 1156.214
## [3,] 1064.071 1051.644 1037.852 1075.425 1127.314 1124.141 1144.403 1156.382
## [4,] 1064.096 1051.460 1039.756 1076.174 1126.689 1124.491 1141.712 1156.334
## [5,] 1064.849 1052.622 1038.428 1076.458 1126.367 1125.419 1142.597 1155.919
## [6,] 1065.490 1053.151 1038.166 1077.389 1124.489 1126.978 1141.568 1155.554
## [,121] [,122] [,123] [,124] [,125] [,126] [,127] [,128]
## [1,] 1181.337 1112.746 1075.276 1054.308 1076.057 1077.344 1123.609 1129.703
## [2,] 1182.383 1112.367 1076.320 1054.667 1077.656 1077.109 1123.801 1127.506
## [3,] 1182.516 1113.029 1076.570 1055.102 1076.408 1075.405 1125.590 1128.259
## [4,] 1182.000 1112.016 1077.076 1055.644 1076.788 1075.552 1125.458 1128.113
## [5,] 1182.898 1112.156 1076.359 1055.449 1076.125 1077.061 1126.825 1128.448
## [6,] 1184.057 1111.435 1077.061 1055.425 1074.736 1077.252 1126.864 1129.349
## [,129] [,130] [,131] [,132] [,133] [,134] [,135] [,136]
## [1,] 1157.865 1192.786 1226.901 1215.690 1220.102 1212.919 1240.919 1217.342
## [2,] 1158.920 1193.692 1226.988 1214.369 1220.168 1213.523 1239.522 1216.945
## [3,] 1157.032 1193.684 1225.683 1214.047 1220.002 1214.446 1239.124 1218.222
## [4,] 1157.244 1193.894 1226.328 1212.264 1218.728 1214.853 1240.020 1217.828
## [5,] 1157.904 1196.365 1226.781 1212.904 1218.610 1215.806 1240.766 1217.529
## [6,] 1159.568 1195.868 1224.181 1214.570 1219.785 1215.036 1240.673 1217.269
## [,137] [,138] [,139] [,140] [,141] [,142] [,143] [,144]
## [1,] 1198.640 1225.251 1216.889 1244.248 1216.780 1215.489 1241.325 1256.715
## [2,] 1199.983 1226.413 1217.183 1244.749 1217.248 1214.536 1241.048 1256.277
## [3,] 1199.062 1226.591 1217.654 1242.618 1215.214 1216.096 1240.759 1256.494
## [4,] 1198.973 1227.574 1217.721 1240.261 1213.489 1217.889 1240.096 1257.239
## [5,] 1198.997 1227.639 1218.685 1239.790 1212.895 1217.518 1239.678 1257.191
## [6,] 1199.161 1228.531 1221.914 1242.014 1213.706 1216.887 1240.348 1258.211
## [,145] [,146] [,147] [,148] [,149] [,150] [,151] [,152]
## [1,] 1283.513 1285.824 1336.084 1312.117 1335.559 1340.577 1393.271 1391.422
## [2,] 1283.690 1288.287 1337.466 1312.380 1335.807 1341.622 1392.998 1392.395
## [3,] 1282.392 1289.926 1334.393 1313.786 1336.174 1339.910 1393.495 1391.821
## [4,] 1281.218 1292.040 1331.797 1313.505 1334.716 1337.998 1394.211 1391.510
## [5,] 1282.034 1292.610 1332.019 1312.766 1335.079 1337.519 1394.351 1392.381
## [6,] 1282.497 1291.853 1332.335 1313.939 1335.001 1339.226 1394.457 1390.048
## [,153] [,154] [,155] [,156] [,157] [,158] [,159] [,160]
## [1,] 1403.891 1400.898 1376.806 1406.258 1459.714 1483.544 1465.474 1413.106
## [2,] 1404.404 1399.971 1377.270 1405.834 1457.206 1483.654 1466.098 1411.824
## [3,] 1402.605 1400.009 1376.111 1405.753 1457.350 1485.615 1466.998 1411.021
## [4,] 1404.153 1400.878 1376.620 1405.251 1456.112 1485.467 1468.210 1412.330
## [5,] 1404.477 1400.954 1375.878 1406.685 1457.250 1485.954 1468.834 1412.927
## [6,] 1403.343 1398.690 1377.338 1407.933 1460.102 1484.876 1467.866 1412.117
## [,161] [,162] [,163] [,164] [,165] [,166] [,167] [,168]
## [1,] 1400.896 1410.229 1439.747 1465.561 1435.756 1412.734 1428.447 1471.390
## [2,] 1402.248 1410.958 1440.922 1464.486 1436.689 1412.069 1428.685 1472.655
## [3,] 1400.415 1410.921 1440.348 1462.285 1435.136 1413.730 1427.383 1473.472
## [4,] 1399.317 1408.694 1442.378 1462.340 1433.145 1414.861 1427.459 1474.033
## [5,] 1400.592 1411.188 1442.862 1461.222 1436.435 1415.280 1426.238 1473.783
## [6,] 1401.334 1412.589 1440.751 1460.667 1437.173 1415.945 1425.872 1474.594
## [,169] [,170] [,171] [,172] [,173] [,174] [,175] [,176]
## [1,] 1476.713 1479.895 1460.631 1525.304 1580.298 1622.919 1645.203 1688.982
## [2,] 1476.010 1480.187 1459.208 1523.406 1582.698 1625.472 1648.731 1690.422
## [3,] 1476.549 1480.454 1460.197 1524.215 1580.370 1625.330 1649.330 1690.927
## [4,] 1475.365 1480.117 1461.375 1526.178 1581.494 1625.916 1649.641 1688.861
## [5,] 1474.265 1480.127 1463.500 1527.942 1581.622 1628.998 1651.558 1689.928
## [6,] 1474.728 1481.357 1466.412 1524.615 1582.039 1628.409 1649.866 1688.554
## [,177] [,178] [,179] [,180] [,181] [,182] [,183] [,184]
## [1,] 1656.481 1571.927 1557.964 1562.213 1560.783 1560.073 1534.384 1523.760
## [2,] 1655.969 1571.046 1559.047 1562.196 1563.180 1558.561 1535.136 1523.547
## [3,] 1652.054 1573.677 1560.220 1562.491 1562.156 1558.389 1537.146 1524.647
## [4,] 1652.418 1573.704 1560.506 1567.038 1561.704 1557.897 1536.523 1522.870
## [5,] 1651.538 1573.788 1560.301 1567.038 1562.104 1558.257 1538.540 1523.288
## [6,] 1651.833 1573.329 1561.453 1567.765 1562.817 1559.026 1538.181 1524.011
## [,185] [,186] [,187] [,188] [,189] [,190] [,191] [,192]
## [1,] 1623.163 1622.370 1607.194 1621.937 1660.499 1686.811 1674.185 1658.884
## [2,] 1623.097 1620.607 1605.685 1620.236 1660.000 1686.400 1676.099 1660.144
## [3,] 1621.572 1620.692 1608.112 1621.787 1656.492 1686.496 1677.581 1659.547
## [4,] 1623.032 1619.354 1608.524 1623.914 1655.833 1687.374 1678.838 1662.050
## [5,] 1621.863 1619.854 1607.504 1623.717 1658.019 1686.237 1679.644 1659.450
## [6,] 1622.972 1619.686 1608.482 1623.791 1656.944 1687.138 1677.684 1657.075
## [,193] [,194] [,195] [,196] [,197] [,198] [,199] [,200]
## [1,] 1581.237 1592.740 1604.503 1601.547 1625.551 1590.423 1603.058 1589.657
## [2,] 1581.809 1592.683 1603.330 1600.907 1624.933 1590.423 1604.042 1590.707
## [3,] 1580.955 1591.679 1601.520 1598.242 1624.113 1590.766 1601.725 1590.064
## [4,] 1581.404 1593.597 1601.341 1597.674 1624.058 1592.693 1600.807 1591.221
## [5,] 1583.302 1593.003 1602.730 1597.147 1622.532 1592.074 1600.389 1590.799
## [6,] 1582.007 1591.120 1600.698 1595.271 1623.344 1589.911 1599.165 1589.944
## [,201] [,202] [,203] [,204] [,205] [,206] [,207] [,208]
## [1,] 1558.793 1554.519 1574.682 1535.583 1585.149 1574.208 1576.683 1627.618
## [2,] 1557.611 1555.641 1576.745 1535.863 1584.510 1573.469 1577.414 1627.618
## [3,] 1555.322 1554.615 1577.483 1535.020 1583.220 1573.096 1578.140 1625.878
## [4,] 1554.751 1552.006 1579.483 1534.810 1582.109 1573.883 1576.465 1626.173
## [5,] 1556.038 1552.044 1578.265 1535.484 1583.294 1576.320 1577.923 1623.470
## [6,] 1555.157 1550.536 1578.366 1532.922 1582.619 1574.688 1575.215 1624.050
## [,209] [,210] [,211] [,212] [,213] [,214] [,215] [,216]
## [1,] 1649.491 1670.472 1674.536 1662.140 1624.711 1670.394 1682.932 1739.882
## [2,] 1650.342 1667.969 1675.440 1661.858 1623.899 1672.869 1683.603 1739.843
## [3,] 1651.692 1667.964 1675.807 1661.015 1624.002 1672.018 1684.326 1741.166
## [4,] 1650.481 1667.590 1674.411 1660.240 1623.507 1673.814 1681.974 1743.224
## [5,] 1649.463 1670.204 1674.748 1661.731 1622.657 1672.629 1680.729 1742.803
## [6,] 1648.171 1667.963 1676.379 1665.049 1621.913 1671.448 1681.825 1744.269
## [,217] [,218] [,219] [,220] [,221] [,222] [,223] [,224]
## [1,] 1781.291 1832.995 1837.585 1861.941 1885.824 1921.853 1877.078 1879.587
## [2,] 1778.694 1833.388 1840.344 1862.529 1884.978 1924.303 1874.666 1878.502
## [3,] 1777.700 1833.283 1838.847 1863.813 1882.462 1925.087 1873.708 1880.847
## [4,] 1778.614 1835.550 1839.715 1862.762 1879.460 1924.209 1872.151 1879.161
## [5,] 1776.506 1837.413 1837.961 1859.979 1877.697 1926.852 1870.628 1879.817
## [6,] 1777.829 1838.854 1839.969 1860.789 1879.581 1927.683 1872.175 1878.188
## [,225] [,226] [,227] [,228] [,229] [,230] [,231] [,232]
## [1,] 1898.665 1851.823 1850.356 1848.606 1810.975 1851.549 1854.517 1870.568
## [2,] 1900.189 1853.362 1848.154 1851.651 1808.116 1853.787 1856.106 1866.512
## [3,] 1900.335 1851.394 1848.101 1851.112 1808.424 1854.187 1855.916 1864.686
## [4,] 1899.581 1852.190 1849.084 1848.221 1809.197 1852.388 1856.466 1865.732
## [5,] 1902.189 1852.571 1849.067 1846.703 1811.437 1852.097 1859.417 1865.832
## [6,] 1899.656 1852.617 1847.569 1848.892 1811.819 1851.889 1859.735 1866.281
## [,233] [,234] [,235] [,236] [,237] [,238] [,239] [,240]
## [1,] 1915.481 1916.461 1879.095 1889.094 1858.083 1829.267 1786.407 1822.642
## [2,] 1916.548 1916.626 1879.605 1888.583 1859.097 1829.151 1787.867 1822.892
## [3,] 1917.674 1914.946 1876.521 1887.111 1858.125 1831.469 1786.647 1820.624
## [4,] 1915.221 1915.049 1876.936 1886.192 1858.145 1832.748 1785.775 1822.192
## [5,] 1916.216 1913.469 1876.016 1885.690 1859.052 1833.320 1783.354 1823.004
## [6,] 1912.302 1914.734 1872.414 1885.875 1859.700 1837.978 1784.222 1821.976
## [,241] [,242] [,243] [,244] [,245] [,246] [,247] [,248]
## [1,] 1879.569 1911.799 1870.792 1876.856 1913.946 1939.015 1975.586 1974.970
## [2,] 1877.556 1911.799 1869.312 1877.157 1913.402 1937.723 1977.965 1976.351
## [3,] 1876.438 1910.499 1869.762 1877.319 1910.505 1937.211 1979.351 1975.440
## [4,] 1877.828 1910.704 1870.609 1877.170 1909.616 1938.787 1978.658 1974.869
## [5,] 1878.562 1909.790 1870.839 1878.750 1908.366 1940.222 1978.259 1974.647
## [6,] 1878.436 1910.024 1871.888 1876.790 1908.498 1941.788 1978.616 1972.833
## [,249] [,250] [,251] [,252] [,253] [,254] [,255] [,256]
## [1,] 2028.659 2007.597 1980.247 2045.447 2047.759 2033.597 2027.500 2008.664
## [2,] 2032.560 2005.534 1979.034 2044.694 2046.319 2032.507 2029.203 2005.792
## [3,] 2032.242 2007.771 1977.199 2044.865 2047.746 2030.564 2024.003 2006.694
## [4,] 2029.852 2008.664 1977.590 2046.954 2046.213 2029.855 2024.339 2004.928
## [5,] 2028.301 2006.541 1976.787 2045.326 2045.797 2032.919 2023.972 2002.514
## [6,] 2029.447 2006.377 1978.966 2045.522 2044.628 2034.819 2028.265 2001.183
## [,257] [,258] [,259] [,260] [,261] [,262] [,263] [,264]
## [1,] 1952.744 1943.534 1876.188 1880.402 1839.827 1895.123 1857.678 1863.403
## [2,] 1953.194 1942.448 1872.794 1879.536 1837.837 1890.978 1858.753 1862.567
## [3,] 1950.941 1943.005 1873.749 1878.452 1836.859 1889.361 1855.146 1864.250
## [4,] 1950.603 1939.565 1872.019 1878.623 1837.592 1892.690 1856.109 1865.784
## [5,] 1949.365 1938.855 1870.719 1878.206 1836.621 1891.927 1857.928 1863.090
## [6,] 1948.967 1937.573 1869.544 1879.265 1837.673 1891.941 1858.160 1860.238
## [,265] [,266] [,267] [,268] [,269] [,270] [,271] [,272]
## [1,] 1889.022 1904.910 1958.961 1999.619 2060.717 2129.064 2138.481 2123.832
## [2,] 1889.216 1906.232 1957.348 2001.121 2060.669 2132.852 2138.586 2119.193
## [3,] 1890.988 1901.041 1955.480 2001.411 2060.405 2131.420 2137.981 2115.540
## [4,] 1894.653 1900.519 1956.495 1999.330 2058.487 2133.237 2134.444 2116.876
## [5,] 1894.269 1900.838 1953.455 1996.392 2058.520 2133.466 2134.320 2115.768
## [6,] 1899.954 1899.584 1952.068 1997.968 2062.033 2135.071 2136.359 2116.749
## [,273] [,274] [,275] [,276] [,277] [,278] [,279] [,280]
## [1,] 2094.721 2135.201 2094.605 2094.960 2150.756 2099.264 2070.320 2033.035
## [2,] 2094.800 2131.961 2092.759 2093.107 2152.347 2098.211 2073.017 2030.921
## [3,] 2091.608 2132.936 2091.787 2093.339 2148.834 2097.567 2073.947 2028.294
## [4,] 2091.858 2129.720 2090.264 2092.951 2147.818 2096.570 2071.874 2027.486
## [5,] 2089.829 2126.583 2091.772 2093.324 2150.798 2094.630 2070.733 2027.776
## [6,] 2087.817 2124.443 2091.264 2092.691 2151.895 2097.343 2071.313 2028.233
## [,281] [,282] [,283] [,284] [,285] [,286] [,287] [,288]
## [1,] 2017.803 2160.101 2185.866 2191.388 2198.046 2092.598 2094.504 2033.750
## [2,] 2021.296 2159.617 2183.855 2191.921 2202.035 2088.601 2091.605 2029.840
## [3,] 2020.325 2161.981 2183.749 2194.090 2199.096 2088.344 2089.855 2029.045
## [4,] 2020.070 2158.026 2183.900 2193.393 2199.390 2087.950 2089.867 2029.479
## [5,] 2021.257 2158.681 2183.593 2189.872 2198.304 2084.905 2087.528 2029.965
## [6,] 2022.180 2156.933 2182.814 2188.304 2199.445 2085.613 2086.791 2029.887
## [,289] [,290] [,291] [,292] [,293] [,294] [,295] [,296]
## [1,] 2065.179 2154.221 2126.328 2133.158 2179.247 2136.059 2182.157 2204.874
## [2,] 2063.237 2150.991 2127.082 2133.919 2177.869 2133.031 2182.632 2204.227
## [3,] 2065.938 2151.722 2126.618 2139.079 2177.126 2133.529 2182.221 2205.713
## [4,] 2067.393 2150.513 2124.931 2138.726 2177.003 2129.656 2181.504 2203.399
## [5,] 2069.443 2147.818 2125.890 2139.162 2174.858 2129.204 2182.084 2204.006
## [6,] 2069.357 2151.494 2121.549 2137.551 2179.469 2129.452 2181.658 2205.373
## [,297] [,298] [,299] [,300] [,301] [,302] [,303] [,304]
## [1,] 2180.889 2210.285 2258.230 2292.905 2235.001 2304.908 2269.877 2255.402
## [2,] 2177.435 2213.721 2257.270 2292.629 2236.132 2307.830 2271.698 2259.396
## [3,] 2176.694 2213.311 2256.172 2296.850 2232.276 2306.147 2267.338 2258.140
## [4,] 2173.623 2212.693 2257.423 2295.598 2231.572 2306.988 2263.842 2256.852
## [5,] 2170.463 2209.995 2255.830 2293.029 2234.322 2305.019 2265.688 2259.566
## [6,] 2171.869 2209.949 2255.037 2292.789 2234.036 2307.483 2265.569 2261.328
## [,305] [,306] [,307] [,308] [,309] [,310] [,311] [,312]
## [1,] 2290.734 2354.807 2363.676 2363.986 2510.124 2499.910 2621.326 2673.422
## [2,] 2287.801 2349.706 2364.083 2361.585 2513.186 2501.593 2624.691 2673.989
## [3,] 2285.558 2349.714 2362.573 2361.965 2514.543 2504.851 2623.449 2672.918
## [4,] 2285.310 2351.058 2363.155 2358.787 2510.537 2506.814 2623.704 2675.551
## [5,] 2286.548 2349.004 2368.980 2360.506 2516.031 2510.475 2624.743 2672.277
## [6,] 2289.478 2346.714 2367.125 2357.431 2513.438 2511.015 2626.775 2670.557
## [,313] [,314] [,315] [,316] [,317] [,318] [,319] [,320]
## [1,] 2640.377 2650.370 2697.531 2813.053 2741.037 2813.644 2848.949 2847.520
## [2,] 2637.946 2651.398 2694.935 2810.761 2740.793 2815.801 2850.452 2845.536
## [3,] 2639.349 2653.888 2696.407 2809.446 2737.453 2815.355 2852.581 2845.955
## [4,] 2638.060 2655.740 2698.444 2809.078 2739.058 2816.683 2854.905 2844.389
## [5,] 2640.542 2658.149 2699.211 2811.455 2738.641 2815.107 2854.826 2845.082
## [6,] 2638.172 2656.321 2697.973 2814.736 2736.412 2817.074 2845.364 2839.471
## [,321] [,322] [,323] [,324] [,325] [,326] [,327] [,328]
## [1,] 2846.205 2890.325 2865.368 2840.406 2901.507 2756.306 2781.521 2682.364
## [2,] 2843.150 2886.982 2862.207 2837.995 2895.338 2760.433 2781.732 2682.185
## [3,] 2839.925 2885.190 2867.968 2840.418 2890.964 2757.117 2780.779 2680.820
## [4,] 2841.087 2888.680 2868.932 2838.293 2885.999 2759.372 2776.822 2682.700
## [5,] 2840.093 2885.937 2865.238 2835.924 2886.557 2758.512 2775.331 2675.186
## [6,] 2838.002 2887.433 2868.087 2833.366 2886.834 2753.142 2776.876 2679.351
## [,329] [,330] [,331] [,332] [,333] [,334] [,335] [,336]
## [1,] 2692.918 2732.396 2786.443 2738.496 2661.705 2638.997 2736.517 2785.331
## [2,] 2694.546 2734.350 2790.127 2741.170 2660.927 2640.659 2735.061 2789.305
## [3,] 2694.714 2734.546 2789.663 2739.633 2653.650 2640.792 2734.943 2788.292
## [4,] 2696.648 2734.058 2792.310 2741.248 2654.721 2640.643 2739.104 2791.744
## [5,] 2692.683 2730.728 2789.219 2743.661 2649.182 2640.309 2733.156 2788.610
## [6,] 2697.721 2728.306 2785.569 2741.911 2656.229 2642.359 2728.074 2788.179
## [,337] [,338] [,339] [,340] [,341] [,342] [,343] [,344]
## [1,] 2780.295 2800.200 2855.392 2998.874 2971.760 2975.330 3125.103 3139.395
## [2,] 2780.224 2801.669 2856.888 2997.873 2971.529 2974.708 3124.148 3141.143
## [3,] 2777.330 2799.621 2854.106 2995.775 2974.392 2974.556 3127.641 3135.627
## [4,] 2778.203 2798.895 2851.155 2992.192 2969.672 2975.231 3132.836 3135.287
## [5,] 2778.321 2796.319 2852.167 2995.969 2968.569 2978.576 3139.703 3137.652
## [6,] 2779.697 2794.451 2856.871 2999.844 2967.741 2982.683 3139.102 3136.769
## [,345] [,346] [,347] [,348] [,349] [,350] [,351] [,352]
## [1,] 3149.582 3263.039 3227.902 3235.298 3212.664 3257.629 3238.204 3202.192
## [2,] 3151.142 3258.200 3224.131 3238.271 3214.888 3251.384 3239.902 3202.550
## [3,] 3149.599 3252.774 3224.020 3236.282 3220.218 3252.979 3237.723 3201.691
## [4,] 3146.017 3252.046 3221.245 3233.765 3221.934 3253.766 3234.244 3200.069
## [5,] 3148.153 3255.439 3223.970 3242.344 3224.539 3256.697 3232.984 3200.631
## [6,] 3145.084 3255.070 3227.480 3244.314 3219.288 3256.360 3237.436 3198.120
## [,353] [,354] [,355] [,356] [,357] [,358] [,359] [,360]
## [1,] 3246.021 3169.346 3093.696 3105.552 3315.596 3283.204 3234.593 3267.884
## [2,] 3244.060 3174.041 3089.196 3109.452 3315.812 3286.971 3236.604 3267.747
## [3,] 3248.184 3172.779 3091.950 3109.954 3310.301 3291.927 3238.867 3272.044
## [4,] 3252.670 3175.617 3090.893 3111.899 3312.302 3290.324 3239.191 3270.274
## [5,] 3252.195 3171.853 3084.010 3112.495 3313.957 3288.893 3238.378 3270.825
## [6,] 3251.281 3175.497 3084.974 3117.649 3314.507 3290.269 3235.533 3268.662
## [,361] [,362] [,363] [,364] [,365] [,366] [,367] [,368]
## [1,] 3360.138 3443.470 3424.354 3598.779 3567.524 3615.479 3724.551 3657.160
## [2,] 3365.591 3445.802 3421.192 3598.598 3565.096 3618.979 3724.376 3656.421
## [3,] 3368.715 3442.797 3421.518 3596.212 3557.508 3619.145 3724.498 3652.410
## [4,] 3367.645 3444.432 3421.088 3595.105 3556.578 3619.762 3725.023 3655.550
## [5,] 3369.046 3443.947 3418.009 3595.986 3553.935 3620.312 3717.823 3654.487
## [6,] 3367.054 3440.928 3415.962 3598.398 3563.328 3620.556 3711.308 3650.223
## [,369] [,370] [,371] [,372] [,373] [,374] [,375] [,376]
## [1,] 3737.419 3732.827 3741.874 3850.754 3926.355 3859.033 3771.722 3735.240
## [2,] 3735.088 3736.204 3743.762 3853.291 3920.369 3864.616 3770.597 3728.118
## [3,] 3735.516 3738.454 3742.126 3851.205 3927.298 3868.292 3774.673 3730.504
## [4,] 3733.973 3743.082 3741.394 3852.357 3930.208 3857.826 3772.482 3726.753
## [5,] 3736.510 3744.176 3740.897 3843.853 3933.169 3860.548 3768.462 3736.733
## [6,] 3731.641 3750.676 3740.409 3849.060 3944.110 3859.542 3770.654 3731.117
## [,377] [,378] [,379] [,380] [,381] [,382] [,383] [,384]
## [1,] 3800.936 3539.196 3502.177 3632.007 3701.896 3732.498 3595.860 3720.769
## [2,] 3794.923 3540.255 3492.781 3632.219 3706.108 3730.322 3587.672 3723.235
## [3,] 3802.757 3544.998 3489.318 3629.375 3710.504 3727.457 3588.007 3720.790
## [4,] 3803.532 3551.388 3495.800 3631.503 3713.639 3734.294 3590.131 3716.054
## [5,] 3808.444 3548.565 3493.364 3630.270 3702.131 3733.264 3582.737 3714.056
## [6,] 3804.791 3551.465 3494.826 3632.135 3701.756 3731.059 3582.799 3719.693
## [,385] [,386] [,387] [,388] [,389] [,390] [,391] [,392]
## [1,] 3789.087 3751.951 3866.296 3921.949 3873.236 3994.195 4026.774 4031.282
## [2,] 3792.190 3753.749 3865.294 3917.499 3877.941 4002.009 4020.577 4029.648
## [3,] 3794.048 3748.608 3860.703 3919.333 3871.333 3999.829 4023.372 4028.246
## [4,] 3784.330 3748.793 3862.749 3916.103 3873.534 4001.665 4028.196 4027.131
## [5,] 3782.795 3756.426 3867.434 3914.466 3873.168 4000.148 4024.495 4019.433
## [6,] 3779.312 3753.527 3868.153 3918.197 3875.085 4002.362 4025.333 4018.808
## [,393] [,394] [,395] [,396] [,397] [,398] [,399] [,400]
## [1,] 4010.922 4042.870 4018.389 3937.033 3960.864 4020.943 4112.858 4082.154
## [2,] 4011.592 4040.448 4008.856 3933.398 3959.788 4016.317 4119.924 4085.411
## [3,] 4011.582 4038.839 4011.429 3928.162 3955.185 4016.276 4119.004 4081.954
## [4,] 4011.443 4043.759 4006.341 3927.138 3957.889 4013.466 4112.994 4077.518
## [5,] 4004.147 4046.925 4010.565 3929.132 3961.857 4012.632 4117.950 4073.733
## [6,] 4002.288 4046.540 4008.288 3931.543 3964.353 4017.711 4110.116 4068.972
## [,401] [,402] [,403] [,404] [,405] [,406] [,407] [,408]
## [1,] 4058.059 3998.570 4017.335 3948.794 4047.732 4157.842 4333.825 4344.609
## [2,] 4061.543 3991.499 4019.650 3944.763 4049.272 4162.361 4333.711 4344.677
## [3,] 4059.993 4001.783 4018.771 3945.353 4052.376 4157.275 4331.346 4335.988
## [4,] 4055.491 4008.843 4020.951 3951.600 4055.440 4167.663 4328.281 4337.663
## [5,] 4051.660 4011.412 4016.117 3957.240 4050.159 4176.259 4321.164 4336.055
## [6,] 4046.241 4009.331 4012.326 3962.848 4048.294 4174.453 4317.330 4338.385
## [,409] [,410] [,411] [,412] [,413] [,414] [,415] [,416]
## [1,] 4372.985 4281.622 4356.793 4502.935 4462.130 4582.488 4596.948 4526.385
## [2,] 4377.232 4280.198 4359.130 4499.139 4459.548 4594.089 4607.172 4535.612
## [3,] 4379.298 4284.742 4365.525 4502.543 4464.683 4595.481 4604.859 4538.870
## [4,] 4386.121 4289.173 4365.853 4504.188 4469.048 4599.843 4598.693 4540.270
## [5,] 4384.959 4286.908 4364.396 4511.241 4472.800 4594.818 4592.167 4535.931
## [6,] 4382.886 4270.270 4364.734 4509.939 4472.551 4585.103 4588.810 4537.853
## [,417] [,418] [,419] [,420] [,421] [,422] [,423] [,424]
## [1,] 4584.906 4542.568 4451.371 4501.896 4633.516 4640.446 4809.956 4918.937
## [2,] 4582.372 4540.410 4453.330 4506.590 4632.556 4631.963 4796.642 4919.250
## [3,] 4577.052 4538.734 4454.862 4500.003 4631.561 4626.913 4797.777 4915.754
## [4,] 4583.162 4536.715 4453.392 4499.629 4629.172 4632.661 4799.643 4926.281
## [5,] 4585.224 4531.276 4463.007 4504.274 4628.028 4632.742 4796.812 4927.484
## [6,] 4572.268 4537.536 4470.747 4505.562 4628.100 4629.661 4796.973 4930.725
## [,425] [,426] [,427] [,428] [,429] [,430] [,431] [,432]
## [1,] 4943.808 5218.831 5303.293 5404.108 5378.225 5399.788 5613.290 5726.926
## [2,] 4947.832 5212.199 5299.993 5402.211 5378.249 5392.415 5613.845 5719.944
## [3,] 4956.005 5217.377 5294.604 5401.117 5378.493 5396.250 5614.397 5720.638
## [4,] 4956.313 5217.365 5299.801 5398.294 5382.335 5398.061 5616.842 5707.738
## [5,] 4952.356 5215.304 5289.313 5393.378 5379.399 5391.281 5619.735 5703.679
## [6,] 4952.243 5221.202 5287.906 5386.981 5370.107 5388.354 5630.923 5699.101
## [,433] [,434] [,435] [,436] [,437] [,438] [,439] [,440]
## [1,] 5716.541 5860.073 5836.589 5990.841 6171.960 6272.144 6168.084 6331.535
## [2,] 5724.813 5861.581 5837.999 5984.444 6165.218 6257.044 6167.737 6333.900
## [3,] 5717.106 5868.475 5836.848 5985.163 6165.941 6252.386 6163.016 6340.138
## [4,] 5719.375 5874.650 5833.154 5991.646 6159.400 6265.112 6154.837 6344.429
## [5,] 5723.752 5877.959 5818.338 5994.940 6163.216 6265.552 6157.512 6335.756
## [6,] 5734.525 5883.141 5825.589 5991.912 6156.895 6271.828 6161.277 6340.496
## [,441] [,442] [,443] [,444] [,445] [,446] [,447] [,448]
## [1,] 6418.375 6583.947 6539.283 6405.154 6274.960 6420.036 6303.201 6363.277
## [2,] 6420.743 6600.658 6527.141 6412.062 6264.337 6415.498 6297.446 6360.215
## [3,] 6420.576 6597.035 6518.624 6409.030 6256.878 6428.375 6296.871 6360.815
## [4,] 6424.954 6597.745 6524.219 6414.156 6254.236 6417.679 6289.652 6354.847
## [5,] 6426.556 6603.912 6518.154 6412.477 6258.670 6418.473 6286.766 6363.120
## [6,] 6419.588 6606.882 6533.485 6405.474 6264.864 6426.489 6285.687 6376.583
## [,449] [,450] [,451] [,452] [,453] [,454] [,455] [,456]
## [1,] 6413.598 6316.829 6105.752 6143.509 6197.133 6124.593 5832.266 5765.773
## [2,] 6416.215 6322.645 6104.262 6139.989 6185.425 6117.498 5839.480 5763.472
## [3,] 6410.557 6339.772 6108.839 6136.318 6184.077 6104.628 5844.271 5769.456
## [4,] 6409.779 6337.422 6111.069 6133.561 6168.751 6096.111 5852.464 5775.795
## [5,] 6403.350 6339.380 6119.688 6130.202 6181.537 6103.417 5850.674 5779.545
## [6,] 6398.080 6328.114 6128.898 6139.434 6175.833 6110.655 5838.329 5778.967
## [,457] [,458] [,459] [,460] [,461] [,462] [,463] [,464]
## [1,] 5732.081 5919.496 5766.271 5688.095 5821.570 5764.944 5874.165 6222.408
## [2,] 5744.829 5911.162 5762.599 5695.927 5813.454 5771.624 5868.373 6222.840
## [3,] 5741.551 5908.264 5764.336 5706.720 5801.634 5767.112 5864.048 6229.692
## [4,] 5749.354 5907.663 5763.186 5709.736 5795.588 5764.632 5866.770 6219.684
## [5,] 5752.312 5907.177 5771.713 5718.807 5802.926 5759.489 5868.952 6215.550
## [6,] 5762.954 5894.896 5766.546 5717.005 5805.599 5749.656 5872.770 6219.362
## [,465] [,466] [,467] [,468] [,469] [,470] [,471] [,472]
## [1,] 6030.130 5968.764 6038.841 6093.036 6210.085 6450.044 6752.210 6810.726
## [2,] 6028.602 5961.587 6034.273 6105.542 6202.222 6452.979 6755.178 6819.461
## [3,] 6022.221 5956.672 6041.168 6118.541 6197.912 6451.987 6750.645 6821.124
## [4,] 6009.227 5962.591 6044.538 6115.303 6199.427 6445.859 6744.009 6817.487
## [5,] 6012.827 5966.843 6044.868 6111.078 6189.602 6448.826 6742.696 6819.000
## [6,] 6012.377 5955.186 6056.532 6117.750 6190.905 6449.072 6737.394 6826.942
## [,473] [,474] [,475] [,476] [,477] [,478] [,479] [,480]
## [1,] 6893.725 6763.208 6801.850 6892.932 6647.245 6481.383 6471.868 6424.756
## [2,] 6894.891 6780.229 6802.100 6883.545 6643.219 6471.325 6473.259 6433.404
## [3,] 6885.918 6773.657 6805.886 6881.083 6634.833 6472.844 6475.717 6428.664
## [4,] 6876.895 6768.745 6814.002 6859.262 6634.412 6493.663 6473.732 6417.721
## [5,] 6874.081 6780.006 6811.075 6871.774 6636.199 6480.233 6474.028 6419.770
## [6,] 6864.102 6773.882 6816.899 6875.145 6647.405 6470.242 6466.798 6417.051
## [,481] [,482] [,483] [,484] [,485] [,486] [,487] [,488]
## [1,] 6359.820 6489.542 6439.720 6487.099 6472.277 6314.680 6461.664 6616.061
## [2,] 6367.235 6486.019 6436.712 6486.825 6478.438 6311.293 6459.415 6621.921
## [3,] 6351.520 6488.263 6426.894 6471.142 6468.637 6316.842 6462.195 6621.191
## [4,] 6356.376 6487.372 6430.808 6474.074 6466.108 6324.528 6458.990 6628.944
## [5,] 6362.102 6490.243 6425.205 6473.546 6480.222 6311.205 6444.744 6645.319
## [6,] 6354.989 6492.506 6408.233 6478.259 6471.409 6311.932 6440.293 6650.001
## [,489] [,490] [,491] [,492] [,493] [,494] [,495] [,496]
## [1,] 6469.134 6437.092 6253.439 6389.658 6585.859 6602.719 6591.821 6572.352
## [2,] 6464.293 6440.783 6263.703 6386.295 6588.162 6591.508 6591.279 6562.182
## [3,] 6471.370 6447.875 6250.358 6380.042 6588.997 6589.323 6595.826 6560.918
## [4,] 6464.938 6438.777 6250.883 6390.656 6590.246 6589.125 6597.946 6564.310
## [5,] 6466.964 6447.364 6259.862 6387.186 6588.807 6589.769 6588.035 6567.328
## [6,] 6471.269 6453.810 6263.845 6388.143 6593.279 6600.619 6581.912 6579.494
## [,497] [,498] [,499] [,500]
## [1,] 6419.338 6281.154 6632.882 6594.490
## [2,] 6403.503 6268.866 6629.783 6589.532
## [3,] 6399.397 6263.396 6641.469 6587.606
## [4,] 6411.950 6274.413 6636.104 6585.258
## [5,] 6411.293 6280.996 6625.515 6588.509
## [6,] 6412.646 6296.283 6623.459 6594.073
# Análisis: valor final del portafolio
final_values <- portfolio_values[n_days, ]
summary(final_values)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 654.9 1153.4 1916.4 2614.8 3731.8 6894.9
# VaR al 1% y 5%
VaR_1 <- quantile(final_values, probs = 0.01)
VaR_5 <- quantile(final_values, probs = 0.05)
cat("VaR al 1%:", VaR_1, "\n")
## VaR al 1%: 669.9733
cat("VaR al 5%:", VaR_5, "\n")
## VaR al 5%: 696.2228
# Histograma con líneas de VaR
hist(final_values, breaks = 50, col = "lightblue",
main = "Distribución del valor final del portafolio",
xlab = "Valor del portafolio (USD)")
abline(v = VaR_1, col = "red", lwd = 2)
abline(v = VaR_5, col = "orange", lwd = 2)
legend("topright", legend = c("VaR 1%", "VaR 5%"),
col = c("red", "orange"), lwd = 2)
#INTERPRETACION
###Para cada acción, seleccionamos opciones con vencimiento trimestral hasta 2 años. Tipo de opciones: Put: para proteger contra caídas (cobertura directa). Call vendidas: para generar ingresos si el precio no sube demasiado (estrategia de ingresos). Strike price: puede ser el precio actual o el promedio simulado. Modelo de valuación: Europeas: Black-Scholes. Americanas: Árbol binomial.
# Función para opción europea tipo call
BS_Call <- function(S, K, r, sigma, T){
d1 <- (log(S/K) + (r + 0.5*sigma^2)*T) / (sigma * sqrt(T))
d2 <- d1 - sigma * sqrt(T)
C <- S * pnorm(d1) - K * exp(-r * T) * pnorm(d2)
return(C)
}
# Función para opción europea tipo put
BS_Put <- function(S, K, r, sigma, T){
d1 <- (log(S/K) + (r + 0.5*sigma^2)*T) / (sigma * sqrt(T))
d2 <- d1 - sigma * sqrt(T)
P <- K * exp(-r * T) * pnorm(-d2) - S * pnorm(-d1)
return(P)
}
# Tasa del bono a 10 años
r <- 0.045
# Tiempo hasta vencimiento (trimestre)
T <- 0.25
# AAPL
S_AAPL <- 170 # Precio actual
K_AAPL <- 170 # Strike
sigma_AAPL <- 0.25 # Volatilidad
# NFLX
S_NFLX <- 400
K_NFLX <- 400
sigma_NFLX <- 0.30
# LLY
S_LLY <- 600
K_LLY <- 600
sigma_LLY <- 0.22
# AAPL
call_AAPL <- BS_Call(S_AAPL, K_AAPL, r, sigma_AAPL, T)
put_AAPL <- BS_Put(S_AAPL, K_AAPL, r, sigma_AAPL, T)
# NFLX
call_NFLX <- BS_Call(S_NFLX, K_NFLX, r, sigma_NFLX, T)
put_NFLX <- BS_Put(S_NFLX, K_NFLX, r, sigma_NFLX, T)
# LLY
call_LLY <- BS_Call(S_LLY, K_LLY, r, sigma_LLY, T)
put_LLY <- BS_Put(S_LLY, K_LLY, r, sigma_LLY, T)
# Mostrar resultados
cat("AAPL - Call:", call_AAPL, " Put:", put_AAPL, "\n")
## AAPL - Call: 9.409563 Put: 7.50778
cat("NFLX - Call:", call_NFLX, " Put:", put_NFLX, "\n")
## NFLX - Call: 26.08447 Put: 21.60969
cat("LLY - Call:", call_LLY, " Put:", put_LLY, "\n")
## LLY - Call: 29.66241 Put: 22.95024
###La valuación de opciones europeas mediante el modelo de Black-Scholes permite estimar el costo teórico de cobertura por activo. Las primas obtenidas reflejan la volatilidad implícita de cada acción, siendo más elevadas en NFLX y LLY. La opción put sobre AAPL, por ejemplo, tiene una prima de 7.51 USD, lo que implica un costo total de cobertura de aproximadamente 171,600 USD para cubrir el monto asignado. Esta información es clave para dimensionar el gasto en derivados y evaluar la eficiencia de la estrategia de protección del portafolio.
# Función para opción americana tipo PUT con árbol binomial
binomial_tree_american_put <- function(S, K, r, sigma, T, steps) {
dt <- T / steps
u <- exp(sigma * sqrt(dt))
d <- 1 / u
p <- (exp(r * dt) - d) / (u - d)
# Árbol de precios
prices <- matrix(0, nrow = steps + 1, ncol = steps + 1)
for (i in 0:steps) {
for (j in 0:i) {
prices[j + 1, i + 1] <- S * u^j * d^(i - j)
}
}
# Árbol de valores de opción
option <- matrix(0, nrow = steps + 1, ncol = steps + 1)
for (j in 0:steps) {
option[j + 1, steps + 1] <- max(K - prices[j + 1, steps + 1], 0)
}
# Retroceso en el árbol
for (i in (steps - 1):0) {
for (j in 0:i) {
hold <- exp(-r * dt) * (p * option[j + 2, i + 2] + (1 - p) * option[j + 1, i + 2])
exercise <- max(K - prices[j + 1, i + 1], 0)
option[j + 1, i + 1] <- max(hold, exercise)
}
}
return(option[1, 1])
}
# Parámetros de prueba
S <- 170 # Precio actual
K <- 170 # Strike
r <- 0.045 # Tasa libre de riesgo
sigma <- 0.25 # Volatilidad
T <- 0.25 # Tiempo en años
steps <- 100 # Pasos del árbol
# Ejecutar función
binomial_tree_american_put(S, K, r, sigma, T, steps)
## [1] 7.650303
# Parámetros generales
r <- 0.045
T <- 0.25
steps <- 100
# AAPL
put_AAPL <- binomial_tree_american_put(S = 170, K = 170, r = r, sigma = 0.25, T = T, steps = steps)
# NFLX
put_NFLX <- binomial_tree_american_put(S = 400, K = 400, r = r, sigma = 0.30, T = T, steps = steps)
# LLY
put_LLY <- binomial_tree_american_put(S = 600, K = 600, r = r, sigma = 0.22, T = T, steps = steps)
# Mostrar resultados
cat("AAPL - Put americana:", put_AAPL, "\n")
## AAPL - Put americana: 7.650303
cat("NFLX - Put americana:", put_NFLX, "\n")
## NFLX - Put americana: 21.92848
cat("LLY - Put americana:", put_LLY, "\n")
## LLY - Put americana: 23.47025
###El análisis realizado permitió valorar el riesgo de un portafolio compuesto por tres activos (AAPL, NFLX y LLY) mediante simulaciones estocásticas y métricas de Value at Risk (VaR), evidenciando escenarios de pérdida extrema que justifican la implementación de una estrategia de cobertura. La valuación de opciones europeas y americanas, tanto call como put, se realizó utilizando modelos robustos (Black-Scholes y árbol binomial), y se seleccionaron opciones americanas tipo put como instrumento principal de protección por su flexibilidad de ejercicio anticipado.
###La cobertura se estructuró sobre el 85% de la inversión total, distribuida proporcionalmente según los pesos del portafolio optimizado. El costo total de cobertura fue estimado en 391,459 USD, financiado mediante apalancamiento con la tasa del bono del tesoro (4.5%), lo cual permite mantener la exposición al mercado sin comprometer la liquidez inmediata.
Hull, J. C. (2017). Options, Futures, and Other Derivatives (9th ed.). Pearson Education. R Core Team. (2023). R: A language and environment for statistical computing. R Foundation for Statistical Computing. https://www.R-project.org/ U.S. Department of the Treasury. (2025). Daily Treasury Yield Curve Rates. https://home.treasury.gov/resource-center/data-chart-center/interest-rates