Python for Finance: Analyze Big Financial Data

(Elle) #1
In  [ 21 ]: jd.update(lamb=0.9)
In [ 22 ]: %time paths_4 = jd.get_instrument_values()
Out[22]: CPU times: user 26.3 ms, sys: 2.07 ms, total: 28.4 ms
Wall time: 27.7 ms

Figure 16-2 compares a couple of simulated paths from the two sets with low and high


intensity (jump probability), respectively. You can spot a few jumps for the low intensity


case and multiple jumps for the high intensity case in the figure:


In  [ 23 ]: plt.figure(figsize=( 8 ,     4 ))
p1 = plt.plot(gbm.time_grid, paths_3[:, : 10 ], ‘b’)
p2 = plt.plot(gbm.time_grid, paths_4[:, : 10 ], ‘r-.’)
plt.grid(True)
l1 = plt.legend([p1[ 0 ], p2[ 0 ]],
[‘low intensity’, ‘high intensity’], loc= 3 )
plt.gca().add_artist(l1)
plt.xticks(rotation= 30 )

Figure 16-2. Simulated paths from jump diffusion simulation class
Free download pdf