RustQuant icon indicating copy to clipboard operation
RustQuant copied to clipboard

Add more calendars.

Open avhz opened this issue 2 years ago • 7 comments

This involves:

1: Adding a new Market enum variant in calendar.rs

Add either:

  • A new country (e.g. Australia).
  • Or an MIC code (e.g. XASX) if for a specific exchange.
pub enum Market {
    /// Null calendar.
    None,
    /// Weekend-only calendar.
    Weekends,

    /// Argentina national calendar.
    Argentina,
    /// Australia national calendar.
    Australia,
    ...
}

2: Implement the appropriate is_holiday_impl_* function

Add a new is_holiday_impl_* function in the appropriate file under countries/.

pub(crate) fn is_holiday_impl_australia(date: Date) -> bool {
    let (y, m, d, wd, yd, em) = unpack_date(date, false);

    if
    // New Year's Day (possibly moved to Monday)
    ((d == 1 || ((d == 2 || d == 3) && wd == Weekday::Monday)) && m == Month::January)
            // Australia Day, January 26th (possibly moved to Monday)
            || ((d == 26 || ((d == 27 || d == 28) && wd == Weekday::Monday)) && m == Month::January)
            ...
            // National Day of Mourning for Her Majesty, September 22 (only 2022)
            || (d == 22 && m == Month::September && y == 2022)
    {
        return true;
    }

    false
}

To-do:

  • [x] Argentina
  • [x] Australia
  • [x] Austria
  • [x] Botswana
  • [x] Brazil
  • [x] Canada
  • [x] Chile
  • [x] China
  • [x] Czech Republic
  • [x] Denmark
  • [x] Finland
  • [x] France
  • [x] Germany
  • [x] Hong Kong
  • [x] Hungary
  • [x] Iceland
  • [x] India
  • [x] Indonesia
  • [x] Israel
  • [ ] Italy
  • [ ] Japan
  • [ ] Mexico
  • [x] New Zealand
  • [ ] Norway
  • [ ] Poland
  • [ ] Romania
  • [ ] Russia
  • [ ] Saudi Arabia
  • [x] Singapore
  • [ ] Slovakia
  • [ ] South Africa
  • [ ] South Korea
  • [ ] Sweden
  • [ ] Switzerland
  • [ ] Taiwan
  • [ ] Thailand
  • [ ] Turkey
  • [ ] Ukraine
  • [x] United Kingdom
  • [x] United States of America

avhz avatar Oct 19 '23 12:10 avhz

can i take this task?

daksh-code avatar Oct 25 '23 18:10 daksh-code

Sure :) take a look at what is already implemented for an idea of what needs to be done.

Thanks for your interest !

avhz avatar Oct 25 '23 21:10 avhz

@avhz Getting this error while building locally on mac air m1.

dakshdagariya@Dakshs-MacBook-Air RustQuant % cargo build
error: failed to download `color_quant v1.1.0`

Caused by:
  unable to get `packages` from source

Caused by:
  failed to download replaced source registry `crates-io`

Caused by:
  failed to read `/Users/dakshdagariya/.cargo/registry/src/index.crates.io-6f17d22bba15001f/color_quant-1.1.0/Cargo.toml`

Caused by:
  No such file or directory (os error 2)

daksh-code avatar Oct 27 '23 23:10 daksh-code

Hi, I'm not getting that error. Looks like a problem with the plotters crate.

Is your Rust up-to-date? Try rustup update and re-compile and let me know what happens.

Edit: probably also worth running cargo clean after updating Rust.

avhz avatar Oct 28 '23 10:10 avhz

Hi thanks @avhz I'm able to build now but how to run this locally getting this.

dakshdagariya@Dakshs-MacBook-Air RustQuant % cargo run            
error: a bin target must be available for `cargo run`

daksh-code avatar Oct 28 '23 11:10 daksh-code

RustQuant is a library, not a binary. So you can't run it.

You may find the Rust book helpful: https://doc.rust-lang.org/book/

I believe there's a chapter about libraries and binaries.

avhz avatar Oct 28 '23 11:10 avhz

okay thanks a lot.

daksh-code avatar Oct 28 '23 11:10 daksh-code