-
Notifications
You must be signed in to change notification settings - Fork 619
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
Improve handling of Weekday schedules when EndTime < StartTime #568
Improve handling of Weekday schedules when EndTime < StartTime #568
Conversation
In FX session typically starts on Sun evening and is reset around 5PM NewYork time. So daily schedule may look like this Sun 17:05 - Mon 16:55 Mon 17:05 - Tue 16:55 Tue 17:05 - Wed 16:55 Wed 17:05 - Thu 16:55 Thu 17:05 - Fri 16:55 I was expecting that below settings would achieve this: ``` Weekdays = SUNDAY,MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY StartTime = 17:05:00 EndTime = 16:55:00 ``` But they don't, because DefaultSessionSchedule considers the interval [Fri 17:05 - Sat 16:55] to be in session - even if Sat is not a weekday. This change improves weekday behaviour by going backwards until both start and end days are weekdays. It does not have any impact in cases when EndTime > StartTime. As a precaution, if suitable interval could not be found we revert to original behaviour. This should be configuration error, but even then returning something which is not quite right is better than getting stuck in infinite loop.
As a bit of background |
Hi @AndreyNudko , thanks for the PR. 👍 Sounds like this bug, do you agree? #486 |
It looks similar, but two TimeZone-s makes it even more complicated |
I think the other issue is that in certain configurations adjusting time by 1 day is not enough; here's how interval calculations go on Sun in the "23:55:00 Europe/Madrid - 17:05:00 America/New_York" scenario:
I can make the other test pass by swapping condition for a loop at DefaultSessionSchedule:212
I would be inclined to submit that a separate patch, because it seems less intrusive than my change. One thing which I realized is that my understanding of Weekdays is slightly different from 486. |
Actually, looking at #133 which introduced Weekdays: "comma-delimited list of the days to start the session on" I'm going to close this PR and maybe submit another one to just improve documentation, as it's currently a bit vague |
@AndreyNudko but #574 is still valid? |
In FX session typically starts on Sun evening and is reset around 5PM NewYork time. So daily schedule may look like this
Sun 17:05 - Mon 16:55
Mon 17:05 - Tue 16:55
Tue 17:05 - Wed 16:55
Wed 17:05 - Thu 16:55
Thu 17:05 - Fri 16:55
I was expecting that below settings would achieve this:
But they don't, because DefaultSessionSchedule considers the interval [Fri 17:05 - Sat 16:55] to be in session - even if Sat is not a weekday.
This change improves weekday behaviour by going backwards until both start and end days are weekdays. It does not have any impact in cases when EndTime > StartTime.
As a precaution, if suitable interval could not be found we revert to original behaviour. This should be configuration error, but even then returning something which is not quite right is better than getting stuck in infinite loop.