For this tutorial, both minimum-variance and mean-variance will be taught. The PortfolioAnalytics package will be used extensively throughout as it allows for a simple workflow for portfolio optimisations. The first part of the code is to define that a portfolio optimisation problem exists. The only variable that needs to be defined is the names of […]

# Portfolio Management

## Modern Portfolio Theory

This is a brief recap of Modern Portfolio Theory (MPT) before delving into practical applications of it. While there are many aspects of MPT, the focus will be on its application for portfolio optimisation. The origin of MPT came from a paper written by Harry Markowitz in 1952 to create an optimal portfolio. From thereon, […]

## Calculating Stock Returns and Portfolio Returns in R

To calculate the returns of AAPL & GOOG over the time period, you can use the Return.calculate function. This will then calculate the daily returns of AAPL and GOOG over the time period. The first day, as there is nothing to divide it by, will be NA. It generally makes sense to use this code […]

## Downloading Stock Data in R Using QuantMod

We will use QuantMod R package to download stock data. This allows for downloading stock data from multiple sources, although Yahoo is the default option. To start using the Quantmod library, you can install and load it in your R environment using the following commands in R console or R Studio (Preferred). Once the package […]

## R Financial Packages for Portfolio Analysis

This tutorial will teach you about how to use R for portfolio analysis. We will be using various financial packages from R that will help us perform portfolio analysis. Let’s look at these packages: Quantmod Quantmod is a very powerful package that is designed for quant traders to explore and build quantitative trading models. For […]

## Best Sector for Long-term Investment

Long-term investment may mean different thing for different people, but for me and for the purpose of this article, let’s say we are looking at an investment horizon of 8-10 years. If I ask you to make an investment for this long a period, i.e., invest and forget, and then I ask you to pick […]

## Short-fall Risk, Safety-first Ratio, and Optimal Portfolio Selection

Shortfall Risk Shortfall risk refers to the probability that a portfolio will not exceed the minimum return level (target return, benchmark return). Shortfall-risk is more consistent with the investors’ intuitive perception of risk in that it focusses more on the real economic risk of an investor. On the other hand, the standard deviation is rather […]

## What is Tracking Error

Tracking error is a measure of how closely a portfolio follows its benchmark. A tracking error of zero means that the portfolio exactly follows its benchmark. The benchmark could be an index such as S&P 500 index. Let’s say the S&P 500 index provides a return of 6% and your portfolio tracking the S&P 500 […]

## Calculate Risk-adjusted Returns Using Beta

The risk-adjusted return of a portfolio or an asset can be calculated using the Capital Asset Pricing Model. Using this model, we calculate the expected return on the asset commensurate with the risk in the asset. The asset’s beta is used as the measure of risk, which indicates how much more or less volatile the […]

## How to Build Efficient Frontier in Excel

As we know, an efficient frontier represents the set of efficient portfolios that will give the highest return at each level of risk or the lowest risk for each level of return. A portfolio is efficient if there is no alternative with: Higher expected return with same level of risk Same expected return with lower […]