library("tseries")
library("PortfolioAnalytics")
library("quantmod")
library("Quandl")
library("DEoptim")
# BSE Stocks(S&P BSE SENSEX)
getSymbols("^BSESN", src="yahoo", from="2008-01-01", to="2018-01-01")
Warning: ^BSESN contains missing values. Some functions will not work if objects contain missing values in the middle of the series. Consider using na.omit(), na.approx(), na.fill(), etc to remove or replace them.
[1] "^BSESN"
bse_stocks <- BSESN[,6]
na.omit(bse_stocks)
BSESN.Adjusted
2008-01-02 20465.30
2008-01-03 20345.20
2008-01-04 20686.89
2008-01-07 20812.65
2008-01-08 20873.33
2008-01-09 20869.78
2008-01-10 20582.08
2008-01-11 20827.45
2008-01-14 20728.05
2008-01-15 20251.09
2008-01-16 19868.11
2008-01-17 19700.82
2008-01-18 19013.70
2008-01-21 17605.35
2008-01-22 16729.94
2008-01-23 17594.07
2008-01-24 17221.74
2008-01-25 18361.66
2008-01-28 18152.78
2008-01-29 18091.94
2008-01-30 17758.64
2008-01-31 17648.71
2008-02-01 18242.58
2008-02-04 18660.32
2008-02-05 18663.16
2008-02-06 18139.49
2008-02-07 17526.93
2008-02-08 17464.89
2008-02-11 16630.91
2008-02-12 16608.01
2008-02-13 16949.14
2008-02-14 17766.63
2008-02-15 18115.25
2008-02-18 18048.05
2008-02-19 18075.66
2008-02-20 17617.60
2008-02-21 17734.68
2008-02-22 17349.07
2008-02-25 17650.57
2008-02-26 17806.19
2008-02-27 17825.99
2008-02-28 17824.48
2008-02-29 17578.72
2008-03-03 16677.88
2008-03-04 16339.89
2008-03-05 16542.08
2008-03-07 15975.52
2008-03-10 15923.72
2008-03-11 16123.15
2008-03-12 16127.98
2008-03-13 15357.35
2008-03-14 15760.52
2008-03-17 14809.49
2008-03-18 14833.46
2008-03-19 14994.83
2008-03-24 15289.40
2008-03-25 16217.49
2008-03-26 16086.83
2008-03-27 16015.56
2008-03-28 16371.29
2008-03-31 15644.44
2008-04-01 15626.62
2008-04-02 15750.40
2008-04-03 15832.55
2008-04-04 15343.12
2008-04-07 15757.08
2008-04-08 15587.62
2008-04-09 15790.51
2008-04-10 15695.10
2008-04-11 15807.64
2008-04-15 16153.66
2008-04-16 16244.19
2008-04-17 16481.20
2008-04-21 16739.33
2008-04-22 16783.87
2008-04-23 16698.04
2008-04-24 16721.08
2008-04-25 17125.98
2008-04-28 17015.96
2008-04-29 17378.46
2008-04-30 17287.31
2008-05-02 17600.12
2008-05-05 17490.90
2008-05-06 17373.01
2008-05-07 17339.31
2008-05-08 17080.65
2008-05-09 16737.07
2008-05-12 16860.90
2008-05-13 16752.86
2008-05-14 16978.35
2008-05-15 17353.54
2008-05-16 17434.94
2008-05-20 17230.18
2008-05-21 17243.16
2008-05-22 16907.11
2008-05-23 16649.64
2008-05-26 16348.50
2008-05-27 16275.59
2008-05-28 16525.37
2008-05-29 16316.26
2008-05-30 16415.57
2008-06-02 16063.18
2008-06-03 15962.56
2008-06-04 15514.79
2008-06-05 15769.72
2008-06-06 15572.18
2008-06-09 15066.10
2008-06-10 14889.25
2008-06-11 15185.32
2008-06-12 15250.20
2008-06-13 15189.62
2008-06-16 15395.82
2008-06-17 15696.90
2008-06-18 15422.31
2008-06-19 15087.99
2008-06-20 14571.29
2008-06-23 14293.32
2008-06-24 14106.58
2008-06-25 14220.07
2008-06-26 14421.82
2008-06-27 13802.22
2008-06-30 13461.60
2008-07-01 12961.68
2008-07-02 13664.62
2008-07-03 13094.11
2008-07-04 13454.00
2008-07-07 13525.99
2008-07-08 13349.65
2008-07-09 13964.26
2008-07-10 13926.24
2008-07-11 13469.85
2008-07-14 13330.51
2008-07-15 12676.19
2008-07-16 12575.80
2008-07-17 13111.85
2008-07-18 13635.40
2008-07-21 13850.04
2008-07-22 14104.20
2008-07-23 14942.28
2008-07-24 14777.01
2008-07-25 14274.94
2008-07-28 14349.11
2008-07-29 13791.54
2008-07-30 14287.21
2008-07-31 14355.75
2008-08-01 14656.69
2008-08-04 14577.87
2008-08-05 14961.07
2008-08-06 15073.54
2008-08-07 15117.25
2008-08-08 15167.82
2008-08-11 15503.92
2008-08-12 15212.13
2008-08-13 15093.12
2008-08-14 14724.18
2008-08-18 14645.66
2008-08-19 14543.73
2008-08-20 14678.23
2008-08-21 14243.73
2008-08-22 14401.49
2008-08-25 14450.35
2008-08-26 14482.22
2008-08-27 14296.79
2008-08-28 14048.34
2008-08-29 14564.53
2008-09-01 14498.51
2008-09-02 15049.86
2008-09-04 14899.10
2008-09-05 14483.83
2008-09-08 14944.97
2008-09-09 14900.76
2008-09-10 14662.61
2008-09-11 14324.29
2008-09-12 14000.81
2008-09-15 13531.27
2008-09-16 13518.80
2008-09-17 13262.90
2008-09-18 13315.60
2008-09-19 14042.32
2008-09-22 13994.96
2008-09-23 13570.31
2008-09-24 13692.52
2008-09-25 13547.18
2008-09-26 13102.18
2008-09-29 12595.75
2008-09-30 12860.43
2008-10-01 13055.67
2008-10-03 12526.32
2008-10-06 11801.70
2008-10-07 11695.24
2008-10-08 11328.36
2008-10-10 10527.85
2008-10-13 11309.09
2008-10-14 11483.40
2008-10-15 10809.12
2008-10-16 10581.49
2008-10-17 9975.35
2008-10-20 10223.09
2008-10-21 10683.39
2008-10-22 10169.90
2008-10-23 9771.70
2008-10-24 8701.07
2008-10-27 8509.56
2008-10-29 9044.51
2008-10-31 9788.06
2008-11-03 10337.68
2008-11-04 10631.12
2008-11-05 10120.01
2008-11-06 9734.22
2008-11-07 9964.29
2008-11-10 10536.16
2008-11-11 9839.69
2008-11-12 9536.33
2008-11-14 9385.42
2008-11-17 9291.01
2008-11-18 8937.20
2008-11-19 8773.78
2008-11-20 8451.01
2008-11-21 8915.21
2008-11-24 8903.12
2008-11-25 8695.53
2008-11-26 9026.72
2008-11-28 9092.72
2008-12-01 8839.87
2008-12-02 8739.24
2008-12-03 8747.43
2008-12-04 9229.75
2008-12-05 8965.20
2008-12-08 9162.62
2008-12-10 9654.90
2008-12-11 9645.46
2008-12-12 9690.07
2008-12-15 9832.39
2008-12-16 9976.98
2008-12-17 9715.29
2008-12-18 10076.43
2008-12-19 10099.91
2008-12-22 9928.35
2008-12-23 9686.75
2008-12-24 9568.72
2008-12-26 9328.92
2008-12-29 9533.52
2008-12-30 9716.16
2008-12-31 9647.31
2009-01-02 9958.22
2009-01-05 10275.60
2009-01-06 10335.93
2009-01-07 9586.88
2009-01-09 9406.47
2009-01-12 9110.05
2009-01-13 9071.36
2009-01-14 9370.49
2009-01-15 9046.74
2009-01-16 9323.59
2009-01-19 9329.57
2009-01-20 9100.55
2009-01-21 8779.17
2009-01-22 8813.84
2009-01-23 8674.35
2009-01-27 9004.08
2009-01-28 9257.47
2009-01-29 9236.28
2009-01-30 9424.24
2009-02-02 9066.70
2009-02-03 9149.30
2009-02-04 9201.85
2009-02-05 9090.88
2009-02-06 9300.86
2009-02-09 9583.89
2009-02-10 9647.47
2009-02-11 9618.54
2009-02-12 9465.83
2009-02-13 9634.74
2009-02-16 9305.45
2009-02-17 9035.00
2009-02-18 9015.18
2009-02-19 9042.63
2009-02-20 8843.21
2009-02-24 8822.06
2009-02-25 8902.56
2009-02-26 8954.86
2009-02-27 8891.61
2009-03-02 8607.08
2009-03-03 8427.29
2009-03-04 8446.49
2009-03-05 8197.92
2009-03-06 8325.82
2009-03-09 8160.40
2009-03-12 8343.75
2009-03-13 8756.61
2009-03-16 8943.54
2009-03-17 8863.82
2009-03-18 8976.68
2009-03-19 9001.75
2009-03-20 8966.68
2009-03-23 9424.02
2009-03-24 9471.04
2009-03-25 9667.90
2009-03-26 10003.10
2009-03-27 10048.49
2009-03-30 9568.14
2009-03-31 9708.50
2009-04-01 9901.99
2009-04-02 10348.83
2009-04-06 10534.87
2009-04-08 10742.34
2009-04-09 10803.86
2009-04-13 10967.22
2009-04-15 11284.73
2009-04-16 10947.40
2009-04-17 11023.09
2009-04-20 10979.50
2009-04-21 10898.11
2009-04-22 10817.54
2009-04-23 11134.99
2009-04-24 11329.05
2009-04-27 11371.85
2009-04-28 11001.75
2009-04-29 11403.25
2009-05-04 12134.75
2009-05-05 12131.08
2009-05-06 11952.75
2009-05-07 12116.94
2009-05-08 11876.43
2009-05-11 11682.99
2009-05-12 12158.03
2009-05-13 12019.65
2009-05-14 11872.91
2009-05-15 12173.42
2009-05-18 14284.21
2009-05-19 14302.03
2009-05-20 14060.66
2009-05-21 13736.54
2009-05-22 13887.15
2009-05-25 13913.22
2009-05-26 13589.23
2009-05-27 14109.64
2009-05-28 14296.01
2009-05-29 14625.25
2009-06-01 14840.63
2009-06-02 14874.91
2009-06-03 14870.90
2009-06-04 15008.68
2009-06-05 15103.55
2009-06-08 14665.92
2009-06-09 15127.00
2009-06-10 15466.81
2009-06-11 15411.47
2009-06-12 15237.94
2009-06-15 14875.52
2009-06-16 14957.91
2009-06-17 14522.84
2009-06-18 14265.53
2009-06-19 14521.89
2009-06-22 14326.22
2009-06-23 14324.01
2009-06-24 14422.73
2009-06-25 14345.62
2009-06-26 14764.64
2009-06-29 14785.74
2009-06-30 14493.84
2009-07-01 14645.47
2009-07-02 14658.49
2009-07-03 14913.05
2009-07-06 14043.40
2009-07-07 14170.45
2009-07-08 13769.15
2009-07-09 13757.46
2009-07-10 13504.22
2009-07-13 13400.32
2009-07-14 13853.70
2009-07-15 14253.24
2009-07-16 14250.25
2009-07-17 14744.92
2009-07-20 15191.01
2009-07-21 15062.49
2009-07-22 14843.12
2009-07-23 15231.04
2009-07-24 15378.96
2009-07-27 15375.04
2009-07-28 15331.94
2009-07-29 15173.46
2009-07-30 15387.96
2009-07-31 15670.31
2009-08-03 15924.23
2009-08-04 15830.98
2009-08-05 15903.83
2009-08-06 15514.03
2009-08-07 15160.24
2009-08-10 15009.77
2009-08-11 15074.59
2009-08-12 15020.16
2009-08-13 15518.49
2009-08-14 15411.63
2009-08-17 14784.92
2009-08-18 15035.26
2009-08-19 14809.64
2009-08-20 15012.32
2009-08-21 15240.83
2009-08-24 15628.75
2009-08-25 15688.47
2009-08-26 15769.85
2009-08-27 15781.07
2009-08-28 15922.34
2009-08-31 15666.64
2009-09-01 15551.19
2009-09-02 15467.46
2009-09-03 15398.33
2009-09-04 15689.12
2009-09-07 16016.32
2009-09-08 16123.67
2009-09-09 16183.55
2009-09-10 16216.86
2009-09-11 16264.30
2009-09-14 16214.19
2009-09-15 16454.45
2009-09-16 16677.04
2009-09-17 16711.11
2009-09-18 16741.30
2009-09-22 16886.43
2009-09-23 16719.50
2009-09-24 16781.43
2009-09-25 16693.00
2009-09-29 16852.91
2009-09-30 17126.84
2009-10-01 17134.55
2009-10-05 16866.41
2009-10-06 16958.54
2009-10-07 16806.66
2009-10-08 16843.54
2009-10-09 16642.66
2009-10-12 17026.67
2009-10-14 17231.11
2009-10-15 17195.20
2009-10-16 17322.82
2009-10-20 17223.01
2009-10-21 17009.17
2009-10-22 16789.74
2009-10-23 16810.81
2009-10-26 16740.50
2009-10-27 16353.40
2009-10-28 16283.49
2009-10-29 16052.72
2009-10-30 15896.28
2009-11-03 15404.94
2009-11-04 15912.13
2009-11-05 16063.90
2009-11-06 16158.28
2009-11-09 16498.72
2009-11-10 16440.56
2009-11-11 16849.60
2009-11-12 16696.03
2009-11-13 16848.83
2009-11-16 17032.51
2009-11-17 17050.65
2009-11-18 16998.78
2009-11-19 16785.65
2009-11-20 17021.85
2009-11-23 17180.18
2009-11-24 17131.08
2009-11-25 17198.95
2009-11-26 16854.93
2009-11-27 16632.01
2009-11-30 16926.22
2009-12-01 17198.27
2009-12-02 17169.91
2009-12-03 17185.68
2009-12-04 17101.54
2009-12-07 16983.14
2009-12-08 17227.68
2009-12-09 17125.22
2009-12-10 17189.31
2009-12-11 17119.03
2009-12-14 17097.55
2009-12-15 16877.16
2009-12-16 16912.77
2009-12-17 16894.25
2009-12-18 16719.83
2009-12-21 16601.20
2009-12-22 16692.00
2009-12-23 17231.11
2009-12-24 17360.61
2009-12-29 17401.56
2009-12-30 17343.82
2009-12-31 17464.81
2010-01-04 17558.73
2010-01-05 17686.24
2010-01-06 17701.13
2010-01-07 17615.72
2010-01-08 17540.29
2010-01-11 17526.71
2010-01-12 17422.51
2010-01-13 17509.80
2010-01-14 17584.87
2010-01-15 17554.30
2010-01-18 17641.08
2010-01-19 17486.06
2010-01-20 17474.49
2010-01-21 17051.14
2010-01-22 16859.68
2010-01-25 16780.46
2010-01-27 16289.82
2010-01-28 16306.87
2010-01-29 16357.96
2010-02-01 16356.03
2010-02-02 16163.44
2010-02-03 16496.05
2010-02-04 16224.95
2010-02-05 15790.93
2010-02-08 15935.61
2010-02-09 16042.18
2010-02-10 15922.17
2010-02-11 16152.59
2010-02-15 16038.35
2010-02-16 16226.68
2010-02-17 16428.91
2010-02-18 16327.84
2010-02-19 16191.63
2010-02-22 16237.05
2010-02-23 16286.32
2010-02-24 16255.97
2010-02-25 16254.20
2010-02-26 16429.55
2010-03-02 16772.56
2010-03-03 17000.01
2010-03-04 16971.70
2010-03-05 16994.49
2010-03-08 17102.60
2010-03-09 17052.54
2010-03-10 17098.33
2010-03-11 17167.96
2010-03-12 17166.62
2010-03-15 17164.99
2010-03-16 17383.18
2010-03-17 17490.08
2010-03-18 17519.26
2010-03-19 17578.23
2010-03-22 17410.57
2010-03-23 17451.02
2010-03-25 17558.85
2010-03-26 17644.76
2010-03-29 17711.35
2010-03-30 17590.17
2010-03-31 17527.77
2010-04-01 17692.62
2010-04-05 17935.68
2010-04-06 17941.37
2010-04-07 17970.02
2010-04-08 17714.40
2010-04-09 17933.14
2010-04-12 17853.00
2010-04-13 17821.96
2010-04-15 17639.26
2010-04-16 17591.18
2010-04-19 17400.68
2010-04-20 17460.58
2010-04-21 17472.56
2010-04-22 17573.99
2010-04-23 17694.20
2010-04-26 17745.28
2010-04-27 17690.62
2010-04-28 17380.08
2010-04-29 17503.47
2010-04-30 17558.71
2010-05-03 17386.08
2010-05-04 17137.14
2010-05-05 17087.96
2010-05-06 16987.53
2010-05-07 16769.11
2010-05-10 17330.55
2010-05-11 17141.53
2010-05-12 17195.81
2010-05-13 17265.87
2010-05-14 16994.60
2010-05-17 16835.56
2010-05-18 16875.76
2010-05-19 16408.49
2010-05-20 16519.68
2010-05-21 16445.61
2010-05-24 16469.55
2010-05-25 16022.48
2010-05-26 16387.84
2010-05-27 16666.40
2010-05-28 16863.06
2010-05-31 16944.63
2010-06-01 16572.03
2010-06-02 16741.84
2010-06-03 17022.33
2010-06-04 17117.69
2010-06-07 16781.07
2010-06-08 16617.10
2010-06-09 16657.89
2010-06-10 16922.08
2010-06-11 17064.95
2010-06-14 17338.17
2010-06-15 17412.83
2010-06-16 17462.87
2010-06-17 17616.69
2010-06-18 17570.82
2010-06-21 17876.55
2010-06-22 17749.69
2010-06-23 17755.94
2010-06-24 17730.24
2010-06-25 17574.53
2010-06-28 17774.26
2010-06-29 17534.09
2010-06-30 17700.90
2010-07-01 17509.33
2010-07-02 17460.95
2010-07-05 17441.44
2010-07-06 17614.48
2010-07-07 17471.03
2010-07-08 17651.73
2010-07-09 17833.54
2010-07-12 17937.20
2010-07-13 17985.90
2010-07-14 17938.16
2010-07-15 17909.46
2010-07-16 17955.82
2010-07-19 17928.42
2010-07-20 17878.14
2010-07-21 17977.23
2010-07-22 18113.15
2010-07-23 18130.98
2010-07-26 18020.05
2010-07-27 18077.61
2010-07-28 17957.37
2010-07-29 17992.00
2010-07-30 17868.29
2010-08-02 18081.21
2010-08-03 18114.83
2010-08-04 18217.44
2010-08-05 18172.83
2010-08-06 18143.99
2010-08-09 18287.50
2010-08-10 18219.99
2010-08-11 18070.19
2010-08-12 18073.90
2010-08-13 18167.03
2010-08-16 18050.78
2010-08-17 18048.85
2010-08-18 18257.12
2010-08-19 18454.94
2010-08-20 18401.82
2010-08-23 18409.35
2010-08-24 18311.59
2010-08-25 18179.64
2010-08-26 18226.35
2010-08-27 17998.41
2010-08-30 18032.11
2010-08-31 17971.12
2010-09-01 18205.87
2010-09-02 18238.31
2010-09-03 18221.43
2010-09-06 18560.05
2010-09-07 18645.06
2010-09-08 18666.71
2010-09-09 18799.66
2010-09-13 19208.33
2010-09-14 19346.96
2010-09-15 19502.11
2010-09-16 19417.49
2010-09-17 19594.75
2010-09-20 19906.10
2010-09-21 20001.55
2010-09-22 19941.72
2010-09-23 19861.01
2010-09-24 20045.18
2010-09-27 20117.38
2010-09-28 20104.86
2010-09-29 19956.34
2010-09-30 20069.12
2010-10-01 20445.04
2010-10-04 20475.73
2010-10-05 20407.71
2010-10-06 20543.08
2010-10-07 20315.32
2010-10-08 20250.26
2010-10-11 20339.89
2010-10-12 20203.34
2010-10-13 20687.88
2010-10-14 20497.64
2010-10-15 20125.05
2010-10-18 20168.89
2010-10-19 19983.13
2010-10-20 19872.15
2010-10-21 20260.58
2010-10-22 20165.86
2010-10-25 20303.12
2010-10-26 20221.39
2010-10-27 20005.37
2010-10-28 19941.04
2010-10-29 20032.34
2010-11-01 20355.63
2010-11-02 20345.69
2010-11-03 20465.74
2010-11-04 20893.57
2010-11-08 20852.38
2010-11-09 20932.48
2010-11-10 20875.71
2010-11-11 20589.09
2010-11-12 20156.89
2010-11-15 20309.69
2010-11-16 19865.14
2010-11-18 19930.64
2010-11-19 19585.44
2010-11-22 19957.59
2010-11-23 19691.84
2010-11-24 19459.85
2010-11-25 19318.16
2010-11-26 19136.61
2010-11-29 19405.10
2010-11-30 19521.25
2010-12-01 19850.00
2010-12-02 19992.70
2010-12-03 19966.93
2010-12-06 19981.31
2010-12-07 19934.64
2010-12-08 19696.48
2010-12-09 19242.36
2010-12-10 19508.89
2010-12-13 19691.78
2010-12-14 19799.19
2010-12-15 19647.77
2010-12-16 19864.85
2010-12-20 19888.88
2010-12-21 20060.32
2010-12-22 20015.80
2010-12-23 19982.88
2010-12-24 20073.66
2010-12-27 20028.93
2010-12-28 20025.42
2010-12-29 20256.03
2010-12-30 20389.07
2010-12-31 20509.09
2011-01-03 20561.05
2011-01-04 20498.72
2011-01-05 20301.10
2011-01-06 20184.74
2011-01-07 19691.81
2011-01-10 19224.12
2011-01-11 19196.34
2011-01-12 19534.10
2011-01-13 19182.82
2011-01-14 18860.44
2011-01-17 18882.25
2011-01-18 19092.05
2011-01-19 18978.32
2011-01-20 19046.54
2011-01-21 19007.53
2011-01-24 19151.28
2011-01-25 18969.45
2011-01-27 18684.43
2011-01-28 18395.97
2011-01-31 18327.76
2011-02-01 18022.22
2011-02-02 18090.62
2011-02-03 18449.31
2011-02-04 18008.15
2011-02-07 18037.19
2011-02-08 17775.70
2011-02-09 17592.77
2011-02-10 17463.04
2011-02-11 17728.61
2011-02-14 18202.20
2011-02-15 18273.80
2011-02-16 18300.90
2011-02-17 18506.82
2011-02-18 18211.52
2011-02-21 18438.31
2011-02-22 18296.16
2011-02-23 18178.33
2011-02-24 17632.41
2011-02-25 17700.91
2011-02-28 17823.40
2011-03-01 18446.50
2011-03-03 18489.76
2011-03-04 18486.45
2011-03-07 18222.67
2011-03-08 18439.65
2011-03-09 18469.95
2011-03-10 18327.98
2011-03-11 18174.09
2011-03-14 18439.48
2011-03-15 18167.64
2011-03-16 18358.69
2011-03-17 18149.87
2011-03-18 17878.81
2011-03-21 17839.05
2011-03-22 17988.30
2011-03-23 18206.16
2011-03-24 18350.74
2011-03-25 18815.64
2011-03-28 18943.14
2011-03-29 19120.80
2011-03-30 19290.18
2011-03-31 19445.22
2011-04-01 19420.39
2011-04-04 19701.73
2011-04-05 19686.82
2011-04-06 19612.20
2011-04-07 19591.18
2011-04-08 19451.45
2011-04-11 19262.54
2011-04-13 19696.86
2011-04-15 19386.82
2011-04-18 19091.17
2011-04-19 19121.83
2011-04-20 19470.98
2011-04-21 19602.23
2011-04-25 19584.31
2011-04-26 19545.35
2011-04-27 19448.69
2011-04-28 19292.02
2011-04-29 19135.96
2011-05-02 18998.02
2011-05-03 18534.69
2011-05-04 18469.36
2011-05-05 18210.58
2011-05-06 18518.81
2011-05-09 18528.96
2011-05-10 18512.77
2011-05-11 18584.96
2011-05-12 18335.79
2011-05-13 18531.28
2011-05-16 18345.03
2011-05-17 18137.35
2011-05-18 18086.20
2011-05-19 18141.40
2011-05-20 18326.09
2011-05-23 17993.33
2011-05-24 18011.97
2011-05-25 17847.24
2011-05-26 18044.64
2011-05-27 18266.10
2011-05-30 18232.06
2011-05-31 18503.28
2011-06-01 18608.81
2011-06-02 18494.18
2011-06-03 18376.48
2011-06-06 18420.11
2011-06-07 18495.62
2011-06-08 18394.29
2011-06-09 18384.90
2011-06-10 18268.54
2011-06-13 18266.03
2011-06-14 18308.66
2011-06-15 18132.24
2011-06-16 17985.88
2011-06-17 17870.53
2011-06-20 17506.63
2011-06-21 17560.30
2011-06-22 17550.63
2011-06-23 17727.49
2011-06-24 18240.68
2011-06-27 18412.41
2011-06-28 18492.45
2011-06-29 18693.86
2011-06-30 18845.87
2011-07-01 18762.80
2011-07-04 18814.48
2011-07-05 18744.56
2011-07-06 18726.97
2011-07-07 19078.30
2011-07-08 18858.04
2011-07-11 18721.39
2011-07-12 18411.62
2011-07-13 18596.02
2011-07-14 18618.20
2011-07-15 18561.92
2011-07-18 18507.04
2011-07-19 18653.87
2011-07-20 18502.38
2011-07-21 18436.19
2011-07-22 18722.30
2011-07-25 18871.29
2011-07-26 18518.22
2011-07-27 18432.25
2011-07-28 18209.52
2011-07-29 18197.20
2011-08-01 18314.33
2011-08-02 18109.89
2011-08-03 17940.55
2011-08-04 17693.18
2011-08-05 17305.87
2011-08-08 16990.18
2011-08-09 16857.91
2011-08-10 17130.51
2011-08-11 17059.40
2011-08-12 16839.63
2011-08-16 16730.94
2011-08-17 16840.80
2011-08-18 16469.79
2011-08-19 16141.67
2011-08-22 16341.70
2011-08-23 16498.47
2011-08-24 16284.98
2011-08-25 16146.33
2011-08-26 15848.83
2011-08-29 16416.33
2011-08-30 16676.75
2011-09-02 16821.46
2011-09-05 16713.33
2011-09-06 16862.81
2011-09-07 17065.00
2011-09-08 17165.54
2011-09-09 16866.97
2011-09-12 16501.74
2011-09-13 16467.44
2011-09-14 16709.60
2011-09-15 16876.54
2011-09-16 16933.83
2011-09-19 16745.35
2011-09-20 17099.28
2011-09-21 17065.15
2011-09-22 16361.15
2011-09-23 16162.06
2011-09-26 16051.10
2011-09-27 16524.03
2011-09-28 16446.02
2011-09-29 16698.07
2011-09-30 16453.76
2011-10-03 16151.45
2011-10-04 15864.86
2011-10-05 15792.41
2011-10-07 16232.54
2011-10-10 16557.23
2011-10-11 16536.47
2011-10-12 16958.39
2011-10-13 16883.92
2011-10-14 17082.69
2011-10-17 17025.09
2011-10-18 16748.29
2011-10-19 17085.34
2011-10-20 16936.89
2011-10-21 16785.64
2011-10-24 16939.28
2011-10-25 17254.86
2011-10-28 17804.80
2011-10-31 17705.01
2011-11-01 17480.83
2011-11-02 17464.85
2011-11-03 17481.93
2011-11-04 17562.61
2011-11-08 17569.53
2011-11-09 17362.10
2011-11-11 17192.82
2011-11-14 17118.74
2011-11-15 16882.67
2011-11-16 16775.87
2011-11-17 16461.71
2011-11-18 16371.51
2011-11-21 15946.10
2011-11-22 16065.42
2011-11-23 15699.97
2011-11-24 15858.49
2011-11-25 15695.43
2011-11-28 16167.13
2011-11-29 16008.34
2011-11-30 16123.46
2011-12-01 16483.45
2011-12-02 16846.83
2011-12-05 16805.33
2011-12-07 16877.06
2011-12-08 16488.24
2011-12-09 16213.46
2011-12-12 15870.35
2011-12-13 16002.51
2011-12-14 15881.14
2011-12-15 15836.47
2011-12-16 15491.35
2011-12-19 15379.34
2011-12-20 15175.08
2011-12-21 15685.21
2011-12-22 15813.36
2011-12-23 15738.70
2011-12-26 15970.75
2011-12-27 15873.95
2011-12-28 15727.85
2011-12-29 15543.93
2011-12-30 15454.92
2012-01-03 15939.36
2012-01-04 15882.64
2012-01-05 15857.08
2012-01-06 15867.73
2012-01-09 15814.72
2012-01-10 16165.09
2012-01-11 16175.86
2012-01-12 16037.51
2012-01-13 16154.62
2012-01-16 16189.36
2012-01-17 16466.05
2012-01-18 16451.47
2012-01-19 16643.74
2012-01-20 16739.01
2012-01-23 16751.73
2012-01-24 16995.77
2012-01-25 17077.18
2012-01-27 17233.98
2012-01-30 16863.30
[ reached getOption("max.print") -- omitted 1450 rows ]
#bse_stocks <- as.numeric(bse_stocks)
mstocks <- monthlyReturn(bse_stocks, type='arithmetic')
Warning in to_period(xx, period = on.opts[[period]], ...) :
missing values removed from data
#View(mstocks)
colnames(mstocks) <- "mstocks"
table.AnnualizedReturns(mstocks)
charts.PerformanceSummary(mstocks)
# Indian Bond Market
bse_bonds <- getSymbols("BSE-500.BO", src="yahoo", from="2008-01-01", to="2018-01-01")
Warning: BSE-500.BO contains missing values. Some functions will not work if objects contain missing values in the middle of the series. Consider using na.omit(), na.approx(), na.fill(), etc to remove or replace them.
bsebonds <- bse_bonds[,6]
Error in bse_bonds[, 6] : incorrect number of dimensions
#Portfolio Optimization
#1. Mean Maximization
# Portfolio Specifications
mport1c <- portfolio.spec(assets = colnames(mport))
# Portfolio Constraints
mport1c <- add.constraint(mport1c,type="weight_sum",min_sum=0.99,max_sum=1.01)
mport1c <- add.constraint(mport1c,type="long_only")
# Portfolio Objectives
mport1c <- add.objective(mport1c,type="return",name="mean")
# Portfolio Optimization
mportopt1 <- optimize.portfolio(R=mport["::2014-12-31"],portfolio=mport1c,optimize_method="DEoptim", )
Iteration: 1 bestvalit: -0.012046 bestmemit: 0.014000 0.816000 0.000000 0.180000
Iteration: 2 bestvalit: -0.012055 bestmemit: 0.010000 0.634000 0.000000 0.366000
Iteration: 3 bestvalit: -0.012055 bestmemit: 0.010000 0.634000 0.000000 0.366000
Iteration: 4 bestvalit: -0.012055 bestmemit: 0.010000 0.634000 0.000000 0.366000
Iteration: 5 bestvalit: -0.012055 bestmemit: 0.010000 0.634000 0.000000 0.366000
Iteration: 6 bestvalit: -0.012055 bestmemit: 0.010000 0.634000 0.000000 0.366000
Iteration: 7 bestvalit: -0.012055 bestmemit: 0.010000 0.634000 0.000000 0.366000
Iteration: 8 bestvalit: -0.012055 bestmemit: 0.010000 0.634000 0.000000 0.366000
Iteration: 9 bestvalit: -0.012055 bestmemit: 0.010000 0.634000 0.000000 0.366000
[1] 0.010 0.634 0.000 0.366
chart.Weights(mportopt1)
# 2. Standard deviation minimization
# Portfolio Specifications
mport2c <- portfolio.spec(assets=colnames(mport))
# Portfolio Constraints
mport2c <- add.constraint(mport2c,type="weight_sum",min_sum=0.99,max_sum=1.01)
mport2c <- add.constraint(mport2c,type="long_only")
# Portfolio Objectives
mport2c <- add.objective(mport2c,type="risk",name="StdDev")
# Portfolio Optimization
mportopt2 <- optimize.portfolio(R=mport["::2014-12-31"],portfolio=mport2c,optimize_method="DEoptim",search_size=20000,trace=T)
Iteration: 1 bestvalit: 0.004611 bestmemit: 0.000000 0.124000 0.868000 0.010000
Iteration: 2 bestvalit: 0.004016 bestmemit: 0.002000 0.114000 0.890000 0.000000
Iteration: 3 bestvalit: 0.002619 bestmemit: 0.024000 0.010000 0.938000 0.036000
Iteration: 4 bestvalit: 0.002619 bestmemit: 0.024000 0.010000 0.938000 0.036000
Iteration: 5 bestvalit: 0.002469 bestmemit: 0.042000 0.006000 0.952000 0.002000
Iteration: 6 bestvalit: 0.001757 bestmemit: 0.010000 0.014000 0.964000 0.018000
Iteration: 7 bestvalit: 0.001599 bestmemit: 0.000000 0.026000 0.956000 0.010000
Iteration: 8 bestvalit: 0.001309 bestmemit: 0.016000 0.000000 0.982000 0.000000
Iteration: 9 bestvalit: 0.001052 bestmemit: 0.000000 0.000000 0.998000 0.004000
Iteration: 10 bestvalit: 0.001052 bestmemit: 0.000000 0.000000 0.998000 0.004000
Iteration: 11 bestvalit: 0.001052 bestmemit: 0.000000 0.000000 0.998000 0.004000
Iteration: 12 bestvalit: 0.001052 bestmemit: 0.000000 0.000000 0.998000 0.004000
Iteration: 13 bestvalit: 0.001052 bestmemit: 0.000000 0.000000 0.998000 0.004000
Iteration: 14 bestvalit: 0.001052 bestmemit: 0.000000 0.000000 0.998000 0.004000
Iteration: 15 bestvalit: 0.001052 bestmemit: 0.000000 0.000000 0.998000 0.004000
Iteration: 16 bestvalit: 0.001052 bestmemit: 0.000000 0.000000 0.998000 0.004000
[1] 0.000 0.000 0.998 0.004
chart.Weights(mportopt2)
#3. Mean Maximization and Standard Deviation Minimization Portfolio
# Portfolio Specifications
mport3c <- portfolio.spec(assets=colnames(mport))
# Portfolio Constraints
mport3c <- add.constraint(mport3c,type="weight_sum",min_sum=0.99,max_sum=1.01)
mport3c <- add.constraint(mport3c,type="long_only")
# Portfolio Objectives
mport3c <- add.objective(mport3c,type="return",name="mean")
mport3c <- add.objective(mport3c,type="risk",name="StdDev")
# Portfolio Optimization
mportopt3 <- optimize.portfolio(R=mport["::2014-12-31"],portfolio=mport3c,optimize_method="DEoptim",search_size=20000,trace=T)
Iteration: 1 bestvalit: -0.005658 bestmemit: 0.000000 0.014000 0.970000 0.022000
Iteration: 2 bestvalit: -0.005658 bestmemit: 0.000000 0.014000 0.970000 0.022000
Iteration: 3 bestvalit: -0.005658 bestmemit: 0.000000 0.014000 0.970000 0.022000
Iteration: 4 bestvalit: -0.005658 bestmemit: 0.000000 0.014000 0.970000 0.022000
Iteration: 5 bestvalit: -0.005684 bestmemit: 0.000000 0.036000 0.974000 0.000000
Iteration: 6 bestvalit: -0.005698 bestmemit: 0.012000 0.018000 0.972000 0.000000
Iteration: 7 bestvalit: -0.005698 bestmemit: 0.012000 0.018000 0.972000 0.000000
Iteration: 8 bestvalit: -0.005698 bestmemit: 0.012000 0.018000 0.972000 0.000000
Iteration: 9 bestvalit: -0.005698 bestmemit: 0.012000 0.018000 0.972000 0.000000
Iteration: 10 bestvalit: -0.005698 bestmemit: 0.012000 0.018000 0.972000 0.000000
Iteration: 11 bestvalit: -0.005698 bestmemit: 0.012000 0.018000 0.972000 0.000000
Iteration: 12 bestvalit: -0.005698 bestmemit: 0.012000 0.018000 0.972000 0.000000
Iteration: 13 bestvalit: -0.005698 bestmemit: 0.012000 0.018000 0.972000 0.000000
[1] 0.012 0.018 0.972 0.000
chart.Weights(mportopt3)
chart.EfficientFrontier(mportopt3,match.col="StdDev",ylim="mean")
Error in plot.window(...) : invalid 'ylim' value
This is an R Markdown Notebook. When you execute code within the notebook, the results appear beneath the code.
Try executing this chunk by clicking the Run button within the chunk or by placing your cursor inside it and pressing Ctrl+Shift+Enter.
plot(cars)
Add a new chunk by clicking the Insert Chunk button on the toolbar or by pressing Ctrl+Alt+I.
When you save the notebook, an HTML file containing the code and output will be saved alongside it (click the Preview button or press Ctrl+Shift+K to preview the HTML file).
The preview shows you a rendered HTML copy of the contents of the editor. Consequently, unlike Knit, Preview does not run any R code chunks. Instead, the output of the chunk when it was last run in the editor is displayed.