Stochastic Portfolio Theory Basics 2024
In Quantitative Finance, one of the interesting and newer areas of exploration is Stochastic Portfolio Theory (SPT), which provides a framework for analyzing the performance and behavior of portfolios in markets where assets follow stochastic processes. This approach emphasizes portfolio diversity, market structure, and stability, offering insights into the growth of wealth without assuming market equilibrium or investor rationality.
Let’s explore a basic idea from SPT: Portfolio Drift.
Mathematical Formula for Portfolio Drift
The drift of a portfolio measures how its expected return compares to the weighted sum of the expected returns of individual assets in the portfolio. For a portfolio ( \pi ) of ( n ) assets, the drift ( D_{\pi}(t) ) is given by:
\[
D_{\pi}(t) = \sum_{i=1}^{n} \pi_i \mu_i - \mu_{\pi}
\]
Where:
- \( \pi_i \) is the weight of the \( i \)-th asset in the portfolio.
- \( \mu_i \) is the expected return of the \( i \)-th asset.
- \( \mu_{\pi} \) is the expected return of the portfolio, i.e., the weighted sum of the expected returns.
Stochastic Portfolio Theory: Python Code Example
Let’s simulate a portfolio drift calculation using Python. We'll use random asset returns to illustrate the formula:
import numpy as np
import matplotlib.pyplot as plt
# Number of assets
n_assets = 5
# Time horizon
T = 100
# Simulating asset returns (random walk)
np.random.seed(42)
mu = np.random.normal(0.05, 0.1, n_assets) # expected returns for each asset
cov_matrix = np.random.rand(n_assets, n_assets)
cov_matrix = np.dot(cov_matrix, cov_matrix.T) # creating a positive semi-definite covariance matrix
# Portfolio weights (normalized)
weights = np.random.dirichlet(np.ones(n_assets), size=1)[0]
# Calculate portfolio drift over time
portfolio_returns = []
for t in range(T):
# Simulate asset returns at each time step
asset_returns = np.random.multivariate_normal(mu, cov_matrix)
# Calculate portfolio return at time t
portfolio_return = np.dot(weights, asset_returns)
# Calculate drift as difference between weighted expected returns and portfolio return
drift = np.dot(weights, mu) - portfolio_return
portfolio_returns.append(portfolio_return)
# Plot the portfolio returns over time
plt.plot(range(T), portfolio_returns)
plt.title('Simulated Portfolio Returns Over Time')
plt.xlabel('Time')
plt.ylabel('Portfolio Return')
plt.grid(True)
plt.show()
Explanation of the Code:
- We initialize a portfolio of ( n = 5 ) assets and generate random expected returns \( \mu \) for each asset. The covariance matrix is generated to represent correlations between assets.
- We create a portfolio by assigning random weights to the assets (ensuring the sum is 1).
- For each time step \( t \), we simulate the returns of each asset using a multivariate normal distribution and calculate the portfolio return.
- The portfolio drift is calculated as the difference between the weighted expected returns of the assets and the actual return of the portfolio at each time step.
Insight:
In this simple setup, the drift gives us insight into how the portfolio's actual returns deviate from its expected returns over time. This can be a crucial metric when designing portfolios with long-term growth objectives in Stochastic Portfolio Theory.
This example shows how quantitative finance can use stochastic processes to model portfolio behavior, and this is a growing field of study in modern finance.