The0.Sdk 0.3.2

dotnet add package The0.Sdk --version 0.3.2
                    
NuGet\Install-Package The0.Sdk -Version 0.3.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="The0.Sdk" Version="0.3.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="The0.Sdk" Version="0.3.2" />
                    
Directory.Packages.props
<PackageReference Include="The0.Sdk" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add The0.Sdk --version 0.3.2
                    
#r "nuget: The0.Sdk, 0.3.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package The0.Sdk@0.3.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=The0.Sdk&version=0.3.2
                    
Install as a Cake Addin
#tool nuget:?package=The0.Sdk&version=0.3.2
                    
Install as a Cake Tool

the0 C#/.NET SDK

Optional SDK for building trading bots on the0 platform using C#/.NET 8.

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

Minimal Example (No SDK)

// No SDK needed - just run your code and exit normally
var botId = Environment.GetEnvironmentVariable("BOT_ID");
var configJson = Environment.GetEnvironmentVariable("BOT_CONFIG");

Console.Error.WriteLine($"Bot {botId} running...");

// Your trading logic here

// Exit normally - runtime outputs {"status":"success",...}

With SDK (Optional)

The SDK provides convenience methods for parsing config and outputting custom results.

Installation

Install from NuGet:

dotnet add package The0.Sdk

Or add to your .csproj:

<PackageReference Include="The0.Sdk" Version="0.1.2" />

Usage

using The0;

// Parse bot configuration
var (botId, config) = Input.Parse();

Console.Error.WriteLine($"Bot {botId} starting...");

// Access configuration values
var symbol = config?["symbol"]?.ToString() ?? "BTC/USDT";
var amount = config?["amount"]?.GetValue<decimal>() ?? 100m;

// Your trading logic here

// Optionally output custom result (otherwise runtime generates it)
Input.Success("Trade executed for " + symbol);

API Reference

Input.Parse()

Parse bot configuration from environment variables.

var (botId, config) = Input.Parse();
// botId: string - unique bot instance ID
// config: JsonNode? - configuration as JSON

Input.ParseAsDict()

Parse configuration as a Dictionary for easier access.

var (botId, config) = Input.ParseAsDict();
// config: Dictionary<string, JsonNode?>
if (config.TryGetValue("symbol", out var symbol))
{
    Console.Error.WriteLine($"Symbol: {symbol}");
}

Input.Success(message)

Output a success result.

Input.Success("Trade executed successfully");
// Output: {"status":"success","message":"Trade executed successfully"}

Input.Error(message)

Output an error result and exit with code 1.

Input.Error("Failed to connect to exchange");
// Output: {"status":"error","message":"Failed to connect to exchange"}
// Process exits with code 1

Input.Result(data)

Output a custom JSON result.

Input.Result(new {
    status = "success",
    trade_id = "12345",
    filled_amount = 0.5m
});

Input.Metric(type, data)

Emit a metric for the platform to collect.

Input.Metric("price", new { symbol = "BTC/USD", value = 45000.0 });
// Output to stdout: {"_metric":"price","symbol":"BTC/USD","value":45000,"timestamp":"..."}

Input.Log(message, data?, level?)

Log a structured message to stderr.

// Simple log (defaults to info level)
Input.Log("Starting bot");

// Log with level
Input.Log("Connection lost", null, LogLevel.Warn);

// Log with structured data
Input.Log("Order placed", new { orderId = "12345", symbol = "BTC" });

// Log with data and level
Input.Log("Order failed", new { orderId = "12345" }, LogLevel.Error);

Environment Variables

The SDK reads from these environment variables (set automatically by the0 runtime):

  • BOT_ID - Unique identifier for the bot instance
  • BOT_CONFIG - JSON-encoded configuration object

Logging

Use Console.Error for logs (stdout is reserved for results):

Console.Error.WriteLine("DEBUG: Processing trade...");  // Logs to stderr
Console.WriteLine("...");  // Reserved for JSON result output

Publishing (Maintainers)

This package is published to NuGet.org.

export NUGET_API_KEY="your_key_here"
make publish

Get your API key from: https://www.nuget.org/account/apikeys

License

Apache-2.0

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.3.2 188 1/9/2026
0.3.1 137 1/8/2026
0.3.0 142 1/4/2026
0.2.1 141 1/3/2026
0.2.0 146 1/3/2026
0.1.3 150 12/27/2025
0.1.2 139 12/26/2025
0.1.1 167 12/26/2025