A lightweight Python library for simulating geometric Brownian motion (GBM) paths and managing parameterized simulation experiments.
This project was created as a learning exercise in object-oriented Python design, API development, packaging, and automated testing. The library demonstrates how to structure a small simulation framework that separates model definitions, simulation configuration, and simulation results.
- Geometric Brownian Motion model implementation
- Immutable time-series container (
Path) - Parameter configuration objects (
ParameterSet) - Hashable parameter sets suitable for caching simulations
- Simple Monte Carlo path generation
- Basic automated test suite using
pytest
Clone the repository and install the package in editable mode:
git clone https://github.com/<your-username>/gbm_simulation.git
cd gbm_simulation
pip install -e .Install dependencies:
pip install -r requirements.txtfrom gbm_simulation import ParameterSet
# Define simulation parameters
params = ParameterSet(mu=0.1, sigma=0.2, T=1.0, steps=100)
# Run simulation
path = params.simulation()
print(len(path))
print(path[0])Example output:
101
(0.0, 1.0)
For a complete runnable example see: examples/basic_simulation.py
Run it with:
python examples/basic_simulation.pygbm_simulation/
│
├─ gbm_simulation/
│ ├─ __init__.py
│ ├─ gbm.py
│ ├─ path.py
│ └─ parameters.py
│
├─ tests/
│ ├─ test_gbm.py
│ ├─ test_path.py
│ └─ test_parameters.py
│
├─ requirements.txt
├─ pyproject.toml
└─ README.md
Implements a geometric Brownian motion model with:
- drift parameter
mu - volatility parameter
sigma - Monte Carlo path generation
Immutable container representing a simulated time series.
Features:
- indexing
- slicing
- length queries
- representation suitable for debugging
Configuration object representing a full simulation setup:
(mu, sigma, T, steps)
Parameter sets are:
- immutable
- comparable
- hashable
This allows them to be used as keys in dictionaries for simulation caching or experiment tracking.
Execute the test suite with:
pytestThe tests verify the behavior of:
GBMPathParameterSet
- numpy
This repository demonstrates:
- Python package structure
- API design for internal libraries
- object-oriented modeling
- dependency management
- automated testing with
pytest
The project is intentionally small and focuses on clear structure and reproducibility rather than