About Team and Dashboard Project

Team Members:

Objective:

To purchase securities for the key objective of maximizing profits and decide when to sell shares in Apple Inc. (AAPL).

Stock Price Trend for Apple

Column

Prices of Apple Stocks

Percent closing price Comparison with S&P500

Historical Performance

Column

Monthly Percentage of Returns

Revenue growth and Dividends

Apple Stock Valuation & Next Year Predictions

Row

PE ratio for Valuation of Apple

Row

Next Year Predictions

Conclusion

Since apple in the recent years has been mostly relying on the sales of IPhones when compared to it’s other products, there has not been a major shakeup in it’s product line to see a boost in sales from other areas. A decade back when apple reinvented itself to enter into the Smart Phone market, it was a huge step that contributed to the increase in it’s share price in the following years, even with the stock split in 2014. Since the share price has not observed real huge strides, but the return per share being higher indicate this the time to invest in acquiring more shares instead of selling shares. But even in this case, if investors want to sell shares then couple of months before the next year iPhone release is a good time to sell. There are other areas like Virtual Reality, and Autonomous cars being explored by Apple. With the talent pool and leadership at Apple, it won’t be long before they reinvent themselves to adapt to the emerging trends. This will definitely see huge improvement in the increasing share price trends, and reap higher returns in the long run.

---
title: "Dashboard Lab"
author: "Pranita Patil"
output: 
  flexdashboard::flex_dashboard:
    orientation: rows
    vertical_layout: fill
    source_code: embed
---

```{r}
library(flexdashboard)
library(quantmod)
library(ggplot2)
library(dplyr)
library(dygraphs)
library(lubridate)
library(tidyquant)
library(plotly)
library(DT)
ticker <- "AAPL"
invisible(getSymbols(ticker,src="yahoo",from="2012-10-22",to="2017-10-26"))


```

About Team and Dashboard Project
===================================== 
Team Members:

* Pranita Patil 
* Sai Potturi

Objective: 

To purchase securities for the key objective of maximizing profits and decide when to sell shares in Apple Inc. (AAPL). 


Stock Price Trend for Apple
===================================== 

Summary {.sidebar}
-------------------------------------
The stock price of Apple has been observed to be varying through the year, even though the fluctuations can be minor. The increase in stock has seasonality to it. The increase in stock price around the month of July can be attributed to the rumors and leaks around the specs and features in the to be launched IPhone model. The price plateaus for the rest of the year, but there can be minor fluctuations in Fall with launch of rival smartphones. Apple has been observed to bring huge design changes to the phone every other year. This is when we can observe a considerable increase in the price when compared to the previous year.

Column {data-width=500}
-----------------------------------------------------------------------

### Prices of Apple Stocks
```{r}
AAPL_xts <- AAPL
dygraph(AAPL_xts[, -5], main = "Apple") %>%
  dyCandlestick() %>%
  dyAxis("y", label="Price") %>%
  dyOptions(colors= RColorBrewer::brewer.pal(5, "Set1")) %>%
  dyHighlight(highlightCircleSize = 4,
              highlightSeriesOpts = list(strokeWidth = 3),
              highlightSeriesBackgroundAlpha = 1) %>%
  dyRangeSelector(height = 65)
```

### Percent closing price Comparison with S&P500
```{r}
tickers<-c("AAPL","SPY")
invisible(getSymbols(tickers,src="yahoo",from="2012-10-22",to="2017-10-26"))
closePrices <- cbind(AAPL$AAPL.Close,SPY$SPY.Close)
dygraph(closePrices, group = "stock") %>%
  dyRebase(percent = TRUE) %>%
  dyAxis("y", label="Close Price %") %>%
  dyRangeSelector(height=55) %>%
  dyLegend(show = "onmouseover")%>%
dyOptions(colors = RColorBrewer::brewer.pal(5, "Set1")) %>%
  dyHighlight(highlightSeriesBackgroundAlpha = 0.3,
              highlightSeriesOpts = list(strokeWidth = 2)) %>%
  dyRangeSelector(height = 65)
```


Historical Performance
===================================== 


Summary {.sidebar}
-------------------------------------
The monthly percentage of returns indicates the overall gain or loss percentage, taking into consideration the value at the beginning of the month, and the value the end of the month. The pattern seems to sync with the release events of Apple and it's rival smart phone makers. The spikes can be observed in the window prior to the product release. The dips and spikes can be also observed in relation to the quarterly earnings report which is in relation the overall sales reports.

From the revenue growth and dividends plot, we can evaluate the financial status of Apple. Since Apple's dividend is showing increasing/growing trend annually then sustainable and solid dividend with high cash hoard is a important consideration to keep existing shares. Apple showed decline in year over year revenue last year further in the past but Apple's revenue jumped to 7% in 2017.Apple's strong revenue growth indicates good sign for investors. 




Column {.tabset .tabset-fade data-height=650}
-------------------------------------

### Monthly Percentage of Returns

```{r}
ticker <- "AAPL"
symbol <- getSymbols(ticker, src = 'yahoo', auto.assign = FALSE, warnings = FALSE)
year <- ymd("2011-10-22")
duration <- ymd("2017-10-26")
data<- periodReturn(symbol, period='monthly', subset=paste(year, "::", sep = ""), type ='log')
returns_percentage <- data$monthly.returns*100
  
dygraph(returns_percentage, main = "Monthly Percentage Of Return") %>%
  dyAxis("y", label = "return") %>%
  dyOptions(colors = RColorBrewer::brewer.pal(5, "Set1")) %>%
  dyHighlight(highlightSeriesBackgroundAlpha = 0.2,
              highlightSeriesOpts = list(strokeWidth = 3)) %>%
  dyRangeSelector(height = 75)

```





### Revenue growth and Dividends

```{r}

AAPL_growth <- tq_get("AAPL", get = "key.ratios")
# prat<-AAPL_growth$data[[3]]


AAPL_growth_revenue <- AAPL_growth %>%
filter(section == "Growth") %>%
unnest() %>%
filter(category == "Year over Year") %>%
select(category, date, value)


AAPL_growth_revenue1 <-AAPL_growth_revenue[,2:3]
AAPL_growth_revenue1$category <- "revenue"
AAPL_dividends <- tq_get("AAPL", get = "dividends")
colnames(AAPL_dividends)[2] <- "value"
AAPL_dividends$value <- AAPL_dividends$value*100
AAPL_dividends$category <- "dividends"
 
tog<-rbind(AAPL_growth_revenue1,AAPL_dividends)


ggplot(data=tog,aes(x=date,y=value,fill=category))+geom_bar(stat='identity',position=position_dodge(),color="black")+scale_fill_manual(values=c("blue","red"))+theme_minimal()


```


Apple Stock Valuation & Next Year Predictions {data-orientation=rows}
=====================================================================


# Summary {.sidebar}
------------------------------------
Investors have long considered the price earnings ratio, which is also known as the p/e ratio for short, a useful metric for evaluating the relative attractiveness of a company's stock price compared to the current earnings of a firm. The apple stock has been split in 2014, and considering the history of splitting stock, it was just done 4 times since the beginning. Observing the trend of p/e ratio, it is hovering between 10 and 15 in the recent years. The share value is trending between 100 and 150. This implies the lower p/e value indicates a higher increase in profits per earnings. With the share value kind of plateauing, this would imply higher returns for the shares bought at this price. With this trend, it would be advisable to buy shares at this price, rather than sell the existing shares.


Row {data-height=800}
-----------------------------------------------------------------------

### PE ratio for Valuation of Apple

```{r}
# invisible(getFin("AAPL"))
# invisible(getFin("SPY"))
# viewFin(AAPL.f)
# viewFin(SPY.f)

AAPL_pe <- tq_get("AAPL", get = "key.ratios")

AAPL_pe_ratios <- AAPL_pe %>%
filter(section == "Valuation Ratios") %>%
unnest() %>%
filter(category == "Price to Earnings") %>%
select(category, date, value)


pe <- (AAPL_pe_ratios)
ggplot(pe, aes(x = date, y = value, group = 1)) + 
  geom_point(color='Red')+
  ylab(label="PE Ratio") + 
  xlab("Year") +
  theme(legend.position="right")+
  scale_colour_manual(values =c(AAPL="blue",SPY="red"))+
  ggtitle("PE ratio for Apple")


```


Row {.tabset .tabset-fade data-height=200}
-----------------------------------------------------------------------

### Next Year Predictions
```{r out.width = "400px"}
knitr::include_graphics("E:\\Harrisburg courses\\sem 6-Fall 2017\\Data Visualization\\dashboard lab\\Capture11.PNG")
```


```{r error = TRUE}
# what_metrics <- yahooQF(c("Dividend Yield",
#                           "Market Capitalization",
#                           "EPS Estimate Current Year",
#                           "EPS Estimate Next Quarter",
#                           "EPS Estimate Next Year",
#                           "Price/EPS Estimate Next Year",
#                           "1 yr Target Price"))
# 
# tickers <- "AAPL"
# # Not all the metrics are returned by Yahoo.
# metrics <- getQuote(paste(tickers, sep="", collapse=";"), what=what_metrics)
# 
# #Add tickers as the first column and remove the first column which had date stamps
# metrics <- data.frame(Symbol=tickers, metrics[,2:length(metrics)])
# 
# #Change colnames
# colnames(metrics) <- c("Symbol","Dividend Yield",
#                           "Market Capitalization",
#                           "EPS Estimate Current Year",
#                           "EPS Estimate Next Quarter",
#                           "EPS Estimate Next Year",
#                           "Price/EPS Estimate Next Year",
#                           "1 yr Target Price")
# 
# DT::datatable(metrics, class = 'cell-border stripe', options = list(dom = 't'))

```


Conclusion
===================================== 
Since apple in the recent years has been mostly relying on the sales of IPhones when compared to it's other products, there has not been a major shakeup in it's product line to see a boost in sales from other areas. A decade back when apple reinvented itself to enter into the Smart Phone market, it was a huge step that contributed to the increase in it's share price in the following years, even with the stock split in 2014. Since the share price has not observed real huge strides, but the return per share being higher indicate this the time to invest in acquiring more shares instead of selling shares. But even in this case, if investors want to sell shares then couple of months before the next year iPhone release is a good time to sell. There are other areas like Virtual Reality, and Autonomous cars being explored by Apple. With the talent pool and leadership at Apple, it won't be long before they reinvent themselves to adapt to the emerging trends. This will definitely see huge improvement in the increasing share price trends, and reap higher returns in the long run.