python-bizdays icon indicating copy to clipboard operation
python-bizdays copied to clipboard

getdate unable to handle '1st bizday before 2nd fri'

Open RichardDale opened this issue 3 years ago • 1 comments

In bizdays 1.0.2, in the getdate function, I'm unable to pass in '1st bizday before 2nd fri'

contractyear=2002
contractmonth=5
newltd=cal.getdate("1st bizday before 2nd fri",contractyear,contractmonth)

This shows:

  File ".../bizdays.py", line 888, in getdate
    dt = self._index.getdate(expr, year, month)
  File ".../bizdays.py", line 313, in getdate
    raise ValueError('Invalid reference day:', tok[4])
ValueError: ('Invalid reference day:', 'fri')

(Incidentally, the usage case for this is for futures market expiries - this one in particular is the 90 Day Bank Accepted Bills contract listed on the Australian Securities Exchange (formerly Sydney Futures Exchange).

Of course, I can do this is a nested fashion, as below, but it'd be nicer for the parser to handle this.

newltd=cal.offset(cal.getdate("2nd fri",contractyear,contractmonth),-1)

RichardDale avatar Sep 01 '22 03:09 RichardDale

Hi @RichardDale,

I took some time to investigate in the code. It is not implemented. I'm setting this issue as an enhancement and this will be available in future releases.

Thanks

wilsonfreitas avatar Sep 22 '22 08:09 wilsonfreitas