The Cox-Ingersoll-Ross (CIR) model is a one-factor model that was proposed to address the negative interest rates found in the Vasicek model. The process is given as follows:
The term increases the standard deviation as the short-rate increases. Now the vasicek() function can be rewritten as the CIR model in Python:
In [ ]: import math import numpy as np def CIR(r0, K, theta, sigma, T=1.,N=10,seed=777): np.random.seed(seed) dt = T/float(N) rates = [r0] for i in range(N): dr = K*(theta-rates[-1])*dt + \ sigma*math.sqrt(rates[-1])*\ ...
Get Mastering Python for Finance - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.