Hello, I'm combining the Module 6 and Module 7 Python codes or lectures 6 and 7, because in a way, Vasicek and CIR resource are pretty similar. It's good to have him just in one that for you to be able to do the comparison. As you recall, for Vasicek and CIR, we have analytical form for zero-coupon bond pricing. Are you seeing the code? If the model is Vasicek is much, much simpler. Here are A and B, you do remember, once you get the A and B is very easy to price the zero-coupon bond, which simply is what I'm actually substituting over here. In the case of CIR, as soon the solution is known, the analytical form, but it is a bit more involved. But anyway, you have the code, you can compare it with what I had in the slides. Having said this, then you are getting the model parameters. Whatever model parameters you substitute here are not Kappa, Theta, and Sigma. Then the entire range for Tau, you can do simply plug it in and you get a curve for zero-coupon bond for whatever parameters that you're providing. Let's pass this one through. Shift enter here. The same thing over here. Now we come to the data. I'm sorry, there were a bit more to discuss here. My apologies. I just jumped a bit. That was for zero-coupon bond pricing. Once you have the curve, then you have the zero-coupon bond curve, you can use swap rate equation which are provided in the slides. Then once you have it, you get any swap rate through this equation. The way I formed it is that you providing the T range and the P range and the maturities for the SWAP, say 2, 3, 5, 7, 10, 15, and 30. Then it would give you a range for the SWAP as well. That means this S is coming is the S that corresponds to 2, 3, 5, 7, 10, 15, and 30. The same thing for LIBOR Rates. Exact same thing. I'm exactly implementing what I provided in the slides. The objective function, as you remember, we call objective function to be the score of relative error on SWAP. I'm doing it separately on LIBOR, I'm doing it separately and I'm adding it up. That's what it is over here. You can play with this one. I mean, for example, instead of having the score, you can't do the absolute value. This is absolutely up to you. You can play with this yourself. My apologies. As you see, once I'm coming inside the objective function, because I already know the zero-coupon curve, I'm simply passing it to get the market ones. Let me make sure that I'm correct here. Yes, this one becomes the model, my apologies, SNL, then the other ones are the market. As I said, I'm looking at the relative error which the goal is to minimize the distance between the model and the market. That's fine. For calibration, what I am doing is I'm actually passing here Nelder-mead, as opposed to any gradient distance I'm using Nelder-mead here. You can change it to some other optimization routine. That should be absolutely fine. Now, the market rates, I'm picking two different dates. You remember in this slides I have this for day 1, 2, 3, 6, and 12 months. I'm having two snapshots. I actually could have put this one down here to be able to visualize it nicer. Let's see. I could've done it like this. Sorry about this. Good. Then as you seeing, the first column here is the maturity, this is for one of the days, this is for the second day, the same thing here. The maturity for SWAP term, the first set and the second, these are the snapshot I'm having. The second column corresponds to one of the days and the third column corresponds to the other day we have in mind. You can go through the data yourself and just pick any days that you wish. Let's pass this through as well. Now for the parameters, starting points is important. I'm assuming the following his starting point, I'm using the same starting point for both of them. This is for V naught, this is for Kappa, Theta, and this is for Sigma or Lambda, depends how exactly I'm putting actually up here what they are. Let's pass this one through two. Now then for Vasicek, as I said, I'm assuming two different days for Vasicek model. For the first day, I'm passing the objective and I do my optimization. It was done very quickly and this is the perimeters I'm getting out. For the second date, exact same thing. I'm doing that one, round optimization and this is the parameters I'm getting. I'm doing the exact same thing for CIR as well. For the first date, for the second date you have the code, you can play the code that should be easy. As you noticing here, when I say which day, then I'm going and picking the corresponding column because I know the third column corresponds to one of the days, second column corresponds to the first day that I'm picking. What I'm doing is now the one that I did for the first day, which is December 14th, 2017, I simply do plots. The first plot is what's coming out of the calibration, the curve for zero-coupon bond. The second and the third are LIBOR and swap rates respectively. Let me make sure that that's the case. Let me go through it. The first one, the blue curve are the market and the orange ones are the model, and as you see one would expect the same thing. It doesn't mean you would perfectly match it because that's calibration. You've seen that we doing a relatively good job on the short-term here if you missed. Then on the other hand, over here, we did a very nice job on the 10, but we overestimated here and underestimated there. There's always a trade off when you do the fit. This is the one that we did for October 11th, 2018. Let's see how well we did here. We did actually slightly better here. For the LIBOR we did a good job, for the swap again, we did a nice job on the 10 and the 30, but we underpriced the 15 and overpriced actually 5 and 7, and that's the corresponding curve. Then I'm plotting actually the curves for these two days, the day one. Let me plot this one. This is for Vasicek. The orange one corresponds to October 11th, 2018 and the blue one December 14th, 2017. As you see, because the rate been going up October 11th, 2018, actually the curve is lower. That's exactly what we had in the first module, if you remember. As the rate goes higher the curve starts going down faster, that's trivial. We do exact same thing for CIR. For the CIR, the fit is relatively close to what we've seen for Vasicek. Some underpricing, some overpricing, this is for LIBOR, the fit for LIBOR and swap, that's its corresponding curve. On October 2018, do that calibration it does slightly better now. LIBOR relatively a good job and the swap does a very nice job on 3 and 3, 10 and 30. But we underpriced 15 and overpriced 5 and 7. One more time, of course this is a very, very simplistic model. But this missing sometimes is a sign from perspective signal traders. But of course just one snapshot is not enough, you need a time series of it, you need a cross section and cross sectional analysis, it's a sign for good mispricing or maybe market been overbought or oversold or something is cheap or something is rich. Now let's do the comparison between the two. Again, between these two days the CIR consistent to what we had from Vasicek as well. You can also compare the two models against each other, both Vasicek and CIR. I leave it to you that should be pretty easy to do. But as you remembered in the slides, for these two days actually they're pretty consistent. That means no matter if you would have used Vasicek or CIR, you would have gotten the same results. This is not always the case. It turned out to be that case but then definitely, you can try it and I'm going to actually assign something for your assignment or homework that we pick other days because you have four and a half years of data. We can go maybe to January second, 2014, and you'll see if you do it yourself and it's very, very easy to do. It's a matter of just simply going up here and replacing, it's as simple as that. Simply replacing this column with January. This one, and that one with the one on January 2nd, 2014. I could have done it, but I want to leave it for you because I want you to do a comparison between Vasicek and CIR. Now you have all these tools that you can simply setting it up, playing with the objective function, playing with various different days and do the fit and see. Even with one factor, with some very, very simplistic model, we can still do a relatively good job fitting the curve. That was my goal at least for this lecture. Thank you so much.