sequence-algo-sdk 0.1.0

Sequence Markets Algo SDK — write HFT trading algos in Rust, compile to WASM, deploy to Sequence
Documentation
  • Coverage
  • 44.89%
    79 out of 176 items documented0 out of 90 items with examples
  • Size
  • Source code size: 48.49 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 6.04 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 13s Average build duration of successful builds.
  • all releases: 14s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • Bai-Funds/algo-sdk
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • muhammad-awan0

sequence-algo-sdk

Crates.io docs.rs License

Write ultra-low-latency trading algos in Rust, compile to WASM, deploy to Sequence Markets. Zero dependencies. The SDK provides the Algo trait, order book types, and action buffers — everything you need to write a trading algorithm that runs on Sequence's edge infrastructure.

Quick Start

# Cargo.toml
[package]
name = "my-algo"
version = "0.1.0"
edition = "2021"

[lib]
crate-type = ["cdylib"]

[dependencies]
sequence-algo-sdk = { version = "0.1", default-features = false }
wee_alloc = "0.4"

[profile.release]
opt-level = "z"
lto = true
codegen-units = 1
panic = "abort"
// src/lib.rs
#![no_std]
extern crate alloc;
use algo_sdk::*;

struct MyAlgo {
    next_id: u64,
}

impl Algo for MyAlgo {
    fn on_book(&mut self, book: &L2Book, state: &AlgoState, actions: &mut Actions) {
        // Your trading logic here
        if book.spread_bps() > 10 && state.is_flat() {
            self.next_id += 1;
            actions.buy(self.next_id, 1_000_000, book.bids[0].px_1e9 + 100);
        }
    }

    fn on_fill(&mut self, _fill: &Fill, _state: &AlgoState) {}
    fn on_reject(&mut self, _reject: &Reject) {}
    fn on_shutdown(&mut self, _state: &AlgoState, actions: &mut Actions) {
        actions.clear(); // Cancel all pending orders
    }
}

export_algo!(MyAlgo { next_id: 0 });

#[panic_handler]
fn panic(_: &core::panic::PanicInfo) -> ! { loop {} }

#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;

Build & Deploy

Install the Sequence CLI and deploy:

sequence build
sequence deploy BTC-USD --start
sequence logs BTC-USD --follow

Or build manually:

cargo build --target wasm32-unknown-unknown --release

Key Types

Type Description
Algo Trait your algo implements — on_book, on_fill, on_reject, on_shutdown
L2Book 20-level order book (688 bytes, fits in L1 cache)
AlgoState Position + open orders, server-managed
Actions Buffer for placing/canceling orders (up to 16 per tick)
Fill Fill event with price, quantity, and timing
Reject Rejection with typed error codes

Fixed-Point Format

All prices and quantities use fixed-point integers for deterministic, allocation-free arithmetic:

  • Prices: px_1e9 — multiply by 10^9 (e.g., $50,000.00 = 50_000_000_000_000)
  • Quantities: qty_1e8 — multiply by 10^8 (e.g., 1.0 BTC = 100_000_000)

License

Licensed under either of Apache License, Version 2.0 or MIT License at your option.