Skip to content

Commit 00d8213

Browse files
avhzavhz
authored andcommitted
docs: fix ISO 10383 constants docs
1 parent c9ae943 commit 00d8213

34 files changed

+334
-271
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ derive_builder = "0.20.0" # https://docs.rs/derive_builder/latest/derive_build
8686
errorfunctions = "0.2.0" # https://docs.rs/errorfunctions/latest/errorfunctions/
8787
finitediff = "0.1.4" # https://docs.rs/finitediff/latest/finitediff/
8888
icu = "1.5.0" # https://docs.rs/icu/latest/icu/
89+
log = "0.4.22" # https://docs.rs/log/latest/log/
8990
nalgebra = "0.33.0" # https://docs.rs/nalgebra/latest/nalgebra/
9091
ndrustfft = "0.5.0" # https://docs.rs/ndrustfft/latest/ndrustfft/
9192
ndarray-rand = "0.15.0" # https://docs.rs/ndarray-rand/latest/ndarray_rand/

crates/RustQuant_iso/src/iso_10383.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,12 @@ macro_rules! iso_10383 {
7272
$description:literal,
7373
)*) => {
7474
$(
75-
/// $description
75+
#[doc = concat!(
76+
"**MIC: ", stringify!($mic), "** (Operating MIC: ", $operating_mic, ")\n\n",
77+
"* Country Code: ", $iso_3166, "\n",
78+
"* City: ", $city, "\n",
79+
"* Status: ", stringify!($status)
80+
)]
7681
pub const $mic: ISO_10383 = ISO_10383 {
7782
operating_mic: $operating_mic,
7883
country_code: $iso_3166,

crates/RustQuant_time/src/calendar.rs

Lines changed: 6 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,13 @@
1111
1212
use crate::utilities::is_weekend;
1313
use time::Date;
14-
use RustQuant_iso::{ISO_10383, ISO_3166};
15-
16-
/// Calendar metadata struct.
17-
pub struct CalendarMetadata {
18-
/// Name of the calendar, typically the country name, but could also be
19-
/// a region/subdivision or a special calendar, such as a financial calendar (e.g. NYSE).
20-
pub name: &'static str,
21-
22-
/// ISO 3166-1 country code.
23-
pub country_code: ISO_3166,
24-
25-
/// ISO 10383 market identifier code.
26-
pub market_identifier_code: ISO_10383,
27-
}
14+
use RustQuant_iso::*;
2815

2916
/// Calendar trait.
3017
pub trait Calendar {
18+
/// Create a new instance of the calendar.
19+
fn new() -> Self;
20+
3121
/// Name of the calendar, typically the country name, but could also be
3222
/// a region/subdivision or a special calendar, such as a financial calendar (e.g. NYSE).
3323
fn name(&self) -> &'static str;
@@ -50,7 +40,7 @@ pub trait Calendar {
5040

5141
/// Function to list all holidays for a given range of `Date`s.
5242
fn all_holidays_between(&self, start_date: Date, end_date: Date) -> Vec<Date> {
53-
let mut holidays = Vec::new();
43+
let mut holidays = Vec::with_capacity((end_date - start_date).whole_days() as usize);
5444

5545
let mut temp_date = start_date;
5646

@@ -69,7 +59,7 @@ pub trait Calendar {
6959

7060
/// Function to list all business days for a given range of `Date`s.
7161
fn all_business_days_between(&self, start_date: Date, end_date: Date) -> Vec<Date> {
72-
let mut business_days = Vec::new();
62+
let mut business_days = Vec::with_capacity((end_date - start_date).whole_days() as usize);
7363

7464
let mut temp_date = start_date;
7565

@@ -86,37 +76,3 @@ pub trait Calendar {
8676
business_days
8777
}
8878
}
89-
90-
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
91-
// IMPLEMENTATIONS
92-
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
93-
94-
impl CalendarMetadata {
95-
/// New calendar metadata.
96-
pub fn new(
97-
name: &'static str,
98-
country_code: ISO_3166,
99-
market_identifier_code: ISO_10383,
100-
) -> Self {
101-
Self {
102-
name,
103-
country_code,
104-
market_identifier_code,
105-
}
106-
}
107-
108-
/// Returns the name of the calendar.
109-
pub fn name(&self) -> &'static str {
110-
self.name
111-
}
112-
113-
/// Returns the ISO 3166-1 country code.
114-
pub fn country_code(&self) -> ISO_3166 {
115-
self.country_code
116-
}
117-
118-
/// Returns the ISO 10383 market identifier code.
119-
pub fn market_identifier_code(&self) -> ISO_10383 {
120-
self.market_identifier_code
121-
}
122-
}

crates/RustQuant_time/src/countries/south_america/argentina.rs renamed to crates/RustQuant_time/src/countries/argentina.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ pub struct ArgentinaCalendar;
2828
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2929

3030
impl Calendar for ArgentinaCalendar {
31+
fn new() -> Self {
32+
Self
33+
}
34+
3135
fn name(&self) -> &'static str {
3236
"Argentina"
3337
}

crates/RustQuant_time/src/countries/oceania/australia.rs renamed to crates/RustQuant_time/src/countries/australia.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,18 @@ use RustQuant_iso::*;
1818
#[derive(Debug, Clone, Copy)]
1919
pub struct AustraliaCalendar;
2020

21+
impl AustraliaCalendar {
22+
/// Creates a new instance of the Australian calendar.
23+
pub fn new() -> Self {
24+
Self
25+
}
26+
}
27+
2128
impl Calendar for AustraliaCalendar {
29+
fn new() -> Self {
30+
Self
31+
}
32+
2233
fn name(&self) -> &'static str {
2334
"Australia"
2435
}

crates/RustQuant_time/src/countries/europe/austria.rs renamed to crates/RustQuant_time/src/countries/austria.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ pub struct AustriaCalendar;
2828
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2929

3030
impl Calendar for AustriaCalendar {
31+
fn new() -> Self {
32+
Self
33+
}
34+
3135
fn name(&self) -> &'static str {
3236
"Austria"
3337
}

crates/RustQuant_time/src/countries/africa/botswana.rs renamed to crates/RustQuant_time/src/countries/botswana.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ pub struct BotswanaCalendar;
3030
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3131

3232
impl Calendar for BotswanaCalendar {
33+
fn new() -> Self {
34+
Self
35+
}
36+
3337
fn name(&self) -> &'static str {
3438
"Botswana"
3539
}

crates/RustQuant_time/src/countries/south_america/brazil.rs renamed to crates/RustQuant_time/src/countries/brazil.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ pub struct BrazilCalendar;
2828
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2929

3030
impl Calendar for BrazilCalendar {
31+
fn new() -> Self {
32+
Self
33+
}
34+
3135
fn name(&self) -> &'static str {
3236
"Brazil"
3337
}

crates/RustQuant_time/src/countries/north_america/canada.rs renamed to crates/RustQuant_time/src/countries/canada.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ pub struct CanadaCalendar;
2828
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2929

3030
impl Calendar for CanadaCalendar {
31+
fn new() -> Self {
32+
Self
33+
}
34+
3135
fn name(&self) -> &'static str {
3236
"Canada"
3337
}

crates/RustQuant_time/src/countries/south_america/chile.rs renamed to crates/RustQuant_time/src/countries/chile.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ pub struct ChileCalendar;
2828
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2929

3030
impl Calendar for ChileCalendar {
31+
fn new() -> Self {
32+
Self
33+
}
34+
3135
fn name(&self) -> &'static str {
3236
"Chile"
3337
}

0 commit comments

Comments
 (0)