-
-
Notifications
You must be signed in to change notification settings - Fork 71
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
to.period is not working as expected for the first record #153
Comments
I'm not convinced this is a bug. If you look at the output of head(endpoints(GBPUSD, 'minutes', k=2))
#[1] 0 1 3 5 7 9 This is because the index for If you subtract a small amount from each index value, you get the behavior you seem to expect. This is because the .index(GBPUSD) <- .index(GBPUSD) - 0.0001
options(digits.secs=6, width=120)
head(xx <- to.period(GBPUSD,period = 'minutes', k=2))
# GBPUSD.Open GBPUSD.High GBPUSD.Low GBPUSD.Close GBPUSD.Volume
#2002-10-20 19:01:59.9998 1.5501 1.5501 1.5501 1.5501 115.55860
#2002-10-20 19:03:59.9998 1.5501 1.5501 1.5501 1.5501 33.79091
#2002-10-20 19:05:59.9998 1.5500 1.5500 1.5493 1.5497 41.72415
#2002-10-20 19:07:59.9998 1.5498 1.5498 1.5497 1.5498 144.68929
#2002-10-20 19:09:59.9998 1.5494 1.5494 1.5492 1.5492 41.73473
#2002-10-20 19:11:59.9998 1.5491 1.5493 1.5491 1.5493 113.86047
head(endpoints(GBPUSD, 'minutes', k=2))
#[1] 0 2 4 6 8 10 |
Note that there is no data point for T= 2002-10-21T04:00:00. Therefore, the first two minutes must be in the range of 2002-10-21T04:01:00 and 2002-10-21T04:02:59.999. |
|
My question is how does |
The baseline is determined by the period you choose. If you choose |
So the cutoff on |
No, the cutoff for |
Ok, we're getting somewhere). So if |
Every 2 minutes. So, xx:x1:59.999, xx:x3:59.999, etc. The first 2 minutes of every hour are from xx:00:00.000-xx:01:59.999. The next two minutes are xx:02:00.000-xx:03:59.999... and the last 2 minutes are xx:58:00.000-xx:59:59.999. |
So, in a way, you can state that for periods larger than 1 minute, the cutoff is between the end of one hour and the beginning of the next hour, or XX:59:59.999, just like I wrote above. Well, it's not a bug then, but |
The first endpoint is being assigned to the first record, regardless of time. In the following example the record with time 04:01 ends up not aggregated in the processed xts records.
Reproduction of the error:
head(xx)
The text was updated successfully, but these errors were encountered: