VeighNa量化社区
你的开源社区量化交易平台
Member
avatar
加入于:
帖子: 50
声望: 1
在base.py里

  def calculate_option_impv(self) -> None:
    """"""
    if not self.tick or not self.underlying:
        return

    underlying_price = self.underlying.mid_price
    if not underlying_price:
        return
    underlying_price += self.underlying_adjustment

    # Adjustment for crypto inverse option contract
    if self.inverse:
        ask_price = self.tick.ask_price_1 * underlying_price
        bid_price = self.tick.bid_price_1 * underlying_price
    else:
        ask_price = self.tick.ask_price_1
        bid_price = self.tick.bid_price_1

    self.ask_impv = self.calculate_impv(
        ask_price,
        underlying_price,
        self.strike_price,
        self.interest_rate,
        self.time_to_expiry,
        self.option_type
    )

    self.bid_impv = self.calculate_impv(
        bid_price,
        underlying_price,
        self.strike_price,
        self.interest_rate,
        self.time_to_expiry,
        self.option_type
    )

    self.mid_impv = (self.ask_impv + self.bid_impv) / 2


因为self.calculate_impv返回值有可能为0,那么这个地方需不需要判断返回值为0的情况,如果最终self.mid_impv等于0,那么在计算greeks的时候就会出现除数为0的错误

Member
avatar
加入于:
帖子: 4696
声望: 287

下面的calculate_cash_greeks函数如果self.mid_impv为0会return

Member
avatar
加入于:
帖子: 50
声望: 1

xiaohe wrote:

下面的calculate_cash_greeks函数如果self.mid_impv为0会return

看到了,谢谢

那如果,self.ask_impv 和 self.bid_impv 其中一个为0,一个不为0,那么得到的self.mid_impv是不是就会很不合理

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

沪公网安备 31011502017034号

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