Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Implementing a binomial tree in python. I'm trying to create a function that returns a binomial tree (2d list) of simulated stock price movements. I

Implementing a binomial tree in python. I'm trying to create a function that returns a binomial tree (2d list) of simulated stock price movements.

I cannot use built-in function numpy. However, I can use helper function called zeros, which makes a 2d matrix with n rows and n columns.

build_binomial_stock_price_tree(s, sigma, rf, div, T, n) this function takes 6 inputs.

s = current stock price

rf = (annulized rish free rate of return)

div = (annualized divided rate ; assume contiouns dividends rate )

T = time to maturity , n = number of discrete time periods to use in the tree.

I have another helper function that calculates factor u & d, hence up -state = u * previous price , down-state = u* previous price

This is what i have so far "

def build_binomial_stock_price_tree(s, sigma, rf, div, T, n): """ builds and returns a binomail tree of simulated stock price movements """ u , d = get_binomial_factors(sigma, rf, div, n * T) binomial_up = zeros(n+1) for r in range( n+ 1): for c in range( r + 1): binomial_up[r][c] = s * (d ** c) * (u**(r-c)) return binomial_up

However, its giving me ouput looks like [[ 100.00, 0.00,] [ 127.12, 85.21,]]

Instead, i should expect to see an output looks like :

[[100, 124.60767305873807], [0.0, 83.5270211411272]]

Can someone plz help me with this function ?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning C# 2005 Databases

Authors: Karli Watson

1st Edition

0470044063, 978-0470044063

More Books

Students also viewed these Databases questions