Skip to content

Commit

Permalink
docs: fix ISO 10383 constants docs
Browse files Browse the repository at this point in the history
  • Loading branch information
avhz authored and avhz committed Nov 22, 2024
1 parent c9ae943 commit 00d8213
Show file tree
Hide file tree
Showing 34 changed files with 334 additions and 271 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ derive_builder = "0.20.0" # https://docs.rs/derive_builder/latest/derive_build
errorfunctions = "0.2.0" # https://docs.rs/errorfunctions/latest/errorfunctions/
finitediff = "0.1.4" # https://docs.rs/finitediff/latest/finitediff/
icu = "1.5.0" # https://docs.rs/icu/latest/icu/
log = "0.4.22" # https://docs.rs/log/latest/log/
nalgebra = "0.33.0" # https://docs.rs/nalgebra/latest/nalgebra/
ndrustfft = "0.5.0" # https://docs.rs/ndrustfft/latest/ndrustfft/
ndarray-rand = "0.15.0" # https://docs.rs/ndarray-rand/latest/ndarray_rand/
Expand Down
7 changes: 6 additions & 1 deletion crates/RustQuant_iso/src/iso_10383.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,12 @@ macro_rules! iso_10383 {
$description:literal,
)*) => {
$(
/// $description
#[doc = concat!(
"**MIC: ", stringify!($mic), "** (Operating MIC: ", $operating_mic, ")\n\n",
"* Country Code: ", $iso_3166, "\n",
"* City: ", $city, "\n",
"* Status: ", stringify!($status)
)]
pub const $mic: ISO_10383 = ISO_10383 {
operating_mic: $operating_mic,
country_code: $iso_3166,
Expand Down
56 changes: 6 additions & 50 deletions crates/RustQuant_time/src/calendar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,13 @@

use crate::utilities::is_weekend;
use time::Date;
use RustQuant_iso::{ISO_10383, ISO_3166};

/// Calendar metadata struct.
pub struct CalendarMetadata {
/// Name of the calendar, typically the country name, but could also be
/// a region/subdivision or a special calendar, such as a financial calendar (e.g. NYSE).
pub name: &'static str,

/// ISO 3166-1 country code.
pub country_code: ISO_3166,

/// ISO 10383 market identifier code.
pub market_identifier_code: ISO_10383,
}
use RustQuant_iso::*;

/// Calendar trait.
pub trait Calendar {
/// Create a new instance of the calendar.
fn new() -> Self;

/// Name of the calendar, typically the country name, but could also be
/// a region/subdivision or a special calendar, such as a financial calendar (e.g. NYSE).
fn name(&self) -> &'static str;
Expand All @@ -50,7 +40,7 @@ pub trait Calendar {

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

let mut temp_date = start_date;

Expand All @@ -69,7 +59,7 @@ pub trait Calendar {

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

let mut temp_date = start_date;

Expand All @@ -86,37 +76,3 @@ pub trait Calendar {
business_days
}
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// IMPLEMENTATIONS
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

impl CalendarMetadata {
/// New calendar metadata.
pub fn new(
name: &'static str,
country_code: ISO_3166,
market_identifier_code: ISO_10383,
) -> Self {
Self {
name,
country_code,
market_identifier_code,
}
}

/// Returns the name of the calendar.
pub fn name(&self) -> &'static str {
self.name
}

/// Returns the ISO 3166-1 country code.
pub fn country_code(&self) -> ISO_3166 {
self.country_code
}

/// Returns the ISO 10383 market identifier code.
pub fn market_identifier_code(&self) -> ISO_10383 {
self.market_identifier_code
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ pub struct ArgentinaCalendar;
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

impl Calendar for ArgentinaCalendar {
fn new() -> Self {
Self
}

fn name(&self) -> &'static str {
"Argentina"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,18 @@ use RustQuant_iso::*;
#[derive(Debug, Clone, Copy)]
pub struct AustraliaCalendar;

impl AustraliaCalendar {
/// Creates a new instance of the Australian calendar.
pub fn new() -> Self {
Self
}
}

impl Calendar for AustraliaCalendar {
fn new() -> Self {
Self
}

fn name(&self) -> &'static str {
"Australia"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ pub struct AustriaCalendar;
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

impl Calendar for AustriaCalendar {
fn new() -> Self {
Self
}

fn name(&self) -> &'static str {
"Austria"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ pub struct BotswanaCalendar;
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

impl Calendar for BotswanaCalendar {
fn new() -> Self {
Self
}

fn name(&self) -> &'static str {
"Botswana"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ pub struct BrazilCalendar;
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

impl Calendar for BrazilCalendar {
fn new() -> Self {
Self
}

fn name(&self) -> &'static str {
"Brazil"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ pub struct CanadaCalendar;
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

impl Calendar for CanadaCalendar {
fn new() -> Self {
Self
}

fn name(&self) -> &'static str {
"Canada"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ pub struct ChileCalendar;
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

impl Calendar for ChileCalendar {
fn new() -> Self {
Self
}

fn name(&self) -> &'static str {
"Chile"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ pub struct ChinaCalendar;
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

impl Calendar for ChinaCalendar {
fn new() -> Self {
Self
}

fn name(&self) -> &'static str {
"China"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ pub struct CzechRepublicCalendar;
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

impl Calendar for CzechRepublicCalendar {
fn new() -> Self {
Self
}

fn name(&self) -> &'static str {
"Czech Republic"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ pub struct DenmarkCalendar;
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

impl Calendar for DenmarkCalendar {
fn new() -> Self {
Self
}

fn name(&self) -> &'static str {
"Denmark"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ pub struct FinlandCalendar;
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

impl Calendar for FinlandCalendar {
fn new() -> Self {
Self
}

fn name(&self) -> &'static str {
"Finland"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ pub struct FranceCalendar;
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

impl Calendar for FranceCalendar {
fn new() -> Self {
Self
}

fn name(&self) -> &'static str {
"France"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ pub struct GermanyCalendar;
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

impl Calendar for GermanyCalendar {
fn new() -> Self {
Self
}

fn name(&self) -> &'static str {
"Germany"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ pub struct HongKongCalendar;
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

impl Calendar for HongKongCalendar {
fn new() -> Self {
Self
}

fn name(&self) -> &'static str {
"Hong Kong"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ pub struct HungaryCalendar;
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

impl Calendar for HungaryCalendar {
fn new() -> Self {
Self
}

fn name(&self) -> &'static str {
"Hungary"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ pub struct IcelandCalendar;
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

impl Calendar for IcelandCalendar {
fn new() -> Self {
Self
}

fn name(&self) -> &'static str {
"Iceland"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ pub struct IndiaCalendar;
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

impl Calendar for IndiaCalendar {
fn new() -> Self {
Self
}

fn name(&self) -> &'static str {
"India"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ pub struct IndonesiaCalendar;
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

impl Calendar for IndonesiaCalendar {
fn new() -> Self {
Self
}

fn name(&self) -> &'static str {
"Indonesia"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ impl IsraelCalendar {
}

impl Calendar for IsraelCalendar {
fn new() -> Self {
Self
}

fn name(&self) -> &'static str {
"Israel"
}
Expand Down
Loading

0 comments on commit 00d8213

Please sign in to comment.