tickerbot_scan
Filter the ticker universe with SQL WHERE clauses, scan historical snapshots, and aggregate stats like counts and medians by sector.
Instructions
Run a SQL WHERE clause against the live ticker universe (or against a past moment with asof — unlimited depth on every plan). Returns matching tickers sorted by chosen column, OR — with group_by — aggregate rollups instead of rows (breadth stats: "count of tickers above their 200dma by sector", "median RSI by sector on 2026-03-03"). The q grammar is a flat WHERE: column names from the schema, AND/OR/NOT, comparison operators, numeric/string literals. No JOIN or subqueries. Example: gap_up AND market_cap < 2000000000 AND NOT earnings_this_week.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| q | Yes | SQL WHERE expression. Max 4000 chars. | |
| dir | No | Sort direction. | |
| asof | No | Optional YYYY-MM-DD or ISO timestamp for a historical scan. Unlimited depth on every plan. | |
| full | No | Row mode: return the FULL wide row for each match (every column) instead of the slim default projection. | |
| limit | No | Page size. Max 100. Default 50. Aggregate mode does not paginate — response sets `truncated: true` when groups were cut. | |
| order | No | Sort column. Default day_change_pct (rows) / tickers (aggregate). | |
| cursor | No | Opaque cursor (row mode only). | |
| fields | No | Comma-separated extra columns to include (row mode only). | |
| having | No | Aggregate filter (requires group_by). Example: `COUNT(*) >= 10`. | |
| select | No | Aggregate output items (requires group_by). Default: group keys + COUNT(*) AS tickers. Aggregates: count/avg/sum/min/max/stddev/string_agg + FILTER (WHERE …). Alias items with AS. Example: `sector, COUNT(*) AS n, AVG(rsi_14) AS avg_rsi`. | |
| group_by | No | AGGREGATE MODE: 1–6 comma-separated group keys (columns or expressions, e.g. `sector`). Results become rollup rows instead of tickers. Alias a key with `AS` to name its JSON key; un-named expressions are named for you. | |
| universe | No | Optional universe slug. |