systematicinvestor/SIT

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

Opened this issue · 0 comments

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.