Skip to main content

stochPathSim

stochPathSim is a Python library designed for stochastic modeling, simulations, and statistical analysis. This library implements widely used stochastic models for financial and quantitative research, such as Geometric Brownian Motion (GBM), Heston Model, Vasicek Model, and more. It also includes utilities for statistical evaluation and visualization of simulations, making it ideal for researchers, quants, and data scientists.


Features

  • Simulation of Stochastic Models:
    • Geometric Brownian Motion (GBM)
    • Heston Model
    • Vasicek Model
    • Hull-White Model
    • Cox-Ingersoll-Ross (CIR) Model
    • Black-Derman-Toy (BDT) Model
    • Ho-Lee Model
  • Statistical Analysis:
    • Probability levels (P_LEVEL)
    • Quantile-based analysis (99th, 90th, 10th, 1st percentiles)
    • Mean value calculation
    • Exceedance metrics (upper and lower exceedance counts)
  • Visualization:
    • Static visualizations using Matplotlib

Installation

To install the library from PyPI:

pip install stochPathSim

Usage

1. Simulate Geometric Brownian Motion (GBM)

from stochPathSim.gbm import GeometricBrownianMotion
from stochPathSim.statistics_utils import calculate_statistics, display_statistics


# Initialize GBM
gbm = GeometricBrownianMotion(mu=0.1, sigma=0.2, s0=100, T=1, n=1000, paths=1000)

# Simulate
time, simulations = gbm.simulate()

# Calculate statistics
initial_value = 100  # Initial value of the simulation
stats_df = calculate_statistics(simulations, initial_value)

# Display statistics
display_statistics(stats_df, time)

# Plot simulation
plot_simulation(time, simulations)

2. Statistical Analysis with P_LEVEL and Exceedance Metrics

from stochPathSim.statistics_utils import calculate_statistics, display_statistics

# Assuming `simulations` is a 2D array of paths and `time` is the time vector
initial_value = 100

# Calculate statistics
stats_df = calculate_statistics(simulations, initial_value)

# Display statistics
display_statistics(stats_df, time)

# Plot simulation with 15 paths
plot_simulation(time, simulations, num_paths=15)

Supported Models

Geometric Brownian Motion (GBM)

  • Simulates the evolution of stock prices under constant drift and volatility.
  • Applications: Equity modeling, option pricing.

Heston Model

  • Stochastic volatility model with mean-reverting variance.
  • Applications: Volatility modeling, derivative pricing.

Vasicek Model

  • Mean-reverting interest rate model.
  • Applications: Fixed income modeling.

Hull-White Model

  • Generalized mean-reverting interest rate model with time-dependent drift.
  • Applications: Bond pricing.

Cox-Ingersoll-Ross (CIR) Model

  • Mean-reverting interest rate model with non-negative constraints.
  • Applications: Credit risk modeling.

Black-Derman-Toy (BDT) Model

  • Lognormal interest rate model.
  • Applications: Term structure modeling.

Ho-Lee Model

  • Arbitrage-free interest rate model with Gaussian increments.
  • Applications: Pricing interest rate derivatives.

Contributing

We welcome contributions! If you'd like to contribute, please:

  1. Fork the repository.
  2. Create a feature branch (git checkout -b feature-name).
  3. Commit your changes (git commit -m 'Add feature-name').
  4. Push to the branch (git push origin feature-name).
  5. Open a pull request.

License

MIT License

Copyright (c) 2024 Amit Kumar Jha

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


Contact

For questions or feedback, contact:

Metadata

Release files for stochPathSim 1.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for stochPathSim 1.1.1
File Size Uploaded Provenance
stochPathSim-1.1.1.tar.gz 9.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for stochPathSim 1.1.1
File Interpreter ABI Platform
stochPathSim-1.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 28.9 kB

Release files / stochPathSim-1.1.1.tar.gz

Download URL stochPathSim-1.1.1.tar.gz
Size 9.8 kB
Tags Source
SHA-256 checksum
How to use checksums
7ad96e316dec295ece5799fd7a7702e48513e7909eaf98b938cacdfe1c9f9bfa
BLAKE2b-256 checksum
How to use checksums
54e75479d7f07286ae7f76cfff4c4cb1574d707193a2d1d5b47c763a37757e37
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.11.9

Release files / stochPathSim-1.1.1-py3-none-any.whl

Download URL stochPathSim-1.1.1-py3-none-any.whl
Size 19.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8dc9dd6c75ba0f7920901aab70402ada5cd63b115884e95f216cb4b257bbde02
BLAKE2b-256 checksum
How to use checksums
4ad81310612c23ebdc29e4c52fd6936e170e4b119a3c9b6a5b281d0f57a07d38
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.11.9

Security for stochPathSim 1.1.1

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page