Eric, thanks for the response and pointers! In terms of constructing a
Matrix, are you talking about something like this?
*3x3 Array{Float64,2}:*
* 50.0 40.0 32.0*
* 0.0 60.0 48.0*
* 0.0 0.0 72.0*
The graph option is interesting too, I hadn't thought about that. Thanks
for the link to the paper, this is extremely helpful!
Thanks!
Chris
On Friday, October 23, 2015 at 8:35:53 PM UTC-4, Eric Forgy wrote:
>
> Hi Christopher,
>
> I am just learning then Julian way myself, but one thing that "might" be
> better than an array of growing arrays is to note that a binary tree can be
> laid into a matrix, i.e. Array{Float64,2}, by rotating it. This is nice in
> case you ever need a ternary tree, which could be represented by
> Array{Float64,3}, etc.
>
> Another thing you might consider is to treat the tree as a directed graph
> and look at incorporating one of the Julia graph theory packages.
>
> On the topic, I have a paper (shameless plug alert!) you might be
> interested in:
>
> - *Financial Modelling Using Discrete Stochastic Calculus*
> <http://phorgyphynance.files.wordpress.com/2008/06/discretesc.pdf>
>
> More papers here <https://phorgyphynance.wordpress.com/my-papers/>.
>
>
> On Saturday, October 24, 2015 at 7:50:59 AM UTC+8, Christopher Alexander
> wrote:
>>
>> Hello all,
>>
>> I am trying to write a method that builds a binomial tree for option
>> pricing. I am trying to set up my tree like this:
>>
>> function build_tree(s_opt::StockOption)
>> u = 1 + s_opt.pu
>> d = 1 - s_opt.pd
>> # qu = (exp((s_opt.r - s_opt.div) * s_opt.dt) - d) / (u - d)
>> # qd = 1 - qu
>>
>> # init array
>> stockTree = Vector{Float64}[ zeros(m) for m = 1:s_opt.N + 1]
>>
>> for i = 1:s_opt.N + 1
>> for j = 1:i
>> stockTree[i][j] = s_opt.S0 * u ^ (j-1) * d ^ (i - j)
>> end
>> end
>>
>> return stockTree
>> end
>>
>> Is this the most "Julian" way to do this (I didn't find really any
>> modules that would suit this purpose)?
>>
>> Here is what prints out:
>>
>> *3-element Array{Array{Float64,1},1}:*
>>
>> * [50.0] *
>>
>> * [40.0,60.0] *
>>
>> * [32.00000000000001,48.0,72.0]*
>>
>> I suppose also I could default the [1][1] state to the spot price (S0),
>> so then I don't need to alter the looping range and instead start the range
>> at 2.
>>
>> Thanks!
>>
>> Chris
>>
>