ibkr-cli

Guides Interactive Brokers CLI setup, trading, market data, and account monitoring workflows.

1.5k|337|Updated Apr 15, 2026
One-click install
npx skills add https://github.com/qusong0627/QuantMind --skill ibkr-cli-qusong0627
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ibkr-cli
Source: https://github.com/qusong0627/QuantMind/tree/main/skills/ibkr-cli
Command: npx skills add https://github.com/qusong0627/QuantMind --skill ibkr-cli-qusong0627

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires ibkr-cli, and includes references (resource) components.

What problem does it solve? Operating Interactive Brokers from the command line requires installing IB Gateway or TWS, configuring API profiles, and knowing dozens of ibkr-cli commands. This Skill walks users through the entire journey — from first-time setup and connectivity checks to placing trades and pulling account reports — without assuming any prior brokerage API experience. ## Core Features & Use Cases - Guided Setup & Diagnostics: Step-by-step installation of IB Gateway/TWS and ibkr-cli, profile selection (gateway-live, live, gateway-paper, paper), and connection troubleshooting with ibkr doctor. - Safe Trading Workflow: Preview-then-submit order model supporting market, limit, stop, stop-limit, trailing, and bracket orders, plus order modification and cancellation. - Market Data & Research: Quotes, historical bars, news headlines and articles, options chains with greeks, market scanners, and Reuters fundamentals. - Account & Historical Reporting: Positions, account summary, P&L, trades, transfers, and dividends via Flex Queries. - Use Case: A user says "I want to buy 10 shares of AAPL." The Skill first verifies connectivity with ibkr doctor, then runs a preview order to show margin and commission impact, and only then guides the user to submit. ## Quick Start Ask the assistant to check your Interactive Brokers connection and show a preview of buying 10 shares of AAPL using ibkr-cli.

Frequently Asked Questions about ibkr-cli

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I buy stocks from the command line with Interactive Brokers?

Use ibkr-cli with a running IB Gateway or TWS instance. Run `ibkr buy AAPL 10 --preview --profile gateway-live` to see margin and commission impact first, then repeat with `--submit` to place the real order. The preview-then-submit flow prevents accidental trades.

How to set up IB Gateway for API trading with ibkr-cli?

Download IB Gateway from the Interactive Brokers website, log in, then install ibkr-cli via pipx or pip. Gateway enables the API by default on ports 4001 (live) and 4002 (paper). Verify connectivity with `ibkr doctor --profile gateway-live`.

What is the difference between IB Gateway and TWS for API access?

IB Gateway is a lightweight API-only application recommended for programmatic access, while TWS is the full trading platform with a graphical interface. TWS requires manually enabling socket clients in API settings; Gateway works out of the box.

Why does ibkr-cli show connection refused errors?

Connection refused usually means Gateway or TWS is not running, or the wrong profile port is selected (e.g., using port 4002 while TWS listens on 7497). Run `ibkr doctor` to diagnose TCP reachability and API handshake issues.

Can I get historical trades and P&L without IB Gateway running?

Yes, Flex Query commands like `ibkr trades`, `ibkr pnl`, `ibkr transfers`, and `ibkr dividends` work over HTTPS directly with IBKR's reporting service. They require a configured Flex Web Service token and query ID, and data is delayed by one business day.

Does ibkr-cli support options chains and greeks?

Yes, `ibkr options chain` lists expirations and strikes, and `ibkr options quotes` fetches quotes with full greeks including IV, delta, gamma, theta, and vega. You can filter by right, strike, and exchange.