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

minute_to_session raises error if passed default_start date #266

Closed
MBounouar opened this issue Dec 11, 2022 · 3 comments
Closed

minute_to_session raises error if passed default_start date #266

MBounouar opened this issue Dec 11, 2022 · 3 comments

Comments

@MBounouar
Copy link

Hi,
before version 4.x passing the default start date wouldn't raise an error and simply return the valid session i.e.

nys = get_calendar("XNYS")
nys.minute_to_session_label(pd.Timestamp("2002-12-11", tz="UTC"))

now nys.minute_to_session(pd.Timestamp("2002-12-11", tz="UTC"))
raises errors.MinuteOutOfBounds(calendar, ts, param_name)

Was that change intentional?

@maread99
Copy link
Collaborator

Hi @MBounouar, yes this change is intentional.

Here the minute is being passed as UTC midnight on the day of the calendar's first session, although the first minute covered by the calendar will be that session's first minute, (14:30 UTC). The exception's raised as the minute passed is earlier than the first minute covered by the calendar.

See the sessions and minutes tutorials for all things sessions and minutes in v4.

Cheers

@MBounouar
Copy link
Author

Hi @maread99

If it was intentional, I will close the issue.

Though, I still would have expected that direction="next" (which is the default) wouldn't be so unforgiving in this particular case, and kept the old behavior.

Cheers,

@maread99
Copy link
Collaborator

Without being strict a user could, without realizing it, pass any minute before the calendar's first minute and wrongly, but reasonably, assume the calendar's first session is the corresponding session.

It makes no difference if the minute passed is 'just' before the first minute - without knowledge of the prior session's open/close it's not possible to know which session to assign a minute to (for example, for a 24h calendar the minute prior to the open should be assigned to the prior session).

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

2 participants