微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

使用 scipy.optimize 函数的默顿模型 - 选择资产价值和波动率的初始值

如何解决使用 scipy.optimize 函数的默顿模型 - 选择资产价值和波动率的初始值

我定义了计算资产价值和波动性的公式如下。在 V_equity > default_point 的情况下,初始资产值设置为 V_equity 然后它工作正常并且结果与 Excel 中的求解器相同。 但是,在 V_equity

for i,row in df.iterrows():
        def equation(x):
            d1 = (np.log(x[0]/row["default_point"]) + (row["arf_rate"]+x[1]**2/2)*T)/(x[1] * np.sqrt(T))
            d2 = d1 - x[1] * np.sqrt(T)
            res1 = x[0] * norm.cdf(d1) - np.exp(-row["arf_rate"]*T) * row["default_point"] * norm.cdf(d2) - row["V_equity"]
            res2 = (x[0] * norm.cdf(d1) * x[1])/row["asigma_equity"] - row["V_equity"]
            return(res1**2+res2**2)
        if row["V_equity"] >= row["default_point"]:
            x0 = (row["V_equity"],row["asigma_equity"])
        else: x0 = (row["default_point"],row["asigma_equity"])
        cons = ({'type': 'ineq','fun': lambda x: x[0]},{'type': 'ineq','fun': lambda x: x[1]})
        result = minimize(equation,x0,constraints=cons)

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。