Install the Packages:

# install.packages("wbstats")
library(wbstats)

# install.packages("quantmod")
library(quantmod)
## Loading required package: xts
## Loading required package: zoo
## 
## 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

Question 6: Which of the following exactly return(s) the daily stock prices for Microsoft during 2025-10-01 ~ 2026-01-31

getSymbols("MSFT", src="yahoo", from = "2025-10-01", to = "2026-02-01")
## [1] "MSFT"

Question 7: How many days of stock prices did you obtain?

number_of_days <- nrow(MSFT)
print(number_of_days)
## [1] 84

Question 8: Could you find out in which time period did Microsoft’s Open prices reach the highest?

plot(MSFT$MSFT.Open, 
     main = "Microsoft Open Prices (Oct 2025 - Jan 2026)", 
     col = "blue", 
     lwd = 2)

MSFT[which.max(MSFT$MSFT.Open), ]
##            MSFT.Open MSFT.High MSFT.Low MSFT.Close MSFT.Volume MSFT.Adjusted
## 2025-10-28       550    553.72   540.77     542.07    29986700      541.0574

Question 10(E.C): Are you able to extract a dataset that you feel interested in via a new API that we have not introduced in class?

Crude Oil Prices extracted from FRED(Federal Reserve Economic Data)

getSymbols("DCOILWTICO", src = "FRED")
## [1] "DCOILWTICO"
head(DCOILWTICO)
##            DCOILWTICO
## 1986-01-02      25.56
## 1986-01-03      26.00
## 1986-01-06      26.53
## 1986-01-07      25.85
## 1986-01-08      25.87
## 1986-01-09      26.03