Skip to main content
The QFEX CLI provides JSON-only command-line access to QFEX for both human operators and AI agents. It is designed for agentic trading workflows where you want a stateless command interface, while a background daemon manages the underlying WebSocket connections to QFEX.

Installation

brew install QFEX-org/tap/qfex

AI Agent Setup

Run this once to configure QFEX CLI for agent workflows:
# Global setup for Claude Code and Codex
qfex agents init

# Project-local setup for the current directory
qfex agents init --local
qfex agents init updates Claude Code and Codex so qfex can be used without repeated permission prompts. The global setup writes to ~/.claude/ and ~/.codex/. The --local mode writes CLAUDE.md and AGENTS.md into the current project, which is useful when you want project-specific agent instructions.

Quick Start

# Start the background daemon
qfex daemon start

# Query market data (no credentials required)
qfex market bbo AAPL-USD

# Log in to trade or access account data
qfex login
qfex daemon restart

# Place an order
qfex order place --symbol AAPL-USD --side BUY --type LIMIT --tif GTC --qty 1 --price 200

# Stop the daemon when finished
qfex daemon stop

Why Use The CLI

  • Built for both humans and AI agents.
  • All command output is JSON, which makes it easy to pipe into jq or parse in code.
  • The daemon keeps persistent connections to market data and trade WebSockets, so your scripts do not need to manage subscriptions, authentication, or socket lifecycle directly.
  • Market data commands work without credentials.
  • Trading commands use the same API keys described in the API introduction.

Agentic Trading Workflow

For an automated or agentic trading setup, the normal flow is:
  1. Run qfex agents init once so your agent can call qfex cleanly.
  2. Start the daemon with qfex daemon start.
  3. Use market data commands immediately, or generate API keys and run qfex login for trading.
  4. Run qfex daemon restart after login so credentials are applied.
  5. Confirm readiness with qfex daemon status.
  6. Issue market data, order, position, and account commands as needed.
The daemon must be running before most CLI commands will work.

Common Commands

# Market data
qfex market bbo AAPL-USD
qfex market orderbook AAPL-USD --depth 5
qfex market trades AAPL-USD --limit 50

# Orders
qfex order place --symbol AAPL-USD --side BUY --type MARKET --tif IOC --qty 1
qfex order list
qfex order cancel --symbol AAPL-USD --order-id <order-id>

# Positions and account state
qfex position list
qfex account balance
qfex account leverage get

# Live streams
qfex watch bbo AAPL-USD
qfex watch orders
qfex watch fills

Environments

The CLI supports both QFEX production and UAT environments:
  • prod: Connects to qfex.com with real funds.
  • uat: Connects to qfex.io for testing strategies and integrations without real funds.
You can select the environment during qfex login or by editing ~/.config/qfex/config.yaml, then restarting the daemon.