Continual Exchange Python SDK: protocol client, reference bots, local runner
Project description
Continual Exchange — Python SDK
Write a bot in Python, run local matches against reference and house bots, and get
a verifiable replay. The SDK is a thin client over the NDJSON loopback-TCP
protocol — the Rust engine is authoritative; the SDK has no game logic beyond
convenience. Spawned bots receive CE_BOT_ADDR=HOST:PORT; run_bot connects
automatically.
The SDK is public on PyPI. During the current staging preview, the engine repository and public-season submissions are not open yet; staging accounts, ratings, and results are test-only.
Install
python -m pip install continual-exchange-sdk
Local matches become available when the engine source repository opens. At that point, build the matching engine release once and point the SDK at its checkout:
git clone https://github.com/continualresearch/continual-exchange.git
(cd continual-exchange/engine && cargo build --release)
export CE_ENGINE_ROOT="$PWD/continual-exchange"
For SDK development, clone this repository and use an editable install:
git clone https://github.com/continualresearch/continual-exchange-sdk.git
cd continual-exchange-sdk
python -m pip install -e '.[dev]'
Your first bot in 30 lines
from ce_sdk import Bot, run_bot, new_order, BUY, IOC
class FirstBot(Bot):
def on_start(self, ms):
self.base = ms["base_price"]; self.cid = 0
def on_tick(self, s):
f = (s.signals or {}).get("s") # FACTOR seats get a factor signal
if f is None:
return [] # IDIO seat: skip in this toy bot
out = []
for inst, beta in ((0, 1.0), (1, 0.8), (2, 0.9)):
fair = self.base + beta * f
ask = s.best_ask(inst)
if ask is not None and ask < fair - 3 and s.position[inst] < 90:
self.cid += 1
out.append(new_order(self.cid, inst, BUY, ask, 2, IOC))
return out
run_bot(FirstBot())
Run a local match after the engine source release
python examples/run_demo.py # reference bots + your bot, then verify
Or from code:
from ce_sdk import run_local_match, verify_replay
r = run_local_match(
["python examples/first_bot.py", "python examples/quoter_bot.py"],
seed="hello", manifest="../testkits/manifests/quick.json",
)
verify_replay(r["replay"]) # bit-identical re-execution
Package a submission
ce-package "python bot.py" --source ./my-bot --out submission.zip
The package is reproducible, contains a versioned submission.json entrypoint,
rejects symlinks and unsafe paths, and enforces the 4 GiB uncompressed limit.
Packaging works without the engine. After the engine source release, append
--smoke to run a Bronze validation with four competitor seats and four
disclosed house bots. The validation requires at least one valid message, no
crash or suspension, and a replay that verifies exactly.
Protocol crib
- Engine → bot (one JSON line each): protocol version 2
MATCH_START,TICK,MATCH_END; each carriestype, version, match id, tick, and sequence. - Bot → engine (one JSON line = array of 0+ messages):
NEW_ORDER,CANCEL,CANCEL_ALL. TickStateaccessors:best_bid(i),best_ask(i),mid(i),.position,.cash,.signals,.signal_type,.trades,.bulletins,.fills,.acks.- Constants:
BUY/SELL,GTC/IOC, instrumentsA=0, B=1, I=2.
Reference bots (ce_sdk.bots)
NoiseTrader, NaiveQuoter, and SignalFollower are readable examples for
random flow, symmetric quoting, and private-signal trading. See
examples/ and the public
first-bot walkthrough.
The public protocol reference documents every wire field.
Releases
PyPI publishing is release-only. Maintainers bump project.version, merge the
change, and publish a GitHub Release whose tag is exactly v<project.version>.
The release workflow builds and verifies both distributions, then publishes
them to PyPI using a short-lived OIDC credential. No PyPI API token is stored in
GitHub.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file continual_exchange_sdk-0.2.2.tar.gz.
File metadata
- Download URL: continual_exchange_sdk-0.2.2.tar.gz
- Upload date:
- Size: 19.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
002ad1e5d2dfbb08a4dc216d419d96543730884672bbcf11ea20cc173afbde7a
|
|
| MD5 |
523da0804bc8f6bd4c1fd83191876195
|
|
| BLAKE2b-256 |
b7509d8a2cf1cf45a1da6249020f8cc1c19575e17acc980fbfc6a6898044cc5c
|
Provenance
The following attestation bundles were made for continual_exchange_sdk-0.2.2.tar.gz:
Publisher:
release.yml on continualresearch/continual-exchange-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
continual_exchange_sdk-0.2.2.tar.gz -
Subject digest:
002ad1e5d2dfbb08a4dc216d419d96543730884672bbcf11ea20cc173afbde7a - Sigstore transparency entry: 2145092831
- Sigstore integration time:
-
Permalink:
continualresearch/continual-exchange-sdk@1cb8507f2b5f1753d4e7300b645f2228385d1819 -
Branch / Tag:
refs/tags/v0.2.2 - Owner: https://github.com/continualresearch
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1cb8507f2b5f1753d4e7300b645f2228385d1819 -
Trigger Event:
release
-
Statement type:
File details
Details for the file continual_exchange_sdk-0.2.2-py3-none-any.whl.
File metadata
- Download URL: continual_exchange_sdk-0.2.2-py3-none-any.whl
- Upload date:
- Size: 17.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
48c2f75db15d16b3cecd6fadf2db20427bc760f8a4ba527b8050659a4b268e09
|
|
| MD5 |
3b96939e18a0ea88d38eb46c984cbb13
|
|
| BLAKE2b-256 |
051521ca1db31108ff2738a060c7a74fe477cf44f42c698b8615d99782d0ee4d
|
Provenance
The following attestation bundles were made for continual_exchange_sdk-0.2.2-py3-none-any.whl:
Publisher:
release.yml on continualresearch/continual-exchange-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
continual_exchange_sdk-0.2.2-py3-none-any.whl -
Subject digest:
48c2f75db15d16b3cecd6fadf2db20427bc760f8a4ba527b8050659a4b268e09 - Sigstore transparency entry: 2145093555
- Sigstore integration time:
-
Permalink:
continualresearch/continual-exchange-sdk@1cb8507f2b5f1753d4e7300b645f2228385d1819 -
Branch / Tag:
refs/tags/v0.2.2 - Owner: https://github.com/continualresearch
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1cb8507f2b5f1753d4e7300b645f2228385d1819 -
Trigger Event:
release
-
Statement type: