montecarlo / returns_gen.py
subhash494's picture
Upload 3 files
e76457a
import random
def dummy_returns(n=67):
#a return can vary between 100% and -100% i.e 2 and -1
#we will generate a random number between -100 and 200 and divide by hundred to get the dummy %return
return [random.randint(-100,200)/100 for _ in range(n)]
def randomise_returns(returns_list):
return random.sample(returns_list,len(returns_list))
def returns_set(original_returns_list,n=10000):
collected_returns=[]
while len(collected_returns)<n:
new_list=randomise_returns(original_returns_list)
if new_list not in collected_returns:
collected_returns.append(new_list)
return collected_returns
def dummy_sims():
return returns_set(dummy_returns())
if __name__=='__main__':
dum_rets=dummy_returns()
paths=returns_set(dum_rets)
for p in paths:
print(p,sum(p))