Now, we’re going to talk about the Almagren and Chriss model for optimal execution of portfolio transactions. So, the aim of the previous lesson was to give you guys some intuition of what the optimal liquidation problem was about without diving into the mathematics. In this notebook, we will dive into the mathematics and gave formal definitions of the terms that we talked about before such as Trading Lists. Almagren and Chriss provided a solution to the optimal liquidation problem by assuming that the permanent and temporary market impact functions were linear functions of the trading rate, and that the stock price followed a discrete random walk. One of the reasons we chose this problem was because the solution given by Almagren and Chriss gives us a nice benchmark to compare our reinforcement learning algorithm too. So, we can see how well or how bad our algorithm performs compared to their solution. The reason we’re taking time to go over their model is because we’re going to train our reinforcement learning algorithm using the same price dynamics and market impact functions that they used. So, you’re encouraged to read this notebook to get a better idea of the equations we’re going to use in our training environment. I will now give a quick summary of the topics covered in this notebook. We begin by taking a look at the formal definitions for trading trajectory, trading list, and trading strategy. This definitions are based on dividing the liquidation time T into N intervals of equal length. This number N will determine the number of trades we will make within the liquidation time. Here, we see an example of a trading trajectory for n equals 12. Then, we will take a look at the price dynamics. We will assume that the stock prices evolve according to this equation, which describes a random walk. This equation at random noise to the stock price at every trading step in order to simulate price fluctuations. We can see what this prize model looks like with this code. Here, we can see the price model for 60 days. We can change if we want the number of days to 100, for example, and we can also change the random seed to see a different realization of the random stock price. Then, we will take a look at the market impact equations. This is the equation we’re going to use to simulate permanent market impact. This is the equation that we’re going to use to simulate temporary market impact. The important thing to remember is that, Sk tilde is the price at which our sell transactions are going to be executed. In other words, Sk tilde is the price per share that we receive whenever we sell a stock. Then we will take a look at the equation for capture. Remember, captured tells us the amount of money that we make by selling our shares following a particular trading strategy. We will then take a look at the implementation shortfall. The implementation shortfall is given by this equation. This is the equation that we want to minimize when determining the optimal trading strategy. However, since the execution price is random fluctuations, so will the implementation shortfall. Therefore, we have to reframe the problem in terms of the average or expectation value of the shortfall and its corresponding variants. So minimizing the implementation shortfall will entail minimizing the expectation value given a particular level of variance. To solve this problem, we will introduce a Lagrange multiplier which is represented by the variable lambda. So, the problem above reduces to the following: Given a particular value of lambda which represents the traders risk aversion, the goal is to find a trading lists that minimizes this utility function. Finally, we will take a look at the solution given by Almgren and Chriss. This equations minimize the utility function given a particular value of lambda. The equation we’re more interested in is the trading list given here. This equation tells us how many shares to sell at each trading step. If we sell our shares following the straight lists, we’ll get an expected shortfall given by this equation and the corresponding variance given by this equation. In the next lesson, we will take a look at this equations more closely.