Stream a market scan
subscribe_scannerSubscribe to a market scanner that continuously updates rankings and returns a handle for reading current rows, checking errors, or canceling the scan.
Instructions
Keep a market scan running so its ranking follows the market; returns a handle.
Takes the same arguments as run_scanner. Read the current rows with
get_subscription_data(subscription_id): rows (best first), updated_at, no_matches
(nothing qualifies right now) and error. Stop it with unsubscribe; it is also
cancelled after the idle time in idle_ttl_s without a read. The same scan asked
for twice returns the existing handle (deduplicated=true).
Limits: at most 50 rows; IBKR allows 10 scanner subscriptions at a time.
Errors: ib_api_error when IBKR rejects the scan (check the codes with
get_scanner_parameters); subscription_limit when no slot is free.
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 |
|---|---|---|---|
| key | Yes | What it streams for: the contract id plus parameters. | |
| kind | Yes | What streams: quotes, depth, tick_by_tick, realtime_bars, bars, scanner, news_bulletins, news or display_group. | |
| contract | No | The instrument, when there is one. | |
| created_at | Yes | ||
| idle_ttl_s | Yes | Seconds without a read before it is cancelled. | |
| deduplicated | No | True when an identical stream was already open and its handle was returned instead of opening a second one. | |
| subscription_id | Yes | Handle for get_subscription_data and unsubscribe. |