Monte Carlo Simulation is a probabilistic technique used in finance to model risk, uncertainty, and possible future outcomes of financial assets, portfolios, or investment strategies. It relies on random sampling and statistical modeling to estimate potential results.
Applications in Finance
✔ Stock price forecasting
✔ Portfolio risk analysis
✔ Option pricing (Black-Scholes model)
✔ Interest rate modeling
✔ Value at Risk (VaR) calculation
1. Monte Carlo Basics – Simulating a Stock Price
Using the Geometric Brownian Motion (GBM) model
GBM Formula: St=S0e(μ−12σ2)t+σWtS_t = S_0 e^{(\mu – \frac{1}{2} \sigma^2)t + \sigma W_t}St=S0e(μ−21σ2)t+σWt
where:
- StS_tSt = Stock price at time ttt
- S0S_0S0 = Initial stock price
- μ\muμ = Expected return
- σ\sigmaσ = Volatility
- WtW_tWt = Wiener process (random component)
Simulating Stock Prices Over Time
import numpy as np
import matplotlib.pyplot as plt
# Parameters
S0 = 100 # Initial stock price
mu = 0.05 # Expected return (5%)
sigma = 0.2 # Volatility (20%)
T = 1 # Time in years
dt = 1/252 # Daily time step
N = int(T / dt) # Number of steps
simulations = 1000 # Number of Monte Carlo simulations
# Generate random numbers for the Wiener process
np.random.seed(42)
Z = np.random.standard_normal((simulations, N))
# Simulate stock price paths
S = np.zeros((simulations, N))
S[:, 0] = S0
for i in range(1, N):
S[:, i] = S[:, i-1] * np.exp((mu - 0.5 * sigma**2) * dt + sigma * np.sqrt(dt) * Z[:, i])
# Plot a few sample paths
plt.figure(figsize=(10, 5))
for i in range(10): # Plot only 10 sample paths
plt.plot(S[i, :], lw=1)
plt.title("Monte Carlo Simulated Stock Prices")
plt.xlabel("Days")
plt.ylabel("Stock Price")
plt.show()
✔ Simulates potential future stock price movements
2. Portfolio Risk Analysis Using Monte Carlo
Estimating Portfolio Value Distribution
Simulating Portfolio Returns
# Portfolio parameters
initial_value = 1_000_000 # Initial portfolio value
mean_return = 0.07 # 7% annual return
volatility = 0.15 # 15% annual volatility
years = 10
num_simulations = 5000
# Monte Carlo simulation
np.random.seed(42)
random_returns = np.random.normal(mean_return, volatility, (num_simulations, years))
portfolio_values = initial_value * np.cumprod(1 + random_returns, axis=1)
# Plot results
plt.figure(figsize=(10, 5))
plt.plot(portfolio_values.T, alpha=0.1, color='blue')
plt.title("Monte Carlo Simulated Portfolio Growth")
plt.xlabel("Years")
plt.ylabel("Portfolio Value")
plt.show()
✔ Shows possible portfolio growth scenarios over 10 years
3. Option Pricing Using Monte Carlo
Estimating the Price of a European Call Option
Black-Scholes Model for Option Pricing: C=e−rT⋅max(ST−K,0)C = e^{-rT} \cdot \max(S_T – K, 0)C=e−rT⋅max(ST−K,0)
where:
- CCC = Call option price
- STS_TST = Stock price at expiration
- KKK = Strike price
- rrr = Risk-free rate
- TTT = Time to maturity
Monte Carlo Approach to Pricing a Call Option
# Option parameters
K = 105 # Strike price
r = 0.03 # Risk-free rate (3%)
T = 1 # Time to expiration (1 year)
simulations = 10000
# Generate stock price at expiration
np.random.seed(42)
Z = np.random.standard_normal(simulations)
ST = S0 * np.exp((mu - 0.5 * sigma**2) * T + sigma * np.sqrt(T) * Z)
# Compute option payoff
payoff = np.maximum(ST - K, 0)
# Discount payoff back to present value
option_price = np.exp(-r * T) * np.mean(payoff)
print(f"Estimated Call Option Price: ${option_price:.2f}")
✔ Uses Monte Carlo simulation to estimate option price
4. Value at Risk (VaR) Calculation
Estimating Portfolio Risk with Monte Carlo
95% Value at Risk (VaR) Simulation
# Simulate portfolio returns
simulated_returns = np.random.normal(mean_return, volatility, num_simulations)
# Compute 95% Value at Risk
VaR_95 = np.percentile(simulated_returns, 5) * initial_value
print(f"95% Value at Risk (VaR): ${-VaR_95:.2f}")
✔ Estimates worst-case loss at a 95% confidence level