Automatically calculate public holidays from 1900-2203

Optuma Forums Optuma Scripting Automatically calculate public holidays from 1900-2203

This topic contains 4 replies, has 4 voices, and was last updated by Avatar Jonathan 2 months, 4 weeks ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #54047
    Avatar
    Dean
    • Topics: 13
    • Replies: 23
    • Posts: 36

    Hello Optuma scripting community.

    Mathew, Matthew, Darren, the Optuma support team and the Optuma scripting community have always been very helpful to me, so I thought I might give something back.

    This post is about a script that automatically calculates public holidays and therefore when markets are closed.

    And you are welcomed to use it.

    I found that in backtesting of my trading strategies it became important to know when public holidays were or will be, but it was quite a distraction to be constantly searching the internet to get answers to questions like ‘when was Good Friday in 2005?’, or ‘why is there no bar in an Optuma daily chart for Friday 22 April, 2011?’

    So I developed a script that automatically calculates public holidays. The MS Excel community has been doing this for years, and I was able to ‘borrow’ the Excel formulas for calculating public holidays and apply them in an Optuma script. And, with Optuma 1.4, new essential script functions like MOD, and the new ‘Numbers’ feature of Show Bar made it possible.

    The attached screen shot (US Public Holidays on SPX) shows the outcome of the script, applied to a daily SPX chart. Each number on the chart corresponds to one of the nine annual public holidays in the US. (You will also see a ’10’ as well: that was an irregular holiday for the state funeral of George Bush Snr… the script handles those sorts of scenarios too).

    While I have not tested the whole range, the Excel community reckons that Excel calculates all public holidays accurately from 1900- 2203, even the tricky ones like Good Friday. I use this script on my live strategies, and have found it to be accurate from 1980 – present so far.

    Now the trick is that there is no data on a public holiday when markets are closed, so Optuma won’t show a daily bar for a public holiday. Fair enough. So to indicate a public holiday on a daily chart, you need to do something like indicating it the day or week before, which sort of makes sense because you really want to know in advance when the markets are closed. So this script gives you the option of indicating 1 day or 7 days before the public holiday.

    The script is intended to be ‘plug-n-play’ so you should be able to just copy the code of this post and try it out for yourself. If you do use it and have some problems I will try to support you as best I can through this forum, but there is always the possibility of issues that I can’t resolve because it is highly likely our environment setups are different. What I also can’t do is warrant the script, so please be aware that you are using it at your own risk. You should understand it, test it, and be satisfied that it is accurate before applying it to your live trading strategies.

    This script is possibly not for the faint-hearted. It’s almost 200 lines long but does have substantial explanatory commentary within it. You can copy and paste and follow the instructions of the Show Bar to get an output like the screen shot, but if that doesn’t work first up, you will need to roll up your sleeves and start debugging.

    You might notice some strange looking things like  ‘@alias’, ‘@constant’, ‘{integer}’, ‘{1|o}’ etc. in the comments. Don’t worry about them, they don’t affect the script. (They’re there because I am developing an auto-documentation generator for Optuma scripts, which is in an alpha-testing phase at the moment).

    As a final note, the script has been developed for US public holidays only, but if there is sufficient interest from the Optuma scripting community, I will build an Australia public holiday equivalent. Just reply to this post if you are interested in an Aussie version.

    Now, here it comes. It’s also attached in a file also for your convenience. Good luck, and I hope that some of you find it useful!

    Cheers, Dean

     

     

     

     

     

    Attachments:
    #54053
    Avatar
    Dean
    • Topics: 13
    • Replies: 23
    • Posts: 36

    US Public Holiday Script

    1 user thanked author for this post.
    #54057
    Avatar
    Trevor R
    • Topics: 51
    • Replies: 155
    • Posts: 206

    Hi Dean

    Absolutely fantastic!! Many thanks for sharing.

    Australian Public Holidays would also be very useful for this Aussie.

    Then there are the holidays in UK, Europe (especially France and Germany), Singapore, Hong Kong, Japan, India and all the other markets that Optuma users watch.

    You could take a real whipping meeting world wide demand.

    Cheers

    Trevor

    #54069
    Mathew
    Mathew
    • Topics: 16
    • Replies: 1,057
    • Posts: 1,073

    That’s Awesome Dean, thanks so much for sharing.

    #54087
    Avatar
    Jonathan
    • Topics: 31
    • Replies: 47
    • Posts: 78

    I guess we’ll see this in an Optuma update 🙂

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

Pin It on Pinterest

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close