Dear *,
I’m a fan of Joda time, especially the simple, immutable LocalDate/LocalDateTime (and formally YearMonthDay/DateTime). However, these are the basic building blocks. I feel that every time I join a financial project I have to re-do the same things and I’d like to suggest an add-on/contribution/sub-project to Joda time. It could become the reference implementation.
The issue is of calculating “next good business” dates for the financial industry (or anything else that has ‘holidays’). For a given date, we need to talk into account 2 parameters on top of a date:
1/ a set of holiday/non-working days
2/ a piece logic to define what to do if we fall on a holiday
The most obvious ones are:
1/ do nothing, fall on a holiday but set a warning flag of some sort
2/ move forward 1 day until you fall on a working day, known as “forward”
3/ move backward 1 day until you fall on a working day, known as “backward”
4/ move forward 1 day until you fall on a working day, unless you cross into a new month in which case you reverse to a backward way; known as “modified forward” or “modified following”
5/ move backward 1 day until you fall on a working day, unless you cross into a new month in which case you reverse to a backward way; known as “modified backward”
The set of holidays can be explicit dates but we should also be able to consider weekends as holidays or not (in a flexible manner as some markets are closed Friday and Sunday but open Saturday).
I have done this in the past and I am quite open to provide a first shot with a tad of guidance from Joda to make it efficient.
The way I did this in the past is by defining a small inheritance structure e.g. ForwardCalendar, BackwardCalendar, etc such a calendar would:
-
accept a set of LocalDate (should they be kept as dates
or something smaller?), or should we use DateTime instead, my feeling is that LocalDate is enough.
-
take a startDate (again LocalDate)
- have a (unique) name
- have some methods like: plusDays(…), plusBusinessDays(…) this modifies the value inside the Calendar and a getLocalDate() returns a LocalDate. The difference between plusDays(int) vs plusBusinessDays(…) is that the first one does the check only on the calculated date: start+offset, whilst the second one moves the date by a number of business days (i.e. if you have a holiday in the middle of the offset, you will move further).
Next steps could include calculating the next IMM dates, IMM dates between 2 dates, handling tenors (1m,5y,S/N/, T/N, etc) and day count (with soooo many conventions) etc… this would become extremely valuable…
Is there an open source project for this? Has anyone done this? Would they be willing to open source it? Would they be willing to help?
Would Joda-Time accept their contribution as an add-on (joda-financial for instance).
Steve, any suggestion, we can discuss offline if you want.
Best regards
Benoit
------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________ Joda-interest mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/joda-interest
