avhz / RustQuant

Rust library for quantitative finance.
https://avhz.github.io
Apache License 2.0
1.02k stars 115 forks source link

Add more calendars. #142

Open avhz opened 10 months ago

avhz commented 10 months ago

This just involves going through each country and completing the following boilerplate (using some source such as timeanddate.com).

pub struct Argentina;

impl Calendar for Argentina {
    fn name(&self) -> &'static str {
        "Argentina"
    }

    fn country_code(&self) -> crate::iso::ISO_3166 {
        crate::iso::ARGENTINA
    }

    // Use the MIC code for the primary stock exchange of the country.
    fn market_identifier_code(&self) -> crate::iso::ISO_10383 {
        crate::iso::XBUE
    }

    fn is_business_day(&self, date: OffsetDateTime) -> bool {
        let (w, d, m, y, dd) = self.unpack_date(date);
        let em = Self::easter_monday(y as usize, false);

        if Self::is_weekend(date)
            || (d == 25 && m == Month::December)  // Christmas
            || (d == 1 && m == Month::January)    // New Years Day
             ...                                  // and so on...
        {
            return false;
        }

        true
    }
}

To-do:

daksh-code commented 10 months ago

can i take this task?

avhz commented 10 months ago

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

Thanks for your interest !

daksh-code commented 9 months ago

@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)
avhz commented 9 months ago

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.

daksh-code commented 9 months ago

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`
avhz commented 9 months ago

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.

daksh-code commented 9 months ago

okay thanks a lot.