Skip to main content

filings-b3 filings-b3

Project Status: Active Python Version PyPI Version Snyk Vulnerabilities Snyk License PyPI Downloads Linting Formatting: isort Test Coverage License Open Issues Contributions Welcome

Biblioteca Python simples e eficiente para acessar os conjuntos de dados públicos da B3 (a bolsa brasileira). Cada reader transforma um pregão em um pandas.DataFrame tipado, validado por contrato e com proveniência — valores monetários como Decimal exato, nunca um float com perda.

✨ Principais recursos

📊 Readers do Boletim Diário (BDI)

🗂️ Readers da Pesquisa por Pregão

O arquivo de instrumentos do pregão (IN{aammdd}.zip, BVBG.028.02) é um download lido de dezoito formas: cada registro aninha os seus campos sob exatamente um de 20 blocos InstrmInf.

🔒 Fidelidade por construção

  • Tipagem explícita — toda coluna tipada na carga, nunca a inferência do pandas.
  • Decimais exatos — dinheiro e qualquer valor cuja parte fracionária importa é decimal.Decimal, nunca um float binário.
  • Contratos — uma fonte que remove uma coluna obrigatória falha de forma barulhenta com ContractError, verificado contra os layouts publicados pela própria B3.

🧾 Proveniência & camada bronze

  • Seis colunas de proveniência em todo frame (url, updated_at, source_key, package_version, ingestion_run_id, content_hash).
  • Passe path_raw= para reter cada página bruta da fonte para a camada bronze de um datalake.

🚀 Primeiros passos

Pré-requisitos

  • Python 3.10+
  • Poetry (recomendado)
  • Opcional: Makefile

Instalação

Opção 1: Pip (recomendado)

pip install filings-b3

Opção 2: Build a partir do código-fonte

git clone https://github.com/guilhermegor/filings-b3.git
cd filings-b3
pyenv install 3.12.2
pyenv local 3.12.2
poetry install --no-root
poetry shell

Uso básico

from datetime import date
from filings_b3.daily_bulletin import BdiBtbLendingOpenPositionsReader

df = BdiBtbLendingOpenPositionsReader(date(2025, 1, 2)).read()
print(df[["TCKR_SYMB", "STOCK_BALANCE", "BALANCE"]].head())

Cada reader é importado pela sua macro-seção (filings_b3.daily_bulletin, filings_b3.search_trading_session, …) — a única forma pública. A raiz do pacote não exporta readers.

⚠️ Mudança na 0.3.0 — duas colunas do arquivo de instrumentos foram renomeadas, porque um mesmo campo vinha publicado com dois nomes diferentes entre readers do mesmo arquivo, quebrando um UNION ALL sobre a família (#165). Só o nome da coluna mudou — caminho de origem e valores são os mesmos.

Reader Antes Agora
InstrumentsFileFxdIncmReader TP UNDRLYG_INSTRM_ID_TP
InstrumentsFileExrcEqtsReader TP OPTN_EXRC_INSTRM_ID_TP

O TP de InstrumentsFileIntlBdReader não muda: ali é o tag Tp de verdade do bloco.

⚠️ Mudança na 0.2.0 — até a 0.1.x cada reader também era reexportado de forma plana na raiz (from filings_b3 import BdiBtbLendingOpenPositionsReader). Isso foi removido: com seis macro-seções e ~105 datasets previstos, a raiz viraria uma lista de mais de cem nomes. Troque o import pela seção correspondente.

date_ref é obrigatório — o endpoint do BDI é endereçado por data, então não existe um padrão "mais recente". Veja a documentação para cada reader e mais receitas.

Rodando os testes

poetry run pytest tests/unit/ -v
poetry run pytest tests/integration/ -v

📂 Estrutura do projeto

filings-b3/
├── .github/
│   ├── workflows/
│   ├── CODEOWNERS
│   └── PULL_REQUEST_TEMPLATE.md
├── assets/
│   └── b3-logo.png
├── bin/
├── docs/
├── src/filings_b3/
│   ├── daily_bulletin/          # readers do Boletim Diário do Pregão (BDI)
│   ├── search_trading_session/  # readers da Pesquisa por Pregão
│   └── _internal/               # privado: contracts, utils, ports
├── tests/
│   ├── unit/
│   ├── integration/
│   └── performance/
├── LICENSE
├── Makefile
├── poetry.lock
├── pyproject.toml
├── README.md
└── requirements.txt

👨‍💻 Autores

📜 Licença

Este projeto é licenciado sob a Licença MIT — veja LICENSE.

Metadata

Release files for opendata-b3 0.3.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for opendata-b3 0.3.2
File Size Uploaded Provenance Actions
opendata_b3-0.3.2.tar.gz 88.5 kB With provenance Details for opendata_b3-0.3.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for opendata-b3 0.3.2
File Interpreter ABI Platform Actions
opendata_b3-0.3.2-py3-none-any.whl Python 3 none any Details for opendata_b3-0.3.2-py3-none-any.whl

Total release size: 252.0 kB

Release files / opendata_b3-0.3.2.tar.gz

Download URL opendata_b3-0.3.2.tar.gz
Size 88.5 kB
Tags Source
SHA-256 checksum
How to use checksums
4a5aac1f6a25430ca9a05bd88c3112ff705033332e81cb74da8bd8f1ef292917
BLAKE2b-256 checksum
How to use checksums
d4ef2a9f062470b16892ef81c5a5f173bb31dc8997f25ccec42e43753af33eea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 11, 2026.

Transparency log

Release files / opendata_b3-0.3.2-py3-none-any.whl

Download URL opendata_b3-0.3.2-py3-none-any.whl
Size 163.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
01e86d9c07833bcd66d94485a3e9bea4a3d960c52f02089f79b0ef1f39e3c16c
BLAKE2b-256 checksum
How to use checksums
5b48d4ffd2138d4c4dda6a7038bdc79fbb3692c4b1f3268cf47df1da26027ac8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 11, 2026.

Transparency log

Security for opendata-b3 0.3.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for opendata_b3-0.3.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 11, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page