Skip to main content

smerisk

Probability and statistical calculations for small and medium-sized businesses: cash-flow and payroll risk, fixed-price projects, utilization, rate estimation with sparse data, survival, receivables, accounting anomalies, perishable goods, service staffing, and forecast reliability.

Two ways to use it:

  • Python library (pip install smerisk): pure functions with no database or network access.
  • HTTP service (FastAPI): clone this repository and run the service to call the same functions under /v1/... from any language; see Running the HTTP service.

Documentation of each formula and use case is in docs/.

Status: first release (0.1.0, alpha). All the functions of the specification are implemented: the formulas, the raw data contracts, parameter preparation, the eleven business use cases, and the HTTP service. The API may still change before 1.0; see the changelog.

Installation

pip install smerisk

Example

from smerisk import risk_measures

result = risk_measures(
    samples=[float(value) for value in range(1, 101)],
    confidence=0.95,
)

print(round(result.result.quantile, 2))  # 5.95
print(round(result.result.var, 2))  # 44.55
print(result.result.expected_shortfall)  # 3.0
print(result.assumptions)

Running the HTTP service

Prerequisites

  • Python 3.11 or newer (python --version) and Git.
  • Nothing else to install by hand: pip install ./ ./service installs the library and the service with all their dependencies (FastAPI, Uvicorn, Pydantic, NumPy, SciPy, cryptography, python-multipart).

1. Get the code and install it

Linux and macOS:

git clone https://github.com/OussamaELGUERRAOUI/smerisk.git
cd smerisk
python3 -m venv .venv
.venv/bin/python -m pip install ./ ./service

Windows (PowerShell):

git clone https://github.com/OussamaELGUERRAOUI/smerisk.git
cd smerisk
python -m venv .venv
.venv\Scripts\python -m pip install ./ ./service

The commands call the Python of .venv directly, so there is no environment to activate.

2. Choose a token and start the service

Each application that calls the service uses a token: a secret string that you choose. To create one:

python -c "import secrets; print(secrets.token_urlsafe(32))"

Linux and macOS:

export SMERISK_API_TOKENS="paste-the-token-here"
.venv/bin/python -m uvicorn smerisk_service.main:app --host 127.0.0.1 --port 8000 --workers 1

Windows (PowerShell):

$env:SMERISK_API_TOKENS = "paste-the-token-here"
.venv\Scripts\python -m uvicorn smerisk_service.main:app --host 127.0.0.1 --port 8000 --workers 1

Several applications: separate their tokens with commas. 127.0.0.1 keeps the service on your machine; on a server, use --host 0.0.0.0 behind a reverse proxy that serves HTTPS. Keep --workers 1. Stop the service with Ctrl+C.

3. Check that it works

  • http://127.0.0.1:8000/health answers {"status": "ok", ...}.
  • http://127.0.0.1:8000/docs shows every route; the Authorize button takes the token.
  • A first calculation:
curl -X POST http://127.0.0.1:8000/v1/pert/estimate \
  -H "Authorization: Bearer paste-the-token-here" -H "Content-Type: application/json" \
  -d '{"tasks": [{"id": "design", "optimistic": 2, "most_likely": 4, "pessimistic": 9}]}'
$body = '{"tasks": [{"id": "design", "optimistic": 2, "most_likely": 4, "pessimistic": 9}]}'
Invoke-RestMethod -Method Post -Uri http://127.0.0.1:8000/v1/pert/estimate `
  -Headers @{ Authorization = "Bearer paste-the-token-here" } -ContentType "application/json" -Body $body

The answer contains "expected": 4.5 in result.total.

To update: git pull, then run the install command of step 1 again. With Docker instead of Python: docker build -f service/Dockerfile -t smerisk-service . then docker run -p 8000:8000 -e SMERISK_API_TOKENS=paste-the-token-here smerisk-service.

The full guide (configuration, use cases, jobs, large datasets, errors, logs) is docs/service.md.

License

Apache 2.0; see LICENSE.

Metadata

Release files for smerisk 0.1.0

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

Source distribution (sdist)

Source distribution for smerisk 0.1.0
File Size Uploaded Provenance
smerisk-0.1.0.tar.gz 195.4 kB With provenance Details

Built distribution (wheel)

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

Total release size: 312.0 kB

Release files / smerisk-0.1.0.tar.gz

Download URL smerisk-0.1.0.tar.gz
Size 195.4 kB
Tags Source
SHA-256 checksum
How to use checksums
295737955287c686d7d77c2e4afba5ee9718cde32029279ebaf6ec7fb2767bb3
BLAKE2b-256 checksum
How to use checksums
33c05a581c3254f401beb9fb06b60f04f69ee01dc34ee53f031136d9e18d7163
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

Release files / smerisk-0.1.0-py3-none-any.whl

Download URL smerisk-0.1.0-py3-none-any.whl
Size 116.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ff6611240ffd5d8bac45f704f71467e050ba0e62403ff7ba461a87a416774cbe
BLAKE2b-256 checksum
How to use checksums
6ef2caaddb13e346ba95031056448d0fb23ad497a585ac4d3c1163d27ca93ec7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

Security for smerisk 0.1.0

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for smerisk-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

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