VeighNa量化社区
你的开源社区量化交易平台
Member
avatar
加入于:
帖子: 35
声望: 0

陈老师好,关于vnpy_optionmaster里的time.py有个疑问
def calculate_days_to_expiry(option_expiry: datetime) -> int:
""""""
current_dt = datetime.now().replace(hour=0, minute=0, second=0, microsecond=0)
days = 1

while current_dt <= option_expiry:
    current_dt += timedelta(days=1)

    # Ignore weekends
    if current_dt.weekday() in [5, 6]:
        continue

    # Ignore public holidays
    if current_dt in PUBLIC_HOLIDAYS:
        continue

    days += 1

return days

这里days初始值为1,如果我是今天(今天是20220111)到期的期权,option_expiry:20220111,那么返回的就是days就是2,可是明明今天期权就到期了

Member
avatar
加入于:
帖子: 716
声望: 62

这里应该是有问题的,days的初始值应该是设为0或者修改循环条件。我们会在之后的版本更新中进行修复,如果目前需要使用的话,可以参照https://github.com/vnpy/vnpy_optionmaster/pull/5 进行修改。

© 2015-2022 上海韦纳软件科技有限公司
备案服务号:沪ICP备18006526号

沪公网安备 31011502017034号

【用户协议】
【隐私政策】
【免责条款】