In code you find the PyTorch implementation of the numerical method proposed in my master's thesis to approximate the optimal trading strategy and the optimal risky fraction in a Black-Scholes model with transaction costs.
The results along with the trained neural networks of the experiments of Chapter 4 are provided in results.
To run the code and to train your own neural networks, clone this repository and execute the jupyter notebook showcase.
In the two plots below you see the approximate optimal trading strategy and the approximate optimal risky fraction derived by the method NonReluOracleTanh.
The red sell boundary and the green buy boundary is calculated with the code of Belak and Sass.
Moreover, you find in ItoProcesses an implementation to simulate Brownian motion, geometric Brownian motion and the triplet of final, minimal and maximal value of scaled Brownian motion with drift. See showcase_ItoProcesses for illustration.
To simulate a different Ito process:
YourProcess(Minibatch):
def __init__(self, T=1, N=100, D=1,s0=0):
super().__init__(T=T, N=N, D=D,s0=s0)
def increment(self,M):
#your code to specify the distribution of the increment
return
def path(self,M):
return super().path(M)
def step(self,t,x,h,dX):
return super().step(t,x,h,dX)
def drift(self,t,S):
#your code to specify the drift function
return
def vol(self,t,S):
#your code to specify the volatility function
return 
