Skip to main content

the0-sdk (Python)

SDK for building trading bots on the0 platform.

Installation

pip install the0-sdk

Or copy the the0/ directory to your project.

Quick Start

from the0 import parse, success, error, metric, log

# Parse bot configuration from environment
bot_id, config = parse()

log(f"Bot {bot_id} starting...")

# Access configuration
symbol = config.get("symbol", "BTC/USDT")
amount = config.get("amount", 100.0)

try:
    # Your trading logic here
    log(f"Trading {symbol} with amount {amount}")

    # Emit metrics for the dashboard
    metric("price", {
        "symbol": symbol,
        "value": 45000.50,
        "change_pct": 2.5
    })

    # Signal success
    success("Trade executed", {
        "symbol": symbol,
        "amount": amount
    })

except Exception as e:
    error(f"Trade failed: {e}")

API Reference

parse() -> Tuple[str, Dict]

Parse bot configuration from environment variables.

bot_id, config = parse()
# bot_id: Value of BOT_ID env var
# config: Parsed JSON from BOT_CONFIG env var

success(message: str, data: dict = None)

Output a success result.

success("Trade completed")
success("Trade completed", {"trade_id": "12345"})

error(message: str, data: dict = None)

Output an error result, print the message to stderr as an error log line, and exit with code 1.

if amount <= 0:
    error("Amount must be positive")
    # Program exits here

result(data: dict)

Output a custom JSON result.

result({
    "status": "success",
    "trade_id": "abc123",
    "filled_amount": 0.5,
    "average_price": 45123.50
})

metric(type: str, data: dict)

Emit a metric for the platform dashboard.

# Price metric
metric("price", {"symbol": "BTC/USD", "value": 45000})

# Trading signal
metric("signal", {"symbol": "ETH/USD", "direction": "long", "confidence": 0.85})

# Alert
metric("alert", {"type": "price_spike", "severity": "high"})

log(message: str, data: dict = None)

Log a message to the bot's logs.

log("Starting trade...")
log("Order placed", {"order_id": "12345"})

sleep(seconds: float)

Sleep utility.

sleep(5)  # Wait 5 seconds

Publishing (Maintainers)

This package is published to PyPI.

Prerequisites

  1. Install build tools:

    pip install build twine
    
  2. Create a PyPI API token at https://pypi.org/manage/account/token/

Publish

# Build the package
python -m build

# Upload to PyPI
twine upload dist/*

Version Bump

Update the version in pyproject.toml:

version = "0.2.0"

Then rebuild and publish.

License

Apache-2.0

Metadata

Release files for the0-sdk 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for the0-sdk 0.4.0
File Size Uploaded
the0_sdk-0.4.0.tar.gz 22.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for the0-sdk 0.4.0
File Interpreter ABI Platform
the0_sdk-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 36.4 kB

Release files / the0_sdk-0.4.0.tar.gz

Download URL the0_sdk-0.4.0.tar.gz
Size 22.2 kB
Tags Source
SHA-256 checksum
How to use checksums
6b4bee2feb0b5163b78374b080c5b7ae3c49d11e58b744a3200e5513d332390c
BLAKE2b-256 checksum
How to use checksums
717b3c523bc29156ef1781e446b32019344790904b835a54b3d38fff9742da0c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 12, 2026.

Transparency log

Release files / the0_sdk-0.4.0-py3-none-any.whl

Download URL the0_sdk-0.4.0-py3-none-any.whl
Size 14.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bbdf4dc9ed5124f80cfd8c313226ce4afe8883ee80875f57e7ab83b5dc094a0c
BLAKE2b-256 checksum
How to use checksums
59ba7d6cf1f74bc5a52e08bfa2cc362154c9d4399997244390b83f58a3c8f605
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 12, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page