Expose holidays in HolidayCalendar interface

The implementation of ImmutableHolidayCalendar has a #getHolidays method, it would be very useful to have this exposed so that the class can be used to represent economic event calendars. It’s an unfortunate reality that most if not all calendar providers co-mingle these economic events calendars with holiday calendars and having a NavigableSet of holiday dates would allow the class to be used across an entire dataset of provider data.

We could expose the method on ImmutableHolidayCalendar without too much of a problem. But we want to keep the HolidayCalendar interface clean, so we wouldn’t want to add the method to the interface. Would that be enough?

That’s certainly a good start, I believe the only way to get access to an ImmutableHolidayCalendar is to cast on the way out of a ReferenceData ?

I guess there’s a conceptual question here about whether you intend HolidayCalendar to be used outside the core of Strata, i.e. it would be a pretty standard use case to display a trader dashboard showing all the holiday / economic events for a given week/month, and right now to implement that you either have to decorate your class, or implement your own holiday code in order to populate yours.

I would suggest something like NavigableSet<LocalDate> getHolidays(LocalDate fromInclusive, LocalDate toExclusive) would be a useful addition to the HolidayCalendar interface.

1 Like

This is the proposed change:

Awesome, thanks for implementing

It occurred to me that you may want to allow the user to specify whether to include weekends or not rather than filter them out afterwards?

The interface does not distinguish holidays and weekends (that is an implementation choice). As such, I wouldn’t want to burden the interface with that knowledge.