Appendium / objectlabkit

Date Calculators for Business /FX, FX Rate Calculator and Utils
http://objectlabkit.sf.net
Apache License 2.0
67 stars 24 forks source link

CAD value dates spot offset #2

Closed susspectsoftware-dev closed 10 years ago

susspectsoftware-dev commented 10 years ago

How does one handle the CAD T+1 offset when the default spot offset it T+2 for all values within the factory?

benoitx commented 10 years ago

Hi

This is handled by the caller of the methode moveByTenor

See http://objectlabkit.sourceforge.net/tenor.html

You can use the calculator as follows:

DateCalculator.moveByTenor(TenorCode.SPOT, 1); // 1 for CAD, 2 for nearly everything else.

The test AbstractForwardDateCalculatorTest has several examples with 1D and 2D for spot lag.

testMoveByTenorSpotOneDayToSpot()

and

testMoveByTenorSpotTwoDaysToSpot()

I hope this answers your question. Regards Benoit

On 31 July 2014 16:52, celerite notifications@github.com wrote:

How does one handle the CAD T+1 offset when the default spot offset it T+2 for all values within the factory?

— Reply to this email directly or view it on GitHub https://github.com/Appendium/objectlabkit/issues/2.

Follow us on Twitter @appendium http://twitter.com/appendium and

http://www.appendium.com

IMPORTANT NOTICE This communication contains information that is considered confidential and may also be privileged . It is for the exclusive use of the intended recipient(s). If you are not the intended recipient(s) please note that any form of distribution, copying or use of this communication or the information in it is strictly prohibited and may be unlawful. If you have received this communication in error please return it to the sender and delete the original.

susspectsoftware-dev commented 10 years ago

Morning,

We seem to have an issue we have created a USD holiday on Monday for instance and we are trying to trade SP for EUR/USD. When we go getSpot it is returning the 6th so Wednesday rather than Tuesday. The issue seems to be around the following lines of code where it is adding the holiday regardless if the day is holiday.

LocalDateCalculator.java line 100

That food loop looks to take any date that is holiday and move it forward.

On 31 Jul 2014, at 16:59, Benoit Xhenseval notifications@github.com wrote:

Hi

This is handled by the caller of the methode moveByTenor

See http://objectlabkit.sourceforge.net/tenor.html

You can use the calculator as follows:

DateCalculator.moveByTenor(TenorCode.SPOT, 1); // 1 for CAD, 2 for nearly everything else.

The test AbstractForwardDateCalculatorTest has several examples with 1D and 2D for spot lag.

testMoveByTenorSpotOneDayToSpot()

and

testMoveByTenorSpotTwoDaysToSpot()

I hope this answers your question. Regards Benoit

On 31 July 2014 16:52, celerite notifications@github.com wrote:

How does one handle the CAD T+1 offset when the default spot offset it T+2 for all values within the factory?

— Reply to this email directly or view it on GitHub https://github.com/Appendium/objectlabkit/issues/2.

Follow us on Twitter @appendium http://twitter.com/appendium and

http://www.appendium.com

IMPORTANT NOTICE This communication contains information that is considered confidential and may also be privileged . It is for the exclusive use of the intended recipient(s). If you are not the intended recipient(s) please note that any form of distribution, copying or use of this communication or the information in it is strictly prohibited and may be unlawful. If you have received this communication in error please return it to the sender and delete the original. — Reply to this email directly or view it on GitHub.

benoitx commented 10 years ago

Morning

What is your startDate? Friday? Bank holiday on Monday? usd with spotLag of 2?

Kindly confirm and I'll try to have a look today but this was 'quite' tested by several banks...


Important Notice This communication contains information that is considered confidential and may also be privileged. It is for the exclusive use of the intended recipient(s). If you are not the intended recipient(s) please note that any form of distribution, copying or use of this communication or the information in it is strictly prohibited and may be unlawful. If you have received this communication in error please return it to the sender and delete the original

On 1 Aug 2014, at 08:46, celerite notifications@github.com wrote:

Morning,

We seem to have an issue we have created a USD holiday on Monday for instance and we are trying to trade SP for EUR/USD. When we go getSpot it is returning the 6th so Wednesday rather than Tuesday. The issue seems to be around the following lines of code where it is adding the holiday regardless if the day is holiday.

LocalDateCalculator.java line 100

That food loop looks to take any date that is holiday and move it forward.

On 31 Jul 2014, at 16:59, Benoit Xhenseval notifications@github.com wrote:

Hi

This is handled by the caller of the methode moveByTenor

See http://objectlabkit.sourceforge.net/tenor.html

You can use the calculator as follows:

DateCalculator.moveByTenor(TenorCode.SPOT, 1); // 1 for CAD, 2 for nearly everything else.

The test AbstractForwardDateCalculatorTest has several examples with 1D and 2D for spot lag.

testMoveByTenorSpotOneDayToSpot()

and

testMoveByTenorSpotTwoDaysToSpot()

I hope this answers your question. Regards Benoit

On 31 July 2014 16:52, celerite notifications@github.com wrote:

How does one handle the CAD T+1 offset when the default spot offset it T+2 for all values within the factory?

— Reply to this email directly or view it on GitHub https://github.com/Appendium/objectlabkit/issues/2.

Follow us on Twitter @appendium http://twitter.com/appendium and

http://www.appendium.com

IMPORTANT NOTICE This communication contains information that is considered confidential and may also be privileged . It is for the exclusive use of the intended recipient(s). If you are not the intended recipient(s) please note that any form of distribution, copying or use of this communication or the information in it is strictly prohibited and may be unlawful. If you have received this communication in error please return it to the sender and delete the original. — Reply to this email directly or view it on GitHub.

— Reply to this email directly or view it on GitHub https://github.com/Appendium/objectlabkit/issues/2#issuecomment-50858031.

susspectsoftware-dev commented 10 years ago

I will confirm but Scott knows,

startDate today, Monday setup as USD holiday, trading EUR/USD spot lag of 2.

On 1 Aug 2014, at 09:03, Benoit Xhenseval notifications@github.com wrote:

Morning

What is your startDate? Friday? Bank holiday on Monday? usd with spotLag of 2?

Kindly confirm and I'll try to have a look today but this was 'quite' tested by several banks...


Important Notice This communication contains information that is considered confidential and may also be privileged. It is for the exclusive use of the intended recipient(s). If you are not the intended recipient(s) please note that any form of distribution, copying or use of this communication or the information in it is strictly prohibited and may be unlawful. If you have received this communication in error please return it to the sender and delete the original

On 1 Aug 2014, at 08:46, celerite notifications@github.com wrote:

Morning,

We seem to have an issue we have created a USD holiday on Monday for instance and we are trying to trade SP for EUR/USD. When we go getSpot it is returning the 6th so Wednesday rather than Tuesday. The issue seems to be around the following lines of code where it is adding the holiday regardless if the day is holiday.

LocalDateCalculator.java line 100

That food loop looks to take any date that is holiday and move it forward.

On 31 Jul 2014, at 16:59, Benoit Xhenseval notifications@github.com wrote:

Hi

This is handled by the caller of the methode moveByTenor

See http://objectlabkit.sourceforge.net/tenor.html

You can use the calculator as follows:

DateCalculator.moveByTenor(TenorCode.SPOT, 1); // 1 for CAD, 2 for nearly everything else.

The test AbstractForwardDateCalculatorTest has several examples with 1D and 2D for spot lag.

testMoveByTenorSpotOneDayToSpot()

and

testMoveByTenorSpotTwoDaysToSpot()

I hope this answers your question. Regards Benoit

On 31 July 2014 16:52, celerite notifications@github.com wrote:

How does one handle the CAD T+1 offset when the default spot offset it T+2 for all values within the factory?

— Reply to this email directly or view it on GitHub https://github.com/Appendium/objectlabkit/issues/2.

Follow us on Twitter @appendium http://twitter.com/appendium and

http://www.appendium.com

IMPORTANT NOTICE This communication contains information that is considered confidential and may also be privileged . It is for the exclusive use of the intended recipient(s). If you are not the intended recipient(s) please note that any form of distribution, copying or use of this communication or the information in it is strictly prohibited and may be unlawful. If you have received this communication in error please return it to the sender and delete the original. — Reply to this email directly or view it on GitHub.

— Reply to this email directly or view it on GitHub https://github.com/Appendium/objectlabkit/issues/2#issuecomment-50858031. — Reply to this email directly or view it on GitHub.

benoitx commented 10 years ago

Sorry, one more thing, are you using LocalDateCalculator from the JODA library or JDK8?

Which one is line 100 exactly?

Thanks

On 1 August 2014 09:06, celerite notifications@github.com wrote:

I will confirm but Scott knows,

startDate today, Monday setup as USD holiday, trading EUR/USD spot lag of 2.

On 1 Aug 2014, at 09:03, Benoit Xhenseval notifications@github.com wrote:

Morning

What is your startDate? Friday? Bank holiday on Monday? usd with spotLag of 2?

Kindly confirm and I'll try to have a look today but this was 'quite' tested by several banks...


Important Notice This communication contains information that is considered confidential and may also be privileged. It is for the exclusive use of the intended recipient(s). If you are not the intended recipient(s) please note that any form of distribution, copying or use of this communication or the information in it is strictly prohibited and may be unlawful. If you have received this communication in error please return it to the sender and delete the original

On 1 Aug 2014, at 08:46, celerite notifications@github.com wrote:

Morning,

We seem to have an issue we have created a USD holiday on Monday for instance and we are trying to trade SP for EUR/USD. When we go getSpot it is returning the 6th so Wednesday rather than Tuesday. The issue seems to be around the following lines of code where it is adding the holiday regardless if the day is holiday.

LocalDateCalculator.java line 100

That food loop looks to take any date that is holiday and move it forward.

On 31 Jul 2014, at 16:59, Benoit Xhenseval notifications@github.com wrote:

Hi

This is handled by the caller of the methode moveByTenor

See http://objectlabkit.sourceforge.net/tenor.html

You can use the calculator as follows:

DateCalculator.moveByTenor(TenorCode.SPOT, 1); // 1 for CAD, 2 for nearly everything else.

The test AbstractForwardDateCalculatorTest has several examples with 1D and 2D for spot lag.

testMoveByTenorSpotOneDayToSpot()

and

testMoveByTenorSpotTwoDaysToSpot()

I hope this answers your question. Regards Benoit

On 31 July 2014 16:52, celerite notifications@github.com wrote:

How does one handle the CAD T+1 offset when the default spot offset it T+2 for all values within the factory?

— Reply to this email directly or view it on GitHub https://github.com/Appendium/objectlabkit/issues/2.

Follow us on Twitter @appendium http://twitter.com/appendium and

http://www.appendium.com

IMPORTANT NOTICE This communication contains information that is considered confidential and may also be privileged . It is for the exclusive use of the intended recipient(s). If you are not the intended recipient(s) please note that any form of distribution, copying or use of this communication or the information in it is strictly prohibited and may be unlawful. If you have received this communication in error please return it to the sender and delete the original. — Reply to this email directly or view it on GitHub.

— Reply to this email directly or view it on GitHub < https://github.com/Appendium/objectlabkit/issues/2#issuecomment-50858031>.

— Reply to this email directly or view it on GitHub.

— Reply to this email directly or view it on GitHub https://github.com/Appendium/objectlabkit/issues/2#issuecomment-50859581 .

Follow us on Twitter @appendium http://twitter.com/appendium and

http://www.appendium.com

IMPORTANT NOTICE This communication contains information that is considered confidential and may also be privileged . It is for the exclusive use of the intended recipient(s). If you are not the intended recipient(s) please note that any form of distribution, copying or use of this communication or the information in it is strictly prohibited and may be unlawful. If you have received this communication in error please return it to the sender and delete the original.

susspectsoftware-dev commented 10 years ago

We are using LocalDateCalculator from JODA.

Line 100 is the method that says moveDays on the calculator.

public DateCalculator moveByBusinessDays(final int businessDays) { checkHolidayValidity(businessDays);

    final int numberOfStepsLeft = Math.abs(businessDays);
    final int step = (businessDays < 0 ? -1 : 1);

    for (int i = 0; i < numberOfStepsLeft; i++) {
        moveByDays(step);
    }

    return this;
}

On 1 Aug 2014, at 09:49, Benoit Xhenseval notifications@github.com wrote:

Sorry, one more thing, are you using LocalDateCalculator from the JODA library or JDK8?

Which one is line 100 exactly?

Thanks

On 1 August 2014 09:06, celerite notifications@github.com wrote:

I will confirm but Scott knows,

startDate today, Monday setup as USD holiday, trading EUR/USD spot lag of

On 1 Aug 2014, at 09:03, Benoit Xhenseval notifications@github.com wrote:

Morning

What is your startDate? Friday? Bank holiday on Monday? usd with spotLag of 2?

Kindly confirm and I'll try to have a look today but this was 'quite' tested by several banks...


Important Notice This communication contains information that is considered confidential and may also be privileged. It is for the exclusive use of the intended recipient(s). If you are not the intended recipient(s) please note that any form of distribution, copying or use of this communication or the information in it is strictly prohibited and may be unlawful. If you have received this communication in error please return it to the sender and delete the original

On 1 Aug 2014, at 08:46, celerite notifications@github.com wrote:

Morning,

We seem to have an issue we have created a USD holiday on Monday for instance and we are trying to trade SP for EUR/USD. When we go getSpot it is returning the 6th so Wednesday rather than Tuesday. The issue seems to be around the following lines of code where it is adding the holiday regardless if the day is holiday.

LocalDateCalculator.java line 100

That food loop looks to take any date that is holiday and move it forward.

On 31 Jul 2014, at 16:59, Benoit Xhenseval notifications@github.com wrote:

Hi

This is handled by the caller of the methode moveByTenor

See http://objectlabkit.sourceforge.net/tenor.html

You can use the calculator as follows:

DateCalculator.moveByTenor(TenorCode.SPOT, 1); // 1 for CAD, 2 for nearly everything else.

The test AbstractForwardDateCalculatorTest has several examples with 1D and 2D for spot lag.

testMoveByTenorSpotOneDayToSpot()

and

testMoveByTenorSpotTwoDaysToSpot()

I hope this answers your question. Regards Benoit

On 31 July 2014 16:52, celerite notifications@github.com wrote:

How does one handle the CAD T+1 offset when the default spot offset it T+2 for all values within the factory?

— Reply to this email directly or view it on GitHub https://github.com/Appendium/objectlabkit/issues/2.

Follow us on Twitter @appendium http://twitter.com/appendium and

http://www.appendium.com

IMPORTANT NOTICE This communication contains information that is considered confidential and may also be privileged . It is for the exclusive use of the intended recipient(s). If you are not the intended recipient(s) please note that any form of distribution, copying or use of this communication or the information in it is strictly prohibited and may be unlawful. If you have received this communication in error please return it to the sender and delete the original. — Reply to this email directly or view it on GitHub.

— Reply to this email directly or view it on GitHub < https://github.com/Appendium/objectlabkit/issues/2#issuecomment-50858031>.

— Reply to this email directly or view it on GitHub.

— Reply to this email directly or view it on GitHub https://github.com/Appendium/objectlabkit/issues/2#issuecomment-50859581 .

Follow us on Twitter @appendium http://twitter.com/appendium and

http://www.appendium.com

IMPORTANT NOTICE This communication contains information that is considered confidential and may also be privileged . It is for the exclusive use of the intended recipient(s). If you are not the intended recipient(s) please note that any form of distribution, copying or use of this communication or the information in it is strictly prohibited and may be unlawful. If you have received this communication in error please return it to the sender and delete the original. — Reply to this email directly or view it on GitHub.

benoitx commented 10 years ago

Ok, it is more complicated.

The definition of spot date typically (say EUR/GBP) requires a spotLag of 2 days meaning 2 WORKING days between today and spot. As such the current calculator is correct.

But things seems to get more funky with USD...

See http://www.londonfx.co.uk/valdates.html

For most T+2 currency pairs, if T+1 is a USD holiday, then this does not normally affect the spot date, but if a non-USD currency in the currency pair has a holiday on T+1, then it will make the spot date become T+3. If USD or either currency of a pair have a holiday on T+2, then the spot date will be T+3. This means, for example, that crosses such as EUR/GBP can never have a spot date on 4th July (although such a date could be quoted as an outright).

So... at the moment, I do not think that we support this correctly.

For EUR/GBP, the calculator would need 3 calendars: EUR, GBP and USD. SpotLag is 2 for that pair If T+1 is a bank holiday for EITHER EUR or GBP -> move to next day if calculated spot is a USD holiday, move forward

For EUR/USD, the calculator would need 2 calendars: EUR and USD SpotLag is 2 for that pair if T+1 is USD holiday -> Ignore and spot is T+2 if T+1 is EUR holiday -> move fwd 1 day, T+3

if calculated spot is either USD or EUR holiday -> move 1 more day.

I'll have to think about this one.

Thanks for raising this

Benoit

On 1 August 2014 09:52, celerite notifications@github.com wrote:

We are using LocalDateCalculator from JODA.

Line 100 is the method that says moveDays on the calculator.

public DateCalculator moveByBusinessDays(final int businessDays) { checkHolidayValidity(businessDays);

final int numberOfStepsLeft = Math.abs(businessDays); final int step = (businessDays < 0 ? -1 : 1);

for (int i = 0; i < numberOfStepsLeft; i++) { moveByDays(step); }

return this; }

On 1 Aug 2014, at 09:49, Benoit Xhenseval notifications@github.com wrote:

Sorry, one more thing, are you using LocalDateCalculator from the JODA library or JDK8?

Which one is line 100 exactly?

Thanks

On 1 August 2014 09:06, celerite notifications@github.com wrote:

I will confirm but Scott knows,

startDate today, Monday setup as USD holiday, trading EUR/USD spot lag of 2.

On 1 Aug 2014, at 09:03, Benoit Xhenseval notifications@github.com wrote:

Morning

What is your startDate? Friday? Bank holiday on Monday? usd with spotLag of 2?

Kindly confirm and I'll try to have a look today but this was 'quite' tested by several banks...


Important Notice This communication contains information that is considered confidential and may also be privileged. It is for the exclusive use of the intended recipient(s). If you are not the intended recipient(s) please note that any form of distribution, copying or use of this communication or the information in it is strictly prohibited and may be unlawful. If you have received this communication in error please return it to the sender and delete the original

On 1 Aug 2014, at 08:46, celerite notifications@github.com wrote:

Morning,

We seem to have an issue we have created a USD holiday on Monday for instance and we are trying to trade SP for EUR/USD. When we go getSpot it is returning the 6th so Wednesday rather than Tuesday. The issue seems to be around the following lines of code where it is adding the holiday regardless if the day is holiday.

LocalDateCalculator.java line 100

That food loop looks to take any date that is holiday and move it forward.

On 31 Jul 2014, at 16:59, Benoit Xhenseval notifications@github.com

wrote:

Hi

This is handled by the caller of the methode moveByTenor

See http://objectlabkit.sourceforge.net/tenor.html

You can use the calculator as follows:

DateCalculator.moveByTenor(TenorCode.SPOT, 1); // 1 for CAD, 2 for nearly everything else.

The test AbstractForwardDateCalculatorTest has several examples with 1D and 2D for spot lag.

testMoveByTenorSpotOneDayToSpot()

and

testMoveByTenorSpotTwoDaysToSpot()

I hope this answers your question. Regards Benoit

On 31 July 2014 16:52, celerite notifications@github.com wrote:

How does one handle the CAD T+1 offset when the default spot offset it T+2 for all values within the factory?

— Reply to this email directly or view it on GitHub https://github.com/Appendium/objectlabkit/issues/2.

Follow us on Twitter @appendium http://twitter.com/appendium and

http://www.appendium.com

IMPORTANT NOTICE This communication contains information that is considered confidential and may also be privileged . It is for the exclusive use of the intended recipient(s). If you are not the intended recipient(s) please note that any form of distribution, copying or use of this communication or the information in it is strictly prohibited and may be unlawful. If you have received this communication in error please return it to the sender and delete the original. — Reply to this email directly or view it on GitHub.

— Reply to this email directly or view it on GitHub <

https://github.com/Appendium/objectlabkit/issues/2#issuecomment-50858031>.

— Reply to this email directly or view it on GitHub.

— Reply to this email directly or view it on GitHub < https://github.com/Appendium/objectlabkit/issues/2#issuecomment-50859581> .

Follow us on Twitter @appendium http://twitter.com/appendium and

http://www.appendium.com

IMPORTANT NOTICE This communication contains information that is considered confidential and may also be privileged . It is for the exclusive use of the intended recipient(s). If you are not the intended recipient(s) please note that any form of distribution, copying or use of this communication or the information in it is strictly prohibited and may be unlawful. If you have received this communication in error please return it to the sender and delete the original. — Reply to this email directly or view it on GitHub.

— Reply to this email directly or view it on GitHub https://github.com/Appendium/objectlabkit/issues/2#issuecomment-50862922 .

Follow us on Twitter @appendium http://twitter.com/appendium and

http://www.appendium.com

IMPORTANT NOTICE This communication contains information that is considered confidential and may also be privileged . It is for the exclusive use of the intended recipient(s). If you are not the intended recipient(s) please note that any form of distribution, copying or use of this communication or the information in it is strictly prohibited and may be unlawful. If you have received this communication in error please return it to the sender and delete the original.

dingwa commented 10 years ago

Hi Benoit,

Thanks for the great library!

I'm working with celerite on getting this going. I have managed to get the behaviour we require by extending the LocalDateCalculator class. Which from what I can see at the moment means we are unable to use the LocalDateFactory. Anyway apologies for posting code into here, but 'our' LocalDateCalculator class looks like

''' public class OurLocalDateCalculator extends LocalDateCalculator {

public OurLocalDateCalculator() {
    //do nothing
}

/**
 * @param name
 * @param startDate
 * @param holidayCalendar
 * @param holidayHandler
 */
public OurLocalDateCalculator(String name, LocalDate startDate,
        HolidayCalendar<LocalDate> holidayCalendar,
        HolidayHandler<LocalDate> holidayHandler) {
    super(name, startDate, holidayCalendar, holidayHandler);
}

@Override
public DateCalculator<LocalDate> moveByBusinessDays(int businessDays) {
    DateCalculator<LocalDate> dateCalculator = super.moveByBusinessDays(businessDays);

    LocalDate currentBusinessDate = dateCalculator.getCurrentBusinessDate();

    HolidayCalendar<LocalDate> holidayCalendar = getHolidayCalendar();
    if(holidayCalendar.isHoliday(currentBusinessDate)) {
         moveByDays(1);
    }

    return this;
}

/**
 * is the given date a non working day?
 */
@Override
public boolean isNonWorkingDay(final LocalDate date) {
    HolidayCalendar<LocalDate> holidayCalendar = getHolidayCalendar();
    if (date != null && (holidayCalendar.getEarlyBoundary() != null || holidayCalendar.getLateBoundary() != null)) {
        checkBoundary(date);
    }
    return isWeekend(date);
}

@Override
protected DateCalculator<LocalDate> createNewCalculator(final String name, final LocalDate startDate,
        final HolidayCalendar<LocalDate> holidays, final HolidayHandler<LocalDate> handler) {
    return new OurLocalDateCalculator(name, startDate, holidays, handler);
}

} '''

I have probably broken some API contracts inherited by the superclasses, but unfortunately this seems to be the only way I can get something working. I'm still currently testing this so let me know if I have missed out anything

susspectsoftware-dev commented 10 years ago

Hi

Where are you based? Are you in London? Do you have a number I was wondering if you free for a chat about other development topics etc?

Regards On 1 Aug 2014, at 14:21, Scott Sue notifications@github.com wrote:

Hi Benoit,

Thanks for the great library!

I'm working with celerite on getting this going. I have managed to get the behaviour we require by extending the LocalDateCalculator class. Which from what I can see at the moment means we are unable to use the LocalDateFactory. Anyway apologies for posting code into here, but 'our' LocalDateCalculator class looks like

''' public class OurLocalDateCalculator extends LocalDateCalculator {

public OurLocalDateCalculator() { //do nothing }

/**

  • @param name
  • @param startDate
  • @param holidayCalendar
  • @param holidayHandler */ public OurLocalDateCalculator(String name, LocalDate startDate, HolidayCalendar holidayCalendar, HolidayHandler holidayHandler) { super(name, startDate, holidayCalendar, holidayHandler); }

@Override public DateCalculator moveByBusinessDays(int businessDays) { DateCalculator dateCalculator = super.moveByBusinessDays(businessDays);

LocalDate currentBusinessDate = dateCalculator.getCurrentBusinessDate();

HolidayCalendar<LocalDate> holidayCalendar = getHolidayCalendar();
if(holidayCalendar.isHoliday(currentBusinessDate)) {
     moveByDays(1);
}

return this;

}

/**

  • is the given date a non working day? */ @Override public boolean isNonWorkingDay(final LocalDate date) { HolidayCalendar holidayCalendar = getHolidayCalendar(); if (date != null && (holidayCalendar.getEarlyBoundary() != null || holidayCalendar.getLateBoundary() != null)) { checkBoundary(date); } return isWeekend(date); }

@Override protected DateCalculator createNewCalculator(final String name, final LocalDate startDate, final HolidayCalendar holidays, final HolidayHandler handler) { return new OurLocalDateCalculator(name, startDate, holidays, handler); } } '''

I have probably broken some API contracts inherited by the superclasses, but unfortunately this seems to be the only way I can get something working. I'm still currently testing this so let me know if I have missed out anything

— Reply to this email directly or view it on GitHub.

benoitx commented 10 years ago

Yep based in London, City.

Why don't you follow me @benoitx on twitter and I'll follow back and DM you

I'll think about a solution over the weekend.

Regards

Benoit


Important Notice This communication contains information that is considered confidential and may also be privileged. It is for the exclusive use of the intended recipient(s). If you are not the intended recipient(s) please note that any form of distribution, copying or use of this communication or the information in it is strictly prohibited and may be unlawful. If you have received this communication in error please return it to the sender and delete the original

On 1 Aug 2014, at 15:10, celerite notifications@github.com wrote:

Hi

Where are you based? Are you in London? Do you have a number I was wondering if you free for a chat about other development topics etc?

Regards On 1 Aug 2014, at 14:21, Scott Sue notifications@github.com wrote:

Hi Benoit,

Thanks for the great library!

I'm working with celerite on getting this going. I have managed to get the behaviour we require by extending the LocalDateCalculator class. Which from what I can see at the moment means we are unable to use the LocalDateFactory. Anyway apologies for posting code into here, but 'our' LocalDateCalculator class looks like

''' public class OurLocalDateCalculator extends LocalDateCalculator {

public OurLocalDateCalculator() { //do nothing }

/**

  • @param name
  • @param startDate
  • @param holidayCalendar
  • @param holidayHandler */ public OurLocalDateCalculator(String name, LocalDate startDate, HolidayCalendar holidayCalendar, HolidayHandler holidayHandler) { super(name, startDate, holidayCalendar, holidayHandler); }

@Override public DateCalculator moveByBusinessDays(int businessDays) { DateCalculator dateCalculator = super.moveByBusinessDays(businessDays);

LocalDate currentBusinessDate = dateCalculator.getCurrentBusinessDate();

HolidayCalendar holidayCalendar = getHolidayCalendar(); if(holidayCalendar.isHoliday(currentBusinessDate)) { moveByDays(1); }

return this; }

/**

  • is the given date a non working day? */ @Override public boolean isNonWorkingDay(final LocalDate date) { HolidayCalendar holidayCalendar = getHolidayCalendar(); if (date != null && (holidayCalendar.getEarlyBoundary() != null || holidayCalendar.getLateBoundary() != null)) { checkBoundary(date); } return isWeekend(date); }

@Override protected DateCalculator createNewCalculator(final String name, final LocalDate startDate, final HolidayCalendar holidays, final HolidayHandler handler) { return new OurLocalDateCalculator(name, startDate, holidays, handler); } } '''

I have probably broken some API contracts inherited by the superclasses, but unfortunately this seems to be the only way I can get something working. I'm still currently testing this so let me know if I have missed out anything

— Reply to this email directly or view it on GitHub.

— Reply to this email directly or view it on GitHub https://github.com/Appendium/objectlabkit/issues/2#issuecomment-50888384.

susspectsoftware-dev commented 10 years ago

Done. Under Celer :)

ping me on my email cuthbert.ben@gmail.com On 1 Aug 2014, at 15:57, Benoit Xhenseval notifications@github.com wrote:

@benoitx