-
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
-
Matching Cash Flows
Here is a simple example, let’s say we have a bond that returns $100 in period 1 and $100 in period 2 that costs $170.
Let’s also say that we have a bond that returns $50 at period 1 costing $40 and a bond that returns $25 in period 1 costing $15. What would the price of matching cash flows be?
price = 40*2+15*4
print(price)
Notice it is less expensive! You could buy those cash flows and short the more expensive bond to make a $30 profit.
Now let’s set it up as an equation.
The assets…
Period | Asset 1 | Asset 2 | Total |
0 |
-40x 1 |
-15x 2 |
-40x 1 -15x 2 |
1 |
50x 1 |
0 |
50x 1 |
2 | 0 |
25x 2 |
25x 2 |
We can solve this problem as a matrix problem if we turn the cash flows for each period (not period 0 and not including the total column) into nested arrays where each array represents a time period, and the inner array represents the cash flows from each asset.
cashFlows = [[50,0],[0,25]]
assetFlows = [100,100]
np.linalg.solve(A,b) solves for the matching portfolio where A is the cash flows, and b is the assetFlows.
import numpy as np
np.linalg.solve(cashFlows,assetFlows)
And to solve for the price of the matching cash flows….
allocations = np.linalg.solve(cashFlows,assetFlows)
prices = [40,15]
print(allocations*prices)
print(sum(allocations*prices))
Challenge