Optional SDK for building trading bots on the0 platform.
Note: This SDK is optional. The the0 runtime automatically wraps your bot's output:
- Exit code 0 →
{"status":"success","message":"Bot executed successfully"} - Exit code non-zero →
{"status":"error","message":"Bot execution failed"} - If you output JSON with a
"status"field, it's passed through as-is
use std::env;
fn main() {
// No SDK needed - just run your code and exit normally
let bot_id = env::var("BOT_ID").unwrap_or_default();
let config_str = env::var("BOT_CONFIG").unwrap_or_default();
eprintln!("Bot {} running...", bot_id);
// Your trading logic here
// Exit normally - runtime outputs {"status":"success",...}
}The SDK provides convenience methods for parsing config and outputting custom results.
Add to your Cargo.toml:
[dependencies]
the0-sdk = "0.1"
serde_json = "1.0" # Required for config accessOr from git:
[dependencies]
the0-sdk = { git = "https://github.com/alexanderwanyoike/the0", subdirectory = "sdk/rust" }use the0_sdk::input;
fn main() {
// Parse bot configuration
let (bot_id, config) = input::parse();
eprintln!("Bot {} starting", bot_id);
// Access config values
if let Some(symbol) = config.get("symbol") {
eprintln!("Trading symbol: {}", symbol);
}
// Your trading logic here
// Optionally output custom result (otherwise runtime generates it)
input::success("Bot executed successfully");
}Parse bot configuration from environment. Returns (bot_id, config).
Parse configuration as a HashMap for easier access.
Output success result and continue execution.
Output error result and exit with code 1.
Output custom JSON result.
See the Rust Quick Start Guide for a complete example.
This package is published to crates.io.
-
Login to crates.io:
cargo login
-
Ensure you have ownership of the crate on crates.io
# Verify the package
cargo publish --dry-run
# Publish to crates.io
cargo publishUpdate the version in Cargo.toml:
version = "0.2.0"Then publish.
Apache-2.0