这是我的写的一篇关于用R语言实现MODEL (CAPM) & CONSTRUCT STOCK PORTFOLIOS的文章!希望能让大家看看!
Portfolio analysis
Abstract
The construction of investment portfolio is a perennial question in the analysis of financial investment. For years, the academic field and the industrial field have proposed many ways to optimize the portfolio. The theory of Markowitz mean-variance model (M-V model) takes the primary place. In the first part, this report introduces a method of constructing an effective stock portfolio with M-V model to establish effective frontier by using R. In the second part, we have built a simple simulation trading system for one stock by using R.
1 Construct portfolio
1.1 Introduction
The Standard & Poor’s 500 (abbreviated as S&P500), is an American stock market index based on the market capitalizations of 500 large companies having common stock listed on NYSE or NASDAQ. The S&P500 index has experienced a circle of bull market and bear market since 2013. So our sample encompasses a over 5-year period from January 2013 to April 2018.
image.png
1.2 portfolio construction
Companies like GOOGLE, IBM, MICROSOFT, APPLE and FACEBOOK are labeled as IT constitutes of S&P500 components. Companies like AFFIL MANAGERS, GOLDMAN SACHS, Citi Group, NASDAQ and MOODYS are labeled as financial constitutes of S&P500 components.
By R command getSymbols(), we get the historical market data of the ten stocks mentioned above and S&P500 index from yahoo finance website.
Supposing that one company can continue operating for more than 10 years, so we take 10-year US treasury interest rate as risk-free rate.
For simple, we construct two equal weighted portfolios:
image.png
The correlation matrix of IT stocks and S&P500 is listed as below.
GOOG/ MSFT/AAPL/FB are highly correlated with each other, IBM is negative correlated with other 4 stocks.
GOOG
IBM
MSFT
AAPL
FB
SPY
GOOG
1.00
-0.23
0.98
0.89
0.97
0.95
IBM
-0.23
1.00
-0.19
-0.29
-0.31
-0.21
MSFT
0.98
-0.19
1.00
0.92
0.96
0.97
AAPL
0.89
-0.29
0.92
1.00
0.93
0.97
FB
0.97
-0.31
0.96
0.93
1.00
0.97
SPY
0.95
-0.21
0.97
0.97
0.97
1.00
1.3 evaluation
The capital asset pricing model(CAPM), derived by Sharpe, Lintner and Mossin, is one of the most celebrated models in all of finance. The model describes the relationship we should expect to see between risk and return for individual assets. Specifically, the CAPM provides a way to calculate an asset’s expected return (or “required” return) based on its level of systematic (or market-related) risk, as measured by the asset’s beta.
For a portfolio, the equation for CAPM is
image.png
Which is the risky free rate, stands for the return of market, represents the sensitivity of the portfolio’s return to the market return.
Through linear regression, R command without intercept image.png, we can get the beta of two portfolios:
image.png
Beta is considered as the systematic risk, in a diversified portfolio, an investor should only be compensated for systematic risk (or beta) exposure. Beta reflects the relationship between the portfolio and the whole market. If beta is larger than 1, the portfolio earns more when the market goes up. If beta is smaller than 1, the portfolio loses less when the market goes down.
Form the linear regression results, we can see portfolio 1 and portfolio 2 both have beta greater than 1. When the market goes up, the

本文介绍了使用R语言实现资本资产定价模型(CAPM)和构建股票投资组合的方法。通过分析标准普尔500指数中IT和金融板块的公司,利用均值-方差模型建立有效前沿,并构建了两个等权重投资组合。此外,还探讨了基于移动平均线的简单交易系统,以谷歌股票为例,展示了不同交易策略的收益和风险情况。
最低0.47元/天 解锁文章
2667

被折叠的 条评论
为什么被折叠?



