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

Q trading_calendars used by zipline not maintained #176

Open
Sutyke opened this issue Feb 25, 2021 · 0 comments
Open

Q trading_calendars used by zipline not maintained #176

Sutyke opened this issue Feb 25, 2021 · 0 comments

Comments

@Sutyke
Copy link

Sutyke commented Feb 25, 2021

Zipline Trader is currently using Q trading_calendars that is not maintained. Former Q Software Engineer Gerry Manoim started to maintain this callendar under new name exchange_calendars, however there are depreciated some items that zipline is using.

I have opened issue in Gerry's repo's if we could work together. If zipline trader can use Gerry's exchange_calendar or maintain it's own.

Currently Q trading_calendars is getting old and doesn't work the same way under old and new pandas.

When I run the code below I get different results:
pandas 0.22,: true
pandas 1.1.5 : false (No error reported)

import pandas as pd
import trading_calendars
from trading_calendars import TradingCalendar
from datetime import timedelta, time as dtime
pd.__version__
cal: TradingCalendar = trading_calendars.get_calendar('NYSE')
end_date = pd.Timestamp('now', tz='utc').date() - timedelta(days=1)
cal.is_session(end_date)

Quick work around is to add timestamp:
cal.is_session(pd.Timestamp(end_date, tz='utc')

Zipline Q trading_calendars used to have open times one minute later.

Why are open times one minute late?
Due to its historical use in the Zipline backtesting system, trading_calendars will only indicate a market is open upon the completion of the first minute bar in a day. Zipline uses minute bars labeled with the end of the bar, e.g. 9:31AM for 9:30-9:31AM. As an example, on a regular trading day for NYSE:

9:30:00 is treated as closed.
9:30:01 is treated as closed.
9:31:00 is the first time treated as open.
16:00:00 is treated as open
16:00:01 is treated as closed
This may change in the future.

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