[摘 要] 本文在給出股票價格的隨機模擬方法步驟的基礎上,設計了求解股票價格的計算程序,這樣可大大提高其計算效率。
[關鍵詞] 股票價格;隨機模擬;信息化實現
[中圖分類號]F275;F232[文獻標識碼]A[文章編號]1673-0194(2009)01-0029-02
1 股票價格的隨機模擬方法
假設股票價格滿足下面的方程:S■= S■exp( μΔt+
σz■),式中,S■為t時刻的股票價格;S■為(t+1)時刻的股票價格; μ為股票價格對數變動的均值;σ為股票價格對數變動的標準差;Δt為要計算的時間間隔(以年為單位,若1年內股票交易天數按250天計算,則Δt=1/250);z為服從標準正態分布的隨機數。
則可以根據這個方程建立股票價格的蒙特卡羅模擬模型。股票價格的蒙特卡羅模擬過程如下:
(1)首先根據股票價格的歷史數據進行統計分析,得出股票價格對數變動的均值和標準差。
(2)利用上述方程對不同的隨機數計算股票價格。
(3)進行足夠多次數的模擬計算,將這些模擬計算結果的平均值作為股票價格的估計。
2 股票價格的隨機模擬及其信息化的實現方案
上述計算是一個相當麻煩的過程,為此,我們編制了一個VBA程序,簡化了上述的計算。VBA程序如下:
Sub zbsj()
Dim n As Integer, m As Integer, i As Integer
n = Cells(4, 2)
m = Cells(5, 2)
Cells(10, 1) = \"輸入各個證券的投資比重,股票價格,對數均值和對數標準差\"
Cells(11, 1) = \"證券\"
For i = 1 To n
Cells(11, i + 1) = \"證券\" i
Next i
Cells(12, 1) = \"投資比重\"
Cells(13, 1) = \"股票價格對數均值\"
Cells(14, 1) = \"股票價格對數標準差\"
Cells(15, 1) = \"目前股票價格\"
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)'各股票價格對數均值
pcn(i) = Cells(14, i + 1)'各股票價格對數標準差
p(i, 0) = Cells(15, i + 1) '各股票的目前價格
Next i
sumt = 0
For i = 1 To n
sumt = sumt + w(i) * p(i, 0)
Next i
pp(0) = sumt '目前的投資組合價格
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)) '各股票價格模擬
sumt = sumt + w(i) * p(i, j)
Next i
sum1 = sum1 + sumt
'顯示計算進度條(模擬過程)
UserForm1.Label5.Width = Int(t / nt * 225)
UserForm1.Label6.Caption = CStr(Int(t / nt * 100)) + \"%\"
DoEvents
Next t
pp(j) = sum1 / nt'各投資組合價格的模擬……