Before I start, I would like to state that I have seen the FAQ entry at https://tsibble.tidyverts.org/articles/faq.html, however I am still unable to get to a workable solution.
I am using the "Aggregates (Bars)" output from polygon.io (https://polygon.io/docs/get_v2_aggs_ticker__forexTicker__range__multiplier___timespan___from___to__anchor)
Due to licensing/copyright restrictions I am unable to post the data here, but if you go to the docs link above, they have a sample there (no login required).
Polygon.io provide timestamp as follows:
t integer The Unix Msec timestamp for the start of the aggregate window.
My attempt so far looks like this :
library(fpp3)
library(fable.prophet)
library(jsonlite)
library(curl)
library(tidyverse)
library(lubridate)
myURL <- # *N.B. For sample data please see doc link in SO question*
myData <- fromJSON(myURL)
myData$ticker
myData$results
parse1 <- myData$results %>% select(t,c) %>%
mutate(dt = as_datetime(t/1000),.keep="unused",.before=1)
print(head(parse1))
parse2 <- as_tsibble(parse1,index=dt)
However this yields:
Error: Can't obtain the interval due to the mismatched index class.