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.2.tar.gz (19.1 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.2-py3-none-any.whl (17.4 kB view details)

Uploaded Python 3

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

Hashes for continual_exchange_sdk-0.2.2.tar.gz
Algorithm Hash digest
SHA256 002ad1e5d2dfbb08a4dc216d419d96543730884672bbcf11ea20cc173afbde7a
MD5 523da0804bc8f6bd4c1fd83191876195
BLAKE2b-256 b7509d8a2cf1cf45a1da6249020f8cc1c19575e17acc980fbfc6a6898044cc5c

See more details on using hashes here.

Provenance

The following attestation bundles were made for continual_exchange_sdk-0.2.2.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.2-py3-none-any.whl.

File metadata

File hashes

Hashes for continual_exchange_sdk-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 48c2f75db15d16b3cecd6fadf2db20427bc760f8a4ba527b8050659a4b268e09
MD5 3b96939e18a0ea88d38eb46c984cbb13
BLAKE2b-256 051521ca1db31108ff2738a060c7a74fe477cf44f42c698b8615d99782d0ee4d

See more details on using hashes here.

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

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