use chrono_tz::US;
use crate::calendar::rule::{MON_THU, SUN_ONLY, SUN_PLUS_MON_THU};
use crate::calendar::schedules::StaticHoursProfile;
use crate::calendar::schedules::timeline::{Revision, local_date, revisions, select_revision};
use crate::calendar::{FuturesSessionProfile, SessionRule};
static MATCHING_GRID: &[SessionRule] = &[SessionRule {
days: SUN_PLUS_MON_THU,
open_ssm: 17 * 3600,
close_ssm: 16 * 3600,
}];
static ORDER_ENTRY_AT_2010_FLOOR: &[SessionRule] = &[
SessionRule {
days: SUN_ONLY,
open_ssm: 16 * 3600 + 15 * 60,
close_ssm: 17 * 3600,
},
SessionRule {
days: MON_THU,
open_ssm: 16 * 3600 + 50 * 60,
close_ssm: 17 * 3600,
},
];
static ORDER_ENTRY_DATED_CURRENT: &[SessionRule] = &[
SessionRule {
days: SUN_ONLY,
open_ssm: 16 * 3600 + 15 * 60,
close_ssm: 17 * 3600,
},
SessionRule {
days: MON_THU,
open_ssm: 16 * 3600 + 45 * 60,
close_ssm: 17 * 3600,
},
];
pub(crate) static ORDER_ENTRY_CURRENT: &[SessionRule] = &[
SessionRule {
days: SUN_ONLY,
open_ssm: 16 * 3600,
close_ssm: 17 * 3600,
},
SessionRule {
days: MON_THU,
open_ssm: 16 * 3600 + 45 * 60,
close_ssm: 17 * 3600,
},
];
pub(crate) static CURRENT_FUTURES_PROFILE: FuturesSessionProfile = FuturesSessionProfile {
tz: US::Central,
regular: &[],
extended: MATCHING_GRID,
order_entry: ORDER_ENTRY_CURRENT,
has_daily_close: true,
has_weekend_close: true,
};
static AT_2010_FLOOR: StaticHoursProfile = StaticHoursProfile {
tz: US::Central,
regular: &[],
extended: MATCHING_GRID,
order_entry: ORDER_ENTRY_AT_2010_FLOOR,
has_daily_close: true,
has_weekend_close: true,
};
static DATED_CURRENT: StaticHoursProfile = StaticHoursProfile {
tz: US::Central,
regular: &[],
extended: MATCHING_GRID,
order_entry: ORDER_ENTRY_DATED_CURRENT,
has_daily_close: true,
has_weekend_close: true,
};
static FX_CURRENT: StaticHoursProfile = StaticHoursProfile {
tz: US::Central,
regular: &[],
extended: MATCHING_GRID,
order_entry: ORDER_ENTRY_CURRENT,
has_daily_close: true,
has_weekend_close: true,
};
static REVISIONS: &[Revision] = revisions![
(2010, 11, 15, &DATED_CURRENT, "CME Globex notice 20101025"),
(2016, 1, 3, &FX_CURRENT, "MARKET-DATA"),
];
pub(crate) fn profile_at(as_of: chrono::DateTime<chrono::Utc>) -> &'static StaticHoursProfile {
select_revision(local_date(as_of, US::Central), &AT_2010_FLOOR, REVISIONS)
}