Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions crates/RustQuant_time/src/calendar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ pub enum Market {
UnitedStates,
/// Switzerland national calendar.
Switzerland,
/// Turkey national calendar.
Turkey,
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// MARKETS / EXCHANGES
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -435,6 +437,7 @@ impl Calendar {
Market::UnitedKingdom => is_holiday_impl_united_kingdom(date),
Market::UnitedStates => is_holiday_impl_united_states(date),
Market::Switzerland => is_holiday_impl_switzerland(date),
Market::Turkey => is_holiday_impl_turkey(date),
// Special case markets:
Market::None => false,
Market::Weekends => false,
Expand Down
4 changes: 4 additions & 0 deletions crates/RustQuant_time/src/countries/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,7 @@ pub(crate) use united_states::*;
/// Switzerland holidays and calendars.
pub mod switzerland;
pub(crate) use switzerland::*;

/// Turkey holidays and calendars.
pub mod turkey;
pub use turkey::*;
41 changes: 41 additions & 0 deletions crates/RustQuant_time/src/countries/turkey.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
use crate::utilities::unpack_date;
use time::{Date, Month};

/// Turkey calendar.
pub fn is_holiday_impl_turkey(date: Date) -> bool {
let (_y, m, d, _wd, _yd, _em) = unpack_date(date, false);

// Borsa Istanbul (BIST) Holiday Calendar
// Source: Official Public Holidays in Turkey

// Fixed Public Holidays (Gregorian Calendar)
if (d == 1 && m == Month::January) // New Year's Day
|| (d == 23 && m == Month::April) // National Sovereignty and Children's Day
|| (d == 1 && m == Month::May) // Labor and Solidarity Day
|| (d == 19 && m == Month::May) // Commemoration of Atatürk, Youth and Sports Day
|| (d == 15 && m == Month::July) // Democracy and National Unity Day
|| (d == 30 && m == Month::August) // Victory Day
|| (d == 29 && m == Month::October)
// Republic Day
{
return true;
}

false
}

#[cfg(test)]
mod tests {
use super::*;
use time::macros::date;

#[test]
fn test_turkey_holidays() {
// Republic Day
assert!(is_holiday_impl_turkey(date!(2024 - 10 - 29)));
// Victory Day
assert!(is_holiday_impl_turkey(date!(2024 - 08 - 30)));
// Regular business day
assert!(!is_holiday_impl_turkey(date!(2024 - 01 - 02)));
}
}
Loading