Skip to main content

SharpeArena for Python

The Python distribution combines SharpeArena's deterministic point-in-time evaluation sandbox with a Gymnasium-compatible environment and optional adapters for multi-agent, RLVR, offline-RL, MCP, and local-model workflows.

Point-in-time observations prevent future-bar access through the environment API. They do not isolate Python code from the host. Run trusted local code here, or use SharpeBench's digest-pinned container path for an untrusted entrant.

Install

pip install sharpearena

The base install includes NumPy, Gymnasium, the Python package, and the compiled pyo3 extension. Optional integrations are explicit:

pip install "sharpearena[pettingzoo]"
pip install "sharpearena[verifiers]"
pip install "sharpearena[minari]"
pip install "sharpearena[mcp]"

Step a Gymnasium environment

from sharpearena import SharpeArenaEnv

env = SharpeArenaEnv(n_symbols=4, n_days=120, seed=7)
observation, info = env.reset(seed=7)

terminated = truncated = False
while not (terminated or truncated):
    action = env.action_space.sample()
    observation, reward, terminated, truncated, info = env.step(action)

Actions are signed target-weight vectors in the environment's symbol order. The default range is [-1, 1]; pass allow_short=False to make it [0, 1], or set max_weight to change the per-symbol bound.

Importing sharpearena registers the following Gymnasium IDs:

SharpeArena/Calm-v1          SharpeArena/Calm-Eval-v1
SharpeArena/Hard-v1          SharpeArena/Hard-Eval-v1
SharpeArena/Extreme-v1       SharpeArena/Extreme-Eval-v1

The -Eval-v1 environments draw from the disjoint evaluation seed band. The -v1 suffix freezes the environment semantics; a rule change requires a new versioned ID.

Native boundary

sharpearena.sharpearena_py.TradingEnv is the low-level binding. Its boundary is JSON: reset() returns an observation string, and step(decision_json) returns (observation_json, reward, done, info_json). The Python Gymnasium wrapper converts between that wire format and NumPy spaces.

The wheel ships py.typed and a stub for the compiled extension. Typed boundary exceptions distinguish invalid input, invalid JSON, invalid salt, unavailable data, and engine failures.

Scoring and typed unavailability

score_run(returns, n_trials, periods_per_year) returns the pinned SharpeBench CompositeScore as JSON. When the kernel cannot score a series (a non-finite observation, fewer than two observations) the composite carries a typed error beside a no-skill floor rather than an estimate: deflation_error (the deflated Sharpe, its bar and its interval are the floor), bootstrap_error (the bootstrap p-value is the conservative 1.0 sentinel) and selection_error (the selection diagnostic is absent). Reading deflated_sharpe past such a key publishes the floor as a score.

A constant track (every return equal, such as the flat baseline's all-zero series) has a sample variance of zero and so no Sharpe ratio. The pinned kernel would still score it, so score_run withholds it: deflation_error reads returns must not be constant: a constant series has no Sharpe ratio (or Sharpe ratio is not finite for a track whose computed standard deviation underflows to zero), deflated_sharpe and psr read the 0.0 floor, the interval and rolling Sharpe fields are absent or null, and passed_k and rank_eligible are false. The seed bootstrap (deflated_sharpe_ci, paired_dsr_diff) raises ValueError with the same reason. The predicate is value equality, not a volatility tolerance, so a dispersed track keeps its score.

sharpearena.kernel_score is the one place a consumer reads the ranked numbers:

  • kernel_deflated_sharpe(composite) and kernel_psr(composite) return the finite value or raise. An unavailability key (deflation_error, bootstrap_error, selection_error, dsr_ci_error, exposure_path_error) raises KernelScoreUnavailable; a gate refusal key (standard_error_refusal, deflation_refusal, exposure_path_refusal, or exposure_path_error holding exactly the exposure-path refusal requirement) raises KernelScoreRefused; both derive from KernelScoreWithheld and name every key present. Any other *_error or *_refusal key raises KernelFieldUnrecognized and is never recorded. Selection, ranking inputs and the paper producers use these and stop. The kernel field convention lists the allowlists.
  • kernel_score_or_unavailable(composite, key="deflated_sharpe") returns the float or the reason string unavailable_scoring_kernel_error: <key>: <message> (or refused_scoring_kernel_gate: <key>: <message> for a refusal) for rows that must be recorded (eval-seed snapshots, generalization and regime rows, the PettingZoo leaderboard, trace meta, the local-field journal). kernel_score_difference makes a gap unavailable when either side is; is_kernel_score_unavailable tests a recorded cell and is_kernel_score_refused picks out a recorded refusal.

Every score_run consumer in this package goes through these helpers; none substitutes a default. The multi-agent ranking places an unscorable agent after every scored one with the reason in its cell.

For the private-copy PettingZoo tournament, fewer than two observed returns are also explicitly unavailable, not a numeric zero. env.final_ranking exposes a detached whole-roster result after all agents finish, including agents removed earlier; it is None before completion and after reset. Step dictionaries retain the Parallel live-agent contract. Row rank is a display position, not a SharpeBench eligibility certificate or a full benchmark-field score.

Other surfaces

Task Surface
Batched Gymnasium rollout SharpeArenaVectorEnv or gymnasium.make_vec(...)
Multi-agent environment MultiAgentSharpeArenaEnv with the pettingzoo extra
RLVR / Prime RL load_environment() with the verifiers extra
Offline RL export to_minari, to_minari_train_test with the minari extra
External tool server MCP server with the mcp extra
Evidence field sharpearena-local-field and the model transport shims; raw schema 2 records source-labelled per-request duration and token/retry accounting
Benchmark compilation sharpearena-compile-bench; bridge schema 2 adds a validated, rank-neutral p50/p95 operational profile beside score submissions
Strategy search sharpearena-strategy-search

Vector reset(seed=k) rebuilds native lanes on k, k+1, ...; a list supplies exactly one nonnegative int64 seed per lane. Unseeded reset and autoreset replay the current scenarios. Explicit seeds are literal, not shifted into the eval band. max_episode_steps enforces a positive executed-step cap per lane, setting truncation while preserving the selected autoreset mode; None keeps the native horizon. Disabled capped lanes freeze with zero subsequent reward. Log custom caps with the window and seeds when comparing runs.

See the repository's Gymnasium guide, training guide, and agent contract for the full workflows.

Build from source

python -m maturin develop --manifest-path crates/sharpearena-py/Cargo.toml

License

MIT OR Apache-2.0

Metadata

Release files for sharpearena 0.32.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 sharpearena 0.32.0
File Size Uploaded Provenance Actions
sharpearena-0.32.0.tar.gz 1.0 MB With provenance Details for sharpearena-0.32.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for sharpearena 0.32.0
File Actions
sharpearena-0.32.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.17+ x86-64 Details for sharpearena-0.32.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
sharpearena-0.32.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ x86-64 Details for sharpearena-0.32.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
sharpearena-0.32.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ x86-64 Details for sharpearena-0.32.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
sharpearena-0.32.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ x86-64 Details for sharpearena-0.32.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Total release size: 7.1 MB

Release files / sharpearena-0.32.0.tar.gz

Download URL sharpearena-0.32.0.tar.gz
Size 1.0 MB
Tags Source
SHA-256 checksum
How to use checksums
bd081a931895e0aa1734e7034d1f8484f40d36564c7cc3fd8962f16ba7d7ce7a
BLAKE2b-256 checksum
How to use checksums
4e2eff5030a6091596b4ff63c52d802cc5308a0f856264c43f7431d2addfc374
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Nov 12, 2026.

Transparency log

Release files / sharpearena-0.32.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL sharpearena-0.32.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.5 MB
Tags CPython 3.13 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
fbce3a807b9f07baf8c51cab591cb09ea1c575323807a6d90d2a3f2f3a704dea
BLAKE2b-256 checksum
How to use checksums
afd93b8256e6c476ee353e2bc1508ffccee09ae5878b10230a72c5006f1f0307
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Nov 12, 2026.

Transparency log

Release files / sharpearena-0.32.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL sharpearena-0.32.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.5 MB
Tags CPython 3.12 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
df55543097c50b94c678c25efb83416386a99948b24459bc7378fae6f3ec09f8
BLAKE2b-256 checksum
How to use checksums
3869733f107c857ad7e56169b41e9302ba2919eeb92f52a844830ec7cbf3a532
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Nov 12, 2026.

Transparency log

Release files / sharpearena-0.32.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL sharpearena-0.32.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.5 MB
Tags CPython 3.11 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
de07e1c87964d0fa3054ea2412bf1782f2da7533105dc69fc8fc882bf3ca9d00
BLAKE2b-256 checksum
How to use checksums
3df3d8b03d0160610d2e10602fc4223e0a6187ebc052f009c1963619ddd39d05
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Nov 12, 2026.

Transparency log

Release files / sharpearena-0.32.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL sharpearena-0.32.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.5 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
9dd3cd5e444aacbb21bbd219ade54b558c5bc62b4fc55289be603e04ebd41b60
BLAKE2b-256 checksum
How to use checksums
a8bf3def616f13727fdfc62a25df8560bee9791ea7775926a944b98422b6318b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Nov 12, 2026.

Transparency log

Security for sharpearena 0.32.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 5 files in this release have been uploaded with provenance metadata.

Select from 5 files

Attestation for sharpearena-0.32.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 Nov 12, 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.

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