Monte Carlo Method Overview
Core Concept
The Monte Carlo simulation technique models potential future paths of risk factors by constructing appropriate random processes, then applies valuation formulas to determine corresponding portfolio values. By repeatedly executing these simulations, the method captures a comprehensive range of possible futurre scenarios for both risk factor evolution and associated portfolio valuations, enabling accurate characterization of future profit and loss distributions.
Underlying this approach is the law of large numbers, which supports using observed event frequencies as approximations of their true probabilities. The method involves designing stochastic experiments where an event's probability relates to an unknown parameter. Through repeated trials, frequency-based estimates approximate the target probability, yielding numerical solutions. Effective approximation typically requires substantial sample sizes, with accuracy improving as trial counts increase.
Implementation Steps
Monte Carlo methodology follows three primary phases:
- Stochastic Process Design: Deterministic problems require artificial construction of probabilistic frameworks.
- Random Sampling: Computers generate variables from known distributions including uniform, normal, exponential, and Poisson distributions.
- Estimator Constructino: After model creation and sampling, relevant random variables estimate the solution, typically using arithmetic means of sampled outcomes.
Data Selection
This analysis uses CSI 500 index and individual stock data to evaluate Monte Carlo simulation performance. Given banking sector stocks' relatively predictable behavior, Ping An Bank (ticker: SZ000001) was selected for price forecasting.
Data Source: Daily closing prices for the Shanghai Composite Index and Ping An Bank from January 2, 2018 through April 12, 2024 were extracted from Wind and Tushare databases.
Model Construction
Fundamental Assumptions
- Stock prices follow geometric Brownian motion.
Geometric Brownian Motion represents a variant of standard Brownian motion describing asset price randomness where logarithmic prices evolve according to Brownian dynamics. This model assumes constant volatility and continuous price movements. Stock price S(t) evolution satisfies the stochastic differential equation:
Where μ represents expected return rate, σ denotes volatility, and dW represents Wiener process increments capturing random variations between time intervals.
- Asset returns exhibit normal distribution characteristics.
- Price changes across different assets remain independent or display known correlation structures.
Parameter Estimation
Historical data estimates geometric Brownian motion parameters using the following implementation:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
dataset = pro.daily(ts_code='000001.SZ', start_date='20180101', end_date='20240411')
# Annual dataset calculation
yearly_prices = dataset.loc['2023-01-01':'2023-12-29','close']
validation_set = dataset.loc['2024-01-01':'2024-04-30','close']
full_series = dataset.loc[:,'close']
# Logarithmic return computation
log_changes = np.log(np.array(yearly_prices[1:]) / np.array(yearly_prices[:-1]))
# Drift and volatility estimation
growth_rate = np.mean(log_changes)
price_volatility = np.std(log_changes)
print("Growth Rate:", growth_rate)
print("Volatility Measure:", price_volatility)
Parameter estimation results:
Five-year Expected Return: -0.0002368310
Five-year Volatility: 0.0206163004
One-year Expected Return: -0.0015885768
One-year Volatility: 0.0133056153
Simulation Execution
Extended historical datasets better capture market dynamics, so training data spans January 1, 2018 to December 29, 2023 for forecasting January 1, 2024 through April 11, 2024 price movements, visualizing predicted values and confidence intervals.
Methodology: N iterations generate prediction bands covering all simulated paths, with mean trajectories representing forecasts.
Initial demonstration uses five paths for interval visualization. Forecast accuracy compares single-run versus five-run averaging approaches, plotting theoretical predictions against actual market performance. Gray shading indicates five-path coverage zones, orange lines show forecast trends, and blue curves represent real market behavior.
Implemantation:
def geometric_random_walk(initial_value, mu, sigma, time_step, num_steps):
path_values = [initial_value]
for _ in range(num_steps):
random_shock = np.random.normal(mu * time_step, sigma * np.sqrt(time_step))
next_value = path_values[-1] * np.exp(random_shock)
path_values.append(next_value)
return path_values
# Simulation configuration
validation_data = dataset.loc['2024-01-01':'2024-04-15','close']
starting_point = validation_data.iloc[0]