zipline icon indicating copy to clipboard operation
zipline copied to clipboard

BUG: env.next_trading_day() not Timezone aware

Open warren-oneill opened this issue 11 years ago • 5 comments

In certain cases the trading day and market open can fall on different days when the timestamp is converted to utc. What this means is the env.next_trading_day() can get stuck in a continuous loop due to the timezone change. Till now this has probably been not much of an issue since the NYSE open times remain on the same day when converted to UTC but when used in markets where the difference between local tz and UTC is bigger this can be an issue. I tried simply converting to the local tz before normalize_date(test_date) is called but this wasn't sufficient. Anyone have any recommendations for other possible solutions? @ssanderson?

warren-oneill avatar May 13 '15 13:05 warren-oneill

@warren-oneill can you give an example of inputs you're providing to zipline that manifest this bug?

ssanderson avatar May 13 '15 14:05 ssanderson

In my case I have a 24h market so market open is, e.g., 1-1-2015 00:00 in local tz and 31-12-2014 23:00 in UTC but it holds for any combination of timezone and open times where the UTC conversion changes the day.

warren-oneill avatar May 13 '15 14:05 warren-oneill

Hey @ssanderson I think I may have found a solution. The PR is here #579

warren-oneill avatar May 20 '15 14:05 warren-oneill

@warren-oneill glad you found a solution, and sorry for not being very responsive. I've been pretty heads-down on a major API redesign, the very WIP form of which lives here: https://github.com/quantopian/zipline/pull/584/files.

ssanderson avatar May 20 '15 19:05 ssanderson

Closed by #579

warren-oneill avatar May 27 '15 09:05 warren-oneill