1 Prices |
|
1 | (54) |
|
1.1 Importing Daily Stock Price Data |
|
|
2 | (1) |
|
1.2 Importing Price Data from Yahoo Finance |
|
|
2 | (10) |
|
|
12 | (4) |
|
|
12 | (2) |
|
1.3.2 Checking the Dimension |
|
|
14 | (1) |
|
1.3.3 Outputting Summary Statistics |
|
|
15 | (1) |
|
1.3.4 Checking the Ticker Symbol |
|
|
15 | (1) |
|
1.4 Basic Data Manipulation Techniques |
|
|
16 | (12) |
|
1.4.1 Keeping and Deleting One Row |
|
|
16 | (1) |
|
1.4.2 Keeping First and Last Rows |
|
|
17 | (1) |
|
1.4.3 Keeping Contiguous Rows |
|
|
18 | (1) |
|
1.4.4 Keeping First Three Rows and Last Row |
|
|
19 | (1) |
|
1.4.5 Keeping and Deleting One Column |
|
|
20 | (1) |
|
1.4.6 Keeping Non-Contiguous Columns |
|
|
21 | (1) |
|
1.4.7 Keeping Contiguous Columns |
|
|
22 | (1) |
|
1.4.8 Keeping Contiguous and Non-Contiguous Columns |
|
|
22 | (1) |
|
1.4.9 Subsetting Rows and Columns |
|
|
23 | (1) |
|
1.4.10 Subsetting Using Dates |
|
|
23 | (2) |
|
1.4.11 Converting Daily Prices to Weekly and Monthly Prices |
|
|
25 | (3) |
|
1.5 Comparing Capital Gains of Multiple Securities Over Time |
|
|
28 | (13) |
|
1.5.1 Alternative Presentation of Normalized Price Chart |
|
|
37 | (4) |
|
1.6 Technical Analysis Examples |
|
|
41 | (11) |
|
1.6.1 Trend: Simple Moving Average Crossover |
|
|
41 | (3) |
|
1.6.2 Volatility: Bollinger Bands |
|
|
44 | (3) |
|
1.6.3 Momentum: Relative Strength Index |
|
|
47 | (5) |
|
|
52 | (1) |
|
|
53 | (2) |
2 Individual Security Returns |
|
55 | (24) |
|
|
56 | (2) |
|
|
58 | (3) |
|
2.3 Logarithmic Total Returns |
|
|
61 | (2) |
|
2.4 Cumulating Multi-Day Returns |
|
|
63 | (5) |
|
2.4.1 Cumulating Arithmetic Returns |
|
|
64 | (1) |
|
2.4.2 Cumulating Logarithmic Returns |
|
|
65 | (1) |
|
2.4.3 Comparing Price Return and Total Return |
|
|
66 | (2) |
|
|
68 | (4) |
|
|
72 | (1) |
|
2.7 Comparing Performance of Multiple Securities: Total Returns |
|
|
73 | (6) |
3 Portfolio Returns |
|
79 | (36) |
|
3.1 Constructing Portfolio Returns (Long Way) |
|
|
79 | (3) |
|
3.2 Constructing Portfolio Returns (Matrix Algebra) |
|
|
82 | (1) |
|
3.3 Constructing Benchmark Portfolio Returns |
|
|
83 | (30) |
|
3.3.1 Equal-Weighted Portfolio |
|
|
86 | (7) |
|
3.3.2 Value-Weighted Portfolio |
|
|
93 | (16) |
|
3.3.3 Normalized EW and VW Portfolio Price Chart |
|
|
109 | (1) |
|
3.3.4 Saving Benchmark Portfolio Returns into a CSV File |
|
|
110 | (3) |
|
|
113 | (1) |
|
|
113 | (2) |
4 Risk |
|
115 | (46) |
|
4.1 Risk-Return Trade-Off |
|
|
116 | (5) |
|
4.2 Individual Security Risk |
|
|
121 | (5) |
|
|
126 | (12) |
|
4.3.1 Two Assets (Manual Approach) |
|
|
127 | (4) |
|
4.3.2 Two Assets (Matrix Algebra) |
|
|
131 | (2) |
|
|
133 | (5) |
|
|
138 | (8) |
|
|
138 | (2) |
|
|
140 | (6) |
|
|
146 | (4) |
|
|
147 | (1) |
|
|
147 | (2) |
|
4.5.3 Comparing VaR and ES |
|
|
149 | (1) |
|
4.6 Alternative Risk Measures |
|
|
150 | (8) |
|
|
150 | (2) |
|
|
152 | (1) |
|
4.6.3 Rogers, Satchell, and Yoon |
|
|
153 | (2) |
|
|
155 | (2) |
|
4.6.5 Comparing the Risk Measures |
|
|
157 | (1) |
|
|
158 | (1) |
|
|
158 | (3) |
5 Factor Models |
|
161 | (32) |
|
|
161 | (10) |
|
|
171 | (1) |
|
5.3 Rolling Window Regressions |
|
|
172 | (3) |
|
5.4 Fama-French Three Factor Model |
|
|
175 | (6) |
|
|
181 | (9) |
|
5.5.1 Example: Netflix July 2013 Earnings Announcement |
|
|
183 | (7) |
|
|
190 | (1) |
|
|
191 | (2) |
6 Risk-Adjusted Portfolio Performance Measures |
|
193 | (16) |
|
6.1 Portfolio and Benchmark Data |
|
|
193 | (4) |
|
|
197 | (2) |
|
6.3 Roy's Safety First Ratio |
|
|
199 | (1) |
|
|
200 | (2) |
|
|
202 | (3) |
|
|
205 | (1) |
|
|
206 | (2) |
|
|
208 | (1) |
|
|
208 | (1) |
7 Markowitz Mean-Variance Optimization |
|
209 | (32) |
|
7.1 Two Assets the "Long Way" |
|
|
209 | (6) |
|
7.2 Two-Assets Using Quadratic Programming |
|
|
215 | (9) |
|
7.3 Multiple Assets Using Quadratic Programming |
|
|
224 | (9) |
|
7.4 Effect of Allowing Short Selling |
|
|
233 | (7) |
|
|
240 | (1) |
|
|
240 | (1) |
8 Fixed Income |
|
241 | (62) |
|
|
242 | (13) |
|
|
242 | (4) |
|
|
246 | (4) |
|
|
250 | (5) |
|
|
255 | (23) |
|
8.2.1 Shape of the US Treasury Yield Curve |
|
|
255 | (8) |
|
8.2.2 Slope of the US Treasury Yield Curve |
|
|
263 | (4) |
|
8.2.3 Real Yields on US Treasuries |
|
|
267 | (3) |
|
8.2.4 Expected Inflation Rates |
|
|
270 | (4) |
|
|
274 | (4) |
|
8.3 Investment Grade Bond Spreads |
|
|
278 | (8) |
|
8.3.1 Time Series of Spreads |
|
|
278 | (2) |
|
8.3.2 Spreads and Real GDP Growth |
|
|
280 | (6) |
|
|
286 | (3) |
|
8.5 Bond Valuation on Coupon Payment Dates |
|
|
289 | (5) |
|
8.5.1 Pricing Vanilla Bonds with Known Yield-to-Maturity |
|
|
289 | (2) |
|
8.5.2 Vanilla Bond Pricing Function |
|
|
291 | (2) |
|
8.5.3 Finding Bond Yield-to-Maturity with Known Price |
|
|
293 | (1) |
|
8.6 Duration and Convexity |
|
|
294 | (4) |
|
8.7 Bond Valuation on Non-Coupon Payment Dates |
|
|
298 | (4) |
|
|
302 | (1) |
|
|
302 | (1) |
9 Options |
|
303 | (30) |
|
9.1 Obtaining Options Chain Data |
|
|
304 | (7) |
|
9.2 Black-Scholes-Merton Options Pricing Model |
|
|
311 | (4) |
|
9.3 Black-Scholes-Merton OPM Function |
|
|
315 | (1) |
|
|
316 | (1) |
|
|
317 | (1) |
|
|
318 | (1) |
|
|
319 | (3) |
|
|
322 | (8) |
|
|
326 | (2) |
|
9.8.2 Binomial Model Function |
|
|
328 | (2) |
|
|
330 | (1) |
|
|
331 | (2) |
Appendix A Getting Started with R |
|
333 | (10) |
Appendix B Constructing a Hypothetical Portfolio |
|
343 | (6) |
Index |
|
349 | |