Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
455 views
in Technique[技术] by (71.8m points)

python - Merton model using scipy.optimize function - choose initial values of asset value and volatility

I define the equation to calculate asset value and volatility as below. In case V_equity > default_point, initial asset value is set to V_equity then it works fine and results the same as Solver's in Excel. However, in case V_equity < default_point, if initial asset value is set to V_equity, then it results V_asset = V_equity and Solver also cannot solve it. Then I add the condition that initial asset value is set to default_point, then it results V_asset = default_point. Does anyone experience that and how should we set initial guess for asset value in this case? Your comment is highly appreciated. Thank you.

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)
question from:https://stackoverflow.com/questions/65874264/merton-model-using-scipy-optimize-function-choose-initial-values-of-asset-valu

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...