Skip to content

Commit 1906531

Browse files
Ozan Kenan GüngörOzan Kenan Güngör
authored andcommitted
feat: add Turkey calendar (Fixed holidays)
1 parent 4795680 commit 1906531

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

crates/RustQuant_time/src/calendar.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ pub enum Market {
8787
UnitedStates,
8888
/// Switzerland national calendar.
8989
Switzerland,
90+
/// Turkey national calendar.
91+
Turkey,
9092
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9193
// MARKETS / EXCHANGES
9294
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -435,6 +437,7 @@ impl Calendar {
435437
Market::UnitedKingdom => is_holiday_impl_united_kingdom(date),
436438
Market::UnitedStates => is_holiday_impl_united_states(date),
437439
Market::Switzerland => is_holiday_impl_switzerland(date),
440+
Market::Turkey => is_holiday_impl_turkey(date),
438441
// Special case markets:
439442
Market::None => false,
440443
Market::Weekends => false,

crates/RustQuant_time/src/countries/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,7 @@ pub(crate) use united_states::*;
116116
/// Switzerland holidays and calendars.
117117
pub mod switzerland;
118118
pub(crate) use switzerland::*;
119+
120+
/// Turkey holidays and calendars.
121+
pub mod turkey;
122+
pub use turkey::*;
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
use crate::utilities::unpack_date;
2+
use time::{Date, Month};
3+
4+
/// Turkey calendar.
5+
pub fn is_holiday_impl_turkey(date: Date) -> bool {
6+
let (_y, m, d, _wd, _yd, _em) = unpack_date(date, false);
7+
8+
// Borsa Istanbul (BIST) Holiday Calendar
9+
// Source: Official Public Holidays in Turkey
10+
11+
// Fixed Public Holidays (Gregorian Calendar)
12+
if (d == 1 && m == Month::January) // New Year's Day
13+
|| (d == 23 && m == Month::April) // National Sovereignty and Children's Day
14+
|| (d == 1 && m == Month::May) // Labor and Solidarity Day
15+
|| (d == 19 && m == Month::May) // Commemoration of Atatürk, Youth and Sports Day
16+
|| (d == 15 && m == Month::July) // Democracy and National Unity Day
17+
|| (d == 30 && m == Month::August) // Victory Day
18+
|| (d == 29 && m == Month::October)
19+
// Republic Day
20+
{
21+
return true;
22+
}
23+
24+
false
25+
}
26+
27+
#[cfg(test)]
28+
mod tests {
29+
use super::*;
30+
use time::macros::date;
31+
32+
#[test]
33+
fn test_turkey_holidays() {
34+
// Republic Day
35+
assert!(is_holiday_impl_turkey(date!(2024 - 10 - 29)));
36+
// Victory Day
37+
assert!(is_holiday_impl_turkey(date!(2024 - 08 - 30)));
38+
// Regular business day
39+
assert!(!is_holiday_impl_turkey(date!(2024 - 01 - 02)));
40+
}
41+
}

0 commit comments

Comments
 (0)