问题描述
我定义了计算资产价值和波动性的公式如下。在 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 (将#修改为@)