Conteúdo do Curso
Introduction to Portfolio Management with Python
Introduction to Portfolio Management with Python
Overview of Modern Portfolio Theory
Previously, we've discovered several methods for estimating portfolio, including return, risk, and their combination known as risk-adjusted return.
However, we still needed to determine how to select weights for portfolio which satisfy our requirements.
The answer on this question is given by Modern Portfolio Theory (MPT).
What is MPT?
First of all, let's define what Modern Portfolio Theory is.
Practically, this theory introduces an important concept known as the efficient frontier, which is a key element of MPT.
What is Efficient Frontier?
Now, let's define the efficient frontier:
Imagine we have a set of different portfolios, each with a specific values of risk and expected return.
In this context, each portfolio could be represented as a point in two-dimensional space, determined by risk and expected return.
We can visualize this using, for example, the following code:
# Importing numpy library for data manipulation and matplotlib for visualization import numpy as np import matplotlib.pyplot as plt # Setting random seed for generating pseudo-random numbers np.random.seed(seed = 1) # Defining dictionary of expected returns expected_returns = {'Apple': 0.00838, 'Meta': 0.10985, 'Amazon': 0.13646} # Defining covariance matrix of returns cov_mat = np.array([[0.000178, 0.000005, 0.000164], [0.000005, 0.000126, 0.000030], [0.000164, 0.000030, 0.000265]]) # Generating random weights for portfolio n_points = 2000 weights = np.random.uniform(0, 1, 3 * n_points).reshape(n_points, 3) weights = np.array([x/sum(x) for x in weights]) risks = np.array([np.sqrt(np.dot(w, np.dot(w, cov_mat))) for w in weights]) returns = np.array([np.dot(w, list(expected_returns.values())) for w in weights]) # Visualizing space of portfolios fig = plt.figure(figsize = (12, 6)) ax = fig.add_subplot(1, 1, 1) ax.scatter(risks, returns) ax.set_xlabel('Risk') ax.set_ylabel('Expected Return') ax.grid() plt.show()
As mentioned earlier, each point here represents a specific portfolio, with corresponding risk and return values.
Practically, the efficient frontier would be a line where each point represents an optimal portfolio, which approximately would look like this:
The efficient frontier is positioned above all the plotted points, indicating that for the same level of risk, points of efficient frontier offer higher expected return. This aligns with the definition of optimality in terms of MPT.
In this context, points that are closer to the efficient frontier represent better portfolios.
Thus, for a given level of risk, portfolios with higher expected returns will be positioned higher. Similarly, for a given level of expected return, portfolios with lower risk will be positioned further to the left.
Additionally there are two special cases of optimal portfolios which we will discuss in detail in the next chapter.
Obrigado pelo seu feedback!