HolidayCalendar for CATO has Easter Monday as holiday. I need banking only


#1

I did a quick test for “current date” 04/14/17.

I got the results with the question marks because St. Patrick Day is present in the CATO holiday calendar? How do I get the HolidayCalendar to act only on the banking holidays?

LocalDate: 04/14/17
OtherDate: 04/18/17
isHoliday: true
isBusinessDay: false
nextDay: 04/18/17
nextOrSameDay: 04/18/17
PrevDay: 04/13/17
PrevOrSameDay: 04/13/17
isLastBusDayOfMonth: false
lastBusDayOfMonth: 04/28/17
numberOfBusDays: 0 ?!?
shifted 3: 04/20/17
adjustBy 3: 04/20/17
isStPatrickDay a Holiday: true ?!?

code

final HolidayCalendar CATO = HolidayCalendars.of("CATO");
	
	
	LocalDate localDate = LocalDate.of(2017, 4, 14);
	LocalDate otherDate = LocalDate.of(2017, 4, 18);
	// is the date a holiday/weekend or a business day
	boolean holiday = CATO.isHoliday(localDate);
	boolean busday  = CATO.isBusinessDay(localDate);
	    
	// next/previous business day
	LocalDate nextDay = CATO.next(localDate);
	LocalDate nextOrSameDay = CATO.nextOrSame(localDate);
	LocalDate prevDay = CATO.previous(localDate);
	LocalDate prevOrSameDay = CATO.previousOrSame(localDate);
	
	    
	// last business day of month
	boolean isLastBusDay   = CATO.isLastBusinessDayOfMonth(localDate);
	LocalDate lastBusDay = CATO.lastBusinessDayOfMonth(localDate);
	    
	// number of business days
	int days = CATO.daysBetween(localDate, otherDate);
	
	LocalDate shifted3 = CATO.shift(localDate, 3);
	
	LocalDate businessShifted3 = localDate.with(CATO.adjustBy(3));
	
	LocalDate stPatrickDay = LocalDate.of(2017, 4, 17);
	
	System.out.format("\nLocalDate: %tD%n"
			+ "OtherDate: %tD%n" 
			+ "isHoliday: %b%n"
			+ "isBusinessDay: %b%n"
			+ "nextDay: %tD%n"
			+ "nextOrSameDay: %tD%n"
			+ "PrevDay: %tD%n"
			+ "PrevOrSameDay: %tD%n"
			+ "isLastBusDayOfMonth: %b%n"
			+ "lastBusDayOfMonth: %tD%n"
			+ "numberOfBusDays: %d%n"
			+ "shifted 3: %tD%n"
			+ "adjustBy 3: %tD%n"
			+ "isHoliday: %b%n",
			localDate, otherDate, holiday, busday, nextDay, nextOrSameDay, prevDay, prevOrSameDay, isLastBusDay, lastBusDay, days, shifted3, businessShifted3, CATO.isHoliday(stPatrickDay));

Thanks


#2

The CATO holiday data is intended to match the fixings of the CDOR and CORRA indices. If it is wrong, then it should be fixed. However, in this case, 2017-04-17 is Easter Monday, which I believe is a valid holiday. You can see the code here:

If you need to replace the data, you can use HolidayCalendarData.ini.


#3

This is the reference we follow
2016 http://iiac.ca/wp-content/uploads/IIAC-Debt-Market-Holiday-Schedule-for-2016.pdf
2017 http://iiac.ca/wp-content/uploads/IIAC-Market-Closure-Schedule-for-2017.pdf

Markets are open on Easter Monday.
What I’m trying to do is to correctly set the settlement date based on T … T+3 rules. I can’t settle correctly if I consider Easter Monday a holiday. In Toronto…

I changed the subject to point to Easter Monday instead of St Patrick day (I did test that one too)

Really appreciate your feedback!


#4

As per this document, CDOR is published

The Benchmark will be published at 10:15 am ET each Business Day, subject to any delay as set forth in section 2.4 below. A Business Day means any day on which Schedule 1 banks under the Bank Act (Canada) are open for business in Toronto, Ontario, Canada

Looking at some bank websites, it seems that Easter Monday is not a holiday. Unfortunately, the CDOR fixings do not seem to be public, so they can’t be checked.

If you like, you could submit a pull request to remove the two Easter Monday lines from GlobalHolidayCalendar and fix the associated test.

In the meantime, you have two options - create a new holiday calendar, or edit the Strata source code and build a local release.

To create your own holiday calendar, create a file named HolidayCalendarData.ini in the classpath location com/opengamma/strata/config/application. It should have the contents:

[MyCATO]
2016-01-01
2016-12-25
Weekend = Sat,Sun

with whatever holiday dates you want. See the existing (empty) HolidayCalendarData.ini file for more details of the format.

Note that you have to use a different name - MyCATO, not CATO. This is another bug, caused by unexpected behaviour in Google’s Guava library. I’ll be fixing that bug.


#5

Thanks again Stephen.

The document you linked is a Thomson Reuters document - one of their products?!?

All Canadian info should come from a (National) trusted source, say

I will speak to my BAs and get the source of our business holidays to post it here.
That data we store in a table and currently load into our apps using objectlab toolkit.

I thought I could use the Starta HolidayCalendar as is but I’ll follow your suggestion and eventually generate a HolidayCalendarData.ini file from the DB to be loaded.

Is there a property that I can set to point to the location of the file? com.opengamma.strata.config.directories?


#6

Easter Monday removed in this PR

https://github.com/OpenGamma/Strata/pull/1440

The Strata holiday data is intended for evaluation purposes rather than production. As part of our commercial work will will be providing integration with well-known holiday calendar sources.

As I mentioned above, a file has to be added to the classpath to change the holiday calendars. The simplest form I described above. Alternative approaches can refer to a Java class that loads the data from an arbitrary location if that is desired. See ExtendedEnum and NamedLookup.


#7

I ended up creating a new Holiday calendar (named after our company) and a “Early close” calendar as well (since I were at it :slight_smile: ) together with their associated HolidayCalendarId’s

HolidayCalendar MY_HOLIDAYS_CAL = generateMine();
HolidayCalendarId MY_HOLIDAYS = HolidayCalendarId.of("MY_HOLIDAYS");

How to link the two so that I’ll be able to use it and be able to resolve the calendar from the ID to create a BusinessDayAdjustment like below?

BusinessDayAdjustment.of(BusinessDayConventions.FOLLOWING, MY_CALENDAR);

If I call the above i get an exception saying it cannot resolve the calendar from the ID. :frowning:
Truth is, I didn’t looked to deep into the sources being busy with a release.

Appreciate you help!


#8

Calendars are a type of extended enum, see the documentation to read details of how they work and how to register your class using a new config file.

You would thus need to add a file named com/opengamma/strata/config/application/HolidayCalendar.ini. The content will be similar to this:

[providers]
com.something.YourHolidayCalendars = constants

#9

Got it, Thanks!

Works like a charm!


#10

Just pulled 2.1.1-snapshot from Github,
My calendar is no longer found…

Reference data not found for identifier 'CANADA_HOLIDAYS' of type 'HolidayCalendarId'

The ini file is still in the newly built jar @ com/opengamma/strata/config/application/HolidayCalendar.ini and has

[providers]
com.candeal.calendar.CandaHolidaysCalendar = constants

in it…
What changed?
Thanks


#11

As per the v2.0 release notes, the file now needs to be in
META-INF/com/opengamma/strata/config/application/
(because of Java 9)


#12

Thanks Stephen!
I put it in that location as well