use chrono_tz::Asia;
use super::super::StaticHoursProfile;
use crate::calendar::SessionRule;
use crate::calendar::rule::MON_FRI;
static TSE_REGULAR_CURRENT: &[SessionRule] = &[
SessionRule {
days: MON_FRI,
open_ssm: 9 * 3600,
close_ssm: 11 * 3600 + 30 * 60,
},
SessionRule {
days: MON_FRI,
open_ssm: 12 * 3600 + 30 * 60,
close_ssm: 15 * 3600 + 25 * 60,
},
];
static TSE_REGULAR_POST_2011: &[SessionRule] = &[
SessionRule {
days: MON_FRI,
open_ssm: 9 * 3600,
close_ssm: 11 * 3600 + 30 * 60,
},
SessionRule {
days: MON_FRI,
open_ssm: 12 * 3600 + 30 * 60,
close_ssm: 15 * 3600,
},
];
static TSE_REGULAR_PRE_2011: &[SessionRule] = &[
SessionRule {
days: MON_FRI,
open_ssm: 9 * 3600,
close_ssm: 11 * 3600,
},
SessionRule {
days: MON_FRI,
open_ssm: 12 * 3600 + 30 * 60,
close_ssm: 15 * 3600,
},
];
static TSE_EXTENDED_CURRENT: &[SessionRule] = &[SessionRule {
days: MON_FRI,
open_ssm: 8 * 3600 + 20 * 60,
close_ssm: 18 * 3600,
}];
static TSE_EXTENDED_PRE_2024: &[SessionRule] = &[SessionRule {
days: MON_FRI,
open_ssm: 8 * 3600 + 20 * 60,
close_ssm: 17 * 3600 + 30 * 60,
}];
static TSE_ORDER_ENTRY: &[SessionRule] = &[SessionRule {
days: MON_FRI,
open_ssm: 8 * 3600,
close_ssm: 8 * 3600 + 20 * 60,
}];
pub(crate) static TSE_PROFILE_CURRENT: StaticHoursProfile = StaticHoursProfile {
tz: Asia::Tokyo,
regular: TSE_REGULAR_CURRENT,
extended: TSE_EXTENDED_CURRENT,
order_entry: TSE_ORDER_ENTRY,
has_daily_close: true,
has_weekend_close: true,
};
pub(crate) static TSE_PROFILE_POST_2011_11_21: StaticHoursProfile = StaticHoursProfile {
tz: Asia::Tokyo,
regular: TSE_REGULAR_POST_2011,
extended: TSE_EXTENDED_PRE_2024,
order_entry: TSE_ORDER_ENTRY,
has_daily_close: true,
has_weekend_close: true,
};
pub(crate) static TSE_PROFILE_PRE_2011_11_21: StaticHoursProfile = StaticHoursProfile {
tz: Asia::Tokyo,
regular: TSE_REGULAR_PRE_2011,
extended: TSE_EXTENDED_PRE_2024,
order_entry: TSE_ORDER_ENTRY,
has_daily_close: true,
has_weekend_close: true,
};
use crate::calendar::schedules::timeline::{Revision, local_date, revisions, select_revision};
pub(crate) const CURRENT: &StaticHoursProfile = &TSE_PROFILE_CURRENT;
static REVISIONS: &[Revision] = revisions![
(
2011,
11,
21,
&TSE_PROFILE_POST_2011_11_21,
"JPX trading-hours transition table"
),
(
2024,
11,
5,
&TSE_PROFILE_CURRENT,
"JPX news release 20241103-01"
),
];
pub(crate) fn profile_at(as_of: chrono::DateTime<chrono::Utc>) -> &'static StaticHoursProfile {
select_revision(
local_date(as_of, CURRENT.tz),
&TSE_PROFILE_PRE_2011_11_21,
REVISIONS,
)
}