I've scoured the web for any solutions to my problem, but haven't really found anything that helps me.
My problem is that I wish to speed up my program by implementing multiprocessing. The function getSVJJPrice is rather fast. However, the size of K is around 1000, making the entire code pretty slow. I therefore wonder if there's anyway to parallelize the for loop? The code is found below.
def func2min(x,S,expiry,K,r,prices,curr):
bid = prices[:,0]
ask = prices[:,1]
C_omega = [0]*len(K)
w = [0]*len(K)
for ind, k in enumerate(K):
w[ind] = 1/np.abs(bid[ind] - ask[ind])
C_omega[ind] = getSVJJPrice(x[0],(x[1] + x[0]**2)/(2*x[2]),
x[2],x[3],x[4],x[5],x[6],x[7],x[8],x[9],S[ind],k,r[ind],expiry[ind],
curr[ind])
right = np.sum(w * (np.subtract(C_omega, np.mean(prices,axis=1)))**2)
print right
#if right < 10:
# print '\n \n func = ', right
if math.isnan(right):
right = 1e12
return right
Thanks a million to whomever looks into this!
Best regards,
Victor