I have a for loop which deals with more than 9 million combinations (for this, I've used itertools library), must perform the code below faster, it's taking too long to loop over all combinations. Appreciate any suggestions
wb = xw.books('FX VEGA BT.xlsm')
sht = wb.sheets['Sheet1']
#retrieving data from excel
df = pd.DataFrame(sht.range('PY_PNL').value, columns=['10','20','25','40','50','60','70','75','80','90'])
#df has shape of 3115 rows × 10 columns
def sharpe(x):
s = round(np.average(x)/np.std(x)*np.sqrt(252),2)
return s
shrps = []
outlist = []
mult = (-1,-2.5,0,1,2.5)
perm = itertools.product(mult,repeat = 10)
for p in perm:
c = df*p
c = c.sum(axis='columns')
outlist.append(p)
shrps.append(sharpe(c))