Stochastic simulation of USD/MAD exchange rate dynamics using Brownian motion to visualize potential trajectories, risk thresholds, and forward rate targets.
This Python script simulates the potential evolution of the USD/MAD exchange rate over a 12-month horizon using a stochastic Brownian motion model. It incorporates budget targets, stop-loss, take-profit levels, and the forward rate, providing a practical visualization of FX risk scenarios.
To model a realistic path of the USD/MAD exchange rate by integrating:
- Market volatility and directional bias
- Business-level reference points (budget, take-profit, stop-loss)
- A forward rate comparison after 12 months
The simulation uses a discrete Brownian motion model with drift:
S(t+1) = S(t) + μ·dt + σ·√dt·ε
Where:
μ = 0.56%monthly drift (annualized)σ = 15%annualized volatilitydt = 1/12(monthly increments)ε ~ N(0,1)i.i.d. standard normal variables
You can customize the following values in the script:
spot_rate = 9.825559 # Initial spot rate USD/MAD
forward_rate = 9.626032 # 12-month forward rate
budget_rate = 9.45 # Internal FX budget assumption
take_profit_levels = [9.85, 10.00, 10.25]
stop_loss_levels = [9.80, 9.50, 9.25]
🖥️ Requirements
Python 3.8+
Packages:
numpy
matplotlib
To install dependencies:pip install numpy matplotlib
▶️ How to Use
Clone or download the repository.
Run the Python script:python usdmad_simulation.py
The output plot will show:
Simulated USD/MAD path over 12 months
Spot rate at start
Forward rate after one year
Budget rate and stop-loss / take-profit threshold📈 Output Example
<!-- Add real image when available -->
🧠 Interpretation
This tool helps visualize:
Whether the forward rate aligns with your business risk tolerance
The likelihood of hitting internal budget targets
Exposure to downside risk under realistic FX market volatility
