%% Simulate Bates Sample Paths by Euler Approximation
% Create a bates object.

AssetPrice = 80;
            Return = 0.03;
            JumpMean = 0.02;
            JumpVol = 0.08;
            JumpFreq = 0.1;
            
            V0 = 0.04;
            Level = 0.05;
            Speed = 1.0;
            Volatility = 0.2;
            Rho = -0.7;
            StartState = [AssetPrice;V0]; 
            Correlation = [1 Rho;Rho 1];

batesObj = bates(Return, Speed, Level, Volatility,...
                JumpFreq, JumpMean, JumpVol,'startstate',StartState,...
                'correlation',Correlation)

% Use simByEuler to simulate NTrials sample paths of this Bates bivariate model driven by NBrowns Brownian motion sources of risk and NJumps compound Poisson processes representing the arrivals of important events over NPeriods consecutive observation periods. This function approximates continuous-time stochastic processes by the Euler approach.

NPeriods = 2;
[Paths,Times,Z,N] = simByEuler(batesObj,NPeriods)

% The output Paths is 3 x 2 dimension. Row number 3 is from NPeriods + 1. The first row is defined by the bates name-value pair argument StartState. The remaining rows are simulated data. Paths always has two columns because the Bates model is a bivariate model. In this case, the first column is the simulated asset price and the second column is the simulated volatilities.
% Copyright 2019 The MathWorks, Inc.