%% Simulate Bates Sample Paths by Quadratic-Exponential Discretization Scheme
% 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 simByQuadExp to simulate NTrials sample paths directly from the stochastic differential equation of motion; the discrete-time process approaches the true continuous-time process only in the limit as DeltaTimes approaches zero.

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

% The output Paths is returned as a (NPeriods + 1)-by-NVars-by-NTrials three-dimensional time-series array.
% Copyright 2019 The MathWorks, Inc.