library(BatchGetSymbols)
library(tidyverse)

first_date <- '2010-01-01'
last_date <- '2020-12-31'

df_prices <- BatchGetSymbols(tickers = 'GOOG', 
                             first.date = first_date,
                             last.date = last_date)[[2]]

value_purchase <- 1000

# solution
my_sol <- last(df_prices$price.adjusted)/first(df_prices$price.adjusted)*value_purchase
my_answers <- afedR::format_cash(
  as.numeric(afedR::make_random_answers(my_sol)), 
  type_cash = 'USD')

#check_answers(my_answers)

Question

Use the BatchGetSymbols package to download Google (GOOG) stock data, fromr first_date to r last_date. If the investor had bought 1000 USD in Google shares on the first day of the data and kept the investment until today, what would be the value of his portfolio?

exams::answerlist(my_answers, markup = "markdown")

Solution


Meta-information

extype: schoice exsolution: r mchoice2string(c(TRUE, FALSE, FALSE, FALSE, FALSE), single = TRUE) exname: "batchgetsymbols" exshuffle: TRUE



msperlin/afedR documentation built on Sept. 11, 2022, 9:49 a.m.