I am trying to build a tree model and to tracking the moving average (say 10 day) of each branch. Is there an easy way to do it? I just built a tree and really have no clue how to proceed from here. Thanks for the help in advance.
import numpy as np
t = 3
r = 0.035
sigma = 0.35
s0 = 86.95
K = 32.59
n = 252*t
dt = t/n
window = 10
u = np.exp(sigma * np.sqrt(dt))
d = 1 / u
p = (np.exp(r * dt) - d) / (u - d)
stock = np.zeros([n + 1, n + 1])
for i in range(n + 1):
for j in range(i + 1):
stock[j, i] = s0 * (u ** (i - j)) * (d ** j)