Run a market scan
run_scannerRun an Interactive Brokers market scan and receive ranked instruments, best first, with optional filters for price, volume, and market cap.
Instructions
Run an IBKR market scan once and return the ranked instruments, best first.
Example: top % gainers among US listed stocks above $5 is scan_code=TOP_PERC_GAIN,
instrument=STK, location_code=STK.US.MAJOR, above_price=5. Find other scan codes,
locations and filter tags with get_scanner_parameters. Each row has the rank
(1 = top) and the contract (with con_id, for quotes or orders).
Limits: at most 50 rows. IBKR allows 10 scanner subscriptions at a time; a run
uses one for a moment and always releases it. Scans need market data permissions
for the exchanges scanned.
Errors: not_found when nothing matches right now (loosen the filters, or the
market may be closed); ib_api_error with IBKR's message for an unknown scan code,
location or filter; subscription_limit when 10 scanner subscriptions are open.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| rows | No | How many rows to return (1-50). | |
| filters | No | More filters as tag: value, with tags from get_scanner_parameters section="filters", e.g. {"avgVolumeAbove": 100000}. | |
| scan_code | Yes | What to rank by, e.g. TOP_PERC_GAIN or MOST_ACTIVE. | |
| instrument | No | Instrument type, e.g. STK (US stocks) or FUT.US. | STK |
| above_price | No | Only prices above this. | |
| below_price | No | Only prices below this. | |
| above_volume | No | Only volume above this. | |
| location_code | No | Market or exchange, e.g. STK.US.MAJOR or STK.NASDAQ. | STK.US.MAJOR |
| market_cap_above | No | Only market capitalization above this. | |
| market_cap_below | No | Only market capitalization below this. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| rows | Yes | ||
| as_of | Yes | When the rows arrived (UTC). | |
| scan_code | Yes | ||
| truncated | No | True when the result was cut to the limit. | |
| instrument | Yes | ||
| location_code | Yes |