I would like to look at stock price data in R at a period smaller than daily. 1minute, 5minute, or 30minute would be ideal. I have tried working with the tq_transmute command but I cannot seem to get this working.
library(quantmod)
library(tidyquant)
library(tidyverse)
library(ggplot2)
# using tidyverse to import a ticker
spy <- tq_get("spy")
spysegment <- tq_get("spy", get ="stock.prices", from ='2022-10-13', to = '2022-10-19')
str(spysegment)
view(spysegment)
# get 30minute data not daily
spy30m <- tq_get(c("spy"), get="stock.prices") %>%
tq_transmute(select=close(),
mutate_fun=to.period,
period="minutes", n=30,
col_rename = "minute_return") %>%
ggplot(aes(date, minute_return)) +
geom_line()