-
-
Notifications
You must be signed in to change notification settings - Fork 173
Open
Labels
choreTedious chore.Tedious chore.enhancementNew feature or requestNew feature or requestreworkRe-work, re-structure, etc. Larger project.Re-work, re-structure, etc. Larger project.
Description
Instead of having a calendar trait and associated structs, I think a single struct would be more simple.
enum Market {
// Market Identifier Codes (MIC)
XNYS,
XNAS,
XASX,
XCBO,
...
// Special case calendars
Weekends,
None,
}
struct Calendar(Market);
impl Calendar {
fn new(market: Market) -> Self {
Self { market }
}
fn is_business_day(&self, date: Date) -> bool {
!self.is_weekend(date) && !self.is_holiday(date)
}
fn is_holiday(&self, date: Date) -> bool {
match self.0 {
Market::XNYS => is_holiday_impl_xnys(date),
Market::XNAS => is_holiday_impl_xnas(date),
Market::XASX => is_holiday_impl_xasx(date),
Market::XCBO => is_holiday_impl_xcbo(date),
...
}
}
}
This will make it easier to pass around (as opposed to using traits), and in particular to write Python bindings.
Metadata
Metadata
Assignees
Labels
choreTedious chore.Tedious chore.enhancementNew feature or requestNew feature or requestreworkRe-work, re-structure, etc. Larger project.Re-work, re-structure, etc. Larger project.