Python for Finance: Analyze Big Financial Data

(Elle) #1

a mixed approach, using Euler for the index and the noncentral chi square-based exact


approach for the volatility process.


Figure 10-11 shows the simulation results as a histogram for both the index level process


and the volatility process:


In  [ 38 ]: fig,    (ax1,   ax2)    =   plt.subplots( 1 ,    2 ,    figsize=( 9 ,    5 ))
ax1.hist(S[- 1 ], bins= 50 )
ax1.set_xlabel(‘index level’)
ax1.set_ylabel(‘frequency’)
ax1.grid(True)
ax2.hist(v[- 1 ], bins= 50 )
ax2.set_xlabel(‘volatility’)
ax2.grid(True)

An inspection of the first 10 simulated paths of each process (cf. Figure 10-12) shows that


the volatility process is drifting positively on average and that it, as expected, converges to


v = 0.25:


In  [ 39 ]: fig,    (ax1,   ax2)    =   plt.subplots( 2 ,    1 ,    sharex=True,    figsize=( 7 ,    6 ))
ax1.plot(S[:, : 10 ], lw=1.5)
ax1.set_ylabel(‘index level’)
ax1.grid(True)
ax2.plot(v[:, : 10 ], lw=1.5)
ax2.set_xlabel(‘time’)
ax2.set_ylabel(‘volatility’)
ax2.grid(True)

Figure 10-11. Simulated stochastic volatility model at maturity
Free download pdf