[摘 要] 本文在介紹投資組合風(fēng)險(xiǎn)價(jià)值理論與蒙特卡羅模擬步驟的基礎(chǔ)上,編制了風(fēng)險(xiǎn)價(jià)值蒙特卡羅模擬的程序,提高了工作效率#65377;
[關(guān)鍵詞] 風(fēng)險(xiǎn)價(jià)值;蒙特卡羅模擬;程序設(shè)計(jì)
[中圖分類號(hào)]F830.59[文獻(xiàn)標(biāo)識(shí)碼]A[文章編號(hào)]1673-0194(2008)21-0053-02
1 投資組合的風(fēng)險(xiǎn)價(jià)值的一般原理
風(fēng)險(xiǎn)價(jià)值的計(jì)算公式為:
VaR= w0(Zσ+ μ)#65377;式中,VaR為風(fēng)險(xiǎn)價(jià)值;w0為初始投資額;σ為投資收益率的標(biāo)準(zhǔn)差;μ為投資收益率的均值;Z為標(biāo)準(zhǔn)正態(tài)分布的抽樣分位數(shù),其由下式確定:1-α=
edy;式中,α為置信水平#65377;
假設(shè)投資組合中各個(gè)風(fēng)險(xiǎn)資產(chǎn)的收益率均服從正態(tài)分布,那么投資組合的收益率也服從正態(tài)分布,則投資組合的風(fēng)險(xiǎn)價(jià)值為:VaR= w0(Zσ+ μ)#65377;式中,VaR為投資組合的風(fēng)險(xiǎn)價(jià)值;σ為投資組合收益率的標(biāo)準(zhǔn)差; μ為投資組合收益率的均值(預(yù)期收益率)#65377;抽樣分位數(shù)Z可由電子表格軟件中的NORMSINV函數(shù)求得#65377;
2 投資組合風(fēng)險(xiǎn)價(jià)值的蒙特卡羅模擬步驟
利用蒙特卡羅模型方法對(duì)投資組合的風(fēng)險(xiǎn)價(jià)值進(jìn)行估計(jì)的方法和步驟:
(1) 首先利用股票價(jià)格的模擬模型來(lái)估計(jì)未來(lái)某一時(shí)期內(nèi)股票的價(jià)格:S= Sexp(μΔt+ σz)#65377;式中,S為t時(shí)刻的股票價(jià)格;S為t+1時(shí)刻的股票價(jià)格;μ為股票價(jià)格對(duì)數(shù)變動(dòng)的均值;σ為股票價(jià)格對(duì)數(shù)變動(dòng)的標(biāo)準(zhǔn)差;Δt為要計(jì)算的時(shí)間間隔(以年為單位);z為服從標(biāo)準(zhǔn)正態(tài)分布的隨機(jī)數(shù)#65377;
(2)根據(jù)得到的未來(lái)股票價(jià)格利用投資組合風(fēng)險(xiǎn)價(jià)值的歷史數(shù)據(jù)模擬計(jì)算模型方法估計(jì)投資組合的風(fēng)險(xiǎn)價(jià)值#65377;
3 公司投資組合風(fēng)險(xiǎn)的最優(yōu)化模型的信息化實(shí)現(xiàn)
上述計(jì)算是一個(gè)相當(dāng)麻煩的過(guò)程,我們編制了一個(gè)VBA程序,簡(jiǎn)化了上述計(jì)算#65377;VBA程序如下:
Sub zbsj()
Dim n As Integer, m As Integer, i As Integer
n = Cells(4, 2)
m = Cells(5, 2)
Cells(10, 1) = "輸入各個(gè)證券的投資比重,股票價(jià)格,對(duì)數(shù)均值和對(duì)數(shù)標(biāo)準(zhǔn)差"
Cells(11, 1) = "證券"
For i = 1 To n
Cells(11, i + 1) = "證券" i
Next i
Cells(12, 1) = "投資比重"
Cells(13, 1) = "股票價(jià)格對(duì)數(shù)均值"
Cells(14, 1) = "股票價(jià)格對(duì)數(shù)標(biāo)準(zhǔn)差"
Cells(15, 1) = "目前股票價(jià)格"
End Sub
Sub js()
Dim i As Integer, j As Integer, n As Integer, m As Integer, nt As Integer
Dim dt As Single, rd As Single, z As Single, sumt As Single, sum1 As Single, sum2 As Single
Dim myrange1 As String, myrange2 As String, myrange3 As String
n = Cells(4, 2)
m = Cells(5, 2)
nt = Cells(8, 2)
dt = Cells(6, 2) / 250
ReDim w(n), p0(n), p1n(n), pcn(n), p(n, m), pp(m), rp(m) As Single
For i = 1 To n
w(i) = Cells(12, i + 1)'各股票的投資比例
p1n(i) = Cells(13, i + 1)'各股票價(jià)格對(duì)數(shù)均值
pcn(i) = Cells(14, i + 1)'各股票價(jià)格對(duì)數(shù)標(biāo)準(zhǔn)差
p(i, 0) = Cells(15, i + 1) '各股票的目前價(jià)格
Next i
sumt = 0
For i = 1 To n
sumt = sumt + w(i)*p(i, 0)
Next i
pp(0) = sumt '目前的投資組合價(jià)格
UserForm1.Show
UserForm1.Label2.Width = 0
For j = 1 To m
sum1 = 0
sum2 = 0
For t = 1 To nt
sumt = 0
rd = Rnd()
z = Worksheets.Application.WorksheetFunction.NormSInv(rd)
For i = 1 To n
p(i, j) = p(i, j - 1)*Exp(p1n(i)*dt + pcn(i)
*z*Sqr(dt)) '各股票價(jià)格模擬
sumt = sumt + w(i)*p(i, j)
Next i
sum1 = sum1 + sumt
'顯示計(jì)算進(jìn)度條(模擬過(guò)程)
UserForm1.Label5.Width = Int(t / nt*225)
UserForm1.Label6.Caption=CStr(Int(t / nt*100)) + "%"
DoEvents
Next t
pp(j) = sum1 / nt'各投資組合價(jià)格的模擬
'顯示計(jì)算進(jìn)度條(總進(jìn)度)
UserForm1.Label2.Width = Int(j / m*225)
UserForm1.Label3.Caption = CStr(Int(j / m*100)) + "%"
DoEvents
Next j
Unload UserForms1
For j = 1 To m
rp(j) = pp(j) - pp(j - 1) '各期投資組合收益的模擬
Next j
Cells(17, 1) = "計(jì)算過(guò)程——(模擬計(jì)算)" nt "次的平均值"
For j = 1 To m
Cells(17 + j, 1) = j
Cells(17 + j, 2) = pp(j)
Cells(17 + j, 3) = rp(j)
Range(Cells(17 + j, 2), Cells(17 + j, 3)).NumberFormat = "0.00"
Next j
myrange1 = "b18" ":" "b" 17 + m '投資組合價(jià)格數(shù)據(jù)區(qū)域
myrange2 = "c18" ":" "c" 17 + m '投資組合各期收益數(shù)據(jù)區(qū)域
myrange3 = "b18" '期初投資組合價(jià)格數(shù)據(jù)區(qū)域
Range("F3") = "=average(" myrange1 " ) "
Range("F4") = "=average(" myrange2 " ) "
Range("F5") = "b3" myrange3
Range("F6") = "f4*f5"
Range("F5:F6").Select
Selection.NumberFormat = "0.00"
nm = Int(Cells(5, 2)*(1 - Cells(7, 2)))
Range("G3") = "第" nm "個(gè)最壞收益"
Range("H3") = "Small(" myrange2 "," nm ")"
Range("H4") = "=F5*ABS(H3)"
Range("H3:H4").Select
Selection.NumberFormat = "0.00"
MsgBox ("模擬計(jì)算結(jié)束")
End Sub
注:本文中所涉及到的圖表#65380;注解#65380;公式等內(nèi)容請(qǐng)以PDF格式閱讀原文