Skip to main content

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())

See examples/first_bot.py.

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 carries type, version, match id, tick, and sequence.
  • Bot → engine (one JSON line = array of 0+ messages): NEW_ORDER, CANCEL, CANCEL_ALL.
  • TickState accessors: best_bid(i), best_ask(i), mid(i), .position, .cash, .signals, .signal_type, .trades, .bulletins, .fills, .acks.
  • Constants: BUY/SELL, GTC/IOC, instruments A=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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

continual_exchange_sdk-0.2.1.tar.gz (18.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

continual_exchange_sdk-0.2.1-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

Details for the file continual_exchange_sdk-0.2.1.tar.gz.

File metadata

  • Download URL: continual_exchange_sdk-0.2.1.tar.gz
  • Upload date:
  • Size: 18.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for continual_exchange_sdk-0.2.1.tar.gz
Algorithm Hash digest
SHA256 e43b1591b13b6a7f03280dc47f6c37b8a99cd47938edcc435274b1a9710eca93
MD5 e3747f8b909810c54eb65b103f751846
BLAKE2b-256 b26a79438ebb208b76971366085f1befe44903391331452617cc41473bced6e7

See more details on using hashes here.

Provenance

The following attestation bundles were made for continual_exchange_sdk-0.2.1.tar.gz:

Publisher: release.yml on continualresearch/continual-exchange-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file continual_exchange_sdk-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for continual_exchange_sdk-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ab705190f5d7f9fe774d444403cf922da5c3c9d7ec429c253d7d519069a01788
MD5 5fa88c9dcaccba0afbc92d883715693f
BLAKE2b-256 4dd4b29bbe732da416416b3c84d667d067684d2aff874ac750d4afcea12d9644

See more details on using hashes here.

Provenance

The following attestation bundles were made for continual_exchange_sdk-0.2.1-py3-none-any.whl:

Publisher: release.yml on continualresearch/continual-exchange-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page