From 89b92e125232b463a3ddeb2613b654a59fb4aa57 Mon Sep 17 00:00:00 2001 From: bxvtr Date: Sun, 1 Mar 2026 10:58:24 +0000 Subject: [PATCH] Chore: repository maintenance, renaming, changelog update, and pyproject cleanup --- .env.example | 2 +- .github/ISSUE_TEMPLATE/bug-report.md | 2 +- .../workflows/argo-build-and-backtest.yaml | 1 - CHANGELOG.md | 93 +++++++++---------- CONTRIBUTING.md | 2 +- README.md | 21 ++--- argo/run-build.yaml | 6 +- argo/workflowtemplate-backtest-fanout.yaml | 8 +- argo/workflowtemplate-build-push-ghcr.yaml | 10 +- pyproject.toml | 6 +- requirements-dev.txt | 26 +++--- requirements.txt | 26 +++--- scripts/compile-requirements.sh | 6 +- trading_runtime/local/backtest.py | 4 +- trading_runtime/strategies/debug_strategy.py | 4 +- 15 files changed, 98 insertions(+), 119 deletions(-) diff --git a/.env.example b/.env.example index 8e4ecd7..6fc9aa8 100644 --- a/.env.example +++ b/.env.example @@ -1 +1 @@ -TRADING_PLATFORM_COMMIT=afde290d6e5b9e1d47ae03e7ac6c2d03b250ae7f +TRADING_FRAMEWORK_COMMIT=934d332c21bef56fa76c19f477143d8d438238c2 diff --git a/.github/ISSUE_TEMPLATE/bug-report.md b/.github/ISSUE_TEMPLATE/bug-report.md index 3170a90..7428e03 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.md +++ b/.github/ISSUE_TEMPLATE/bug-report.md @@ -9,7 +9,7 @@ Clear and concise description of the issue. ## Environment -- Trading Platform version: +- Trading Framework version: - Python version: - Execution mode (local / cloud): - Strategy used: diff --git a/.github/workflows/argo-build-and-backtest.yaml b/.github/workflows/argo-build-and-backtest.yaml index 6b6decd..79eb6a8 100644 --- a/.github/workflows/argo-build-and-backtest.yaml +++ b/.github/workflows/argo-build-and-backtest.yaml @@ -85,7 +85,6 @@ jobs: id: submit_build run: | export RUNTIME_COMMIT="${GITHUB_SHA}" - export PLATFORM_COMMIT="${GITHUB_SHA}" export GIT_BRANCH="${{ needs.resolve-context.outputs.branch }}" BUILD_NAME=$( diff --git a/CHANGELOG.md b/CHANGELOG.md index 8df99b5..7ccab5b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,60 +1,57 @@ # Changelog All notable changes to this project will be documented in this file. - -The format is based on Keep a Changelog -and this project adheres to Semantic Versioning. +This project adheres to Semantic Versioning. ## [Unreleased] -## [0.1.0] - 2026-02-17 +## [0.1.0] – 2026-02-17 -Initial public release of the trading platform backtest core. +Initial public release of the trading-runtime execution and orchestration layer. ### Added -#### Core Domain -- Explicit order state machine -- Structured domain types and reject reasons -- Slot-based order tracking -- Event bus and event sink abstractions -- JSON schema validation for domain events - -#### Risk Layer -- Configurable risk engine -- Risk constraint enforcement -- Deterministic risk gating before execution - -#### Backtest Layer -- Integration with [hftbacktest](https://github.com/nkaz001/hftbacktest) -- Strategy runner abstraction -- Venue adapter interface -- Deterministic event processing pipeline - -#### Orchestration -- Segment-based execution model -- Parameter sweep runtime -- Experiment and segment entrypoints -- Prometheus metrics integration -- MLflow-compatible logging hooks - -#### Execution Modes -- Fully local execution example -- Cloud-native runtime entrypoints -- S3-compatible storage adapter - -#### Strategy Framework -- Base strategy interface -- Structured strategy configuration - -#### Testing -- Semantic invariant test suite -- Order state transition validation -- Queue dominance rules -- Risk constraint validation -- Schema conformance tests +#### Runtime Execution + +- Local deterministic backtest entrypoint +- Argo workflow execution entrypoints +- Structured runtime configuration model +- Strategy execution adapters + +#### Dependency Management + +- Commit-pinned `trading-framework` integration +- Reproducible dependency compilation via pip-tools +- Environment bootstrap scripts + +#### Containerization + +- Deterministic Docker runtime image +- GHCR push workflow template +- Immutable runtime environment definition + +#### Kubernetes & Orchestration + +- Argo WorkflowTemplates for: + - Image build & push + - Backtest orchestration +- microk8s-compatible deployment model +- Namespace-based secret management for GHCR + +#### CI & Infrastructure + +- GitHub-hosted test workflow +- Self-hosted runner for Kubernetes deployment +- Automated Argo template deployment pipeline + +#### Reproducibility + +- Synthetic deterministic test datasets +- Result artifact validation structure +- Environment parity between local and cluster execution #### Tooling -- Dev container configuration -- Development validation scripts -- Dependency compilation helper + +- Dev container bootstrap +- Validation helpers +- Dependency compilation script diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 777f6cc..678e6a1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,7 +2,7 @@ Thank you for your interest in contributing! -This repository is a runtime example for the [trading-platform](https://github.com/trading-engineering/trading-platform) framework using +This repository is a runtime example for the [trading-framework](https://github.com/trading-engineering/trading-framework) framework using [Kubernetes](https://kubernetes.io) (via e.g. [MicroK8s](https://microk8s.io)) and [Argo Workflows](https://argoproj.github.io/workflows). Contributions should preserve clarity, explicitness and reproducibility. diff --git a/README.md b/README.md index 99f374e..5ae2759 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ ![License](https://img.shields.io/badge/license-MIT-green) Runtime execution layer and orchestration environment for the -[trading-platform](https://github.com/trading-engineering/trading-platform) +[trading-framework](https://github.com/trading-engineering/trading-framework) framework. This repository provides: @@ -20,10 +20,9 @@ This repository provides: ## 🧠 What is this? -`trading-runtime` is the execution and orchestration layer built on top of -`trading-platform`. +`trading-runtime` is the execution and orchestration layer built on top of `trading-framework`. -While `trading-platform` implements the deterministic trading framework, +While `trading-framework` implements the deterministic trading framework, this repository focuses on: - how strategies are executed @@ -35,14 +34,14 @@ It intentionally contains no domain framework logic. --- -## 🧩 Relationship to trading-platform +## 🧩 Relationship to trading-framework ``` -trading-platform → core framework, backtesting engine, domain logic +trading-framework → core framework, backtesting engine, domain logic trading-runtime → executing entrypoints, runtime configs, orchestration ``` -The platform is consumed as a pinned Git dependency to guarantee +The framework is consumed as a pinned Git dependency to guarantee deterministic runtime environments. --- @@ -69,12 +68,12 @@ trading_runtime/strategies/ Example strategies ## 📌 Dependency Pinning & Reproducibility -The `trading-platform` dependency is pinned by commit SHA. +The `trading-framework` dependency is pinned by commit SHA. Create a `.env` file: ```bash -TRADING_PLATFORM_COMMIT= +TRADING_FRAMEWORK_COMMIT= ``` Generate reproducible environments: @@ -151,7 +150,7 @@ GitHub Container Registry (GHCR). This image contains: - Python dependencies and entrypoints -- trading-platform and trading-runtime commit SHA +- trading-framework and trading-runtime commit SHA - strategies and configs It acts as an immutable and deterministic runtime environment for all backtests. @@ -229,7 +228,7 @@ Without this secret, the workflow cannot authenticate against GHCR, and Kubernet | Script | Purpose | | ------------------------- | ----------------------------------------------- | -| `compile-requirements.sh` | Pins trading-platform and resolves dependencies | +| `compile-requirements.sh` | Pins trading-framework and resolves dependencies | | `post-create.sh` | Dev container bootstrap | | `check.sh` | Local validation helpers | diff --git a/argo/run-build.yaml b/argo/run-build.yaml index 141ebb6..558c9c4 100644 --- a/argo/run-build.yaml +++ b/argo/run-build.yaml @@ -7,9 +7,7 @@ spec: name: build-push-ghcr arguments: parameters: - - name: trading_runtime_commit - value: "${RUNTIME_COMMIT}" - - name: trading_platform_commit - value: "${PLATFORM_COMMIT}" - name: git_branch value: "${GIT_BRANCH}" + - name: trading_runtime_commit + value: "${RUNTIME_COMMIT}" diff --git a/argo/workflowtemplate-backtest-fanout.yaml b/argo/workflowtemplate-backtest-fanout.yaml index ce62e59..f2a140d 100644 --- a/argo/workflowtemplate-backtest-fanout.yaml +++ b/argo/workflowtemplate-backtest-fanout.yaml @@ -104,7 +104,7 @@ spec: command: [python, -m] args: - - trading_platform.backtest.runtime.entrypoint + - trading_framework.backtest.runtime.entrypoint - --config - "{{workflow.parameters.experiment_config}}" - --run @@ -156,7 +156,7 @@ spec: command: [python, -m] args: - - trading_platform.backtest.runtime.run_sweep + - trading_framework.backtest.runtime.run_sweep - --context - "{{inputs.parameters.sweep-path}}" - --scratch-root @@ -204,7 +204,7 @@ spec: command: [python, -m] args: - - trading_platform.backtest.runtime.segment_finalize_entrypoint + - trading_framework.backtest.runtime.segment_finalize_entrypoint - "--experiment-id" - "{{inputs.parameters.experiment-id}}" @@ -268,7 +268,7 @@ spec: command: [python, -m] args: - - trading_platform.backtest.runtime.experiment_finalize_entrypoint + - trading_framework.backtest.runtime.experiment_finalize_entrypoint - "--experiment-id" - "{{inputs.parameters.experiment-id}}" diff --git a/argo/workflowtemplate-build-push-ghcr.yaml b/argo/workflowtemplate-build-push-ghcr.yaml index e680c1a..a28e1dd 100644 --- a/argo/workflowtemplate-build-push-ghcr.yaml +++ b/argo/workflowtemplate-build-push-ghcr.yaml @@ -17,10 +17,6 @@ spec: description: "Exact commit SHA of trading-runtime" value: "" - - name: trading_platform_commit - description: "Exact commit SHA of trading-platform" - value: "" - templates: - name: build script: @@ -32,10 +28,9 @@ spec: IMAGE_REPO="{{workflow.parameters.image_repo}}" GIT_BRANCH="{{workflow.parameters.git_branch}}" RUNTIME_COMMIT="{{workflow.parameters.trading_runtime_commit}}" - PLATFORM_COMMIT="{{workflow.parameters.trading_platform_commit}}" - if [ -z "$RUNTIME_COMMIT" ] || [ -z "$PLATFORM_COMMIT" ]; then - echo "Both trading_runtime_commit and trading_platform_commit must be set" + if [ -z "$RUNTIME_COMMIT" ]; then + echo "> trading_runtime_commit must be set" exit 1 fi @@ -59,7 +54,6 @@ spec: --dockerfile=Dockerfile \ --target=runtime \ $DESTINATIONS \ - --build-arg=TRADING_PLATFORM_COMMIT=$PLATFORM_COMMIT \ --build-arg=GIT_BRANCH=$GIT_BRANCH \ --build-arg=GIT_COMMIT=$RUNTIME_COMMIT \ --build-arg=GIT_DIRTY=0 \ diff --git a/pyproject.toml b/pyproject.toml index fcc4f39..a538ec5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta" [project] name = "trading-runtime" version = "0.1.0" -description = "Trading runtime." +description = "Runtime execution and Kubernetes orchestration layer for the trading-framework with reproducible environments and deterministic backtesting." readme = "README.md" requires-python = ">=3.11" authors = [{ name = "tradingeng@protonmail.com" }] @@ -18,10 +18,6 @@ classifiers = [ "Operating System :: OS Independent" ] -dependencies = [ - "trading-platform", -] - [project.optional-dependencies] dev = [ "pytest>=9,<10", diff --git a/requirements-dev.txt b/requirements-dev.txt index 79975c3..9c929cb 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -99,7 +99,7 @@ gunicorn==23.0.0 h11==0.16.0 # via uvicorn hftbacktest==2.4.4 - # via trading-platform + # via trading-framework holoviews==1.22.1 # via hftbacktest huey==2.6.0 @@ -125,7 +125,7 @@ jinja2==3.1.6 joblib==1.5.3 # via scikit-learn jsonschema==4.26.0 - # via trading-platform + # via trading-framework jsonschema-specifications==2025.9.1 # via jsonschema kiwisolver==1.4.9 @@ -159,7 +159,7 @@ mdit-py-plugins==0.5.0 mdurl==0.1.2 # via markdown-it-py mlflow==3.9.0 - # via trading-platform + # via trading-framework mlflow-skinny==3.9.0 # via mlflow mlflow-tracing==3.9.0 @@ -189,9 +189,9 @@ numpy==2.2.6 # scikit-learn # scipy # skops - # trading-platform + # trading-framework oci==2.167.1 - # via trading-platform + # via trading-framework opentelemetry-api==1.39.1 # via # mlflow-skinny @@ -247,7 +247,7 @@ polars-runtime-32==1.38.1 prettytable==3.17.0 # via skops prometheus-client==0.24.1 - # via trading-platform + # via trading-framework protobuf==6.33.5 # via # databricks-sdk @@ -257,7 +257,7 @@ protobuf==6.33.5 pyarrow==16.1.0 # via # mlflow - # trading-platform + # trading-framework pyasn1==0.6.2 # via # pyasn1-modules @@ -271,7 +271,7 @@ pydantic==2.12.5 # fastapi # mlflow-skinny # mlflow-tracing - # trading-platform + # trading-framework pydantic-core==2.41.5 # via pydantic pygments==2.19.2 @@ -351,11 +351,9 @@ tornado==6.5.4 tqdm==4.67.3 # via # panel - # trading-platform -trading-platform @ git+https://github.com/trading-engineering/trading-platform.git@e21137d3d2b1414b4d407f13e654f313eedd66cd - # via - # -r _git_deps.in - # trading-runtime (pyproject.toml) + # trading-framework +trading-framework @ git+https://github.com/trading-engineering/trading-framework.git@934d332c21bef56fa76c19f477143d8d438238c2 + # via -r _git_deps.in typing-extensions==4.15.0 # via # alembic @@ -386,7 +384,7 @@ tzdata==2025.3 uc-micro-py==1.0.3 # via linkify-it-py ujson==5.11.0 - # via trading-platform + # via trading-framework urllib3==2.6.3 # via # docker diff --git a/requirements.txt b/requirements.txt index 0a02350..4259c45 100644 --- a/requirements.txt +++ b/requirements.txt @@ -96,7 +96,7 @@ gunicorn==23.0.0 h11==0.16.0 # via uvicorn hftbacktest==2.4.4 - # via trading-platform + # via trading-framework holoviews==1.22.1 # via hftbacktest huey==2.6.0 @@ -118,7 +118,7 @@ jinja2==3.1.6 joblib==1.5.3 # via scikit-learn jsonschema==4.26.0 - # via trading-platform + # via trading-framework jsonschema-specifications==2025.9.1 # via jsonschema kiwisolver==1.4.9 @@ -150,7 +150,7 @@ mdit-py-plugins==0.5.0 mdurl==0.1.2 # via markdown-it-py mlflow==3.9.0 - # via trading-platform + # via trading-framework mlflow-skinny==3.9.0 # via mlflow mlflow-tracing==3.9.0 @@ -176,9 +176,9 @@ numpy==2.2.6 # scikit-learn # scipy # skops - # trading-platform + # trading-framework oci==2.167.1 - # via trading-platform + # via trading-framework opentelemetry-api==1.39.1 # via # mlflow-skinny @@ -229,7 +229,7 @@ polars-runtime-32==1.38.1 prettytable==3.17.0 # via skops prometheus-client==0.24.1 - # via trading-platform + # via trading-framework protobuf==6.33.5 # via # databricks-sdk @@ -239,7 +239,7 @@ protobuf==6.33.5 pyarrow==16.1.0 # via # mlflow - # trading-platform + # trading-framework pyasn1==0.6.2 # via # pyasn1-modules @@ -253,7 +253,7 @@ pydantic==2.12.5 # fastapi # mlflow-skinny # mlflow-tracing - # trading-platform + # trading-framework pydantic-core==2.41.5 # via pydantic pyopenssl==25.1.0 @@ -327,11 +327,9 @@ tornado==6.5.4 tqdm==4.67.3 # via # panel - # trading-platform -trading-platform @ git+https://github.com/trading-engineering/trading-platform.git@e21137d3d2b1414b4d407f13e654f313eedd66cd - # via - # -r _git_deps.in - # trading-runtime (pyproject.toml) + # trading-framework +trading-framework @ git+https://github.com/trading-engineering/trading-framework.git@934d332c21bef56fa76c19f477143d8d438238c2 + # via -r _git_deps.in typing-extensions==4.15.0 # via # alembic @@ -359,7 +357,7 @@ tzdata==2025.3 uc-micro-py==1.0.3 # via linkify-it-py ujson==5.11.0 - # via trading-platform + # via trading-framework urllib3==2.6.3 # via # docker diff --git a/scripts/compile-requirements.sh b/scripts/compile-requirements.sh index b2c1fe5..1bfdcf4 100755 --- a/scripts/compile-requirements.sh +++ b/scripts/compile-requirements.sh @@ -6,10 +6,10 @@ set -a source .env set +a -: "${TRADING_PLATFORM_COMMIT:?Missing TRADING_PLATFORM_COMMIT in .env}" +: "${TRADING_FRAMEWORK_COMMIT:?Missing TRADING_FRAMEWORK_COMMIT in .env}" echo "🔧 Compiling requirements with pip-tools..." -echo "📌 Pinning trading-platform at commit: $TRADING_PLATFORM_COMMIT" +echo "📌 Pinning trading-framework at commit: $TRADING_FRAMEWORK_COMMIT" python -m pip install --upgrade \ "pip>=23.3,<25" \ @@ -19,7 +19,7 @@ python -m pip install --upgrade \ # Temporary requirements input for git dependency cat > _git_deps.in <