# Euler scheme to simulate trajectories + Python Code

Question: Euler scheme to simulate trajectories of S + Python code to get independent trajectories of S?

For solving a problem I have the following assumptions:

• stochastic basis (Ω,FT,(Ft)t≥0,P) where (Ft)t≥0 is a filtration modelling the market information Ft available at time t.

• Considering the Black and Scholes model when the volatility may depend on time.

• volatility is a deterministic function t 􏰀→ σt which is continuous, strictly positive and defined on the time interval [0,T].

• financial market is composed of two assets. The first one is risk-free and its price at time t is St0 = 1, i.e. the risk-free return for the maturity T is zero.

• The risky asset price is supposed to admit a risk neutral probability measure Q ∼ P is such a way that, under Q, its (discounted) value S is given by S =Process where B is a standard Brownian motion under Q

I chose a volatility function of the form σt = α(1 + g(t)) where fix α > 0 and a continuous function g satisfying g > −1 on [0,T]

My solution for the Euler scheme: Euler Scheme Can this work out?

My solution for the Python code:

import numpy as np

import numpy.random as sim

import matplotlib.pyplot as plt

T=3; n=50 ;N=5 ;pas=T/n;rootstep=np.sqrt(T/n);

W=np.zeros((n+1,N));

for j in range(N): # for loop N values j in (0,1,2...,N-1)

for i in range(1+n):

W[i,j]=W[i-1,j]+rootstep*sim.randn()

dates=np.linspace(0,T,n+1)

graph1=plt.plot(dates,W)

plt.show(graph1)


Is the problem with the above code solved? What would be improvements? And how can I confirm numerically the value of EQ(ST)? Which mathematical principle to use for this?