Git Product home page Git Product logo

Comments (9)

xemwebe avatar xemwebe commented on June 12, 2024

Yes, if you just mention where and under what license you got this module from.
I already thought of extracting this module in a crate of its own anyway, since I believe it might be of use outside of finql... Maybe that's just the trigger I weighted for.

from finql.

xemwebe avatar xemwebe commented on June 12, 2024

I have just created a new crate "cal-calc" which contains just the calendar module. It's available on crates.io and on github.

from finql.

midnightcodr avatar midnightcodr commented on June 12, 2024

Awesome, thanks. Also I wanted to give a bit of explanation why I still need to create one specifically for US stock exchange - there are a couple of special rules in it - if a holiday is on a Saturday, if the Friday before it is NOT end of the monthly or accounting period, the Friday will be observed; if a holiday is on a Sunday, if the following Monday is NOT end of the monthly or yearly accounting period, the Monday will be observed; In addition to that, there are a few half-day stock exchange holidays, like the day before Independence Day (unless Independence Day is on a Monday) and Christmas Eve (unless Christmas is on a Friday). I've created the repo and so you can take a look. I am not familiar with license stuff therefore I would greatly appreciate it if you can give your suggestion/advice on how to do that.

from finql.

xemwebe avatar xemwebe commented on June 12, 2024

Well, if the are additional rules required, I would be happy to add them to the crate - I just do not know all possible holidays rules everywhere in the world.

If I understand correctly, you would require just one additional rule, i.e. a modified movable holidays which will be moved to Friday if it falls on a Saturday, but will be moved to Monday if it falls on Sunday? Is it correct? I am not sure how to handle the condition that this Friday or Monday must not fall into another month. If this condition is not fulfilled, will the holiday stay on Saturday or Sunday, or will it move to the next Monday instead of to the previous Friday and vice versa? And how to handle accounting periods? Aren't accounting periods specific to a given company? Would this require to add accounting period information to the calendar rule?

Regarding the half-day holidays: I would suggest to have two set of rules, one for full holidays, another for half-holidays, with full holidays takes precedence. This way, no new rules need be specified, which seems to be the same approach you have taken.

from finql.

xemwebe avatar xemwebe commented on June 12, 2024

I will add an additional rule to move holidays to Friday or Saturday without taking month end or start in to account, following the rules given here: https://www.marketbeat.com/stock-market-holidays/

from finql.

midnightcodr avatar midnightcodr commented on June 12, 2024

I saw that you added Holiday::ModifiedYearlyMovableDay, however there's a bug in the logic, if you want to use that for the US exchange due to rule 7.2. A good example to check is December 31, 2021. It was NOT observed even though 1/1/2022 falls on Saturday, because 12/31/2021 is both the ending of a monthly and yearly accounting period.

Regarding half (or partial) holidays, adding a new set of rules should work, but IMO adding a new attribute to the Holiday struct makes more sense, and that's what I do using HalfCheck

from finql.

xemwebe avatar xemwebe commented on June 12, 2024

Not really a bug, since I did not implement the end-of-month rule intentionally, since the rule wasn't clear to me. Apparently, holidays are not moved if they would fall into another month, as can be observed with January 1st in 2022 (Saturday, not moved) and in 2023 (moved to 2nd). December 31st is no good test, since it is not a regular full holiday. I have update cal-calc to reflect this rule.

I am still not convinced that it's a good idea to store the half-holiday flag with the holiday struct, since you need to tread half and full holidays almost always differently. Therefore, I see little benefit but significant drawbacks if you treat them as the variants of the same.

from finql.

midnightcodr avatar midnightcodr commented on June 12, 2024

@xemwebe you are right, I should have clarified that it's not a bug for not implementing logic to accommodate rule 7.2 which is a US specific rule. What I really meant is if I were to use your library directly without any modification for the US stock exchanges I would have run into the issue. December 31st might not be a good date to test but it is a good date to test for year 2021 (the result should be - it's NOT a stock exchange holiday, if rule 7.2 is considered).

Regarding half-day holidays, the reason I prefer NOT to have two of rules is that the half day holidays are always related to the full-day holidays (the day before Independence Day, the day before Christmas, and the day after Thanksgiving). Adding an attribute to the Holiday struct makes it more efficient IMO.

from finql.

xemwebe avatar xemwebe commented on June 12, 2024

Since the original issue has been solved and I still do not believe that mixing half and full holidays has any benefit, I close this thread.

from finql.

Related Issues (1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.