curl --request POST \
--url https://zcjbtpxuhdekpwcxmepn.supabase.co/rest/v1/rpc/portfolio_debenture_returns \
--header 'Content-Type: application/json' \
--header 'apikey: <api-key>' \
--data '
{
"p_tickers": [
"<string>"
],
"p_end_month": "2023-12-25",
"p_max_monthly_drop_pct": null
}
'import requests
url = "https://zcjbtpxuhdekpwcxmepn.supabase.co/rest/v1/rpc/portfolio_debenture_returns"
payload = {
"p_tickers": ["<string>"],
"p_end_month": "2023-12-25",
"p_max_monthly_drop_pct": None
}
headers = {
"apikey": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {apikey: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
p_tickers: ['<string>'],
p_end_month: '2023-12-25',
p_max_monthly_drop_pct: null
})
};
fetch('https://zcjbtpxuhdekpwcxmepn.supabase.co/rest/v1/rpc/portfolio_debenture_returns', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://zcjbtpxuhdekpwcxmepn.supabase.co/rest/v1/rpc/portfolio_debenture_returns",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'p_tickers' => [
'<string>'
],
'p_end_month' => '2023-12-25',
'p_max_monthly_drop_pct' => null
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"apikey: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://zcjbtpxuhdekpwcxmepn.supabase.co/rest/v1/rpc/portfolio_debenture_returns"
payload := strings.NewReader("{\n \"p_tickers\": [\n \"<string>\"\n ],\n \"p_end_month\": \"2023-12-25\",\n \"p_max_monthly_drop_pct\": null\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("apikey", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://zcjbtpxuhdekpwcxmepn.supabase.co/rest/v1/rpc/portfolio_debenture_returns")
.header("apikey", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"p_tickers\": [\n \"<string>\"\n ],\n \"p_end_month\": \"2023-12-25\",\n \"p_max_monthly_drop_pct\": null\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://zcjbtpxuhdekpwcxmepn.supabase.co/rest/v1/rpc/portfolio_debenture_returns")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["apikey"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"p_tickers\": [\n \"<string>\"\n ],\n \"p_end_month\": \"2023-12-25\",\n \"p_max_monthly_drop_pct\": null\n}"
response = http.request(request)
puts response.read_body[
{
"line_no": 123,
"input_ticker": "<string>",
"ticker": "<string>",
"month": "2023-12-25",
"n_fundos": 123,
"n_invalid_fundos": 123,
"median_pu": 123,
"factor": 123,
"month_flag": "<string>",
"reason": "<string>"
}
]{
"code": "22023",
"message": "<string>",
"details": "<string>",
"hint": "<string>"
}{
"code": "22023",
"message": "<string>",
"details": "<string>",
"hint": "<string>"
}{
"code": "22023",
"message": "<string>",
"details": "<string>",
"hint": "<string>"
}portfolio_debenture_returns
Method B: one call for up to 70 debenture tickers; 13 month-ends from cvm_fi_cda_acoes block 4, tp_aplic Debêntures. Per fund and month, PU = sum(vl_merc_pos_final) / sum(qt_pos_final), then median PU over funds (not pooled values); at least 3 funds are required. factor = median PU / previous month median. A decrease beyond p_max_monthly_drop_pct is flagged queda_pu_possivel_evento because CDA block 4 does not carry the debenture cash-flow events; it is never counted as a loss. NULL threshold (owner decision pending) flags every decrease as limite_pendente. Invalid values, a missing month, or fewer than 3 funds leave the window unevaluated. It is the funds’ marks, not a trade price, and includes no invented coupon or amortization. More than 70 tickers raises 22023; one page, never trimmed.
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 does not page — narrow the window instead.
curl --request POST \
--url https://zcjbtpxuhdekpwcxmepn.supabase.co/rest/v1/rpc/portfolio_debenture_returns \
--header 'Content-Type: application/json' \
--header 'apikey: <api-key>' \
--data '
{
"p_tickers": [
"<string>"
],
"p_end_month": "2023-12-25",
"p_max_monthly_drop_pct": null
}
'import requests
url = "https://zcjbtpxuhdekpwcxmepn.supabase.co/rest/v1/rpc/portfolio_debenture_returns"
payload = {
"p_tickers": ["<string>"],
"p_end_month": "2023-12-25",
"p_max_monthly_drop_pct": None
}
headers = {
"apikey": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {apikey: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
p_tickers: ['<string>'],
p_end_month: '2023-12-25',
p_max_monthly_drop_pct: null
})
};
fetch('https://zcjbtpxuhdekpwcxmepn.supabase.co/rest/v1/rpc/portfolio_debenture_returns', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://zcjbtpxuhdekpwcxmepn.supabase.co/rest/v1/rpc/portfolio_debenture_returns",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'p_tickers' => [
'<string>'
],
'p_end_month' => '2023-12-25',
'p_max_monthly_drop_pct' => null
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"apikey: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://zcjbtpxuhdekpwcxmepn.supabase.co/rest/v1/rpc/portfolio_debenture_returns"
payload := strings.NewReader("{\n \"p_tickers\": [\n \"<string>\"\n ],\n \"p_end_month\": \"2023-12-25\",\n \"p_max_monthly_drop_pct\": null\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("apikey", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://zcjbtpxuhdekpwcxmepn.supabase.co/rest/v1/rpc/portfolio_debenture_returns")
.header("apikey", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"p_tickers\": [\n \"<string>\"\n ],\n \"p_end_month\": \"2023-12-25\",\n \"p_max_monthly_drop_pct\": null\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://zcjbtpxuhdekpwcxmepn.supabase.co/rest/v1/rpc/portfolio_debenture_returns")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["apikey"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"p_tickers\": [\n \"<string>\"\n ],\n \"p_end_month\": \"2023-12-25\",\n \"p_max_monthly_drop_pct\": null\n}"
response = http.request(request)
puts response.read_body[
{
"line_no": 123,
"input_ticker": "<string>",
"ticker": "<string>",
"month": "2023-12-25",
"n_fundos": 123,
"n_invalid_fundos": 123,
"median_pu": 123,
"factor": 123,
"month_flag": "<string>",
"reason": "<string>"
}
]{
"code": "22023",
"message": "<string>",
"details": "<string>",
"hint": "<string>"
}{
"code": "22023",
"message": "<string>",
"details": "<string>",
"hint": "<string>"
}{
"code": "22023",
"message": "<string>",
"details": "<string>",
"hint": "<string>"
}Authorizations
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.
Body
Response
The result set, oldest first. An unknown id is an empty array, not a 404 and never a guessed value.
Was this page helpful?