Skip to main content

qate-env

Trading environments for qate: where a run is defined, which machine it is on, whose credentials it uses, and what it recorded about itself.

qate is a library. It knows what an order book is, how a strategy is called, and how an order is filled — and nothing at all about directories, hosts or keys. That is this package. Keeping them apart is what lets qate be installed and backtested with no notion of a deployment, and what makes "a backtest asks for no credential" true by construction rather than by review.

pip install kamakuraquantlab-qate-env

An environment is a directory

One directory per named environment, under ~/env by default:

~/env/MY_LIVE_RUN/
  trading.json       # which strategy module and variant, and which key set
  config.json        # the strategy's Config
  params.json        # the parameters this run uses
  param_grid.json    # a search space, for an optimize sweep. Optional
  features.json      # feature flags. Optional
  .lock              # PID lock: one process per environment
  env.log            # rotating log

There is no index file naming what loads what. Each <key>.json is read by whatever wants it, and the one class that cannot be known in advance — the strategy's own Config — is resolved from the strategy module that trading.json already names. See knowledge/01_env.md for why there used to be one and why it went.

from qate_env import sys_env
from qate_env.env import Env
from qate_env.env_name import EnvName
from qate_env.trading_env import get_strategy_class, load_trading_env

env = Env(sys_env.get_env_root_dir(), EnvName("MY_LIVE_RUN"))
env.enter()                                   # chdir, log to env.log, take the lock

definition = load_trading_env(env)            # profile, config, params, grid, features
StrategyClass = get_strategy_class(
    definition.profile.strategy_module_name,
    definition.profile.variant,
)
strategy = StrategyClass(definition.config, definition.params)

Layout

Module Holds
qate_env.env Env: the directory and its lifecycle — load, chdir, lock, log
qate_env.env_name EnvName: a validated uppercase name, and a real str
qate_env.sys_env The machine: where environments live, which credentials exist
qate_env.trading_env TradingProfile, TradingEnv, load_trading_env, and the two by-convention class lookups
qate_env.configurator An environment's markets and venues, wired into a qate.trading.runtime.Runtime
qate_env.run_log RunLog: what a run recorded about itself

Wiring a live run

Configurator turns a configuration into objects that can connect, by asking qate's registry for whatever adapter is installed. It names no venue itself.

from qate.trading.runtime import Runtime
from qate_env.configurator import Configurator, GatewayName

runtime = Runtime(strategy)
Configurator(config, profile, gateway_name=GatewayName.PROD).configure(runtime)
runtime.start()

GatewayName is the runner's decision, not the environment's — a live runner passes PROD, a paper or replay runner leaves it at SIMULATOR. It is not a field in trading.json, because a field half its readers ignored was a field that went stale.

Settings

Three answers about the machine, each from a config file, an environment variable, or a documented default. No path is hardcoded anywhere else.

What Default Overridden by
Where environments live ~/env QATE_ENV_ROOT, then env_root_dir in a .qate.json beside the running script
Where credentials live ~/.qate QATE_SECRET_DIR, then secret_dir in that same .qate.json
A credential — <secret dir>/<service>.keys, INI, one section per named key set
[DEFAULT]
API_KEY = ...
SECRET  = ...

A missing file raises CredentialsNotFound naming the path it looked for. Nothing here invents a credential or falls back to an unauthenticated call, so a live run fails at startup rather than part way through — and a backtest, which asks for none, is never affected by their absence.

The variables are still spelled QATE_* and the directory is still ~/.qate: they name the framework, not the distribution, and every deployed host already has them.

There is deliberately no market-data root. Neither qate nor this package reads market data; the tool that downloaded it knows where it is.

What a run recorded

RunLog is the provenance of a number — the environment, the library revision, the configuration, the parameters — written as one JSON file so a figure in a notebook can be traced back to the run that produced it.

It is given what it records, never asked for it. It used to read env.get("config"), which returned something only after a particular load path had run, so a caller that loaded its configuration any other way silently logged "config": null. The provenance of a number is a bad place for a silent null.

Who uses this

Enoshima Backtests an environment's definition without taking its lock
A live runner Reads the same environment, passes GatewayName.PROD, and trades it

qate itself does not, and that is the point of the split.

Development

pip install -e '.[dev]'
pytest

Licence

Apache 2.0. See LICENSE.md.

Metadata

Release files for kamakuraquantlab-qate-env 0.2.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 kamakuraquantlab-qate-env 0.2.0
File Size Uploaded Provenance Actions
kamakuraquantlab_qate_env-0.2.0.tar.gz 19.1 kB Without provenance Details for kamakuraquantlab_qate_env-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for kamakuraquantlab-qate-env 0.2.0
File Interpreter ABI Platform Actions
kamakuraquantlab_qate_env-0.2.0-py3-none-any.whl Python 3 none any Details for kamakuraquantlab_qate_env-0.2.0-py3-none-any.whl

Total release size: 36.2 kB

Release files / kamakuraquantlab_qate_env-0.2.0.tar.gz

Download URL kamakuraquantlab_qate_env-0.2.0.tar.gz
Size 19.1 kB
Tags Source
SHA-256 checksum
How to use checksums
b903de4a09548de98e8dc83a59d9b3998c2bffe63725ff1ccddce1db3c9e9c12
BLAKE2b-256 checksum
How to use checksums
c8bca16e60923e35e2b4437c7ee1ee8d082ca02690d8d6389439b91fe5c3b16e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.9

Release files / kamakuraquantlab_qate_env-0.2.0-py3-none-any.whl

Download URL kamakuraquantlab_qate_env-0.2.0-py3-none-any.whl
Size 17.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3a93299e591c6fb3c92e1375acb06453d88634c783a4f3b4c7d1f2c258444551
BLAKE2b-256 checksum
How to use checksums
f0885d524daa7809327d14b341bab6073bf32aefef4c5c58e768581306cc422b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.9

Security for kamakuraquantlab-qate-env 0.2.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.

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.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No 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