________________________________
From: Carnë Draug <carandraug+...@gmail.com>
To: littleman...@yahoo.com
Cc: Octave Forge <octave-dev@lists.sourceforge.net>
Sent: Saturday, October 27, 2012 8:50 AM
Subject: Re: [OctDev] [bug #37616] holidays result incorrect when New Year's
Day falls on Saturday
On 27 October 2012 14:46, Carnë Draug <carandraug+...@gmail.com> wrote:
> On 26 October 2012 15:24, <littleman...@yahoo.com> wrote:
>> Hi Carnë,
>>
>> After more careful inspection, it appears that when New Years Day falls on a
>> Saturday, the holiday is not observed at all. The holidays function does not
>> check that, so modifying line 41 will fix that (and also allow holidays to
>> pass its test). So please disregard the previous code change suggestion, and
>> consider the following instead.
>>
>> from holidays.m:
>> ------------------------------------------
>> ## New Year's Day
>> tmphol = datenum (yrs, 1, 1);
>> hol = [hol; tmphol(weekday(tmphol(:)) ~= 7)(:)];
>> ------------------------------------------
>> I modified the last line from
>> hol = [hol; tmphol(:)];
>>
>> Thanks for the link. I will submit octave-forge bugs there in the future.
>> Should I open up a new thread there for this bug, or is that unnecessary?
>>
>> -Randy Chamberlin
>
> Hi Randy
>
> not necessary this time. I have commited your changes see
> https://sourceforge.net/p/octave/code/11368
I was taking a closer look at the function and noticed the block near
the end that is meant to adjust for sundays and saturdays.
wd = weekday (hol);
if any (wd == 1)
hol(wd == 1) = hol(wd == 1) + 1;
endif
if any (wd == 7)
hol(wd == 7) = hol(wd == 7) - 1;
endif
I believe that a better fix should go in here.
Carnë
----------------------
Hi Carne,
I think the problem is that according to NYSE rules, holidays are not allowed
to span across a calendar year.
From the NYSE rules at
http://nyserules.nyse.com/nysetools/PlatformViewer.asp?SelectedNode=chp_1_3&manual=/nyse/rules/nyse-rules/
"The Exchange Board has also determined that, when any holiday observed
by the Exchange falls on a Saturday, the Exchange will not be open for
business on the preceding Friday and when any holiday observed by the
Exchange falls on a Sunday, the Exchange will not be open for business
on the succeeding Monday, unless unusual business conditions exist, such
as the ending of a monthly or the yearly accounting period."
So in general, Saturday holidays should be shifted to the previous Friday, and
Sunday holidays to the next Monday, except when it crosses a calendar year. So
I think the original logic (pre my patch) is correct, with the exception that
it does not attempt to account for the case where New Years Day falls on a
Saturday and crosses a yearly accounting period. In that case, the NYSE rules
say it should be ignored, but the original logic alone doesn't do that. If you
check the link posted in the help file for holidays
(http://www.chronos-st.org/NYSE_Observed_Holidays-1885-Present.html), you can
see that Saturday, Jan 1, 2005 was not observed. Since New Years Day is the
only holiday that can cross "yearly account periods", the check is only
required for that one holiday, and so I would argue the previous fix (line 41)
is best for minimizing processor time. If you think it would be easier to read
by putting a change in the weekday pruning block, I believe the
following, added at line 77 would also do it:
## Delete any New Years Day holidays that cross calendar years
hol(day(hol) == 31 & month(hol) == 12) = [];
This must be added after the adjustment for Saturday..
-Randy Chamberlin
------------------------------------------------------------------------------
WINDOWS 8 is here.
Millions of people. Your app in 30 days.
Visit The Windows 8 Center at Sourceforge for all your go to resources.
http://windows8center.sourceforge.net/
join-generation-app-and-make-money-coding-fast/
_______________________________________________
Octave-dev mailing list
Octave-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/octave-dev