Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1 +1 @@
TRADING_PLATFORM_COMMIT=afde290d6e5b9e1d47ae03e7ac6c2d03b250ae7f
TRADING_FRAMEWORK_COMMIT=934d332c21bef56fa76c19f477143d8d438238c2
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/argo-build-and-backtest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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=$(
Expand Down
93 changes: 45 additions & 48 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
21 changes: 10 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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.

---
Expand All @@ -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=<commit-sha>
TRADING_FRAMEWORK_COMMIT=<commit-sha>
```

Generate reproducible environments:
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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 |

Expand Down
6 changes: 2 additions & 4 deletions argo/run-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
8 changes: 4 additions & 4 deletions argo/workflowtemplate-backtest-fanout.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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}}"
Expand Down Expand Up @@ -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}}"
Expand Down
10 changes: 2 additions & 8 deletions argo/workflowtemplate-build-push-ghcr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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

Expand All @@ -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 \
Expand Down
6 changes: 1 addition & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }]
Expand All @@ -18,10 +18,6 @@ classifiers = [
"Operating System :: OS Independent"
]

dependencies = [
"trading-platform",
]

[project.optional-dependencies]
dev = [
"pytest>=9,<10",
Expand Down
26 changes: 12 additions & 14 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading