先附上式子
Function BS_call_difference(S, K, r, T, call_price, sigma)
d1 = (Log(S / K) + (r + 0.5 * sigma ^ 2) * T) / (sigma * Sqr(T))
d2 = d1 - sigma * Sqr(T)
Sum = S * Application.NormSDist(d1) - K * Exp(-r * T) *
Application.NormSDist(d2)
BS_call_difference = Sum - call_price
End Function
=======================================================================
Function Bisection_BS_call(S, K, r, T, call_price)
tolerance = 10 ^ (-6)
down_limit = 0
up_limit = 1
Count = 0
mid_point = (down_limit + up_limit) / 2
Count = Count + 1
Do While Count < 100 And Abs(BS_call_difference(S, K, r, T, call_price,
mid_point)) > tolerance
If BS_call_difference(S, K, r, T, call_price, down_limit) *
BS_call_difference(S, K, r, T, call_price, mid_point) < 0 Then
up_limit = mid_point
ElseIf BS_call_difference(S, K, r, T, call_price, up_limit) *
BS_call_difference(S, K, r, T, call_price, mid_point) < 0 Then
down_limit = mid_point
End If
mid_point = (down_limit + up_limit) / 2
Loop
Bisection_BS_call = mid_point
End Function
========================================================================
这个式子是要透过二分逼近法的应用套在black&scholes来计算出选择权的波动度
我的作法是先用BS_call_difference来做二分逼近法的前置
再把BS_call_difference套进Bisection_BS_call来使用
可是把这个式子套进数字后,一直都跳出value来
程式也没有跑出侦错,所以也不知道从何修起
加上老师说要加入
count起始值要设为0,每一圈循环要将count=count+1
最后一行的Bisection_BS_call 传回值要区分两种情形:count>=100 (传回-1)与 其他 (
传回mid_point)
这段我也不晓得该放在哪个位置
有对这方面了解的朋友能帮个忙吗?
弄两个礼拜都想不出来,不想拖过年啦