Skip to content

B3 Agricultural Futures

Daily settlement prices and open interest of agricultural futures contracts traded on B3: live cattle, corn, coffee, ethanol, soybean.

b3.ajustes()

Daily settlement prices for a specific date.

import agrobr

df = await agrobr.b3.ajustes(data="13/02/2025", contrato="boi")

Parameters

Parameter Type Required Description
data str \| date Yes date, datetime, or YYYY-MM-DD or DD/MM/YYYY text; any other format raises InvalidParameterError before the request
contrato str No Name ("boi", "milho") or ticker ("BGI", "CCM"), case-insensitive; anything outside b3.contratos() raises InvalidParameterError with the list. If None, all
as_polars bool No If True, returns polars.DataFrame
return_meta bool No If True, returns (DataFrame, MetaInfo)

Returned Columns

Column Type Description
data datetime Trading session date
ticker str Contract code (BGI, CCM, ICF, CNL, ETH, SJC, SOY)
descricao str Contract slug (e.g. boi, milho, cafe_arabica)
vencimento_codigo str Expiration code (e.g. "G25")
vencimento_mes int Expiration month (1-12)
vencimento_ano int Expiration year
ajuste_anterior float Previous day's settlement price
ajuste_atual float Current day's settlement price
variacao float Change relative to the previous day
ajuste_por_contrato float Settlement amount per contract, in reais for every contract (including ICF, SJC and SOY, quoted in dollars)
unidade str Unit (BRL/@, BRL/sc60kg, USD/sc60kg, etc.)

b3.historico()

Historical settlement series. Iterates over business days in the period, collecting settlement prices for each day. Each day is a ~11 MB ZIP, and the whole period adds up to one download per business day; at most AGROBR_HTTP_MAX_CONCURRENT_B3 days (default 3) are open at the same time. With no rows, the DataFrame comes out empty with the dtypes of the ajuste_diario contract.

from datetime import date
import agrobr

df = await agrobr.b3.historico(
    contrato="boi",
    inicio=date(2025, 2, 10),
    fim=date(2025, 2, 14),
    vencimento="G25",
)

Parameters

Parameter Type Required Description
contrato str Yes Name ("boi") or ticker ("BGI"), case-insensitive; anything outside b3.contratos() raises InvalidParameterError with the list
inicio str \| date Yes Start date: date, datetime, or YYYY-MM-DD or DD/MM/YYYY text
fim str \| date Yes End date, in the same format; inicio after fim raises InvalidParameterError
vencimento str No Contract month code (e.g. "G25"). Settlements only carry futures: any other format, an option code included (e.g. "FVI1"), raises InvalidParameterError before the request
as_polars bool No If True, returns polars.DataFrame
return_meta bool No If True, returns (DataFrame, MetaInfo)

Returned Columns

Same columns as b3.ajustes(), concatenated for every date in the period.


b3.contratos()

List of available agricultural contracts.

import agrobr

print(agrobr.b3.contratos())
# ['boi', 'cafe_arabica', 'cafe_conillon', 'etanol', 'milho', 'soja_cross', 'soja_fob']

Returns

list[str] — Contract names in alphabetical order.



b3.posicoes_abertas()

Open interest of agricultural futures and options for a specific date.

import agrobr
from datetime import date

df = await agrobr.b3.posicoes_abertas(data=date(2025, 12, 19), contrato="boi")

Parameters

Parameter Type Required Description
data str \| date Yes date, datetime, or YYYY-MM-DD or DD/MM/YYYY text; any other format raises InvalidParameterError before the request
contrato str No Slug (boi, milho, cafe_arabica, cafe_conillon, etanol, soja_cross) or ticker (BGI, CCM, ICF, CNL, ETH, SJC). If None, returns all
tipo str No "futuro" or "opcao"; any other value raises InvalidParameterError. If None, all
as_polars bool No If True, returns polars.DataFrame
return_meta bool No If True, returns (DataFrame, MetaInfo)

Returned Columns

Column Type Description
data datetime Reference date
ticker str Asset code (BGI, CCM, ICF, CNL, ETH, SJC)
descricao str Contract slug (e.g. boi, milho, cafe_conillon)
ticker_completo str Full ticker (e.g. "BGIF26", "BGIF26C030000")
vencimento_codigo str Published expiration code (XprtnCd): "F26" for futures, MYOA for options (e.g. "FVI1")
vencimento_mes int Contract month (1-12), options included
vencimento_ano int Contract year, options included
tipo str "futuro" or "opcao"
posicoes_abertas int Number of open positions (contracts)
variacao_posicoes int Change vs the previous day
unidade str Contract price unit (BRL/@, BRL/sc60kg, USD/sc60kg, etc.); posicoes_abertas and variacao_posicoes are numbers of contracts

The arquivos.b3.com.br endpoint limits requests to 2 per 10s, with a progressive penalty. Each call consumes 2 requests (token + download); agrobr spaces them automatically (1 req/5s).

Availability window: B3 retains some recent days, not just the current day, without guaranteeing a complete archive. HTTP 400/404 when requesting a token indicates an unpublished file and returns an empty result after date validation. At download time, HTTP 404 returns empty data, but HTTP 400 raises SourceUnavailableError. Token/download operations are serialized within the process; historical queries fetch days sequentially. If another open-interest query does not release the turn for AGROBR_HTTP_TIMEOUT_READ seconds (default 30), for example a task of the loop blocked by agrobr.sync, the waiting one raises ResourceLimitError (not SourceUnavailableError: the session is not unavailable); retry the query or serialize the calls, and inside a loop prefer await. For historical weekly positioning, use cftc.cot().


b3.posicoes_abertas_historico()

Historical open interest series. Iterates over business days and concatenates the files available within the source's recent window. Unpublished days are skipped according to the token/download distinction above; other failures are propagated. With no rows, the DataFrame comes out empty with the dtypes of the posicoes_abertas contract, as in b3.posicoes_abertas().

from datetime import date
import agrobr

df = await agrobr.b3.posicoes_abertas_historico(
    contrato="boi",
    inicio=date(2025, 12, 15),
    fim=date(2025, 12, 19),
    tipo="futuro",
)

Parameters

Parameter Type Required Description
contrato str Yes Slug (boi, milho, cafe_arabica, cafe_conillon, etanol, soja_cross) or ticker (BGI, CCM, ICF, CNL, ETH, SJC)
inicio str \| date Yes Start date: date, datetime, or YYYY-MM-DD or DD/MM/YYYY text
fim str \| date Yes End date, in the same format; inicio after fim raises InvalidParameterError
vencimento str No Contract month code (e.g. "F26"), which returns the future and the options of that month, or an option's published code (e.g. "FVI1"); any other format raises InvalidParameterError before the network
tipo str No "futuro" or "opcao"; any other value raises InvalidParameterError. If None, all
as_polars bool No If True, returns polars.DataFrame
return_meta bool No If True, returns (DataFrame, MetaInfo)

Returned Columns

Same columns as b3.posicoes_abertas(), concatenated for every date in the period.


Synchronous Usage

from agrobr import sync

df = sync.b3.ajustes(data="13/02/2025")
df = sync.b3.historico(contrato="boi", inicio="2025-02-10", fim="2025-02-14")
df = sync.b3.posicoes_abertas(data="2025-12-19", contrato="boi")
df = sync.b3.posicoes_abertas_historico(contrato="boi", inicio="2025-12-15", fim="2025-12-19")
print(sync.b3.contratos())

Data Source

  • Provider: B3 — Brasil, Bolsa, Balcao
  • Settlement URL: b3.com.br/pesquisapregao/download (BVBG-086 ZIP/XML)
  • Open interest URL: arquivos.b3.com.br
  • Update: Daily (after the trading session closes) Classification: zona_cinza. The D-1 FAQ waiver and website terms have different scopes; check channel, use and policy dates in Licenses.