jamesmawm / Mastering-Python-for-Finance-source-codes

Accompanying source codes for my book 'Mastering Python for Finance'.
MIT License
513 stars 276 forks source link

incorrect treatment of sigma?? #7

Open vvaidy opened 6 years ago

vvaidy commented 6 years ago

Hi,

I suspect in your CIR model you are forgetting to scale the brownian motion term. If I am reading your code correctly, instead of:

dr = K*(theta-rates[-1])*dt + sigma*np.sqrt(rates[-1])*np.random.normal()

I would have said:

dr = K*(theta-rates[-1])*dt + sigma*np.sqrt(rates[-1])*np.sqrt(dt)*np.random.normal()

What am I missing?

-VV

jamesmawm commented 6 years ago

you're right, please scale it.