GBMSimulator
GBMSimulator is a Python class designed to simulate Geometric Brownian Motion (GBM), a stochastic process widely used in mathematical finance for modeling stock prices and other financial instruments.
Features
- Simulates GBM paths given user-defined parameters.
- Supports customizable drift, volatility, initial value, number of paths, and time steps.
- Returns an array of simulated paths, which can be easily visualized or analyzed.
Installation
Ensure you have Python 3.12 or higher. You can install the package and its dependencies from source with:
pip install -e .
or from PyPi with:
pip install GBMSimulator==0.0.2
Usage
Please also refer to Examples/GBMnotebook.ipynb
- Import the
GBMSimulatorclass andmatplotlibfor plotting
from GBMSimulator.GBMSimulator import GBMSimulator
import matplotlib.pyplot as plt
- Set the parameters for the GBMsimulator
'''
Args:
mu (int): drift coefficient
n (int): number of steps
T (int): time in years
M (int): number of sims
y0 (int): initial value
sigma (int): volatility
'''
mu = 0.1
n = 100
T = 1
M = 1000
y0 = 0.01
sigma = 0.5
- Create an instance of
GMBSimulator
simulator = GBMSimulator()
- Create an array of simulated paths
simulated_paths = simulator.simulate(mu, n, T, M, y0, sigma)
- Plot the data
# template
plt.style.use('ggplot')
# changing size of chart
plt.figure(figsize=(12, 5))
# Loop to do a line plot for each simulation
for num, sim in enumerate(simulated_paths.T):
# length of each simulation
t_values = list(range(len(sim)))
# simulated values
y_values = sim
# line plot for each sim
plt.plot(t_values, y_values, label=f"GBM path {num+1}")
# labelling chart
plt.xlabel("Time")
plt.ylabel("Y(t)")
plt.title("Simulated Geometric Brownian Motion Path")
if M <= 10:
plt.legend()
else:
plt.show()
Documentation
Visit our documentation page.
Contributing
Contributions are welcome! Fork our repository and submit a pull request.
Metadata
Release files for GBMSimulator 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| gbmsimulator-0.0.4.tar.gz | 3.0 kB | Without provenance | Details for gbmsimulator-0.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| gbmsimulator-0.0.4-py3-none-any.whl | Python 3 | none | any | Details for gbmsimulator-0.0.4-py3-none-any.whl |
Total release size: 7.3 kB
Release files / gbmsimulator-0.0.4.tar.gz
| Download URL | gbmsimulator-0.0.4.tar.gz |
|---|---|
| Size | 3.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d9abd6335f7671fc9522af5ffc2b9c710d34feff40d8d358e297c560211fd490
|
|
BLAKE2b-256 checksum How to use checksums |
92fb7cbc94c5167a886eb2e29c6b3aad25574abde5ef04becf6cd8ea0061a65f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.3
|
Release files / gbmsimulator-0.0.4-py3-none-any.whl
| Download URL | gbmsimulator-0.0.4-py3-none-any.whl |
|---|---|
| Size | 4.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
99394f56124f87cdef8ca673e5aa098bb54fdc868c119d86d2025cdb151ba07d
|
|
BLAKE2b-256 checksum How to use checksums |
f16fa84db4711c4116e6304998af05302f84a173af8bf906067df5421a03d18b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.3
|
Security for GBMSimulator 0.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.