AI-native CLI for the Longbridge trading platform with real-time market data, portfolio, and trading...
AI-native CLI for the Longbridge trading platform with real-time market data, portfolio, and trading...
English | 简体中文
AI-native CLI for the Longbridge trading platform — real-time market data, portfolio, and trading. Also ships a full-screen TUI for interactive monitoring.
Covers every Longbridge OpenAPI endpoint: real-time quotes, depth, K-lines, options, and warrants for market data; account balances, stock and fund positions for portfolio management; and order submission, modification, cancellation, and execution history for trading. Designed for scripting, AI-agent tool-calling, and daily trading workflows from the terminal.
…Homebrew (macOS / Linux)
brew install --cask longbridge/tap/longbridge-terminalWindows (Scoop)
scoop install https://github.com/longbridge/longbridge-terminal/raw/refs/heads/main/.scoop/longbridge.jsonWindows (PowerShell)
iwr https://github.com/longbridge/longbridge-terminal/raw/main/install.ps1 | iexInstall script (macOS / Linux)
curl -sSL https://github.com/longbridge/longbridge-terminal/raw/main/install | shInstalls the longbridge binary to /usr/local/bin (macOS/Linux) or %LOCALAPPDATA%\Programs\longbridge (Windows).
Uses OAuth 2.0 via the Longbridge SDK — no manual token management required.
longbridge auth login # Opens browser for OAuth and saves token (managed by SDK)
longbridge auth logout # Clear saved token
longbridge check # Verify token, region, and API endpoint connectivityToken is shared between CLI and TUI. After login, all commands work without re-authenticating.
The CLI picks its API access point from your location: it asks geotest.lbkrs.com which country you are in and caches the answer for 6 hours, so at most one command per session waits on the probe. China Mainland uses the .cn endpoints; everywhere else uses the global ones.
longbridge check # Re-detect the access point, and show both latencies
LONGBRIDGE_REGION=global ... # Pin the access point explicitly (cn or global)check never trusts the cache. It re-detects, measures both endpoints, and repins to whichever one is decisively better — location only approximates that, and a split-tunnel proxy can route the geo probe and the API over entirely different paths. The result is persisted, so later commands follow it too.
Enable tab-completion for longbridge commands and flags in your shell:
Bash — add to ~/.bashrc or ~/.bash_profile:
source ` will suggest subcommands, flags, and values.
## CLI Usage
longbridge [options]
All commands support `--format json` for machine-readable output. Commands that accept `--count` also accept `--limit` as an alias (for AI agent compatibility):
```bash
longbridge quote TSLA.US --format json
longbridge positions --format json | jq '.[] | {symbol, quantity}'longbridge check # Check token validity, and API connectivitylongbridge quote TSLA.US 700.HK # Real-time quotes for one or more symbols
longbridge depth TSLA.US # Level 2 order book depth (bid/ask ladder)
longbridge brokers 700.HK # Broker queue at each price level (HK market)
longbridge trades TSLA.US [--count 50] # Recent tick-by-tick trades
longbridge intraday TSLA.US # Intraday minute-by-minute price and volume lines for today
longbridge kline TSLA.US [--period day] # OHLCV candlestick (K-line) data [--adjust none|forward]
longbridge kline history TSLA.US --start 2024-01-01 # Historical OHLCV candlestick data within a date range
longbridge static TSLA.US # Static reference info for one or more symbols
longbridge calc-index TSLA.US --fields pe,pb,eps # Calculated financial indexes (PE, PB, EPS, turnover rate, etc.)
longbridge capital TSLA.US # Capital distribution snapshot (large/medium/small inflow and outflow)
longbridge capital TSLA.US --flow # Intraday capital flow time series (large/medium/small money in vs out)
longbridge market-temp [HK|US|CN|SG] # Market sentiment temperature index (0–100, higher = more bullish)
longbridge constituent .SPX.US [--sort market-cap] # Index constituent stocks (US indexes need a leading dot, e.g. .DJI.US, .SPX.US)
longbridge constituent IVV.US [--limit 0] # For a US ETF, full holdings from SEC N-PORT (--limit 0 = all); falls back to platform asset allocation when SEC data is unavailable (e.g. SPY)
longbridge trading session # Trading session schedule (open/close times) for all markets
longbridge trading days HK # Trading days and half-trading days for a market
longbridge security-list HK # Full list of securities available in a market
longbridge participants # Market maker (participant) broker IDs and names
longbridge subscriptions # Active real-time WebSocket subscriptions for this sessionlongbridge signals [--limit 20] # Strategy signals: headline, outlook, target prices, triggering catalyst
longbridge signals --symbol 700.HK # Filter by symbol, --strategy-id, --strategy, --catalyst, --catalyst-type, --start/--end, --offset
longbridge signal # One signal; --format json adds the full strategy analysis
longbridge facts AAPL.US [--limit 20] # Fact (catalyst) events behind signals; --begin/--end for a time windowlongbridge news TSLA.US [--count 20] # Latest news articles for a symbol
longbridge news detail # Full Markdown content of a news article
longbridge filing list AAPL.US [--count 20] # Regulatory filings and announcements for a symbol
longbridge filing detail AAPL.US # Full Markdown content of a filing; --file-index N for multi-file filings (e.g. 8-K exhibit)
longbridge topic list TSLA.US [--count 20] # Community discussion topics for a symbol
longbridge topic detail # Full details of a community topic (body, author, tickers, counts, URL)
longbridge topic replies [--page 1] # Paginated list of replies for a topic (--size 1–50)
longbridge topic mine [--type article] # Topics created by the authenticated user
longbridge topic create --body "…" # Publish a new community discussion topic (--title optional)
longbridge topic create-reply --body "…" # Post a reply to a topic (--reply-to for nested replies)longbridge option quote AAPL240119C190000 # Real-time quotes for option contracts
longbridge option chain AAPL.US # Option chain: list all expiry dates
longbridge option chain AAPL.US --date 2024-01-19 # Option chain: strike prices for a given expiry
longbridge option volume AAPL.US # Real-time option Call/Put volume and Put/Call ratio
longbridge option volume daily AAPL.US # Daily option Call/Put volume and open interest history
longbridge option volume daily AAPL.US --count 60 # Return last 60 trading days
longbridge warrant quote 12345.HK # Real-time quotes for warrant contracts
longbridge warrant 700.HK # Warrants linked to an underlying security
longbridge warrant issuers # Warrant issuer list (HK market)longbridge financial-report AAPL.US [--kind IS|BS|CF] # Multi-period financial statements (income / balance sheet / cash flow)
longbridge financial-report AAPL.US --latest # Latest financial report summary (--kind/--latest: AP accounts only)
longbridge financial-report snapshot AAPL.US --report qf --year N --period N # Earnings summary + forecast vs actual (revenue/EBIT/EPS beat/miss) + financial ratios
longbridge financial-statement AAPL.US [--kind IS|BS|CF|ALL] [--report af|saf|qf|cumul] # Detailed financial statement (v3 endpoint)
longbridge institution-rating AAPL.US # Analyst rating distribution and consensus target price
longbridge institution-rating AAPL.US --history # Rating and target price change history
longbridge institution-rating AAPL.US --industry-rank [--page 1] [--limit 20] # Industry-wide institution rating ranking
longbridge institution-rating AAPL.US --views # Monthly buy/hold/sell distribution timeline (institutional views)
longbridge institution-rating detail AAPL.US # Monthly rating trend and analyst accuracy history
longbridge dividend AAPL.US # Historical dividend records
longbridge dividend detail AAPL.US # Dividend allocation plan details
longbridge forecast-eps AAPL.US # Analyst EPS consensus forecast snapshots
longbridge consensus AAPL.US # Revenue / profit / EPS multi-period comparison with beat/miss markers
longbridge valuation AAPL.US [--indicator pe|pb|ps|dvd_yld] # Current valuation snapshot and peer comparison
longbridge valuation AAPL.US --history [--indicator pe] [--range 5] # Historical valuation time series (1 / 3 / 5 / 10 years) (AP accounts only)
longbridge valuation-rank AAPL.US [--start 20240101] [--end 20241231] # Industry valuation percentile ranking (default: last 30 days)
longbridge analyst-estimates AAPL.US # Analyst consensus EPS estimates
longbridge fund-holder AAPL.US [--count 20] # Funds and ETFs holding this stock
longbridge shareholder AAPL.US [--range all|inc|dec] [--sort chg] # Institutional shareholders with QoQ change tracking
longbridge shareholder AAPL.US --top # Top 20 major shareholders (includes individuals and insiders, multi-period)
longbridge shareholder AAPL.US --object-id # Holding and trade detail for a specific shareholder (use ID from --top output)
longbridge compare AAPL.US # Multi-stock valuation comparison vs server-selected industry peers
longbridge compare 9988.HK 700.HK 9999.HK [--currency HKD] # Compare specific stocks side by side (price, market cap, PE/PB/PS, ROE, ROA, div yield, and more)
longbridge corp-action 700.HK [--all] # Corporate actions (splits, dividends, rights, etc.) — default 30, --all for full history
longbridge business-segments AAPL.US [--history] [--report qf|saf|af] [--cate ] # Revenue segment breakdown (current snapshot or historical trends)
longbridge industry-rank --market US|HK|CN|SG [--indicator leading-gainer|...|net-profit-growth] # Industry ranking list; output symbols feed into industry-peers
longbridge industry-peers IN00446.US # Industry peer group hierarchy tree for an industry index symbol (from industry-rank)
longbridge macrodata [--country US] [--page 1] [--limit 20] # List macroeconomic indicators (20/page); names follow --lang
longbridge macrodata US00175 [--start 2024-01-01] [--end 2024-12-31] # Historical releases for one indicator (actual / forecast / previous)longbridge bank-cards # List linked bank cards
longbridge withdrawals [--page 1] [--limit 20] # Withdrawal history
longbridge deposits [--page 1] [--limit 20] [--states 0,1,2] [--currencies HKD,USD] # Deposit historylongbridge search TSLA [--tab market|newNo open issues yet, or sync has not completed.