curl --request POST \
--url https://zcjbtpxuhdekpwcxmepn.supabase.co/rest/v1/rpc/future_nth_series \
--header 'Content-Type: application/json' \
--header 'apikey: <api-key>' \
--data '
{
"p_root": "DI1",
"p_rank": 1,
"p_from": null,
"p_to": null
}
'import requests
url = "https://zcjbtpxuhdekpwcxmepn.supabase.co/rest/v1/rpc/future_nth_series"
payload = {
"p_root": "DI1",
"p_rank": 1,
"p_from": None,
"p_to": 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_root: 'DI1', p_rank: 1, p_from: null, p_to: null})
};
fetch('https://zcjbtpxuhdekpwcxmepn.supabase.co/rest/v1/rpc/future_nth_series', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));[
{
"trade_date": "2023-12-25",
"ticker": "<string>",
"contract_month": "2023-12-25",
"settlement_rate": 123,
"settlement_price": 123,
"prev_settlement_rate": 123,
"open_interest": 123,
"contracts": 123,
"trades": 123,
"notional_brl": 123,
"open_px": 123,
"low_px": 123,
"high_px": 123,
"avg_px": 123,
"close_px": 123,
"settlement_status": "<string>",
"source": "<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>"
}future_nth_series
The Nth nearest futures contract of one root through time, oldest session first, with the same columns as api.future_series (B3 Price Report, b3_futures_settlement, from 2018-01-02). p_root is DI1, DOL or WDO (default DI1, as in future_curve); p_rank is 1 or more (1 = the nearest contract alive, 2 = the next, …); anything else raises 22023. On each session the contracts of the root are ranked by contract_month, and the contract of the session’s own month is left out, because DI1, DOL and WDO mature on the first business day of the contract month: in November the 1st DOL is DOLZ26, the 2nd DOLF27. Rank is by maturity, not by liquidity: past the 1st or 2nd dollar contract, open interest is small. Each row is the published row of that contract, with its ticker, so the roll shows in the ticker column. NOTHING IS ADJUSTED OR SPLICED: the price jumps at each roll, and a return across a ticker change is not a return. A session with fewer than p_rank contracts has no row. Quote columns per root as in api.future_curve: DI1 in rate (% a.a., 252 business days), DOL and WDO in price (BRL per USD 1,000). Default window the 12 months before p_to or today. More than 1000 rows RAISES 22023 (never trimmed): narrow p_from/p_to.
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/future_nth_series \
--header 'Content-Type: application/json' \
--header 'apikey: <api-key>' \
--data '
{
"p_root": "DI1",
"p_rank": 1,
"p_from": null,
"p_to": null
}
'import requests
url = "https://zcjbtpxuhdekpwcxmepn.supabase.co/rest/v1/rpc/future_nth_series"
payload = {
"p_root": "DI1",
"p_rank": 1,
"p_from": None,
"p_to": 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_root: 'DI1', p_rank: 1, p_from: null, p_to: null})
};
fetch('https://zcjbtpxuhdekpwcxmepn.supabase.co/rest/v1/rpc/future_nth_series', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));[
{
"trade_date": "2023-12-25",
"ticker": "<string>",
"contract_month": "2023-12-25",
"settlement_rate": 123,
"settlement_price": 123,
"prev_settlement_rate": 123,
"open_interest": 123,
"contracts": 123,
"trades": 123,
"notional_brl": 123,
"open_px": 123,
"low_px": 123,
"high_px": 123,
"avg_px": 123,
"close_px": 123,
"settlement_status": "<string>",
"source": "<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?