im looking to see how i can navigate through a non-recombinant binomial tree. I have set up my tree as following: enter image description here
def arbolno(t,S0,u,d):
S=[S0]
for i in range(1,2**(t+1)-1):
if i%2==0:
S.append(np.round(S[int(i/2-1)]*u,3))
elif i%2!=0:
S.append(np.round(S[int((i-1)/2)]*d,3))
return S
Now, I want to calculate a return from a holding period, lets say, n moments. How can I index correctly, given my format of listing my nodes? For instance, if I define a return period of 2 moments in time, then, for instance, node number 14 would be compared with node 2. I want to know a general formula if there is, in order to index through my list of nodes correctly. Thanks!