Skip to content
Back to skills

Ibkr

ASecurity

Comprehensive Interactive Brokers (IBKR) TWS/Gateway skill using ib_insync. Includes Python and bash CLIs for account, market data, historical data, contract lookup, scanners, and order lifecycle management.

  • 14 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 7, 2026
businesspythonbashapidocumentation

Works with

  • cli
  • api

Security analysis

A96/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro scans all 10 files and shows the line behind each finding

Scanned September 7, 2026

npx -y skills add modbender/skill-library-mcp --skill ibkr --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Ibkr?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Ibkr
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/modbender-ibkr/badge)](https://www.skillsdirectory.com/skills/modbender-ibkr)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: ibkr
aliases:
  - openclaw
  - openclaw-ibkr
description: Comprehensive Interactive Brokers (IBKR) TWS/Gateway skill using ib_insync. Includes Python and bash CLIs for account, market data, historical data, contract lookup, scanners, and order lifecycle management.
---

# IBKR Skill

## Overview

This skill integrates with Interactive Brokers Trader Workstation (TWS) and IB Gateway through `ib_insync`, exposing operational IBKR workflows through:

- A unified Python CLI: `scripts/ibkr_cli.py`
- A bash CLI wrapper: `scripts/ibkr.sh`
- Compatibility alias: `scripts/openclaw.sh`
- Backward-compatible script entrypoints:
  - `scripts/get_account_info.py`
  - `scripts/get_historical_data.py`
  - `scripts/place_order.py`

## Prerequisites

- Interactive Brokers account with API permissions.
- TWS or IB Gateway running with API enabled.
- Python 3.9+ recommended.
- `ib_insync` installed:

```bash
pip install ib_insync
```

## Connection Configuration

All CLIs support connection overrides using flags or env vars.

Environment variables:

- `IBKR_HOST` (default `127.0.0.1`)
- `IBKR_PORT` (default `7497`)
- `IBKR_CLIENT_ID` (default `1`)
- `IBKR_ACCOUNT` (optional)

Examples:

```bash
IBKR_PORT=4002 IBKR_CLIENT_ID=14 ./scripts/ibkr.sh account-summary
python3 scripts/ibkr_cli.py positions --host 127.0.0.1 --port 7496 --account DU123456
```

## Bash CLI

`./scripts/ibkr.sh <command> [args]`

Supported commands:

- `account` (account summary + positions)
- `account-summary`
- `positions`
- `portfolio`
- `pnl`
- `quote`
- `historical`
- `place-order`
- `cancel-order`
- `open-orders`
- `executions`
- `contract-details`
- `scanner`

`./scripts/openclaw.sh` is an alias to the same CLI surface.

## Python CLI

`python3 scripts/ibkr_cli.py <command> [args]`

### Account Services

```bash
python3 scripts/ibkr_cli.py account-summary --json
python3 scripts/ibkr_cli.py positions --account DU123456
python3 scripts/ibkr_cli.py portfolio --json
python3 scripts/ibkr_cli.py pnl --account DU123456 --wait 2
```

### Market Data Services

```bash
python3 scripts/ibkr_cli.py quote --symbol AAPL --sec-type STK --market-data-type 3
python3 scripts/ibkr_cli.py historical --symbol EURUSD --sec-type CASH --duration "30 D" --bar-size "1 hour"
```

Notes:

- Historical requests support full IB-format values via flags, including spaced tokens like `"30 D"`.
- For `CASH`, default `whatToShow` is `MIDPOINT` unless explicitly overridden.

### Contract Discovery

```bash
python3 scripts/ibkr_cli.py contract-details --symbol ES --sec-type FUT --expiry 202606
```

### Trading and Order Lifecycle

```bash
python3 scripts/ibkr_cli.py place-order --symbol AAPL --sec-type STK --action BUY --quantity 10 --order-type MKT
python3 scripts/ibkr_cli.py place-order --symbol AAPL --sec-type STK --action SELL --quantity 10 --order-type LMT --limit-price 250 --tif GTC
python3 scripts/ibkr_cli.py open-orders
python3 scripts/ibkr_cli.py cancel-order --order-id 12345
python3 scripts/ibkr_cli.py executions --json
```

Supported order types in the CLI:

- `MKT`
- `LMT`
- `STP`
- `STP LMT`

`place-order` waits for status updates and surfaces API errors collected during placement.

### Scanner Service

```bash
python3 scripts/ibkr_cli.py scanner --instrument STK --location-code STK.US.MAJOR --scan-code TOP_PERC_GAIN --rows 25
```

## Compatibility Scripts

Legacy scripts remain supported and now delegate to the unified CLI:

- `get_account_info.py`
- `get_historical_data.py` (legacy positional mode still works)
- `place_order.py` (legacy positional mode still works)

## Error Handling

The CLI returns non-zero exit codes for:

- Import/dependency failures
- Connection failures
- Contract qualification failures
- Invalid arguments
- Missing open order for cancellation

## References

See `references/api_reference.md` for IBKR and ib_insync documentation links.

Files in this skill

  • README.md46 B
  • SKILL.md3.9 KB
  • references/api_reference.md2.8 KB
  • scripts/get_account_info.py1.5 KB
  • scripts/get_historical_data.py4.6 KB
  • scripts/ibkr.sh1.5 KB
  • scripts/ibkr_cli.py23.8 KB
  • scripts/openclaw.sh135 B
  • scripts/place_order.py4.5 KB
  • tests/cli_smoke.sh601 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…