Files
zeekayandHanzo Dev e41949ffc0 the corporate name is Lux Industries Inc
Lux Partners Limited is not the entity behind this work. Every place the
old name stood — copyright lines, site footers, brand config, legal and
compliance text — now names the company that actually holds it.

lux.fund is the exception and is not renamed to match: that site belongs
to Lux Assets Management LLC, a different company, and it says so.

Two kinds of line were left for a person rather than rewritten. A dated
news item recording that Lux Partners Limited was established in the Isle
of Man is a historical fact, and renaming it would falsify the record. And
a sentence asserting that the company is domiciled in the Isle of Man is a
claim about a jurisdiction, not a name — an Inc or an LLC is not an Isle
of Man company, so swapping the name there would assert something untrue.

Co-authored-by: Hanzo Dev <[email protected]>
2026-08-28 12:48:08 -07:00
..

LX C CLI Trading Client

Ultra-fast command-line trading client for LX, designed for HFT traders and embedded systems.

Features

  • Direct WebSocket connection to LX API
  • Sub-millisecond latency (limited only by network)
  • Interactive REPL mode for manual trading
  • Single-command mode for scripting/automation
  • Minimal dependencies (libwebsockets only)
  • Zero heap allocations in hot path
  • POSIX-compliant, runs on Linux/macOS/BSD

Build

Dependencies

macOS:

brew install libwebsockets

Ubuntu/Debian:

apt install libwebsockets-dev

Fedora/RHEL:

dnf install libwebsockets-devel

Compile

make          # Optimized build
make debug    # Debug build with symbols
make static   # Static binary for portability

Usage

Interactive Mode

./build/lx-cli -i

Starts a REPL where you can enter commands interactively:

LX CLI v1.0.0 - Type 'help' for commands
> auth mykey mysecret
Authenticated successfully
> place_order BTC-USD buy limit 50000 0.1
Order placed: ID=12345 BTC-USD 0.1000 @ 50000.00 [open]
> get_orders
{"type":"orders","data":[...]}
> quit
Goodbye

Single Command Mode

Execute a single command and exit:

# Place an order
./build/lx-cli -k KEY -s SECRET place_order BTC-USD buy limit 50000 0.1

# Cancel an order
./build/lx-cli -k KEY -s SECRET cancel_order 12345

# Get open orders
./build/lx-cli -k KEY -s SECRET get_orders

# Get positions
./build/lx-cli -k KEY -s SECRET get_positions

# Get balances
./build/lx-cli -k KEY -s SECRET get_balances

# Measure latency
./build/lx-cli ping

Options

Option Description
-u, --url URL WebSocket URL (default: ws://localhost:8081)
-k, --key KEY API key for authentication
-s, --secret SECRET API secret for authentication
-i, --interactive Run in interactive REPL mode
-v, --verbose Enable verbose output (show raw messages)
-t, --timeout MS Request timeout in milliseconds (default: 5000)
-h, --help Show help message
-V, --version Show version

Commands

Trading

place_order <symbol> <side> <type> <price> <size>

Place a new order.

place_order BTC-USD buy limit 50000 0.1
place_order ETH-USD sell market 0 1.5
place_order BTC-USD buy stop 48000 0.5
  • symbol: Trading pair (e.g., BTC-USD, ETH-USD)
  • side: buy or sell
  • type: limit, market, or stop
  • price: Order price (use 0 for market orders)
  • size: Order size

cancel_order <order_id>

Cancel an existing order.

cancel_order 12345

get_orders

List all open orders.

Portfolio

get_positions

Show all positions.

get_balances

Show account balances.

Market Data

subscribe <symbol>

Subscribe to orderbook updates for a symbol.

subscribe BTC-USD

Connection

auth <api_key> <api_secret>

Authenticate with credentials (can also use -k and -s flags).

ping

Test connection and measure latency.

status

Show connection status.

Scripting Examples

Bash Script

#!/bin/bash
LX="./build/lx-cli -k $API_KEY -s $API_SECRET"

# Place multiple orders
$LX place_order BTC-USD buy limit 49000 0.1
$LX place_order BTC-USD buy limit 48000 0.1
$LX place_order BTC-USD buy limit 47000 0.1

# Check orders
$LX get_orders

Environment Variables

export LX_URL="wss://api.lx.exchange/ws"
export LX_KEY="your-api-key"
export LX_SECRET="your-api-secret"

./build/lx-cli -u "$LX_URL" -k "$LX_KEY" -s "$LX_SECRET" get_orders

Performance

The C client is optimized for minimal latency:

  • No JSON library overhead (inline parsing)
  • Lock-free message queuing
  • Zero-copy receive path
  • Direct WebSocket frames
  • Minimal system calls

Typical round-trip latency: < 1ms (on localhost)

Comparison

Client Language Binary Size Startup Time Latency
lx-cli C ~50KB < 5ms < 1ms
lx-cli-go Go ~8MB ~50ms ~1ms
lx-cli-ts TypeScript N/A (Node) ~500ms ~5ms

Building for Embedded Systems

For embedded Linux systems, use static linking:

make static

Cross-compilation:

CC=arm-linux-gnueabihf-gcc make

Protocol

The client communicates with LX using WebSocket JSON messages.

Request Format

{
  "type": "place_order",
  "order": {
    "symbol": "BTC-USD",
    "side": "buy",
    "type": "limit",
    "price": 50000,
    "size": 0.1
  },
  "request_id": "req_1"
}

Response Format

{
  "type": "order_update",
  "data": {
    "orderId": 12345,
    "symbol": "BTC-USD",
    "status": "open"
  },
  "request_id": "req_1"
}

License

Copyright (c) 2025 Lux Industries Inc

See Also