Hi All,
I am using the following code to calibration an OU process on residuals. What is the correct value for delta? At the moment, I am using 1. / 252 but that gives very low scores (no where in acceptable range). Could someone with experience review this code and help me identify the correct values for delta?
def fitOU(S):
n = np.shape(S)[0] - 1
Sx = np.sum(S[:-1])
Sy = np.sum(S[1:])
Sxx = np.dot(S[:-1], S[:-1])
Sxy = np.dot(S[:-1], S[1:])
Syy = np.dot(S[1:], S[1:])
a = ( n*Sxy - Sx*Sy ) / ( n*Sxx - math.pow(Sx,2))
b = ( Sy - a*Sx ) / n
sd = math.sqrt((n*Syy - math.pow(Sy,2) - a*(n*Sxy - Sx*Sy) )/n/(n-2))
delta = 1. / 252.
mu = b/(1-a)
sigma = sd * math.sqrt( -2* math.log(a)/delta/(1-math.pow(a,2)))
return mu, sigma