예제 #1
0
def vixExpiration(year, month):
    """
    expriration date of a VX future
    """
    t = datetime(year, month, 1) + offsets.relativedelta(months=1)

    offset = offsets.Week(weekday=4)
    if t.weekday() != 4:
        t_new = t + 3 * offset
    else:
        t_new = t + 2 * offset

    t_exp = t_new - offsets.relativedelta(days=30)
    return t_exp
예제 #2
0
def vixExpiration(year, month, precise=True):
    """
    expriration date of a VX future. 
    precise option loads data from file, but is limited
    """

    if not precise:
        t = datetime(year, month, 1) + offsets.relativedelta(months=1)
        offset = offsets.Week(weekday=4)
        if t.weekday() != 4:
            t_new = t + 3 * offset
        else:
            t_new = t + 2 * offset

        t_exp = t_new - offsets.relativedelta(days=30)
    else:
        t_exp = vixExpirations[(year, month)]

    return t_exp