european_option = VanillaOption(payoff, exercise)
spot_handle = SimpleQuote(spot_price)
flat_ts = FlatForward(calculation_date, risk_free_rate, day_count)
dividend_yield = FlatForward(calculation_date, dividend_rate, day_count)
flat_vol_ts = BlackConstantVol(calculation_date, cal, volatility, day_count)
bsm_process = BlackScholesMertonProcess(spot_handle,
dividend_yield,
flat_ts,
flat_vol_ts)
european_option.setPricingEngine(AnalyticEuropeanEngine(bsm_process))
给出错误
File "qlexam.py", line 63, in <module>
european_option.setPricingEngine(AnalyticEuropeanEngine(bsm_process))
AttributeError: 'quantlib.instruments.option.VanillaOption' object has no attribute 'setPricingEngine'
我需要什么进口货
你不需要额外的导入。这个错误的原因是pyql开发人员已经导出了一些具有不同名称的QuantLib,以便遵循PEP 8,并且在Python中更为惯用。正确的电话是
从this pyql example可以看出
相关问题 更多 >
编程相关推荐