> ## Documentation Index
> Fetch the complete documentation index at: https://octo-98895abd.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# quote_history

> Daily price series for one ticker, oldest first, one JSON object per session holding only the selected fields. Default (p_fields omitted): ticker, trade_date, close_adj. close_adj is the close per single share, backward-adjusted for splits, groupings and bonus shares by B3's rule and anchored to the instrument's latest session (past levels change when an event lands; returns do not); no dividend, JCP or subscription-right adjustment; shares and units only; 6 decimal places. It is never null and never the raw close: a window it cannot cover is REFUSED (22023, DETAIL reason=adjustment_unavailable) naming ticker, period and cause. The raw close, OHLC and volume are an explicit selection (p_fields = {close, ...}); fields are listed in catalog(). The series follows the ISIN across boards; p_board restricts it. Refusals (22023, DETAIL reason=...): unknown_ticker; outside_coverage (a window with no coverage, or starting before the instrument's first session; the tape starts 2019-01-02); isin_change (two ISINs in the window that the ticker's lineage does not splice); ambiguous_session (two rows on one session); invalid_field; adjustment_unavailable. A session missing inside the coverage is a session with no trade (prior_no_trade_sessions counts them); a field with no value is a null. A ticker whose company changed its trading code or ISIN runs through its older instrument (ticker lineage, #381): an older (ticker, ISIN) is spliced in front only when it is the same company (the same ticker, or one CNPJ in CVM's FCA map), the same share class (ISIN characters 7-11), its last cash session is the one right before the newer first session with no overlap, no stock event goes ex at the seam, and exactly one candidate qualifies; every row keeps its own ticker and ISIN, close_adj divides older rows by the later instruments' share ratios too, and close_total_return is NULL before a seam (VIIA3 BRVIIAACNOR7 to BHIA3 BRBHIAACNOR1 on 2023-09-20). close_total_return (with close_total_return_null_reason) is selectable too: close_adj with B3's cash distributions reinvested at the ex-date close (#418), NULL with a reason wherever a distribution cannot be valued, never the price return in disguise. data_revision (field, and header X-Silo-Data-Revision) identifies the data; do not combine pages with different revisions. Row cap: more than 1000 rows RAISES 22023 unless p_after pages: '' = first page, then the last row's trade_date as 'YYYY-MM-DD'; a page shorter than 1000 is the last.

**Row cap.** A window producing more than 1000 rows raises SQLSTATE `22023` naming this function. Nothing is trimmed to fit — PostgREST would silently cut the response at 1000 and a cut-short series is indistinguishable from one that simply ends. This function pages: send `p_after = ""` for the first page, then the key copied from the last row; a page shorter than 1000 is the last. `p_after = null` is whole-result mode, which is what refuses.



## OpenAPI

````yaml /openapi.json post /rpc/quote_history
openapi: 3.1.0
info:
  title: SILO Data API
  version: '75'
  summary: >-
    Read-only Brazilian public financial data: CVM filings, BACEN series, B3
    quotes and the B3 BDI group.
  description: >
    Schema `api` over PostgREST. Views are `GET /<view>`; functions are

    `POST /rpc/<function>` with a JSON body.


    **This document is generated** from the live Postgres catalog by

    `scripts/gen_openapi.py` — `pg_get_function_arguments` for the RPC
    signatures,

    `information_schema.columns` for the view columns, and the granted-to-`anon`

    privilege set for which objects exist at all. It is not hand-maintained, and

    `tests/test_openapi_spec.py` fails the build when it drifts from the SQL.


    ### Two different ceilings


    Reading one for the other is the most expensive mistake on this API.


    * **The row cap refuses.** Fifty-nine set-returning functions raise SQLSTATE
      `22023` when the window they were handed would produce more than 1000 rows.
      Nothing is trimmed, and the error says why and how to fix it (the message,
      plus PostgREST's `details` and `hint`). Five of them (`panel`,
      `quote_history`, `fund_nav`, `index_history`, `trade_consolidated_history`)
      take a `p_after` cursor so you can walk the series; the other fifty-four ask you to narrow the window. `fund_nav` paging
      additionally REQUIRES `p_entity_type` — its cursor is a bare period, which
      is unique only within one family, and CNPJs that file under both `fi` and
      `fidc` in the same month would otherwise be ambiguous.
    * **The tier ceiling clamps.** Three other functions (`search_funds`,
      `option_chain`, `option_exercises`) silently lower `p_limit` to a per-tier maximum. No error is raised, so the
      only way to know the result was cut is to know the ceiling. Signing in
      raises it.

    Separately from both, PostgREST's server-wide `db-max-rows = 1000` cuts
    every

    response, on every endpoint, for every tier. On the GET views
    `Content-Range`

    is the signal (`0-999/*`); `Prefer: count=exact` turns the `*` into a total.


    ### Retention


    Most of this warehouse is append-only history. The **B3 BDI group** —

    `short_interest`, `short_interest_by_sector`, `investor_flow`,

    `lending_trades`, `lending_participants` — is not: B3 keeps roughly 21
    business

    days and publishes no archive. A missed session cannot be bought back. See

    Market Coverage.
  license:
    name: See repository
    url: https://github.com/PedroDnT/SILO-BZ
servers:
  - url: https://zcjbtpxuhdekpwcxmepn.supabase.co/rest/v1
    description: Supabase PostgREST, schema `api`
security:
  - apikey: []
tags:
  - name: ANBIMA
  - name: Company events
  - name: Coverage & catalog
  - name: Derivatives
  - name: FIDC
  - name: FNET documents
  - name: Financials
  - name: Funds
  - name: Holdings
  - name: Inflation
  - name: Lookup
  - name: Macro
  - name: Macro expectations
  - name: Other
  - name: Panel
  - name: Portfolio
  - name: Quotes
  - name: Rates
  - name: Research
  - name: Screens
  - name: Securities lending
  - name: Short interest & flows
paths:
  /rpc/quote_history:
    post:
      tags:
        - Quotes
      summary: quote_history
      description: >-
        Daily price series for one ticker, oldest first, one JSON object per
        session holding only the selected fields. Default (p_fields omitted):
        ticker, trade_date, close_adj. close_adj is the close per single share,
        backward-adjusted for splits, groupings and bonus shares by B3's rule
        and anchored to the instrument's latest session (past levels change when
        an event lands; returns do not); no dividend, JCP or subscription-right
        adjustment; shares and units only; 6 decimal places. It is never null
        and never the raw close: a window it cannot cover is REFUSED (22023,
        DETAIL reason=adjustment_unavailable) naming ticker, period and cause.
        The raw close, OHLC and volume are an explicit selection (p_fields =
        {close, ...}); fields are listed in catalog(). The series follows the
        ISIN across boards; p_board restricts it. Refusals (22023, DETAIL
        reason=...): unknown_ticker; outside_coverage (a window with no
        coverage, or starting before the instrument's first session; the tape
        starts 2019-01-02); isin_change (two ISINs in the window that the
        ticker's lineage does not splice); ambiguous_session (two rows on one
        session); invalid_field; adjustment_unavailable. A session missing
        inside the coverage is a session with no trade (prior_no_trade_sessions
        counts them); a field with no value is a null. A ticker whose company
        changed its trading code or ISIN runs through its older instrument
        (ticker lineage, #381): an older (ticker, ISIN) is spliced in front only
        when it is the same company (the same ticker, or one CNPJ in CVM's FCA
        map), the same share class (ISIN characters 7-11), its last cash session
        is the one right before the newer first session with no overlap, no
        stock event goes ex at the seam, and exactly one candidate qualifies;
        every row keeps its own ticker and ISIN, close_adj divides older rows by
        the later instruments' share ratios too, and close_total_return is NULL
        before a seam (VIIA3 BRVIIAACNOR7 to BHIA3 BRBHIAACNOR1 on 2023-09-20).
        close_total_return (with close_total_return_null_reason) is selectable
        too: close_adj with B3's cash distributions reinvested at the ex-date
        close (#418), NULL with a reason wherever a distribution cannot be
        valued, never the price return in disguise. data_revision (field, and
        header X-Silo-Data-Revision) identifies the data; do not combine pages
        with different revisions. Row cap: more than 1000 rows RAISES 22023
        unless p_after pages: '' = first page, then the last row's trade_date as
        'YYYY-MM-DD'; a page shorter than 1000 is the last.


        **Row cap.** A window producing more than 1000 rows raises SQLSTATE
        `22023` naming this function. Nothing is trimmed to fit — PostgREST
        would silently cut the response at 1000 and a cut-short series is
        indistinguishable from one that simply ends. This function pages: send
        `p_after = ""` for the first page, then the key copied from the last
        row; a page shorter than 1000 is the last. `p_after = null` is
        whole-result mode, which is what refuses.
      operationId: rpc_quote_history
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                p_ticker:
                  type:
                    - string
                    - 'null'
                p_from:
                  type:
                    - string
                    - 'null'
                  format: date
                  description: Defaults to `(CURRENT_DATE - 365)`.
                p_to:
                  type:
                    - string
                    - 'null'
                  format: date
                  description: Defaults to `CURRENT_DATE`.
                p_board:
                  type:
                    - string
                    - 'null'
                  description: Defaults to `NULL::text`.
                  default: null
                p_after:
                  type:
                    - string
                    - 'null'
                  description: Defaults to `NULL::text`.
                  default: null
                p_fields:
                  type:
                    - array
                    - 'null'
                  items:
                    type: string
                    enum:
                      - ticker
                      - trade_date
                      - close_adj
                      - close
                      - open
                      - high
                      - low
                      - average
                      - bid
                      - ask
                      - close_unit
                      - trades
                      - quantity
                      - volume
                      - quotation_factor
                      - board
                      - isin
                      - short_name
                      - spec
                      - currency
                      - asset_class
                      - source
                      - coverage_start
                      - coverage_end
                      - prior_no_trade_sessions
                      - events_proven_at
                      - data_revision
                      - close_total_return
                      - close_total_return_null_reason
                      - market
                      - term_days
                      - contract_price
                      - contract_expiry
                      - contract_correction
                      - contract_points
                      - contract_points_raw
                      - distribution_number
                      - fetched_at
                  description: >-
                    Fields to return; null or omitted = ticker, trade_date,
                    close_adj. ticker and trade_date are in every row.
                  default: null
              required:
                - p_ticker
      responses:
        '200':
          description: >-
            The result set, oldest first. An unknown ticker, or a window outside
            its coverage, is refused (22023), never an empty or guessed series.
          content:
            application/json:
              schema:
                type: array
                items:
                  type: object
                  description: >-
                    One object per row holding only the selected fields
                    (p_fields). Omitted p_fields selects: ticker, trade_date,
                    close_adj.
                  properties:
                    ticker:
                      type:
                        - string
                        - 'null'
                      description: >-
                        B3 trading code (CODNEG), as asked, upper-cased. In
                        every row.
                    trade_date:
                      type:
                        - string
                        - 'null'
                      format: date
                      description: Session date. In every row.
                    close_adj:
                      type:
                        - number
                        - 'null'
                      description: >-
                        Close per single share, backward-adjusted for splits
                        (DESDOBRAMENTO), groupings (GRUPAMENTO) and bonus shares
                        (BONIFICACAO) and anchored to the instrument's latest
                        session; rounded to 6 decimal places. No dividend, JCP
                        or subscription-right adjustment. Shares and units only.
                        Null only when the session has no close; a window it
                        cannot adjust is refused, never filled with the raw
                        close.
                    close:
                      type:
                        - number
                        - 'null'
                      description: >-
                        RAW close as traded, per quotation unit (see
                        quotation_factor). Never adjusted.
                    open:
                      type:
                        - number
                        - 'null'
                      description: Raw opening price.
                    high:
                      type:
                        - number
                        - 'null'
                      description: Raw high.
                    low:
                      type:
                        - number
                        - 'null'
                      description: Raw low.
                    average:
                      type:
                        - number
                        - 'null'
                      description: Raw average traded price.
                    bid:
                      type:
                        - number
                        - 'null'
                      description: Best bid at the close.
                    ask:
                      type:
                        - number
                        - 'null'
                      description: Best ask at the close.
                    close_unit:
                      type:
                        - number
                        - 'null'
                      description: >-
                        Raw close divided by quotation_factor: the price of one
                        share, not adjusted for corporate events.
                    trades:
                      type:
                        - integer
                        - 'null'
                      format: int32
                      description: Number of trades.
                    quantity:
                      type:
                        - number
                        - 'null'
                      description: Quantity traded.
                    volume:
                      type:
                        - number
                        - 'null'
                      description: Financial volume in currency.
                    quotation_factor:
                      type:
                        - integer
                        - 'null'
                      format: int32
                      description: >-
                        FATCOT: how many shares the quoted prices refer to (1 or
                        1000).
                    board:
                      type:
                        - string
                        - 'null'
                      description: >-
                        BDI board code (CODBDI) the session printed on; 02 is
                        the standard lot.
                    isin:
                      type:
                        - string
                        - 'null'
                      description: >-
                        ISIN of the instrument this row printed under. One ISIN
                        per series, except across an ISIN change the ticker's
                        lineage splices (api.ticker_lineage), where each row
                        keeps its own.
                    short_name:
                      type:
                        - string
                        - 'null'
                      description: Issuer short name as printed.
                    spec:
                      type:
                        - string
                        - 'null'
                      description: Share specification (ESPECI) as printed.
                    currency:
                      type:
                        - string
                        - 'null'
                      description: Price currency.
                    asset_class:
                      type:
                        - string
                        - 'null'
                      description: Instrument class from published TPMERC/ESPECI.
                    source:
                      type:
                        - string
                        - 'null'
                      description: Source file of the row.
                    coverage_start:
                      type:
                        - string
                        - 'null'
                      format: date
                      description: >-
                        First session of the series on the tape: this ticker
                        under this ISIN, or the oldest instrument of its spliced
                        lineage when the window reaches back to it (the tape
                        starts 2019-01-02).
                    coverage_end:
                      type:
                        - string
                        - 'null'
                      format: date
                      description: >-
                        Last session of the series on the tape (the current
                        instrument's last print).
                    prior_no_trade_sessions:
                      type:
                        - integer
                        - 'null'
                      format: int32
                      description: >-
                        Market sessions (days the B3 cash tape printed) since
                        this ticker's previous row in which it printed nothing.
                        COTAHIST lists only papers that traded, so a missing
                        session is a session with no trade; holidays are not
                        sessions.
                    events_proven_at:
                      type:
                        - string
                        - 'null'
                      description: >-
                        When the issuer's corporate-event history was last
                        proven complete (b3_corporate_event_sweep), ISO 8601
                        UTC. Null outside shares and units or when not proven.
                    data_revision:
                      type:
                        - string
                        - 'null'
                      description: >-
                        Revision of the data behind this response: the latest
                        successful load of the B3 cash tape, the corporate
                        events or their proof, ISO 8601 UTC. It changes when
                        adjusted levels can change; pages with different
                        revisions must not be combined.
                    close_total_return:
                      type:
                        - number
                        - 'null'
                      description: >-
                        close_adj with cash distributions reinvested at the
                        ex-date close (#418): divided by the product of (1 +
                        cash / ex-session close) over later distributions
                        (DIVIDENDO, JRS CAP PROPRIO gross of tax, RENDIMENTO,
                        REST CAP DIN from B3's full history, ISIN proven against
                        the tape). 6 decimal places. NULL, with
                        close_total_return_null_reason, where it cannot be
                        valued.
                    close_total_return_null_reason:
                      type:
                        - string
                        - 'null'
                      description: >-
                        Why close_total_return is NULL on the session; null when
                        it has a value.
                    market:
                      type:
                        - string
                        - 'null'
                      description: >-
                        Original TPMERC code, preserved as text. Cash history is
                        010 only.
                    term_days:
                      type:
                        - string
                        - 'null'
                      description: >-
                        PRAZOT as published; blank for spot. Part of the source
                        natural key.
                    contract_price:
                      type:
                        - number
                        - 'null'
                      description: >-
                        PREEXE as published; exercise price or secondary-forward
                        contract value, not a yield.
                    contract_expiry:
                      type:
                        - string
                        - 'null'
                      format: date
                      description: DATVEN; source sentinel 99991231 is null.
                    contract_correction:
                      type:
                        - string
                        - 'null'
                      description: >-
                        Original INDOPC code; consult the dated COTAHIST
                        reference in catalog.
                    contract_points:
                      type:
                        - number
                        - 'null'
                      description: >-
                        PTOEXE decoded with six implied decimals; zero filler or
                        unreadable points become null.
                    contract_points_raw:
                      type:
                        - string
                        - 'null'
                      description: >-
                        Original PTOEXE text, retaining zero filler and leading
                        zeros.
                    distribution_number:
                      type:
                        - string
                        - 'null'
                      description: DISMES source sequence code, not a dividend amount.
                    fetched_at:
                      type:
                        - string
                        - 'null'
                      description: >-
                        Warehouse timestamp, not original publication time or an
                        as-known source vintage.
                  additionalProperties: false
        '400':
          description: >-
            Bad request. Contract violations raise SQLSTATE `22023` with a
            message naming the limit or the argument at fault.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: >-
            No usable `apikey`, or a request for a schema outside `api`.
            `Accept-Profile: public` and any `cvm_*` / `b3_cotahist` / `cia_*`
            path answer 401 for every caller, by grant — schema `api` is the
            entire public surface.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: No such endpoint in schema `api`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    Error:
      type: object
      description: >-
        PostgREST error body. `code` carries the SQLSTATE — `22023` is a
        contract refusal.
      properties:
        code:
          type:
            - string
            - 'null'
          examples:
            - '22023'
        message:
          type:
            - string
            - 'null'
        details:
          type:
            - string
            - 'null'
        hint:
          type:
            - string
            - 'null'
  securitySchemes:
    apikey:
      type: apiKey
      in: header
      name: apikey
      description: >-
        The publishable key (`sb_publishable_…`), on every request. It is NOT a
        JWT — sending it as `Authorization: Bearer` is rejected as an invalid
        JWT. It identifies the project, not you, and maps to the Postgres `anon`
        role.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.