Column

###Stock Analysis

Column

Table

Johnson & Johnson

Novo Nordisk A/S

Pfizer Inc.

AstraZeneca PLC.


Summary/Findings

The pharma companies have been in more focus ever since the pandemic broke out. I have chosen four most liquid stocks in the pharma zone and have looked at the performance over a period of last 3 years. I have taken details such as Dividend Yields, Closing Prices, Market Cap, Forward Earnings and Present Earnings. Given the visualization that is enclosed here, I feel Pfizer could be a winner as far as short term gains are concerned. I have reached the decision keeping in view the following points in mind: 1. Pfizer stock has recently moved up after touching multi month lows, which is now a support zone for the stock. Other stocks also have bounced back but most of them have been in bull orbit for quite some time. 2. Dividend yield, depending on the holding period is fair as it falls between other pharma stocks. 3. The forward PE shows a positive trend while other pharma stocks show a negative trend. This will result in supporting price movement in positive territory. 4. Pfizer stock is also less volatile which means downside could be limited.

Given the above investment in Pfizer for short term gain looks more appropriate than the other company’s stocks. The next best option would be to invest in Novo Nordisk since the stock is in a long term upward trend. Even the Forward PE (Earnings) looks promising – although, in comparison to Pfizer, the Forward PE (Earnings) will be negative compared to the present earnings therefore, affecting the stock negatively.

---
title: "Lab 1 - Dashboard Financial Analysis"
output: 
  flexdashboard::flex_dashboard:
    source_code: embed
    orientation: columns
    vertical_layout: fill
    
---

```{r}
library(flexdashboard)
library(quantmod)
library(plyr)
library(dplyr)
library(knitr)
library(DT)
library(xts)
library(dygraphs)
library(lubridate)
```
Column{data-width=650}
-----------------------------------------------------------------------
###Stock Analysis
```{r}
what_metrics <- yahooQF(c("Price/Sales", 
                          "P/E Ratio",
                          "Price/EPS Estimate Next Year",
                          "PEG Ratio",
                          "Dividend Yield", 
                          "Market Capitalization"))

tickers <- c("JNJ", "NVO", "PFE", "AZN")
invisible(getSymbols(tickers, from="2020-03-01",to="2023-03-28"))
closingPrices=do.call(merge,lapply(tickers,function(x)Cl(get(x))))

Period=c("2020-03-01","2023-03-28")
dygraph(closingPrices,main="Stock Analysis of Pharmaceutical Companies",group = "Stock")%>%
  dyAxis("y",label="Close")%>%
  dyOptions(colors=RColorBrewer::brewer.pal(4,"Set1"))%>%
  dyHighlight(highlightCircleSize=3,highlightSeriesBackgroundAlpha=1,highlightSeriesOpts=list(strokeWidth=3))%>%
  dyRangeSelector(height=50)
```

Column {.tabset data-width=550}
-----------------------------------------------------------------------

### Table

```{r}
what_metrics=yahooQF(c("Price/Sales", 
                          "P/E Ratio",
                          "Price/EPS Estimate Next Year",
                          "PEG Ratio",
                          "Dividend Yield", 
                          "Market Capitalization"))

metrics=getQuote(paste(tickers,sep="",collapse=";"),what=what_metrics)
metrics=data.frame(Symbol=tickers,metrics[,2:length(metrics)])

colnames(metrics)=c("Symbol","Earnings","Earnings(Forward)","Div Yield","Market Cap")
#datatable(head(metrics,20),options=list(initComplete=JS(function(settings(json){this.api().table().header()).ccs({'backfround-color':'white''color':'#fff'});})))
DT::datatable(metrics)

```

### Johnson & Johnson
```{r}
#Johnson & Johnson

invisible (getSymbols("JNJ",src="yahoo",from='2020-03-01'))
JNJ_x=JNJ
dygraph(JNJ_x[,-5],main="Johnson and Johnson")%>%
  dyCandlestick()%>%
  dyAxis("y",label="Close")%>%
  dyOptions(colors=RColorBrewer::brewer.pal(4,"Set1"))%>%
  dyHighlight(highlightCircleSize=3,
              highlightSeriesBackgroundAlpha=1,
              highlightSeriesOpts=list(strokeWidth=3))%>%
  dyRangeSelector(height=50)
```
### Novo Nordisk A/S
```{r}
#Novo Nordisk A/S

invisible (getSymbols("NVO",src="yahoo",from='2020-03-01'))
NVO_x=NVO
dygraph(NVO_x[,-5],main="Novo Nordisk A/S")%>%
  dyCandlestick()%>%
  dyAxis("y",label="Close")%>%
  dyOptions(colors=RColorBrewer::brewer.pal(4,"Set1"))%>%
  dyHighlight(highlightCircleSize=3,
              highlightSeriesBackgroundAlpha=1,
              highlightSeriesOpts=list(strokeWidth=3))%>%
  dyRangeSelector(height=50)


```
### Pfizer Inc.
```{r}


#Pfizer Inc.

invisible (getSymbols("PFE",src="yahoo",from='2020-03-01'))
PFE_x=PFE
dygraph(PFE_x[,-5],main="Pfizer Inc")%>%
  dyCandlestick()%>%
  dyAxis("y",label="Close")%>%
  dyOptions(colors=RColorBrewer::brewer.pal(4,"Set1"))%>%
  dyHighlight(highlightCircleSize=3,
              highlightSeriesBackgroundAlpha=1,
              highlightSeriesOpts=list(strokeWidth=3))%>%
  dyRangeSelector(height=50)
invisible (getSymbols("PFE",src="yahoo",from='2020-03-01'))

```
### AstraZeneca PLC.
```{r}
#AstraZeneca PLC

invisible (getSymbols("AZN",src="yahoo",from='2020-03-01'))
AZN_x=AZN
dygraph(AZN_x[,-5],main="AstraZeneca PLC")%>%
  dyCandlestick()%>%
  dyAxis("y",label="Close")%>%
  dyOptions(colors=RColorBrewer::brewer.pal(4,"Set1"))%>%
  dyHighlight(highlightCircleSize=3,
              highlightSeriesBackgroundAlpha=1,
              highlightSeriesOpts=list(strokeWidth=3))%>%
  dyRangeSelector(height=50)
```
-----------------------------------------------------------------------
### Summary/Findings

The pharma companies have been in more focus ever since the pandemic broke out. I have chosen four most liquid stocks in the pharma zone and have looked at the performance over a period of last 3 years. I have taken details such as Dividend Yields, Closing Prices, Market Cap, Forward Earnings and Present Earnings.  Given the visualization that is enclosed here, I feel Pfizer could be a winner as far as short term gains are concerned. I have reached the decision keeping in view the following points in mind:
1.	Pfizer stock has recently moved up after touching multi month lows, which is now a support zone for the stock. Other stocks also have bounced back but most of them have been in bull orbit for quite some time.
2.	Dividend yield, depending on the holding period is fair as it falls between other pharma stocks.
3.	The forward PE shows a positive trend while other pharma stocks show a negative trend. This will result in supporting price movement in positive territory.
4.	Pfizer stock is also less volatile which means downside could be limited.

Given the above investment in Pfizer for short term gain looks more appropriate than the other company’s stocks. The next best option would be to invest in Novo Nordisk since the stock is in a long term upward trend. Even the Forward PE (Earnings) looks promising – although, in comparison to Pfizer, the Forward PE (Earnings) will be negative compared to the present earnings therefore, affecting the stock negatively. 

```{r}
###Summary/Findings
```