londrwus GitHub avatar

hyperliquid-python-ml-to-rust-layer

londrwus

A Python-to-Rust trading framework that lets you keep your ML stack in Python while a Rust core executes orders with predictable timing, risk checks, and bit-identical feature verification.

Stars

4

7-day growth

No data

Forks

0

Open issues

0

License

MIT

Last updated

2026-07-28

AI repository intelligence
FR-AI / ANALYSIS

Why it is worth attention

It challenges the assumption that speed requires rewriting models in Rust, instead proving that Rust's value is in deterministic execution and no stalls, with a 70-ns lock-free handoff and over 1,800 tests.

Who it is for

  • Python ML researchers and quants who want low-latency execution without leaving Python
  • Crypto traders seeking a reliable, tested framework for algorithmic trading
  • Developers interested in high-assurance Python-Rust interop for latency-sensitive systems
  • Educators and students studying trading system architecture

Use cases

  • Running ML-based strategies (XGBoost, PyTorch) on Hyperliquid testnet
  • Backtesting strategies with the same engine that goes live, ensuring bit-identical feature computation
  • Deploying risk-controlled trading with automatic kill switch and position limits
  • Learning about deterministic, no-stall execution in trading systems

Strengths

  • 70-ns lock-free shared memory handoff between Python and Rust
  • Bit-identical feature verification ensures strategy behaves same in research and production
  • Predictable execution with no garbage collection pauses; worst-case close to average
  • Comprehensive test suite with 1,885 tests (1,196 Rust + 689 Python) and venue-agnostic design

Considerations

  • Only tested on testnet with small ML models; not yet proven with real money
  • Currently supports only Hyperliquid exchange (though Binance adapter exists in tree)
  • Requires careful setup and understanding of the architecture; not plug-and-play for all users

README quick start

Hyperliquid: Python ML → Rust Layer

Write your trading strategy in Python. Let Rust execute it.

You keep pandas, scikit-learn, XGBoost and PyTorch. You never rewrite a model in Rust. A Rust core takes your strategy's decisions and turns them into live orders — quickly, predictably, and identically every time.

Codename Axon: the wire that carries a signal from the Python brain to the Rust muscle.


The idea in one picture

flowchart LR
    subgraph PY ["🐍 PYTHON — the brain"]
        direction TB
        A["Market dataarrives"] --> B["Computefeatures"]
        B --> C["Run themodel"]
        C --> D["Decide:hold 0.5 BTC"]
    end

    subgraph RS ["🦀 RUST — the muscle"]
        direction TB
        E["Read thedecision"] --> F["Check therisk limits"]
        F --> G["Build theorder"]
        G --> H["Send it tothe exchange"]
    end

    V(("🏦Hyperliquid"))

    D -.->|"shared memory70 nanoseconds"| E
    H -->|"0.2 – 0.9 seconds"| V

    style PY fill:#e8f0fe,stroke:#4285f4,stroke-width:2px,color:#111
    style RS fill:#fdecea,stroke:#e8710a,stroke-width:2px,color:#111
    style V fill:#e6f4ea,stroke:#34a853,stroke-width:2px,color:#111

Python says what it wants. Rust works out how to get it, and deals with the exchange saying no. Nothing is shared between them that either side can corrupt — decisions cross as fixed-size records in a lock-free queue, one writer, one reader.


Where the time actually goes

This is the part almost everyone gets wrong. Measured on real hardware, not quoted from a blog:

 Python → Rust handoff        70 ns   ▏
 Rust core wake-up cycle     366 µs   ▎
 Exchange round-trip     0.2 – 0.9 s  ████████████████████████████████████████
                                      └─ the exchange is >99.8% of the wait

Put it on a human scale. Suppose the Python→Rust handoff took 1 second:

Then this step……would take
🐍→🦀 Handing the decision to Rust1 second
⏱️ Rust noticing there is work to do1.5 hours
🏦 The exchange confirming your order1 to 5 months

The language boundary is not the bottleneck. It was never going to be. Making it ten times faster would change nothing you could measure.

So why use Rust at all?


Because the point isn't speed. It's never stalling.

An exchange order book is **first-come, firs

Description

Write your trading strategy in Python. Let Rust execute it. A venue-agnostic ML execution layer — Hyperliquid is the first adapter.

Related repositories

Similar projects matched by category, topics, and programming language.

MoonshotAI
Featured
MoonshotAI GitHub avatar

Kimi-K3

Kimi K3 is an open-weight, 2.8T-parameter native multimodal agentic model with a 1M-token context window, designed for frontier coding, knowledge work, and reasoning tasks.

AI & Machine LearningAI Agents
3,348
lopopolo
Featured
lopopolo GitHub avatar

harness-engineering

Harness Engineering is a methodology for improving coding agent outputs by carefully crafting the environment around them—providing curated context, tools, and executable constraints that encode an organization’s nonfunctional requirements and cumulative lessons.

AI & Machine LearningAI Agents
2,390
slvDev
Featured
slvDev GitHub avatar

esp32-ai

A 28.9 million parameter language model runs on an $8 ESP32-S3 microcontroller entirely on-device, generating simple stories at about 9.5 tokens per second.

AI & Machine LearningLarge Language Models
1,960