Euler Discretization in python for SDE

Hi, i’m a student of master in finance. I don’t know python very well and I must resolve this exercise:
Write the Euler discretization of the 1-dimensional stochastic equation
$dXt = b (t, X_t) \space dt + \sigma (t, X_t) \space dW_t$

For this part I would say all right because it is a purely theoretical part that I find on any stochastic calculus book.
The problem arises on the optional part:
Set $b (t, x) = tx$, $\sigma (t, x) = \sqrt {t (x + 1)}$ e $X_0 = 1$, numerically approximate the expected value $max$ {$0, 1 - (X_{0.5})^2$} using the Euler-Monte Carlo method.

The discretized equation will be:

$$dX_{t,j+1} = X_{t,j} tX_{t,j} + t_j X_{t,j} \Delta + \sqrt {t_j (X_{t,j} + 1)^+} \Delta W_j$$ with $X_{t_0} = 1$

I post my python code, but I am not at all convinced of what has been done and above all that I have given a value to x. Thanks for support.

import numpy as np
import matplotlib.pyplot as plt
import math

num_sims = 1000000# One Example

One Second and thousand grid points

t_init, t_end = 0, 0.5
N = 100 # Compute 100 grid points
dt = float(t_end - t_init) / N
i = 0

Initial Conditions

x_init = 1
ts = np.arange(t_init, t_end + dt, dt)

dw Random process

def dW(delta_t):
“”“Random sample normal distribution”""
return np.random.normal(loc=0.0, scale=np.sqrt(delta_t))

vectors to fill

ts = np.arange(t_init, t_end + dt, dt)
xs = np.zeros(N + 1)
xs[0] = x_init

Loop

for _ in range(7):
for i in range(N, N + 1):
t = (i - 1) * dt
x = xs[i - 1]
# Metodo di Eulero for SDE
dw_ = dW(dt)
y = np.maximum(0, x + 1)
sigma_norad = t * y
sigma = math.sqrt(sigma_norad)
xs[i] = x + t * dt * x + sigma * (dw_)

Plot

plt.plot(ts, xs)
plt.axis([0.0, 0.5 , 0.4, 1.8])

plt.xlabel(“time (s)”)
plt.grid()
h = plt.ylabel(“X”)
h.set_rotation(0)
plt.show()