npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@aihubspot/agent-trade-cli

v0.1.20

Published

Local spot trading command-line tools for AI Hub

Readme

AI Hub Agent Trade CLI

The package installs two commands:

  • ai-hub provides exact structured commands for every supported capability.
  • aihub <request> provides a deterministic fast path for common balance, price, and open-order reads. It renders Core results directly. Ambiguous requests fall back to an isolated Codex gpt-5.6-luna/low Agent that loads only the globally installed ai-hub-trade-mcp; use --no-agent to disable fallback.

Examples:

aihub show asset balances
aihub show USDT balance
aihub show BTCUSDT price
aihub show open orders

Install globally with npm install -g @aihubspot/agent-trade-cli, then run ai-hub --help.

The complex-request fallback requires both global packages: npm install -g @aihubspot/agent-trade-cli @aihubspot/agent-trade-mcp. Common deterministic reads do not start Codex or MCP.

Create a local profile and enter credentials interactively:

ai-hub config init
ai-hub config set --profile default --openapi-base-url https://your-openapi-domain
ai-hub config set-credentials --profile default

The API key and secret key are stored as plaintext in ~/.ai-hub/config.toml. The configuration directory and file use mode 700 and 600 respectively. ai-hub config show never prints the key values. State-changing operations require a preview followed by a separate confirmation command.

Use ai-hub config path to print the local configuration file path. Use ai-hub capabilities to inspect this installed CLI version's supported tool names, CLI command paths, read/write classification, and OpenAPI contracts. Both commands are local-only: they do not call OpenAPI or read credential values.

If the profile was created by an earlier Keychain-based build, run ai-hub config set-credentials --profile <name> once after upgrading. Credentials are not migrated automatically.

Spot order units

Order commands use explicit asset units. Do not use the legacy volume field.

# Spend exactly 100 USDT to market-buy ETH.
ai-hub spot order market-buy --symbol ETHUSDT --quote-amount 100

# Market-sell exactly 0.5 ETH.
ai-hub spot order market-sell --symbol ETHUSDT --base-quantity 0.5
ai-hub spot order sell-available --symbol ETHUSDT

# Buy exactly 1 ETH at a limit price of 1800 USDT.
ai-hub spot order limit --symbol ETHUSDT --side BUY --base-quantity 1 --price 1800

# Directly select one supported limit-style OpenAPI type.
ai-hub spot order limit --symbol ETHUSDT --side BUY --type POST_ONLY --base-quantity 1 --price 1800

# Conditional orders require an explicit trigger price.
ai-hub spot order stop-limit --symbol ETHUSDT --side SELL --base-quantity 1 --trigger-price 1700 --price 1690
ai-hub spot order stop-market-buy --symbol ETHUSDT --quote-amount 100 --trigger-price 2000

Market BUY cannot guarantee an exact base-asset quantity. If the desired quantity is "1 ETH", use a limit order or first choose an explicit USDT amount to spend.

Use ai-hub account asset-balance --asset ETH for one asset. Use ai-hub account balances when the user requests account balances without naming an asset; it returns only compact balance rows and defaults to non-zero assets. Use ai-hub spot order sell-available --symbol ETHUSDT when the user explicitly wants the maximum executable ETH balance sold: its preview floors only to the configured quantity precision and displays both the remainder and the amount that would be sold.

The same unit rules apply to spot-margin orders: use margin order market-buy --quote-amount, margin order market-sell --base-quantity, margin order limit --type IOC|FOK|POST_ONLY --base-quantity --price, or the matching margin order stop-limit|stop-market-buy|stop-market-sell command. Margin commands support isolated and cross spot margin only; they do not support perpetuals, other non-spot products, or an explicit leverage multiplier such as 10x. Every margin write requires --isolated true for isolated margin or --isolated false for cross margin. The CLI rejects an omitted mode instead of inferring it.

For this OpenAPI, LIMIT, IOC, FOK, and POST_ONLY are direct type values. Do not supply --time-in-force: it is not a server parameter and is rejected by the CLI.

The CLI does not provide spot order place --volume. It deliberately exposes market-buy, market-sell, and limit as separate commands so the asset unit cannot be ambiguous. Batch placement accepts a JSON array with the same semantic fields: quoteAmount for a market BUY and baseQuantity for a market SELL or limit order.

Write confirmation flow

Every state-changing command creates a local five-minute preview and exits; --prepare is accepted as an explicit alias. After showing the preview, stop and wait for a new user message. Then execute the returned confirmation ID in a separate command:

ai-hub spot order market-sell --symbol ETHUSDT --base-quantity 0.5 --prepare
ai-hub confirm --confirmation-id <confirmation-id> --user-confirmation "yes"

The pending preview is stored under ~/.ai-hub/pending-actions/ with owner-only permissions. It contains no credentials, is bound to the original profile and credential version, expires after five minutes, and is atomically consumed before execution. Do not run confirm in the same user instruction that generated the preview.

Before an order preview is created, the CLI lazily loads /sapi/v2/symbols once per local profile and keeps the rule snapshot for one hour in memory and an isolated local cache. It rejects known quantity/price precision and limit-order minimum violations before asking for confirmation.

Bounded market analysis

For a generic trading-pair list, use ai-hub market symbols-overview; it returns only counts and a small sample. Use symbols-list --quote-asset USDT --offset 0 --limit 20 for paged browsing, symbols-search --query BTC for a keyword search, and symbol-info --symbol BTCUSDT only when precision or minimum order rules are needed. These commands return Agent-friendly bounded results instead of complete market payloads. Raw trades and raw klines are capped at 50 rows. Kline intervals are 1min, 5min, 15min, 30min, 60min, 1day, 1week, and 1month (60min, not 1h).