> ## Documentation Index
> Fetch the complete documentation index at: https://docs.qfex.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Agentic Trading

> Use AI agents to research markets, manage positions, and trade on QFEX.

# Agentic Trading

QFEX can be traded directly by AI agents. Agents can read live market data, inspect account state and positions, and place or manage orders using the [QFEX CLI](/api-reference/cli).

The CLI is designed to work cleanly inside agent workflows: every command returns JSON, commands are stateless from the caller's perspective, and a background daemon manages the underlying QFEX WebSocket connections. This lets an agent interact with the exchange through simple shell commands rather than implementing exchange connectivity itself.

## Getting started

Install the CLI:

```sh theme={null}
brew install QFEX-org/tap/qfex
```

Then configure it for your agent:

```sh theme={null}
# Global setup for Claude Code and Codex
qfex agents init

# Or add agent instructions to the current project only
qfex agents init --local
```

`qfex agents init` configures Claude Code and Codex so they can use the QFEX CLI without repeatedly prompting for permission. The local mode writes agent instructions into the current project.

Market data can be queried without credentials. To allow an agent to trade or access private account data, log in first:

```sh theme={null}
qfex login
```

For the full installation guide, command reference, environments, authentication and subaccount controls, see the [QFEX CLI documentation](/api-reference/cli).

## What an agent can do

An agent using the CLI can, among other things:

* query BBOs, order books, trades, candles, mark prices, funding rates and open interest;
* place, modify and cancel orders;
* inspect open orders, positions, balances and leverage;
* watch live market-data, order and fill streams; and
* work with QFEX subaccounts to separate trading strategies or risk.

For example:

```sh theme={null}
qfex market bbo AAPL-USD
qfex market orderbook AAPL-USD --depth 5
qfex position list
qfex account balance
qfex order place --symbol AAPL-USD --side BUY --type MARKET --tif IOC --qty 1
```

## Developing and testing agents

QFEX provides both production and UAT environments. UAT uses the same interface as production but does not use real funds, making it the appropriate environment for testing agent behaviour and order flow before deploying a strategy to production.

<Warning>
  Production trading uses real funds. An agent with authenticated trading access can place and cancel orders on your behalf. Test agent behaviour carefully in UAT before granting it production access.
</Warning>

## Building agentic trading products

Developers can also build trading agents or applications for other QFEX users. [Builder Codes](/qfex/builder-code) are designed to attribute trading activity to an integration and allow the builder to earn a share of the trading fees generated through that application.

<Info>
  Builder Codes are not yet released. See the [Builder Codes page](/qfex/builder-code) for the current design and availability status.
</Info>

Builder Codes are separate from the referral program: referral codes attribute a user at signup, while Builder Codes attribute trading activity generated through an integration.

For developers who need lower-level control, the QFEX API Reference also documents the REST and WebSocket interfaces used underneath the CLI.
