def next_imm_date(reference_date, tenor): """ Third Wednesday of contract month """ dt = reference_date for k in range(tenor): dt = imm.next_date(dt) return pydate_from_qldate(dt)
def next_imm_date(reference_date, tenor): """ Third Wednesday of contract month """ dt = qldate_from_pydate(reference_date) for k in range(tenor): tmp = imm.next_date(dt) dt = pydate_to_qldate(tmp) return pydate_from_qldate(dt)
def zero_curve(ts, dtObs): dtMax = ts.max_date calendar = TARGET() days = range(10, 365 * 20, 30) dtMat = [min(dtMax, calendar.advance(Date.from_datetime(dtObs), d, Days)) for d in days] # largest dtMat < dtMax, yet QL run time error df = np.array([ts.discount(dt) for dt in dtMat]) dtMat = [pydate_from_qldate(dt) for dt in dtMat] dtToday = dtObs.date() dt = np.array([(d - dtToday).days / 365.0 for d in dtMat]) zc = -np.log(df) / dt return (dtMat, zc)
def zero_curve(ts, dtObs): dtMax = ts.max_date calendar = TARGET() days = range(10, 365 * 20, 30) dtMat = [ min(dtMax, calendar.advance(Date.from_datetime(dtObs), d, Days)) for d in days ] # largest dtMat < dtMax, yet QL run time error df = np.array([ts.discount(dt) for dt in dtMat]) dtMat = [pydate_from_qldate(dt) for dt in dtMat] dtToday = dtObs.date() dt = np.array([(d - dtToday).days / 365.0 for d in dtMat]) zc = -np.log(df) / dt return (dtMat, zc)