Self-Assessment #3
Question 1: The purpose of this self-assessment is to implement performance metrics and understand
how the given stocks perform with respect to the market, and which of the two stocks is a better
investment to make. Follow the steps below, and answer the questions outside the code-block, in the R
Markdown File in 1-2 sentences. Knit your code to HTML using R Studio for a more presentable format and
submit the HTML file.
Use echo = TRUE while knitting so that the code is seen.
a. Load the ‘Return_Dataset.csv’ file into your R Studio and print the first 10 rows. (1 point)
Note: The data contains monthly returns of- Risk Free Asset (RF); Market (Mkt); United Parcel Service (UPS); KO
(Coca Cola)
b. Plot and print the cumulative returns of the returns across time. Eventually, by seeing the graph, do
UPS or KO outperform the Market? Explain. (2 points)
Note: The graph should include the legend to evidently see a comparison.
Hint: Use POSIXct for converting date into a time-series object.
c. Calculate and print the Sharpe Ratio and Treynor Ratio of UPS and KO. Which of the two is a better
investment to make? Explain. (Use the StdDev Sharpe Ratio to compare) (3 points)
setwd("C:/Users/OPG2/Desktop/GaTech/MGT 6203")
library(PerformanceAnalytics)
## Loading required package: xts
## Loading required package: zoo
##
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
##
## Attaching package: 'PerformanceAnalytics'
, ## The following object is masked from 'package:graphics':
##
## legend
library(PoSI)
library(xts)
library(lubridate)
##
## Attaching package: 'lubridate'
## The following object is masked from 'package:base':
##
## date
return_data <- read.csv("Return_Dataset.csv", header = TRUE)
return_data <- return_data[order(return_data$Date),]
a) First 10 rows of data
# a) First 10 rows of data
head(return_data, n=10)
## Date RF UPS KO Mkt
## 45 2015-12-01 1e-04 -0.059265990 0.015707901 -0.0216
## 44 2016-01-01 1e-04 -0.031487147 -0.000931283 -0.0576
## 43 2016-02-01 2e-04 0.035944259 0.004893142 -0.0005
## 42 2016-03-01 2e-04 0.101124671 0.075585176 0.0698
## 41 2016-04-01 1e-04 -0.003792522 -0.026743221 0.0093
## 40 2016-05-01 1e-04 -0.018844734 -0.004464390 0.0179
## 39 2016-06-01 2e-04 0.052928782 0.016367823 -0.0003
## 38 2016-07-01 2e-04 0.003527532 -0.030121712 0.0397
## 37 2016-08-01 2e-04 0.010360964 -0.004584034 0.0052
## 36 2016-09-01 2e-04 0.008373973 -0.025558364 0.0027
b) Plot and print the cumulative returns of the returns across time. Eventually, by seeing the graph, do
UPS or KO outperform the Market? Explain. Note: The graph should include the legend to evidently see a
comparison. Hint: Use POSIXct for converting date into a time-series object.
Question 1: The purpose of this self-assessment is to implement performance metrics and understand
how the given stocks perform with respect to the market, and which of the two stocks is a better
investment to make. Follow the steps below, and answer the questions outside the code-block, in the R
Markdown File in 1-2 sentences. Knit your code to HTML using R Studio for a more presentable format and
submit the HTML file.
Use echo = TRUE while knitting so that the code is seen.
a. Load the ‘Return_Dataset.csv’ file into your R Studio and print the first 10 rows. (1 point)
Note: The data contains monthly returns of- Risk Free Asset (RF); Market (Mkt); United Parcel Service (UPS); KO
(Coca Cola)
b. Plot and print the cumulative returns of the returns across time. Eventually, by seeing the graph, do
UPS or KO outperform the Market? Explain. (2 points)
Note: The graph should include the legend to evidently see a comparison.
Hint: Use POSIXct for converting date into a time-series object.
c. Calculate and print the Sharpe Ratio and Treynor Ratio of UPS and KO. Which of the two is a better
investment to make? Explain. (Use the StdDev Sharpe Ratio to compare) (3 points)
setwd("C:/Users/OPG2/Desktop/GaTech/MGT 6203")
library(PerformanceAnalytics)
## Loading required package: xts
## Loading required package: zoo
##
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
##
## Attaching package: 'PerformanceAnalytics'
, ## The following object is masked from 'package:graphics':
##
## legend
library(PoSI)
library(xts)
library(lubridate)
##
## Attaching package: 'lubridate'
## The following object is masked from 'package:base':
##
## date
return_data <- read.csv("Return_Dataset.csv", header = TRUE)
return_data <- return_data[order(return_data$Date),]
a) First 10 rows of data
# a) First 10 rows of data
head(return_data, n=10)
## Date RF UPS KO Mkt
## 45 2015-12-01 1e-04 -0.059265990 0.015707901 -0.0216
## 44 2016-01-01 1e-04 -0.031487147 -0.000931283 -0.0576
## 43 2016-02-01 2e-04 0.035944259 0.004893142 -0.0005
## 42 2016-03-01 2e-04 0.101124671 0.075585176 0.0698
## 41 2016-04-01 1e-04 -0.003792522 -0.026743221 0.0093
## 40 2016-05-01 1e-04 -0.018844734 -0.004464390 0.0179
## 39 2016-06-01 2e-04 0.052928782 0.016367823 -0.0003
## 38 2016-07-01 2e-04 0.003527532 -0.030121712 0.0397
## 37 2016-08-01 2e-04 0.010360964 -0.004584034 0.0052
## 36 2016-09-01 2e-04 0.008373973 -0.025558364 0.0027
b) Plot and print the cumulative returns of the returns across time. Eventually, by seeing the graph, do
UPS or KO outperform the Market? Explain. Note: The graph should include the legend to evidently see a
comparison. Hint: Use POSIXct for converting date into a time-series object.