An interactive web-based dashboard for exploring the Vasicek Interest Rate Model. This application performs real-time stochastic simulations, yield curve derivations, and probability forecasting entirely within the browser using PyScript.
Visualise hundreds of independent interest rate paths generated via Euler-Maruyama discretisation. The simulator accounts for mean reversion and volatility shocks in real-time.
Derive the theoretical term structure for zero-coupon bonds based on the affine property of the Vasicek model.
Calculate the statistical likelihood of rate outcomes at any future horizon using the Ornstein-Uhlenbeck transition density.
A modern, glassmorphic UI that provides immediate feedback as model parameters are adjusted. Includes dynamic KaTeX typesetting for mathematical transparency.
The application follows a modular architecture where PyScript orchestrates the bridge between Pythonic scientific logic and JavaScript-driven visualisations.
graph TD
A[index.html] -->|Initialises| B[PyScript Runtime]
B -->|Orchestrates| C[main.py]
C -->|Mathematical Logic| D[vasicek.py]
C -->|Visualisation Config| E[charts.py]
subgraph "Core Engine"
D -->|Euler-Maruyama| F[SDE Solver]
D -->|Analytical| G[Yield Curve Engine]
D -->|Statistical| H[Distribution Calculator]
end
C -->|Render| I[Plotly.js Dashboard]
vasicek-rate-model/
├── public/ # Static assets and UI screenshots
├── charts.py # Plotly chart configuration logic
├── index.html # Main UI and application entry point
├── main.py # PyScript orchestration and event handling
├── pyscript.toml # PyScript environment configuration
├── requirements.txt # Python dependencies (NumPy, SciPy)
└── vasicek.py # Core mathematical implementation
The Vasicek model describes the evolution of interest rates as a Stochastic Differential Equation (SDE):
-
$a$ (Reversion Speed): The rate at which the process pulls back to the mean. -
$b$ (Long-Term Mean): The equilibrium interest rate level. -
$\sigma$ (Volatility): The magnitude of random market shocks. -
$dW_t$ (Wiener Process): Represents the stochastic component (Brownian Motion).
| Component | Technology |
|---|---|
| Runtime | PyScript (Pyodide) |
| Mathematics | NumPy, SciPy |
| Visualisation | Plotly.js |
| Typesetting | KaTeX |
| Styling | Vanilla CSS3 (Glassmorphism, Bento Grid) |
| Decision | Rationale |
|---|---|
| Client-side Execution | Eliminates server costs and latency by running scientific simulations directly in the user's browser. |
| Vectorised Operations | NumPy is utilised to generate hundreds of simulation paths simultaneously, ensuring fluid UI updates. |
| Decoupled Logic | High-performance Python logic is separated from UI orchestration, allowing for easier auditing of the SDE implementation. |
- A modern web browser with WebAssembly support (Chrome, Firefox, Safari, Edge).
- A local web server for development.
- Clone the repository:
git clone https://github.com/sahmed0/vasicek-rate-model.git
- Navigate to the project directory:
cd vasicek-rate-model - Start a local server (e.g., using Python):
python -m http.server 8000
- Open
http://localhost:8000in your browser.
This project is licensed under the GNU General Public License v3.0. See the LICENSE file for the full text.


