library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(prophet)
## Loading required package: Rcpp
library(xts)
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
## 
## Attaching package: 'xts'
## The following objects are masked from 'package:dplyr':
## 
##     first, last
library(highcharter)
## Highcharts (www.highcharts.com) is a Highsoft software product which is
## not free for commercial and Governmental use
library(quantmod)
## Loading required package: TTR
## Version 0.4-0 included new data defaults. See ?getSymbols.

PORTFOLIO T

———–PORTFOLIO T————-

SnP=getSymbols('^GSPC',auto.assign = FALSE)
##     As of 0.4-0, 'getSymbols' uses env=parent.frame() and
##  auto.assign=TRUE by default.
## 
##  This  behavior  will be  phased out in 0.5-0  when the call  will
##  default to use auto.assign=FALSE. getOption("getSymbols.env") and 
##  getOptions("getSymbols.auto.assign") are now checked for alternate defaults
## 
##  This message is shown once per session and may be disabled by setting 
##  options("getSymbols.warning4.0"=FALSE). See ?getSymbols for more details.
C.Discretionary=getSymbols('XLY',auto.assign=FALSE)
Energy=getSymbols('XLE',auto.assign=FALSE)
Material=getSymbols('XLB',auto.assign=FALSE)
Industrial=getSymbols('XLI',auto.assign=FALSE)
Technology=getSymbols('XLK',auto.assign=FALSE)
Finance=getSymbols('XLF',auto.assign = FALSE)

SECTOR INDEX

highchart() %>% 
  hc_title(text = "Sectors performance") %>% 
  hc_add_theme(hc_theme_darkunica()) %>%
  hc_add_series_ohlc(Energy,type="line") %>% 
  hc_add_series_ohlc(Material,type="line") %>% 
  hc_add_series_ohlc(Industrial,type="line") %>% 
  hc_add_series_ohlc(Technology,type="line") %>% 
  hc_add_series_ohlc(C.Discretionary,type="line") %>% 
  hc_add_series_ohlc(Finance,type="line") 
## Warning: 'hc_add_series_ohlc' is deprecated.
## Use 'hc_add_series' instead.
## See help("Deprecated")

## Warning: 'hc_add_series_ohlc' is deprecated.
## Use 'hc_add_series' instead.
## See help("Deprecated")

## Warning: 'hc_add_series_ohlc' is deprecated.
## Use 'hc_add_series' instead.
## See help("Deprecated")

## Warning: 'hc_add_series_ohlc' is deprecated.
## Use 'hc_add_series' instead.
## See help("Deprecated")

## Warning: 'hc_add_series_ohlc' is deprecated.
## Use 'hc_add_series' instead.
## See help("Deprecated")

## Warning: 'hc_add_series_ohlc' is deprecated.
## Use 'hc_add_series' instead.
## See help("Deprecated")

Jan 19 Portfolio : The portfolio consisted of 10 stocks:

CSCO=getSymbols('CSCO',auto.assign = FALSE)
LNC=getSymbols('LNC',auto.assign = FALSE)
AIR=getSymbols('AIR',auto.assign = FALSE)
RDN=getSymbols('RDN',auto.assign = FALSE)
MFC=getSymbols('MFC',auto.assign = FALSE)
CNO=getSymbols('CNO',auto.assign = FALSE)
UNM=getSymbols('UNM',auto.assign = FALSE)
TECK=getSymbols('TECK',auto.assign = FALSE)
AWH=getSymbols('AWH',auto.assign = FALSE)
CAA=getSymbols('CAA',auto.assign = FALSE)

Stocks that in non-Finance Sectors

highchart() %>% 
  hc_add_theme(hc_theme_darkunica()) %>%
  hc_add_series_ohlc(AIR,type="line") %>% 
  hc_add_series_ohlc(TECK, type = "line")%>% 
  hc_add_series_ohlc(CSCO, type = "line") %>% 
  hc_add_series_ohlc(CAA, type = "line")
## Warning: 'hc_add_series_ohlc' is deprecated.
## Use 'hc_add_series' instead.
## See help("Deprecated")

## Warning: 'hc_add_series_ohlc' is deprecated.
## Use 'hc_add_series' instead.
## See help("Deprecated")

## Warning: 'hc_add_series_ohlc' is deprecated.
## Use 'hc_add_series' instead.
## See help("Deprecated")

## Warning: 'hc_add_series_ohlc' is deprecated.
## Use 'hc_add_series' instead.
## See help("Deprecated")

Stocks that in the Finance Sectors

#Stocks that in the Finance Sectors 
highchart() %>% 
  hc_add_theme(hc_theme_darkunica()) %>%
  hc_add_series_ohlc(MFC,type="line") %>% 
  hc_add_series_ohlc(CNO, type = "line")  %>%
  hc_add_series_ohlc(RDN, type = "line") %>%
  hc_add_series_ohlc(AWH, type = "line")  %>%
  hc_add_series_ohlc(Finance, type = "ohlc")  %>%
  hc_add_series_ohlc(LNC, type = "line") %>%
  hc_add_series_ohlc(UNM, type = "line")  
## Warning: 'hc_add_series_ohlc' is deprecated.
## Use 'hc_add_series' instead.
## See help("Deprecated")

## Warning: 'hc_add_series_ohlc' is deprecated.
## Use 'hc_add_series' instead.
## See help("Deprecated")

## Warning: 'hc_add_series_ohlc' is deprecated.
## Use 'hc_add_series' instead.
## See help("Deprecated")

## Warning: 'hc_add_series_ohlc' is deprecated.
## Use 'hc_add_series' instead.
## See help("Deprecated")

## Warning: 'hc_add_series_ohlc' is deprecated.
## Use 'hc_add_series' instead.
## See help("Deprecated")

## Warning: 'hc_add_series_ohlc' is deprecated.
## Use 'hc_add_series' instead.
## See help("Deprecated")

## Warning: 'hc_add_series_ohlc' is deprecated.
## Use 'hc_add_series' instead.
## See help("Deprecated")

STOCK PICK ILLUSTRATION

#Teck STOCK
highchart() %>% 
  hc_add_theme(hc_theme_darkunica()) %>%
  hc_title(text="Teck Resources")%>%
  hc_add_series_ohlc(TECK) 
## Warning: 'hc_add_series_ohlc' is deprecated.
## Use 'hc_add_series' instead.
## See help("Deprecated")

PORTFOLIO WEIGHT

JAN 17 Portfolio Weight

highchart() %>% 
    hc_add_theme(hc_theme_darkunica()) %>%
    hc_title(text = "Portfolio Weight Jan 17") %>% 
    hc_add_series(name = "Portfolio Weight", type = "pie",
                data = list(list(y = 0.05, name = "CSCO",
                                 sliced = TRUE),
                            list(y = 0.05, name = "LNC"),
                            list(y=0.05,name="RDN"),
                            list(y=0.05,name="AIR"),
                            list(y=0.05,name="MFC"),
                            list(y=0.05,name="CNO"),
                            list(y=0.05,name="UNM"),
                            list(y=0.05,name="TECK"),
                            list(y=0.05,name="AWH"),
                            list(y=0.05,name="CAA"),
                            list(y=0.55,name="Cash")),
                 size = 100,center=c('15%','30%'))%>%
    hc_add_series(name = "Portfolio Weight", type = "pie",
                data = list(list(y = 0.3, name = "Finance",
                                 sliced = TRUE),
                            list(y=0.05,name="IT"),
                            list(y=0.05,name="Industrial"),
                            list(y=0.05,name="Energy"),
                            list(y=0.05,name="Comsumer Discretionary"),
                             list(y=0.55,name="Cash")),
                size = 250,center=c('66%','35%'))

FEB 17: Rebalancing the Portfolio, adding another 1% for each equity that still appeared on the 2nd scan

Portfolio Weight

highchart() %>% 
    hc_add_theme(hc_theme_darkunica()) %>%
    hc_title(text = "Portfolio Weight Feb 17") %>% 
    hc_add_series(name = "Portfolio Weight", type = "pie",
                data = list(list(y = 0.06, name = "MFC",
                                 sliced = TRUE),
                            list(y = 0.06, name = "RDN"),
                            list(y=0.06,name="CCJ"),
                            list(y=0.05,name="PHM"),
                            list(y=0.05,name="CNO"),
                            list(y=0.07,name="AWH"),
                            list(y=0.06,name="MOS"),
                            list(y=0.07,name="UNM"),
                            list(y=0.06,name="CSCO"),
                            list(y=0.05,name="GPRE"),
                            list(y=0.43,name="Cash")),
                size = 100,center=c('15%','30%'))%>% 
    hc_add_series(name = "Portfolio Weight", type = "pie",
                data = list(list(y = 0.31, name = "Finance",
                                 sliced = TRUE),
                            list(y=0.06,name="IT"),
                            list(y=0.05,name="Industrial"),
                            list(y=0.15,name="Basic Material"),
                             list(y=0.43,name="Cash")),
                size = 250, center=c('66%','35%'))

March 17: Rebalancing the Portfolio, adding another 1% for each equity that still appeared on the 2nd Portfolio Weight

highchart() %>% 
    hc_add_theme(hc_theme_darkunica()) %>%
    hc_title(text = "Portfolio Weight MAR 17") %>% 
    hc_add_series(name = "Portfolio Weight", type = "pie",
                data = list(list(y = 0.05, name = "VLO",
                                 sliced = TRUE),
                            list(y = 0.04, name = "MOS"),
                            list(y=0.05,name="CCJ"),
                            list(y=0.06,name="RDN"),
                            list(y=0.06,name="CNO"),
                            list(y=0.06,name="MFC"),
                            list(y=0.06,name="CNO"),
                            list(y=0.05,name="CSCO"),
                            list(y=0.06,name="GPRE"),
                            list(y=0.05,name="UNM"),
                            list(y=0.45,name="Cash")),
                 size = 100,center=c('15%','30%'))%>% 
    hc_add_series(name = "Portfolio Weight", type = "pie",
                data = list(list(y = 0.25, name = "Finance",
                                 sliced = TRUE),
                            list(y=0.06,name="IT"),
                            list(y=0.05,name="Energy"),
                            list(y=0.19,name="Basic Material"),
                             list(y=0.45,name="Cash")),
                size = 250,center=c('66%','35%'))

COMPARISION

PORTFOLIO T RETURN VS MARKET

data=read.csv('return.csv',header=TRUE)
head(data,5)
##         Date  PORTFOLIOT       MARKET   PORTFOLIOC PORTFOLIOL      COMPSP
## 1 2017-01-20 0.000337040 -0.003354892 -0.000734880         NA 0.003366185
## 2 2017-01-23 0.000057700  0.003366185 -0.001260000         NA 0.000667052
## 3 2017-01-24 0.011539295 -0.002690078  0.000768000         NA 0.007235973
## 4 2017-01-25 0.006258483  0.006564542 -0.001550000         NA 0.015320119
## 5 2017-01-26 0.000267775  0.008026069  0.000296774         NA 0.014573550
##        COMPT
## 1 0.00033704
## 2 0.00039475
## 3 0.01193860
## 4 0.01827180
## 5 0.01854447
highchart() %>% 
    hc_add_theme(hc_theme_darkunica()) %>%
    hc_title(text = "Portfolio T vs S&P 500 (Daily Returns)") %>% 
    hc_add_series(name = "Porfolio T", type = "line",data =data$PORTFOLIOT) %>%
    hc_add_series(name = "S&P 500", type = "line",data =data$MARKET)%>%
    hc_xAxis(categories = data$Date) 

COMPOUND DAILY RETURNS

data=read.csv('return.csv',header=TRUE)
head(data,5)
##         Date  PORTFOLIOT       MARKET   PORTFOLIOC PORTFOLIOL      COMPSP
## 1 2017-01-20 0.000337040 -0.003354892 -0.000734880         NA 0.003366185
## 2 2017-01-23 0.000057700  0.003366185 -0.001260000         NA 0.000667052
## 3 2017-01-24 0.011539295 -0.002690078  0.000768000         NA 0.007235973
## 4 2017-01-25 0.006258483  0.006564542 -0.001550000         NA 0.015320119
## 5 2017-01-26 0.000267775  0.008026069  0.000296774         NA 0.014573550
##        COMPT
## 1 0.00033704
## 2 0.00039475
## 3 0.01193860
## 4 0.01827180
## 5 0.01854447
highchart() %>% 
    hc_add_theme(hc_theme_darkunica()) %>%
    hc_title(text = "Portfolio T vs S&P 500 (Compound Daily Returns)") %>% 
    hc_add_series(name = "Porfolio T", type = "line",data =data$COMPT) %>%
    hc_add_series(name = "S&P 500", type = "line",data =data$COMPSP)%>%
    hc_xAxis(categories = data$Date) 
#PORTFOLIO C
CINDY’S PORTFOLIO ###STOCK PICK ILLUSTRATION
r APPLE=getSymbols("AAPL",auto.assign = FALSE) highchart() %>% hc_add_theme(hc_theme_darkunica()) %>% hc_title(text = "APPLE- Portfolio C Stock Pick") %>% hc_add_series_ohlc(APPLE,name = "AAPL")
## Warning: 'hc_add_series_ohlc' is deprecated. ## Use 'hc_add_series' instead. ## See help("Deprecated")
###PORTFOLIO WEIGHT Cindy Portfolio Weight
Portfolio Weight
r highchart() %>% hc_add_theme(hc_theme_darkunica()) %>% hc_title(text = "% Investment by Sectors of Portfolio C") %>% hc_add_series(name = "Portfolio Weight", type = "pie", data = list(list(y = 0.23, name = "IT", sliced = TRUE), list(y=0.1,name="Service"), list(y=0.11,name="Utilities"), list(y=0.09,name="Health Care"), list(y=0.48,name="Cash")), size = 250,center=c('50%','50%'))
###COMPARISION PORTFOLIO C VS MARKET
r time(data$Date)
## [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 ## [24] 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 ## attr(,"tsp") ## [1] 1 40 1
r highchart() %>% hc_add_theme(hc_theme_darkunica()) %>% hc_title(text = "Portfolio C vs S&P 500 (Daily Returns)") %>% hc_add_series(name = "Porfolio C", type = "line",data =data$PORTFOLIOC) %>% hc_add_series(name = "S&P 500", type = "line",data =data$MARKET)%>% hc_xAxis(categories = data$Date)

PORTFOLIO L

LUC’S PORTFOLIO

STOCK PICK ILLUSTRATION

AQN=getSymbols("AQN.TO",auto.assign = FALSE)
highchart() %>% 
    hc_add_theme(hc_theme_darkunica()) %>%
    hc_title(text = "Algonquin Power and Utilities Corporation- Portfolio L Stock Pick") %>% 
    hc_add_series_ohlc(AQN,name = "AQN.TO")
## Warning: 'hc_add_series_ohlc' is deprecated.
## Use 'hc_add_series' instead.
## See help("Deprecated")

PORTFOLIO WEIGHT

Portfolio Weight

highchart() %>% 
    hc_add_theme(hc_theme_darkunica()) %>%
    hc_title(text = "% Investment by Sectors of Portfolio L") %>% 
    hc_add_series(name = "Portfolio Weight", type = "pie",
                data = list(list(y = 0.25, name = "Finance",
                                 sliced = TRUE),
                            list(y=0.05,name="IT"),
                            list(y=0.08,name="Service"),
                            list(y=0.08,name="Others"),
                            list(y=0.22,name="Consumer Goods"),
                            list(y=0.15,name="Industrial Goods"),
                             list(y=0.4,name="Basic Material"),
                             list(y=0.03,name="Cash")),
                size = 250,center=c('50%','50%'))

COMPARISION OF TCL VS MARKET

data=read.csv('Compound Return.csv',header=TRUE)
head(data,5)
##         Date          T            C            L      COMPSP
## 1 2017-01-20 0.00033704  0.000000000  0.000000000 0.003366185
## 2 2017-01-23 0.00039475 -0.001255042 -0.006524050 0.000667052
## 3 2017-01-24 0.01193860 -0.000487538  0.004833539 0.007235973
## 4 2017-01-25 0.01827180 -0.002041730  0.015054080 0.015320119
## 5 2017-01-26 0.01854447 -0.001745563  0.012760623 0.014573550
highchart() %>% 
    hc_add_theme(hc_theme_darkunica()) %>%
    hc_title(text = "Compounded Daily Returns ") %>% 
    hc_add_series(name = "S&P 500", type = "line",data =data$COMPSP)%>%  
    hc_add_series(name = "Porfolio T", type = "line",data =data$T) %>%
    hc_add_series(name = "Portfolio C", type = "line",data =data$C)%>%
    hc_add_series(name = "Portfolio L", type = "line",data =data$L)%>%
    hc_xAxis(categories = data$Date)