-
Return and Variance 7
-
Lecture1.1
-
Lecture1.2
-
Lecture1.3
-
Lecture1.4
-
Lecture1.5
-
Lecture1.6
-
Lecture1.7
-
-
Solving Equations 5
-
Lecture2.1
-
Lecture2.2
-
Lecture2.3
-
Lecture2.4
-
Lecture2.5
-
-
Capital Allocation Line 6
-
Lecture3.1
-
Lecture3.2
-
Lecture3.3
-
Lecture3.4
-
Lecture3.5
-
Lecture3.6
-
-
Diversification 3
-
Lecture4.1
-
Lecture4.2
-
Lecture4.3
-
-
Investment Sets 3
-
Lecture5.1
-
Lecture5.2
-
Lecture5.3
-
-
Portfolios 7
-
Lecture6.1
-
Lecture6.2
-
Lecture6.3
-
Lecture6.4
-
Lecture6.5
-
Lecture6.6
-
Lecture6.7
-
-
Capital and Security Market Lines 3
-
Lecture7.1
-
Lecture7.2
-
Lecture7.3
-
-
Arbitrage 3
-
Lecture8.1
-
Lecture8.2
-
Lecture8.3
-
-
Dividend Discount Model 2
-
Lecture9.1
-
Lecture9.2
-
-
Fixed Income 4
-
Lecture10.1
-
Lecture10.2
-
Lecture10.3
-
Lecture10.4
-
-
Duration and Immunization 4
-
Lecture11.1
-
Lecture11.2
-
Lecture11.3
-
Lecture11.4
-
The Basics
When we work with stocks, or more generally assets, we will say that they have an expected return. This is what investors on average expect to get in return for investment, in a percentage. Let’s implement a simple stock class that initializes with an expected return variable.
class stock:
def __init__(self,expectedReturn):
self.expectedReturn = expectedReturn
Now, let’s create an array of stocks with different returns.
stocks = [stock(.04),stock(.02),stock(.03)]
The other array we will create is an array which represents how many dollars we invest in the matching stock.
investments = [10000,20000,5000]
Remember that the way we get the attribute of a class is by putting .variable. If we wanted an array of all the expected returns we would do this:
print([x.expectedReturn for x in stocks])
Now, we will introduce the zip() function in case you have not seen it yet. What the zip functions is it allows you to get iterate through 2 arrays at the same time.
for x,y in zip(stocks,investments):
print(x.expectedReturn)
print(y)
Using list comprehension, we can observe the gains that each investment will accrue.
[x.expectedReturn * y for x,y in zip(stocks,investments)]
If we add 1 to the expected returns we can see what each position is equal to at the end of the year (or period if the expected return were for less or more than a year).
[(x.expectedReturn+1) * y for x,y in zip(stocks,investments)]
Time to introduce one of the basic investment equations, a portfolio return! We will introduce two different ways of representing it which are both valid.
Equation
$$ r_{i} = \text{Return on asset i} $$
$$ A_{i} = \text{Investment in asset i} $$
We could also represent this where we divide each investment by the total portoflio investment to get weights for each investment.
Equation
$$ r_{i} = \text{Return on asset i} $$
$$ w_{i} = \text{Weight in asset i} $$
Challenge