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));[
{
"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));[
{
"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
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?