关于 futu-trading
futu-trading 是一项指导 Agent 使用本地官方 futu CLI 执行证券账户与交易操作的技能,涵盖登录检查、参数选择和操作确认。它强调先检查运行环境,并要求对涉及真实资产的操作取得明确确认。
主要功能
- 01检查 CLI 是否安装及登录状态
- 02查询账户、订单与成交信息
- 03处理分页及参数选择
- 04交易操作前要求明确确认
- 05指导安装与更新 CLI
适用场景
- 01检查账户是否已登录
- 02查询证券订单与成交记录
- 03准备买卖或修改订单命令
- 04按用户确认执行交易操作
安装
复制下面的命令,在终端中运行。
npx skills add https:/ / github.com/ futunnopen/ futu-agent-hub --skill futu-trading安装后在 Claude Code 中输入/futu-trading确认已加载。
附带文件references/cli-parameters.mdreferences/dictionaries.md
README 原文English
来自项目 READMEREADME 暂无中文译文,以下为英文原文;中文介绍见上方。
Futu Trading
Use the locally available futu CLI for securities trading. Answer in the user's language by default. Keep commands, flags, JSON fields, error codes, and symbols in their original form.
Futu CLI runtime
This skill requires the official futu CLI. macOS and Linux install it to $HOME/.futu/bin/futu. Windows installs futu.exe to %LOCALAPPDATA%\FutuCLI\bin. See the futu-cli install guide.
Probe futu before any business command.
macOS / Linux:
if command -v futu >/dev/null 2>&1; then futu auth status --format json; elif [ -x "$HOME/.futu/bin/futu" ]; then "$HOME/.futu/bin/futu" auth status --format json; else echo '__FUTU_CLI_MISSING__'; fi
Windows, including Git Bash: do not use that bash block or install.sh. install.sh rejects Windows. Use this PowerShell call instead:
$exe = Join-Path $env:LOCALAPPDATA 'FutuCLI\bin\futu.exe'
if (Get-Command futu -ErrorAction SilentlyContinue) { futu auth status --format json } elseif (Test-Path $exe) { & $exe auth status --format json } else { Write-Output '__FUTU_CLI_MISSING__' }
__FUTU_CLI_MISSING__ means stop. Do not run an account or trading command yet. Ask the user before installing. After they agree:
macOS / Linux:
curl -fsSL https://raw.githubusercontent.com/FutunnOpen/futu-cli/main/scripts/install.sh | sh
Windows PowerShell. The official Windows installer supports amd64:
iwr -UseBasicParsing https://raw.githubusercontent.com/FutunnOpen/futu-cli/main/scripts/install.ps1 -OutFile install.ps1
powershell -ExecutionPolicy Bypass -File .\install.ps1
If the Windows installer reports an unsupported architecture, stop and relay that message. Never run either installer without explicit consent. Then run futu version. If the current shell still cannot see futu, call $HOME/.futu/bin/futu or %LOCALAPPDATA%\FutuCLI\bin\futu.exe directly.
To update an already installed futu CLI, use futu update --check and, after the user agrees, futu update.
Usage rules
- Follow Futu CLI runtime before any account or trading command. If the probe prints
__FUTU_CLI_MISSING__, stop untilfutuis installed. - When the probe succeeds, its business output is
futu auth status --format json. If that returnsnot logged in, tell the user to runfutu auth loginand continue only after login. Do not run the business command directly. - Invocation convention for this skill: when calling the
futuCLI from Bash, always append the hidden internal marker--source skillat the end of the command. With--source skill, the CLI automatically detects hosts such as Codex or Claude Code and reportsagent_name. Append--agent codexor--agent claude_codeonly when auto-detection fails and the CLI is confirmed to support it. Do not include these internal markers in commands shown to the user. - Do not read or print token file contents. The CLI attaches the OAuth Bearer token automatically.
PERMISSION_DENIEDis a server-side permission denial. Do not explain it as a missing token. - Use the smallest parameter set when generating commands. If the CLI already has a default and the user did not specify a value, do not pass that flag explicitly.
- Do not assume a default account is configured. Omit
--accountonly when this turn has already confirmed a default account throughfutu auth statusor config. Otherwise, list accounts or ask the user to choose one, and pass--accountexplicitly. - Add
--format jsonwhen the output must be parsed, when extracting account, order, or fill fields, or when a follow-up action depends on the result. Commands meant only for the user to copy and run can use the default table output. - Securities order and fill lists are paginated and merged by the CLI. Do not pass
page_flagmanually. Adjust--page-sizeonly when needed. account cash-logsreturns one page per call. Use--format json, readpage_flagandcompleted, and call again with--page-flaguntilcompletedis true or the user has enough rows.order feesneeds a concreteorder_id(fromorder list,order history, ororder detail). Open API does not support FX order fees yet.margin-ratiorequires--security-firmand--codes(up to 10 symbols). Prefersecurity_firmfromaccount list --format jsonfor the user's account.- Commands that change real assets require explicit user confirmation, including
order buy,order sell,order place,order modify, andorder cancel. - Do not guess a second confirmation on behalf of the CLI or the server. If the CLI reports broker confirmation because the API returned
need_order_confirm=trueorconfirm_id, relay it as-is and wait for explicit user consent before enteringy.
References
- When building a specific command, checking required, default, or optional parameters, handling pagination, or mapping fields, read CLI parameters.
- When choosing or explaining markets, trade sides, order types, statuses, account-market dictionaries, and response fields, read dictionaries.
- For crypto trading, use
futu-crypto.