Skip to content
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

bt.prep/bt.merge causes downloaded price data to be off by one day #34

Open
SidJnsn opened this issue Jan 3, 2019 · 0 comments
Open

Comments

@SidJnsn
Copy link

SidJnsn commented Jan 3, 2019

When prices are downloaded, they are indexed by Date. In bt.merge, conversion is done to POSIXct with the local timezone. Downloaded data converted to POSIXct, with no TZ conversion, has a time of midnight GMT. For any timezone earlier than that, the conversion results in each date being moved back one day. In my case, I am in the America/Chicago TZ, which is UTC-6 hours. The class statement at the bottom of bt.merge() converted 12-31-18 to 12-30-18 18:00:00:00.

I've used this code for years, but only noticed the problem this weekend, when it appeared that I had a market price for Sunday.

I realize this is an old problem with date conversions in R. Just curious if it was intentional to leave it unaddressed, or if the idea was to always run with the sysenv(TZ) set to GMT. My original fix was to do the latter, but I thought I saw that it screwed up my results - haven't gone back to verify that. My next fix was to add 6 hours to Unique.dates prior to the class statement (not pretty, I know, but effective for now).

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant