To walk through the code and for a thorough description, refer to A. Meucci - A Fully Integrated Liquidity and Market Risk Model, Financial Analyst Journal, 68, 6, 35-47 (2012).
Latest version of article and code available at http://symmys.com/node/350
Attilio Meucci (2020). A Fully Integrated Liquidity and Market Risk Model (https://www.mathworks.com/matlabcentral/fileexchange/43243-a-fully-integrated-liquidity-and-market-risk-model), MATLAB Central File Exchange. Retrieved .