处理python包中的特定异常

时间:2018-09-13 08:20:21

标签: python exception exception-handling python-3.7

我想以特定方式处理py_vollib / py_lets_be_rational中的以下异常。

py_lets_be_rational.exceptions.BelowIntrinsicException: The volatility is below the intrinsic value.

尝试不成功:

from py_vollib.black.implied_volatility import implied_volatility as impl_vol_b
from py_lets_be_rational.exceptions import BelowIntrinsicException

try:
    call_vol = impl_vol_b(discounted_option_price, F, K, r, t, type)
except BelowIntrinsicException as e:
    if str(e) != 'The volatility is below the intrinsic value':
        raise
    else:
        call_vol = 0

我在做什么错?任何帮助将不胜感激。

0 个答案:

没有答案
相关问题