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

AI Agent Setup

Run this once to configure QFEX CLI for agent workflows:
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

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

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.

Subaccounts

If your account has subaccounts, qfex login will prompt you to choose which account should be active by default. The selected value is stored in ~/.config/qfex/config.yaml as selected_subaccount. Use these commands to inspect or change it later:
Selecting a different subaccount updates the config and restarts the daemon so authenticated trading and account requests use the new account context. You can also transfer money very easily, between subaccounts using the following command
This command accepts --from, --to, and --amount (in USD). You can set either --from or --to to "primary" to refer to your main account. The other account should be a UUID returned by qfex account subaccounts list.