Question 1

API stands for Application Programming Interface. For more text explanations of how an API works, examples, types of APIs, and types of API protocols, please read: (https://www.ibm.com/think/topics/api).

After your reading, could we say one of the benefits of API is providing some level of privacy or control over one’s internal data and the rate at which it can be accessed?

Answer: True.

Question 2

We need to run install.packages(“package_name”) each time when we call a function from a R package.

Answer: False.

Question 3

We need to load / activate the package when we call a function from a R package.

Answer: True.

Question 4

From where can we check how a package’s function works (e.g., how getSymbols() function works)? Select all that applies.

Answer: Options A, B, C, and D.

Question 5

Based on the Q3 suggested approaches, check if the following function description is correct:

In quantmod package, getSymbols() function loads and manage data from multiple sources such as yahoo finance, FRED, oanda, google, MySQL, csv, RData and Alpha Vantage.

Answer: True.

Question 6

Which of the following exactly return(s) the daily stock prices for Microsoft during 2025-10-01 ~ 2026-01-31 (including both end dates, pay attention to whether the ending day is included)?

(Note that you may need to search online for the stock symbol of Microsoft. Also, stock market closes during weekends, so it is normal if there are dates missing in your extracted data)

library(quantmod)
## Loading required package: xts
## Warning: package 'xts' was built under R version 4.4.3
## Loading required package: zoo
## Warning: package 'zoo' was built under R version 4.4.3
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
## Loading required package: TTR
## Registered S3 method overwritten by 'quantmod':
##   method            from
##   as.zoo.data.frame zoo
getSymbols("MSFT", src="yahoo",from = "2025-10-01", to = "2026-01-31")
## [1] "MSFT"
head(MSFT, 1)
##            MSFT.Open MSFT.High MSFT.Low MSFT.Close MSFT.Volume MSFT.Adjusted
## 2025-10-01     514.8    520.51   511.69     519.71    22632300      515.4689
tail(MSFT, 1)
##            MSFT.Open MSFT.High MSFT.Low MSFT.Close MSFT.Volume MSFT.Adjusted
## 2026-01-30    439.17     439.6   426.45     430.29    58566800      427.5774
dim(MSFT)
## [1] 84  6
getSymbols(c("GOOG","AMZN"), src="yahoo")
## [1] "GOOG" "AMZN"
head(GOOG, 1)
##            GOOG.Open GOOG.High GOOG.Low GOOG.Close GOOG.Volume GOOG.Adjusted
## 2007-01-03   11.6065    11.872  11.4847    11.6461   309415434      11.53683
tail(GOOG, 1)
##            GOOG.Open GOOG.High GOOG.Low GOOG.Close GOOG.Volume GOOG.Adjusted
## 2026-11-06   283.415    289.22      283     283.93    24585600        283.93
head(AMZN, 1)
##            AMZN.Open AMZN.High AMZN.Low AMZN.Close AMZN.Volume AMZN.Adjusted
## 2007-01-03     1.934     1.953   1.9025      1.935   248102000         1.935
tail(AMZN, 1)
##            AMZN.Open AMZN.High AMZN.Low AMZN.Close AMZN.Volume AMZN.Adjusted
## 2026-11-06    259.81    264.18   258.53      259.3    42497100         259.3
getSymbols("Microsoft", src="yahoo", from = "2025-10-01", to = "2026-01-31")
## Error in getSymbols.yahoo(Symbols = "Microsoft", env = <environment>, : Unable to import "Microsoft".
## HTTP error 404.
getSymbols.yahoo("MSFT", .GlobalEnv, from = "2025-10-01", to = "2026-01-31", periodicity = "weekly")
## [1] "MSFT"
head(.GlobalEnv$MSFT, 3)
##            MSFT.Open MSFT.High MSFT.Low MSFT.Close MSFT.Volume MSFT.Adjusted
## 2025-09-29    513.24    521.60   509.66     517.35    78695700      513.1281
## 2025-10-06    518.61    531.03   509.63     510.96    91844600      506.7903
## 2025-10-13    516.41    517.19   506.00     513.58    79090600      509.3889
tail(.GlobalEnv$MSFT, 1)
##            MSFT.Open MSFT.High MSFT.Low MSFT.Close MSFT.Volume MSFT.Adjusted
## 2026-01-26    465.31    483.74   421.02     430.29   282802600      427.5774
getSymbols("Microsoft", src="yahoo",from = "2025-10-01", to = Sys.Date())
## Error in getSymbols.yahoo(Symbols = "Microsoft", env = <environment>, : Unable to import "Microsoft".
## HTTP error 404.
getSymbols("MSFT", src="yahoo",from = "2025-10-01", to = "2026-02-01")
## [1] "MSFT"
head(MSFT, 1)
##            MSFT.Open MSFT.High MSFT.Low MSFT.Close MSFT.Volume MSFT.Adjusted
## 2025-10-01     514.8    520.51   511.69     519.71    22632300      515.4689
tail(MSFT, 1)
##            MSFT.Open MSFT.High MSFT.Low MSFT.Close MSFT.Volume MSFT.Adjusted
## 2026-01-30    439.17     439.6   426.45     430.29    58566800      427.5774
dim(MSFT)
## [1] 84  6

Answer: Options F.

Question 7

Which of the following exactly return(s) the daily stock prices for Microsoft during 2025-10-01 ~ 2026-01-31 (including both end dates, pay attention to whether the ending day is included)?

(Note that you may need to search online for the stock symbol of Microsoft. Also, stock market closes during weekends, so it is normal if there are dates missing in your extracted data)

getSymbols("Microsoft", src="yahoo", from = "2025-10-01", to = "2026-01-31")
## Error in getSymbols.yahoo(Symbols = "Microsoft", env = <environment>, : Unable to import "Microsoft".
## HTTP error 404.
getSymbols.yahoo("MSFT", .GlobalEnv, from = "2025-10-01", to = "2026-01-31", periodicity = "weekly")
## [1] "MSFT"
head(.GlobalEnv$MSFT, 3)
##            MSFT.Open MSFT.High MSFT.Low MSFT.Close MSFT.Volume MSFT.Adjusted
## 2025-09-29    513.24    521.60   509.66     517.35    78695700      513.1281
## 2025-10-06    518.61    531.03   509.63     510.96    91844600      506.7903
## 2025-10-13    516.41    517.19   506.00     513.58    79090600      509.3889
tail(.GlobalEnv$MSFT, 1)
##            MSFT.Open MSFT.High MSFT.Low MSFT.Close MSFT.Volume MSFT.Adjusted
## 2026-01-26    465.31    483.74   421.02     430.29   282802600      427.5774
getSymbols("MSFT", src="yahoo", from = "2025-10-01", to = "2026-02-01")
## [1] "MSFT"
head(MSFT, 1)
##            MSFT.Open MSFT.High MSFT.Low MSFT.Close MSFT.Volume MSFT.Adjusted
## 2025-10-01     514.8    520.51   511.69     519.71    22632300      515.4689
tail(MSFT, 1)
##            MSFT.Open MSFT.High MSFT.Low MSFT.Close MSFT.Volume MSFT.Adjusted
## 2026-01-30    439.17     439.6   426.45     430.29    58566800      427.5774
dim(MSFT)
## [1] 84  6
getSymbols("Microsoft", src="yahoo", from = "2025-10-01", to = Sys.Date())
## Error in getSymbols.yahoo(Symbols = "Microsoft", env = <environment>, : Unable to import "Microsoft".
## HTTP error 404.
getSymbols("MSFT", src="yahoo", from = "2025-10-01", to = "2026-01-31")
## [1] "MSFT"
head(MSFT, 1)
##            MSFT.Open MSFT.High MSFT.Low MSFT.Close MSFT.Volume MSFT.Adjusted
## 2025-10-01     514.8    520.51   511.69     519.71    22632300      515.4689
tail(MSFT, 1)
##            MSFT.Open MSFT.High MSFT.Low MSFT.Close MSFT.Volume MSFT.Adjusted
## 2026-01-30    439.17     439.6   426.45     430.29    58566800      427.5774
dim(MSFT)
## [1] 84  6
getSymbols(c("GOOG","AMZN"), src="yahoo")
## [1] "GOOG" "AMZN"
head(GOOG, 1)
##            GOOG.Open GOOG.High GOOG.Low GOOG.Close GOOG.Volume GOOG.Adjusted
## 2007-01-03   11.6065    11.872  11.4847    11.6461   309415434      11.53683
tail(GOOG, 1)
##            GOOG.Open GOOG.High GOOG.Low GOOG.Close GOOG.Volume GOOG.Adjusted
## 2026-11-06   283.415    289.22      283     283.93    24585600        283.93
head(AMZN, 1)
##            AMZN.Open AMZN.High AMZN.Low AMZN.Close AMZN.Volume AMZN.Adjusted
## 2007-01-03     1.934     1.953   1.9025      1.935   248102000         1.935
tail(AMZN, 1)
##            AMZN.Open AMZN.High AMZN.Low AMZN.Close AMZN.Volume AMZN.Adjusted
## 2026-11-06    259.81    264.18   258.53      259.3    42497100         259.3

Answer: Options C.

Question 8

Continuing on the previous question, how many days of stock prices did you obtain?

Answer: Option A, 84.

Question 9

Could you find out in which time period did Microsoft’s Open prices reach the highest? (Hint: You may either directly check the open price through the data object in the environment. Or you may use plot() to observe the flutuation through a line chart, and you may need to use $ to index the corresponding column of open price)

plot(MSFT$MSFT.Open)

MSFT[which.max(MSFT$MSFT.Open), "MSFT.Open"]
##            MSFT.Open
## 2025-10-28       550

Answer: Option B, Oct27 - Nov4.

Question 10

Did you complete the DataCamp -> Assignments on one of the practice? (e.g., Introduction to R, Intermediate R, etc.)? If yes, congratulations on earning your badge from DataCamp! This step ensures you have established the fundamentals of R programming.

By clicking True, you confirm that the exercises are already complete, or that you will complete them within the next few days (by November 17th). The instructor can verify completion directly from the DataCamp dashboard if you complete either of the assigned practice.

Answer: True.