In this module we'll walk through formulating and solving the optimum execution problem that we introduced in the previous video module. In order to set up the problem, I arbitrarily took that the asset we are trying to sell is the first asset. So the volatility of this one was read off from the previous worksheet. And it was the worksheet of volatility was given in percentage so I divided by a 100 to get what the volatility numbers are. The volume is the typical daily volume that I'm going to be using, and I need these two numbers in order to compute the [INAUDIBLE] glance's temporary price impact function. For the Permanent price function I took it to be gamma times n and the gamma number was taken to be .001. The alphas and the deltas, these correspond to the alpha here, corresponds to alpha two times B1 which is the volatility plus alpha 3. This one corresponds to basically the constant term in the temporary price impact function delta. I took I took it to be alpha1 plus the power divided plus beta. This is the other term that is involved in the temporary price impact function. And these 2 are used to compute what a temporary price impact function is going to be. Okay, I have a total of a thousand shares that I want to sell. These are the various trades so, in trade 1, in this particular setup, whatever I have, I sell 849 shares and in trade 2, I sell 104 shares and so on. And, should add up, and so this 1,000, this is a constraint that I'm going to put. In my portfolio selection, or execution problem. X is the inventory, so before anything gets sold the inventory is a 1,000. After I sell whatever is necessary, this is going to be simply initial inventory minus the trade. Similarly over here it's going to be now. This inventory minus the trade and so on. So by the end, I must have inventory equal to 0. In the beginning I have inventory equal to a 1000. All of these trades must add up to a 1000. So, given the trade amount, I can compute what the temporary cost is going to be, and what the permanent cost is going to be. The temporary cost is simply alpha, which is a linear term, times the absolute value of the trade, plus delta times the trade to the power 1 plus beta. And the beta turned out to be 1.5, in this particular case. And that has been read from the worksheet mean variance liquidity. What about the permanent cost? Permanent cost is going to be the linear term, so it's gamma times the trade, times the inventory, because any trade that I do, it's permanent price impact, effects all the inventory that is there at the end of the day. So that's what that term is going to be. The variance is simply going to be. Inventory squared times volatility squared, and that's what I'm going to sum. So the total trading cost is going to be the sum of the temporary cost plus the sum of the permanent cost. The variance is going to be just a sum of these x variance terms. The objective I've said it to be basically, the sum of the trading cost plus rho times the variance, and this is what I want to minimize. So let's start with row equals 0. So there is, I'm completely ignoring variability in my calculations, and I want to see what is going to happen to my execution strategy. When we talked about it in the module, we said that because I don't care about variability and the temporary price impact and the permanent price impact get minimized when you do equal, you should end up doing uniformly. And let's see whether that helps up happening. Here are my constraints that I want to minimize the objective subject to the constraint that the total sale, total amount of stocks that I share, sell, must equal 1,000. I had to put this extra constraint that any trade that is going to be less than the initial inventory just to keep the optimization problem bounded. I also made it on, all the unconstrained variables to be non negative which means that I cannot put an opposite trait. I can when I'm trying to sell along the way I'm not allowed to buy. But this is something that's worth exploring and may at least lead to some lower cost but I'm ignoring it. And now let's solve it. So when you started solver, it didn't give you exactly what we expected and that's because this is a non linear problem and the solver doesn't get you exactly the solution that you're looking for, but it is going towards a solution of uniform trades. It's over 100 shares over all ten days, totaling to a 1000 shares. Now if I put rho equal to 1, which means that I'm starting to value variability and I want to minimize variability, but the weight is around 1. I solve it now. So you end up getting front loading the optimal solution for this should be completely monotone but it's not exactly towards the very end you see .50.53.66. It should be monotone but because it's looking for a local minimum, it didn't exactly find it. Now, if I increase rho to be two, then it should try to reduce variability even further which means that it starts front loading and pay. The cost that is necessary for it. So now, buy 912 shares and you end up paying, which goes to give you a very high temporary price impact as well as a permanent price impact, and that's the cost you pay because you want to reduce variability. And pretty much that's what I wanted to show you in this particular worksheet.