-
Notifications
You must be signed in to change notification settings - Fork 14
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
src/agent/market_hours.rs: Add market hours format implementation #93
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice. I think there's one issue here with day wrapping (see inline) but good aside from that.
match self { | ||
Self::Open => true, | ||
Self::Closed => false, | ||
Self::TimeRange(start, end) => start <= &when_market_local && &when_market_local <= end, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you need to support 24:00 in the format so that you can have intervals like:
17:00-24:00,00:00-17:00 (for 5pm on the first day through 5pm on the second day).
I think this current check will stop publishing between 11:59 pm and midnight every day if you're not careful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also can you add a test case for this day wraparound behavior?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is a very good observation. I added support for explicit 24:00
to mean 23:59:59.999(...)
down to a nanosecond and tested how it works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice
Motivation
This is the first in a series of changes realizing the market hours feature for conditional publishing according to dedicated market hours metadata. This change introduces a market hours format that lets us define a weekly schedule for a market, along with its local timezone. The format works as follows:
Examples
Asia/Hong_Kong,9:00-17:00,9:00-17:00,9:00-17:00,9:00-17:00,9:00-17:00,C,C
Europe/Lisbon,O,O,O,O,O,O,O
- This will probably be the default for symbols with no market hours metadataSummary of changes
src/agent/metrics.rs
- rustfmt really wanted me to add thissrc/agent/market_hours.rs
- The core of the changeCargo.toml
,Cargo.lock
- Bumpchrono
version, addchrono_tz
Review highlights
src/agent/market_hours.rs
- I think it would make sense to have more non-trivial timezone handling tests, including DST chanes etc.,ideas welcome