求vba的期权定价二叉树程序(有偿)

论坛 期权论坛 期权     
水晶的蜕变   2018-4-26 13:47   13849   3
分享到 :
0 人收藏

3 个回复

倒序浏览
2#
blanksmith1012  2级吧友 | 2018-4-30 02:06:53 发帖IP地址来自
Function BinoptVal(iopt, iea, S, X, r, tyr, sigma, nstep)
'Returns Binomial Option Value(ipot=1 for call,-1for put;
'iea=1 for euro,=2 for amer)

Dim delt, erdt, ermqdt, u, d, P, pstar, mu
Dim i As Integer, j As Integer

Dim vvec As Variant    'to be a vector
ReDim vvec(nstep)     'know size of vector
'caculate parameters
delt = tyr / nstep  'length of the time step
erdt = Exp(r * delt) 'compounding factor
mu = 0

u = Exp(mu * delt + sigma * Sqr(delt)) 'up multiplier
d = Exp(mu * delt - sigma * Sqr(delt)) 'down multiplier
P = (ermqdt - d) / (u - d) ' up prob
pstar = 1 - P 'down prob

  'calculating vector of option values after n steps
    For i = 0 To nstep
      vvec(i) = Application.Max(iopt * (S * (u ^ i) * (d ^ (nstep - i)) - X), 0)
    Next i

    'calculating conditional payoffs & discounting back step by step
        For j = nstep - 1 To 0 Step -1
            For i = 0 To j
            vvec(i) = (P * vvec(i + 1) + pstar * vvec(i)) / erdt
  Next i
        Next j

    BinoptVal = vvec(0)

End Function
3#
santababy  3级会员 | 2018-4-30 02:06:54 发帖IP地址来自
to 楼上
运行的时候会出现错误 没有end sub
而且程序中没有单元格 这样对吗?
4#
yjrkecx  4级常客 | 2018-4-30 02:06:55 发帖IP地址来自
20晚8点之前帮我传下 谢谢
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:
帖子:
精华:
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP