Skip to main content
Parameters, response columns and types are generated from the SQL catalog and render under Endpoints in the sidebar. This page carries what a schema cannot. All five functions refuse above one 1,000-row page (22023) and have no cursor. None gives advice: they name a peer group, an equivalent or a value on a curve.

Overview

portfolio_fee_peers

Compares the fee with the active FI funds of the same ANBIMA class, FUNDO_COTAS flag and document scope. Active ETFs join a class only when their underlying_index is mapped to it in an owner-reviewed list. An ETF’s fee comes from a third-party site (etfsbrasil), never from CVM, and etf_peer_fee_source says so. At least 30 usable fund fees are required (including the target when eligible); ETF fees do not count toward that minimum. Once the fund group qualifies, statistics use the combined fund and ETF fees. The function does not widen the group.

class_return_distribution

Two rows, with window_months 12 and 6, ending at the close of p_month (NULL means the last complete FI month). It gives p25_pct, median_pct and p75_pct over n_funds returns, and counts the funds it left out. With fewer than 30 funds or an incomplete month, the row is nao_avaliado, with NULL statistics and a reason. ETFs are not in the universe.

portfolio_equivalents

Takes 1 to 50 classes as filed. is_equivalent marks the ETF with the largest PL (pl_rank 1) across the class’s indices. A class with no approved index pair (sem_par) or no active ETF (sem_etf) returns one row with NULL ETF columns. If active ETFs exist but none has PL, each ETF keeps its identity columns with status sem_pl, NULL pl_rank and is_equivalent = false. PL and fee are third-party values with their dates. It names an ETF with the same objective, not a recommendation.

portfolio_credit_returns

Takes 1 to 70 CETIP codes (a leading CRA- or CRI- is stripped) and returns up to 13 month-ends from the securitizer’s filings. pu is valor_certificados / quantidade_certificados, and factor is (pu + paid) / previous pu. A month_flag makes a month unknown, for example mes_ausente, pu_repetido or queda_sem_evento_arquivado. A fall in PU with no filed payment is never read as a loss. It is the securitizer’s value on its curve, not a market price.

portfolio_debenture_returns

Takes up to 70 debenture tickers and returns 13 month-ends from CVM CDA block 4. For each month it takes the median PU across funds (at least 3 funds), and factor is that median over the previous month’s. A fall beyond p_max_monthly_drop_pct is flagged queda_pu_possivel_evento; with a NULL threshold every fall is flagged limite_pendente. It is the funds’ marks, not a trade price, and it invents no coupon or amortization.

Implementation source

The five functions are implemented in 31_api_portfolio.sql. The fee minimum is checked against n_fund; the portfolio_equivalents query retains ETF rows when n_pl = 0. The monthly debenture decline threshold remains an owner decision pending in the implementation: NULL flags every decline as limite_pendente.