AI agents and API

The ftw-trade CLI

ftw.trade from the command line, for people and agents. Sign up with a wallet key, write and backtest Flowscript locally, run strategies, push sources and scripts, and read the log and portfolio. Every command takes --json.

Terminal
npx ftw-trade login     # a new wallet key and a new account, signed in
npx ftw-trade whoami

It needs Node 20 or newer. npm i -g ftw-trade installs it as ftw-trade and ftw.

Coming soon

The CLI goes up on npm closer to launch, so npx ftw-trade doesn't work yet. Until then, connect your AI by hand or call the MCP server directly.

Sign in#

Terminal
ftw-trade login                         # no key yet: make one and sign up with it (a paper-only token)
ftw-trade login --key-file ~/me.json    # sign in with a key you have
ftw-trade login --live                  # a token that may trade live
ftw-trade login --token fwb_…           # or use a key from the AI & API page
ftw-trade logout

The wallet key is the account: it signs you in (Sign-In with Ethereum) and approves payments and withdrawals. It never leaves your machine; only signatures go to ftw.trade, after the CLI has checked what it's signing. Profiles (--profile) keep more than one account.

Connect your AI#

Terminal
ftw-trade connect claude-code   # installs the skills and runs `claude mcp add`
ftw-trade connect codex
ftw-trade connect claude        # prints the address to paste, and where
ftw-trade connect chatgpt
ftw-trade skills install --for all

Everyday commands#

Terminal
ftw-trade projects list
ftw-trade projects create --name Desk --template desk
ftw-trade projects balances <id>

ftw-trade strategies series                       # what can be backtested
ftw-trade strategies save ema.flow
ftw-trade strategies backtest ema.flow --series feed:btc-usd-chainlink --interval 1h
ftw-trade strategies run ema --series feed:btc-usd-chainlink --interval 1h
ftw-trade strategies running
ftw-trade strategies stop <deployment>

ftw-trade sources save tick.json --project p_1 --deploy
ftw-trade sources events tick --follow --json
ftw-trade push src/*.ts --project p_1 --deploy    # TypeScript scripts, sources and actions

ftw-trade log --errors
ftw-trade portfolio
ftw-trade fund                                    # the deposit address and the main wallet's ETH
ftw-trade fund --paper 1                          # play ETH

ftw-trade tools                                   # every MCP tool
ftw-trade mcp get_pool '{"pool":"base:0x…"}'      # call any of them

On your own machine#

The package ships the Flowscript compiler as WebAssembly, ftw.trade's host (every read and protocol library) and the server's paper books, so a local backtest makes the trades the server's would.

Terminal
ftw-trade local check ema.flow
ftw-trade local test ema.json
ftw-trade local backtest ema.flow --interval 1h --csv btc-1h.csv
ftw-trade local backtest ema.flow --series feed:btc-usd-chainlink --interval 1h --save-bundle run.json
ftw-trade local backtest --bundle run.json        # replay offline, again and again
ftw-trade local run ema.flow --series feed:btc-usd-chainlink --interval 1h
ftw-trade fmt *.flow --write

For agents#

  • --json prints exactly one JSON object (--follow, one per line). A failure prints {"error":{"message","status","field"}} on stderr.
  • Exit codes: 0 done, 1 refused or failed, 2 used wrong.
  • Nothing prompts. A step that moves funds (withdraw, pay, send) shows what it would do and sends nothing without --yes.
  • Environment: FTW_TOKEN, FTW_URL, FTW_PROFILE, FTW_KEY_FILE, FTW_HOME.
  • Hand a sub-agent a narrower key, never the wallet key: ftw-trade keys create scout --access paper --expires 1d --save-as scout.