-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Calendarise self-defined date-times (e.g. business days and time) and respect structural missingness #18
Comments
I've also got some work done on exporting a subset of https://github.com/DavisVaughan/calendarrr There is also
I could see how you could attach a calendar object to a |
I was poking around calendarrr yesterday. It's a good starting point, although it doesn't provide time adjustment within a day. Maybe you wanna share some your thoughts here. |
On one hand, I'd like to modify the quantlib source directly to make the internal adjustments to allow for setting times within a day that are not allowed (like trading hours or something similar). The core of that problem would be defining (in cpp) The downside of this is that if quantlib changes and we want to merge in that new code, its not as straightforward as a copy paste because now we have changed their source code directly. I'm not sure if there is a good way to add new methods to the classes that are already there without modifying their code directly, but that would be ideal. Alternatively, this is something that the Quantlib team might be interested in, so they might be open to having this in quantlib directly. |
I'm also interested in knowing if it's possible to vectorise To incorporate a calendar into the tsibble framework, I suppose a new argument |
Does it make much sense to vectorize both For For If I'm a bit torn on what to do for this |
Probably vectorize both as in x <- Sys.Date() + 1:2
x
#> [1] "2018-08-28" "2018-08-29"
x + 1
#> [1] "2018-08-29" "2018-08-30"
x + 1:2
#> [1] "2018-08-29" "2018-08-31"
x + 1:3
#> Warning in unclass(e1) + unclass(e2): longer object length is not a
#> multiple of shorter object length
#> [1] "2018-08-29" "2018-08-31" "2018-08-31"
x[1] + 1:3
#> [1] "2018-08-29" "2018-08-30" "2018-08-31"
Line 232 in 9dabeab
I'd rather not to go for an Also, it would be nice to set a default calendar as a global option, like what bizdays does here. |
tsibble is designed to work with many types of index objects, as long as these S3 methods including
index_valid()
andpull_interval()
are defined for custom index classes, for example thetimeDate
class, and thenfill_na()
naturally work out of box.Since trading/business hours differ from one market/store to another, data are not recorded out of the trading hours. But
fill_na()
will insertNA
to the non-trading time, because tsibble thinks it as calendar periods. tsibble needs a more general class that handles custom time ranges and respects these missing observations.For example, the data set
calls
from the fpp2 package contains five-minute call volume handled on weekdays between 7:00am and 9:05pm, from 3 March 2003 to 23 May 2003. A possible interface may look like this?Define your own calendar function:
Then apply to a vector of date-times and tsibble respects its missing time gaps:
How others handle with custom business days and hours:
pandas
API for custom business daysThe text was updated successfully, but these errors were encountered: