[MUSIC] All right, so welcome back, and in this session, we're going to just do some setup work. The grand plan at the end of this whole sequence of lab sessions is to answer what I think is one of the most important purposes of investing. And the goal of investing is not simply to grow your assets to as large a number as possible. The goal of investing in my opinion is to make sure that you will have the money that you need to do the things that you want to do in the future. So that you will have the resources to be able to have the consumption patterns that you want in the future. To me, that's a better way of looking at investing. And so we are going to solve that problem, or at least address the technologies that we have available to us to address that problem. But we need to do some sort of setup work, and that's really the goal of this session. So let me specifically describe what we're going to do here. We are going to try and come up with some basic functionality that allows us to measure two things. One is, what is this future liability, this future consumption, what is it, how do I model that? And then the second is to measure, do I have enough money today to be able to meet that, and how do I measure that? And that's obviously what we call the funding ratio. So we're going to come up with a formal, Practical way of measuring liabilities that is actually useful for investment purposes. And we're going to come up with a measure of how we're doing with our assets so far that we actually do have today, in order to meet those future liabilities, and that's the funding ratio. Okay, so the first step along the way is to come up with a measure for, what exactly is the extent of these future liabilities? And the way we do that is actually pretty straightforward if you've ever done anything with fixed income or bonds. And that is to compute the present value of those liabilities. And how you compute the present value of those liabilities is nothing more than a simple sum of each of the liabilities. But instead of just adding those future liabilities, you have to discount them somehow for the time value of money. In other words, you discount each liability, that's what that liability is, right? So you discount each liability by some factor. And that factor is simply a measure of, what would $1, at that point ti in the future, cost me to buy today? Right, and that is nothing more than the price of a pure discount bond, that is, a zero coupon bond that pays $1 at time ti. Okay, so what is that discount factor? Well, it's simply what the cost of $1 at some time t in the future is today, and obviously, that just depends on interest rates. So if you're having trouble understanding what this is, and you haven't worked with this here, let me try and make it a little easier. You can look at it this way, let me just, instead of thinking of it this way, you can say this. Right, so, Whatever that price is I have today, and if I multiply that by that number, that will give me 1. Right, that's an easier way for you to kind of see what's going on with this B(t). B(t) is simply the amount of money such that, when compounded at the current interest rate t times, will give me $1. Okay, good, so that's basically what we're talking about. So, let me put it back to the way it was. Okay, good, okay, enough background. So let's do our usual stuff that by now should be comfortable and familiar. import pandas as pd, import numpy as np, import edhec, whoops, edhec_risk_kit as erk. And of course we'll do the usual in terms of the load extension. So load_ext autoreload, And, And then what is it? Autoreload, okay, so now we're set. Now let's start writing this, right, so this should be actually fairly straightforward. Let's call it discount, so discount is a function, and it would take what? It takes t and some interest rate, so how much time, and what is the interest rate? Right, and I'll just put some simple comments in place. Something like, compute the price of a pure discount bond, That pays a dollar at time t, given, Interest rate r, okay? So let's just keep it really simple, well, this turns out to be super easy, right? It's nothing more than return 1 divided by 1 + r, To the power t. Right, and you can simplify this a little bit if you like by saying- t. Right, okay, so we're done with that. So let's just make sure that that works, right, so for example, what is the discount price? So let's say it's discount in 10 years' time, and assuming the interest rate's 3%. Right, now I'm making an assumption that [COUGH] is a simplifying assumption. I'm assuming that the yield curve is flat. So what that means is that the interest rate is the same, regardless of whether it's one year or three year or five years. We're assuming that the yield curve, that is, the function that tells us what the current interest rate is for different horizons, we're just assuming it's the same. That's not usually the case, but it is close enough for at least showing the principles at work here. Right, so that is about 0.74, so it's about 74 cents is what it costs me to get $1 back at the end of 10 years. And in fact, we can verify that that's the case by just saying, let me just do that. Let's just verify that that's the case, so let me just take that number. I'm just going to just copy it and paste it, right, and let me compound that multiplied by 1.03 to the power 10. Right, so I'm going times 1.03 And I should get back about $1. And that's exactly what happens, right? So you can see how this compounds. Okay, so now that we know how to discount a number, sorry, how to discount a liability, we can extend that to computing the present value. The present value is nothing more than the sum of the discounted liabilities, makes sense, okay? So let's look at this. So we'll say, let's say define present value of a set of liabilities given an interest rate r, right? What is that? So let's, Computes the present value of a sequence of liabilities, right? And let's define our liabilities given this way. So l is a data frame. Actually, it didn't have to be a data frame. l is indexed by the time, and the values are the amounts of each liability, right? And it returns, The present value, Okay? Okay, Okay, so how do we do this? Well, it's pretty straightforward. We have the dates in the index and let's call it l.index, right? So we have that sequence of, that's the index of the series or that we're giving it. And the discounts, is what it, we already have the code to do that. It's nothing more than the discount given the dates of those liabilities. Makes sense? And so what we do now is we just return. What's the formula? You multiply each liability by its discount and then sum them up. That's essentially what this is saying. Well, that's easy to do in Python. It's just, discounts, Times the liabilities itself and that'll give you each of them. That'll be weighted and you just sum them up. Okay, Good, well, now we've got enough, let's try and see if we can make this work. So now let's assume that we have some liabilities, right? So let's write up some liabilities. So let's say liabilities, is that right? Yeah, that's right. Liabilities, okay, and let's do that as a Series first. And let's do the data is, these are the actual liabilities, remember? So let's say 1 million, 1.5 million, and then there's a 2 million later in the future, and then there's one more payment that's due way out of 2.5 million. And let's say the index, right, so now, let's give it a sequence. So let's say that 1 million is due in 3 years, and let's say the 1.5 million is due in 3.5 years. And then let's say 4 and then 4.5, right? So you understand what's going on here. This basically represents a sequence of liabilities that says in three years, I need to pay $1 million. In six months after that, I've got to pay one and a half. And then at the fourth year, I need to pay $2 million and at the four and a half year, I need to pay $2.5 million. So here, just to make it super clear what we're talking about here, that's what I'm talking about. That's my payment schedule, okay? So now I can say, what is the present value of my liabilities, right, given that interest rates are 0.03, okay? That does not make any sense but that's because what did I do wrong here? Well, of course, I'm discounting by the liability but I'm just actually be discounting by the interest rate. Well, let's fix that, and let's try that again. And those liabilities still look good. Now let's get to the present value and there you go. That seems much more reasonable. So what that saying is, let's the sum of the liabilities here is 1, 2.5, 4.5, 5, 7, so there's $7 million. So if you look at liabilities.sum, Right, that's $7 million, but the present value of those liabilities because of the time value of money is about $6.2 million, okay? Good, so now that we've got that, actually, all we have to do is compute the ratio. And that is essentially what we call the funding ratio. So what that means is this. I owe $7 million in the future, but the present value of those liabilities is only $6.2 million. So if I had a $6.2 million today and I have this particular sequence of liabilities in the future, I can pay it off, no problem because I know interest rates are 3%, right? So that's essentially what the intuition here. So let's formalize that. So let's define something called funding_ratio, Right, and the funding ratio, I have to give it some set of assets that I have today. And I'm going to give it a sequence of liabilities and I'm going to give it an interest rate, right? Okay, and what am I going to do here, I'll put a, just keep something simple now, Computes, okay. Okay, so how do we do it? Well, this is so simple we might as well just do it in one line. And that is, it's whatever my assets are, divided by the present value of the liabilities, right, assuming these interest rates, right? Okay, so now let's take this example that we did before. Let's look at, let's say I have $5 million and I have those same liabilities that I had before, right, that sequence of liabilities that we just saw right over there. And let's say interest rates, again, let's just [INAUDIBLE] 0.03. It's a 3%, right? What does that mean? What this means is your underfunded, you're 80% funded, okay? That means your $5 million unless you do something else, you cannot just put it in bonds and expect to meet your liabilities. You do not have the money today to meet your liabilities. Now let's assume, however, that interest rates go down. So I'm going to just copy that. And I'm going to paste it. And let's assume interest rates are actually only 2%, right? Now let's look at what that happens or what that does, right? And it turns out that your funding ratio is even worse, right? And the reason is because the value of the liabilities has actually gone up now, or put differently, the amount by which the assets that you have now will grow more slowly. And therefore you won't be able to meet your liabilities as comfortably, right? So on the other hand, let's do that same thing again and let's assume I don't know, 5%, right? So now you can see that your funding_ratio is actually up to about 86%, okay? So it's basically what's going on here, we can actually, let's do one last thing before we sort of end this section. And that is, I'll use the stuff that we had before. That is import ipython, no, what is it, ipywidgets, if you remember, right? As widgets, and then from IPython.display import display, right? And then we're going to plot it, so let's do a little plotlib in line just in case. And now let's just see what I'm going to do is I'm going to try and understand exactly what interest rates and asset values due to my funding ratio, right? Because at the end of the day, that is what matters. My funding ratio is what matters. Do I have the money? So let's just say def show_funding_ratio, right? And that takes a set of assets and some interest rate, right? So that's what I want to understand, how does my funding ratio change when either the assets I have increase or the interest rates change, right? And well, all I have to do is I have to, let me compute the funding ratio so that this funding ratio of assets and my liabilities and at some interest rate r, yeah? And what I'm going to do now, actually instead of plotting it, let me just print it, right? So I'm just going to print. How do I print it? Let's do this, let's give it give an excuse to start working with these. And whatever the funding ratio, so what I'm going to do is, just an excuse to use a different way of displaying these things is I'm going to format the funding ratio in some nice way. So I'm going to multiply it by, let's say 100. And I'm going to show it with decimal point and two decimal places, okay? So these format codes, if you haven't seen them before, you can look up the documentation. But if you use s printf or printf for any of these kinds of other string formatting codes for decimal numbers, they'll pretty much just work, okay? Okay, so I think that's it, we're done with that. Now, let's do one last thing, which is to actually display the controls. So the controls is widgets.interactive, I believe, interactive, yeah, right? And the function I'm going to call is show_funding_ratio. And let's say what are the things I want to show? Assets, and I'll make that IntSlider, right? If you remember that IntSlider. And the three numbers are min, max, and kind of the step, right? So actually, let me show you how that's done, let's spell it out. So min is 1, let's say max is 10. Let's say we'll do it in steps. Step is 1, and we'll do value, the default value is 5, let's say, right? And then what should we do with interest rates? Let's keep that simple, let's just say from 0 to 20% in steps of 0.01, okay? I think that's it, and then all we have to do is display this. So come here, there you go, display controls, right? Okay, all right, so let's look at what happens now. What happens if my assets increase in value? Well, my funding ratio is going to hopefully increase in value and that's exactly right, right? So you're in 145%, right? And here, if my assets decrease, you'll see that I'm underfunded. And when I get to about $5 million in assets, well I'm funded and when I am at about, $6 or $7 million, dollars in assets, I'm over funded, right? Let's say now my interest rate, that was a 10% interest rate, let's say interest rates start to drop, right? And you can see that interest rates come down, my funding ratio is dropping as well. And if interest rates go down to let's say 3%, then you're only 80% funded. If you have $5 million today and your liabilities are those liabilities that we just talked about that about $7 million in total out in the future, right? These liabilities, liabilities, right? If these are your liabilities and you have $5 million today and interest rates currently are 3%, you only have 80% of the money. So what are your choices? One, you can try and get more assets. And in a pension fund this amounts to the sponsoring company actually putting in more cash into the company. This is not something they enjoy doing, but sometimes they're forced to, sometimes by law, someone is going to have to put in some money there. Or the other option is you have to get a higher rate of return. You've got to end up finding some way to improve the rate of return that you're going to get on your assets on that $5 million by the time the liabilities come due. And that's essentially what we're going to be talking about, how to do that in the future sessions. So what I would do now, is I would just take all this code that we've developed here and we'll stick that all this, so PV discount, and funding ratio, these are the only three functions we've written here. And I'm going to add that to my edit brisket. You should do the same, and I'll catch you in the next session. See you then. [MUSIC]