| Category: Excel |
View Full Details
|
Binomial Tree Plotting or display in Excel with multi node values |
| Submitter: vanna |
Date: 2009/11/27 |
|
|
Description:
For an example of using this in a spreadsheet, click hereThe function DisplayMultiBinomialTree can be used to create a binomial tree display on an excel spreadhsheet. Parameters are: treeData - 3 level array with the following levels: 1st level - array of node values (eg., volatility,stock price,etc.) 2nd level - array of above array for a given time 3rd level - array of above arrays sheetName - name of an existing worksheet to plot the tree Demo for usage (Here we create a tree with 6 time steps and displaying 4 data at each node):
Public Function GetNodeValues(i, j) As Variant
ReDim retVal(1 To 4)
retVal(1) = Rnd()
retVal(2) = Rnd() * 10
retVal(3) = Rnd() * 100 + 5
retVal(4) = Rnd() * 100 + 5
GetNodeValues = retVal
End Function
Private Sub CommandButton1_Click()
n = 6 'no of time nodes
ReDim treeData(1 To n) As Variant
For i = 1 To n 'loop over time axis
ReDim tmpArr(1 To i) 'array of nodes at each time step
For j = 1 To i 'loop over each tree node
tmpArr(j) = GetNodeValues(i, j)
Next j
treeData(i) = tmpArr
Next i
DisplayMultiBinomialTree treeData, "treesheet2"
End Sub
Got a question or problem with this link? Just enter your message and click on submit. No registration is required.
|
1286 0 bytes Excel VBA http://www.quantcode.com/ |
|
Discuss this file. Just enter your message and click on submit. No registration is required.