Skip to main content
The server exposes eleven tools. Eight 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 into prices.
  • 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_anomaly is true failed OHLC validation; exclude them from analysis.

load_screener

Loads the full PSX screener into screener: 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_today is 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 on traded_today before ranking daily gainers, losers or most-traded stocks.
  • ex_flag is XD (ex-dividend), XB (ex-bonus) or XR (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 into index_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 into sectors: advances, declines, turnover and market cap for all 37 sectors. 15-minute snapshot.

load_fundamentals

Loads the list of filed financial reports into fundamentals: 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 into symbols.

load_debt_market

Loads PSX debt instruments into debt_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 into eligible_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 VIEW and CREATE TABLE work, so the assistant can build intermediate results.
A typical query the assistant writes after 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; use query("DESCRIBE <table>") for those.

quote

Returns the latest snapshot for one symbol (price, sector, market cap, P/E, dividend yield, 1-year change) without creating a table. Handy for a quick check on a single stock.

Errors

Tool errors come back to the assistant as plain messages it can act on: