load_* tools fetch PSX data into DuckDB tables; query, list_tables and quote read it. Your assistant picks the tools itself. This page is for when you want to know what it’s doing, or need to steer it.
Column names are lower
snake_case. To see a table’s columns, the assistant runs query("DESCRIBE prices").
Loading data
load_prices
Loads daily OHLCV prices for up to 50 symbols per call intoprices.
- Re-loading a symbol replaces all of that symbol’s rows; other symbols are kept.
- Unknown symbols, and symbols with no data in the range, are reported as failures while the rest still load.
- Prices are in PKR and not adjusted for splits, bonus issues or dividends.
- Rows where
is_anomalyis true failed OHLC validation; exclude them from analysis.
load_screener
Loads the full PSX screener intoscreener: sector, price, market cap, P/E, dividend yield, free float, 30-day average volume, 1-year change, traded_today and ex_flag for every listed symbol. This is where valuation metrics live. It’s a 15-minute snapshot.
traded_todayis true if the symbol has traded on the PSX board so far this session, false if not, NULL if unknown. PSX keeps delisted and non-trading symbols in the screener with their last trading day’s price and move, so filter ontraded_todaybefore ranking daily gainers, losers or most-traded stocks.ex_flagisXD(ex-dividend),XB(ex-bonus) orXR(ex-rights) when PSX shows that badge, otherwise NULL. A stock that goes ex drops by roughly the entitlement without a real loss.
load_index
Loads the constituents and weights of one PSX index intoindex_constituents, including each constituent’s ex_flag.
Loading another index adds its rows; re-loading an index replaces only that index’s rows. Filter by
index_name when several are loaded.
load_sectors
Loads the sector summary intosectors: advances, declines, turnover and market cap for all 37 sectors. 15-minute snapshot.
load_fundamentals
Loads the list of filed financial reports intofundamentals: year, report type, period, posting date and a link to the document. These are filings, not valuation metrics; P/E and dividend yield are in screener.
load_symbols
Loads every listed symbol with company name, sector and ETF/debt/GEM flags intosymbols.
load_debt_market
Loads PSX debt instruments intodebt_market: face value, issue and maturity dates, coupon rate. The category column names the instrument group: GoP Ijarah Sukuk, Public Debt Securities, Privately Debt Securities or Government Debt Securities.
load_eligible_scrips
Loads margin-trading eligible scrips intoeligible_scrips, with the market in the category column (for example Regular Deliverable Equity Market or Future Deliverable Contract Market).
If PSX returns no data for a snapshot (for example outside market hours or during an outage), the server keeps the previously loaded table instead of wiping it, and tells the assistant when that data was loaded.
Reading data
query
Runs DuckDB SQL over the loaded tables and returns the result as a Markdown table.
Limits:
- At most 200 rows are returned. Larger results report how many rows were cut, so the assistant knows to aggregate or add
LIMIT. - Each query is cancelled after 30 seconds.
- Cells longer than 100 characters are truncated.
- File and network access are disabled, extensions can’t be installed, and the sandbox settings can’t be changed from SQL.
CREATE VIEWandCREATE TABLEwork, so the assistant can build intermediate results.
load_prices(["OGDC", "PPL", "MARI"], start="2026-01-01"):
list_tables
Lists the loaded tables with row counts and load time (UTC), plus any views the assistant created. It doesn’t list columns; usequery("DESCRIBE <table>") for those.