I've been given this code, written in Python 3 using QuantLib. It is supposed to work as it is but I cant get it to work. Below is a minimalist example to reproduce the error. Could someone please take a look.
import QuantLib as ql
class myDate(ql.Date):
origin = None
year_frac = DayCount.ACT360.yearFraction
@classmethod
def from_timestamp(cls, date):
return cls(date.day, date.month, date.year)
def __init__(self, *args):
super().__init__(*args)
self.t = self.year_frac(self.origin, self)
When I do this:
x1 = pandas.Timestamp('2015-01-13 00:00:00')
myDate.from_timestamp(x1)
It throws : "ValueError: invalid null reference in method 'DayCounter_yearFraction', argument 2 of type 'Date const &'" highlighting the second line below in Quantlib code.
def yearFraction(self, *args) -> "Time":
return _QuantLib.DayCounter_yearFraction(self, *args)
I am using QuantLib_Python-1.6.1-cp35-none-win_amd64.whl for QuantLib.