Today we will continue to use the SP 500 data we use the last time. If the data is not loaded. Huge load to load our data. If you look at the environment on the right side, you can see if it is loaded. Today, I will briefly introduced The concept of back testing, I can say people who use data analysis for investment decision. They used back testing. I will introduce the most basic concept of back testing engine, that professionals misstologists and tourists are based on this basic idea. Our Lecter's focuses on accurately reflecting the time difference of the data as discussed earlier. Dad. Now shall we begin what it back testing? It is no exaggeration if I say that it is one most important word to characterize the paper who use the data and mothers for investment decisions. Back testing method may vary, but I can a form that no single quantitative investment professionals do not huge back past back testing is the process of looking at how your investment strategy has performed in the past. By looking at past the performance, you can gauge what your strategy will do in the future. Basically it is based on the strong assumption that if it was in the past, especially if the word has not changed significantly, it will be similar in the future. To the investors who do not rely on data analysis and modern claim that the passage only the past, it is a significant criticism against data driven investment. But can there be an investor who does not think about an experience, of course, the performing profit testing to overcome the limitation from the past data, we distinguish a useful analysis and allow the analysis. After back testing, you should gather more information. Besides the future expected returns, today we are taking the first step. So we started by applying checking past returns using our what. First, let me explain what we are going to do today. You probably know the asset of location portfolios, most common competition age, 60% stocks and 40% bond. Now, in our data SP 500 we have a column of data for the return of SMP 500 representing stocks and the year of the U. S. 10 year bond representing bond. Now, assuming the numbers in the two columns are the returns for each year they create and store the return for portfolio with 60 to 40 asset allocation. Create a column named the port in the S P 500 data. You restore the data in this column the value of the return of a portfolio and you can get played by multiplying annual written column by 2.6 plus the U S tenure bond interest rate were deployed by 0.4. It is simple to do in our now I am going to create a hypothetical investment rule. These are the rules I made only for your practice. After learning more later, I hope you to check if the loser I have suggested are right. Here is the rule after the year when the dividend eight age over 30% increase the allocation of stocks from 60% to 80% and reduce the location of a bond from 40% to 20%. So how do you check whether the annual dividend already over 3% youth s P $500 dividend the Earth is greater than 0.3 and store it in a column named the indicator? Should we check the data? There are trust and force value in the column named the indicator. Of course, if the value of dividend is the color on the same law is greater than 3% either be true, and if it is less than 3% they will be forced. First, let us create a new column and input the value. Zero. Use the rap function to make zero as many laws as the SP 500 data and store them in a new Cologne Court Street. Now let us look at the strategy that we use your dividend the Earth to decide stock, bond or location, using if clothes and full of in our okay. When you transform the data into formula to make an investment decision, we call this transform the formula or signal a signal agent input for investment decisions. I could not make a short of programming, but I write all the vary over again to clarify the explanation. For example, I write the condition of dividend Earth, which is greater than 3%. Instead of using the indicator color we already made, let us start by if close after writing. If right, the lounge bracket with the condition to check and then write the things to be done. If the condition is satisfied inside the curly bracket, then you write errors and in another colour bracket, right the things to be done if conditions in the lounge bracket are not satisfied. Next we assume that we invested for the following year if dividend the value is greater than 0.3 in vitro. So the return of the following year is the return from the strategy that should be 80% of the annual return and 20% of 10 year treasury aid. Therefore, if dividend the area is in the ideal law, then the result of this calculation should be the value of the I plus one throw that is 19 after. If they have done the earth in vitro is greater than 0.3 That is not satisfied. The following the next role of a Strad is 60% of the SMP 500 annual return of the next role. I am 40% of the 10 year treasury, it of the next law. The value is calculated in Cali bracket coming after earth, so if given the is the value of either law, the rest of the data must be the value of the I plus one? No. After one night, and now we'll keep doing the same by replacing I using follow up again. Again, I It is the law of dividend yield. We use that information, so we will need you to change it from one to the 19 off from the last. If I ate from one to the first value of the S P 500 which is the last line, there is no value of annual return and 10 year Treasury in the next line. Now let us run the court with a follow up. And, if clothes we store the original 60% stocks and 40% point portfolio and your return in a port column, we stored the Richard According to the rules we made in a straight column to compare the two Richard. Let us apply the summary function you learned earlier to did two columns of S P 500 Mhm as we did before. We can also make a vector with two column names used the same method we used before, right? Our data name SP 500 to capture the part of this data used to scale bracket inside that right, a space comma and then a vector of column names. Let us compare the mean and max first. You can see that the strap every annual return is slightly higher, and the maximum value of this threat is also slightly higher. On the other hand, though, the minimum return it is the same 25% of the straight return, ages slightly higher. We can lovely conclude that our strategy creates more favor of returns, right? Yes, this time, let us draw a graph of a cumulative returns by reusing what we learned earlier. First, to get the cumulative return of the annual returns stored in the port and threat we created the two columns in the data reported a CR and straight that CR and stored in a M in them and again right the same for the command that we used to calculate the cumulative return before. Since there is no first role of cumulative return import, I started at two the cumulative return of reported multiplying one plus the second data 21 plus that the next lost data and then minus one, multiply up to I D data plus one using product function and then subtract one from there do the same thing to get straight to see are the only difference here is that you have to use the straight column, not the Port column. Now let us run it and check the data. First. We plot port, the CR that are located 60% of all stocks and 40% of our bond. Using the flood comment, I said x as the EU column and removed the first data and also removed the first data from Porta CR and set it as white data. Next, named the XY, exists using the command you learned in the last time inside the plot. We will add one more line of the cumulative Britain graph of the port. Make the same data structure using straight To see our column, you have to remove the first data for the second line of straight to see our usual lines function inside the lines function right to your column, commas and the straight to see our column. I used the type to designate the line time at the line air and the line color using core. Should I run it? Today? We have covered the basic idea of back testing. It is a fundamental concept in quantitative investing, if not most important, save the script where not to forget it Perfect. Yeah.