Filings B3 
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)
BdiStocksSummaryReader— o resumo por pregão do mercado à vista de ações (DailyAverageStocks).BdiBtbLendingOpenPositionsReader— o retrato das posições em aberto de empréstimo de ativos (BTB) (BTBLendingOpenPosition).
🔒 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 umfloatbiná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())
Importar pela macro-seção (filings_b3.daily_bulletin) é a forma organizada e preferida; a
reexportação plana a partir da raiz (from filings_b3 import BdiBtbLendingOpenPositionsReader)
continua válida por retrocompatibilidade.
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.jpg
├── 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.
🔗 Links úteis
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file filings_b3-0.1.3.tar.gz.
File metadata
- Download URL: filings_b3-0.1.3.tar.gz
- Upload date:
- Size: 55.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e391346fabf890575110e032632aaec95fdaf9641533c5325baf6916ce9702d
|
|
| MD5 |
57420ce8616fd31ac52beb450f9d6aee
|
|
| BLAKE2b-256 |
5481053f0bc13ccdc85fbabc64e817988524f41c8f0df30b1cecc97bd57774fe
|
Provenance
The following attestation bundles were made for filings_b3-0.1.3.tar.gz:
Publisher:
release-pypi.yaml on guilhermegor/filings-b3
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
filings_b3-0.1.3.tar.gz -
Subject digest:
6e391346fabf890575110e032632aaec95fdaf9641533c5325baf6916ce9702d - Sigstore transparency entry: 2254104731
- Sigstore integration time:
-
Permalink:
guilhermegor/filings-b3@4b5ade46afecfe57d5256ab7df741958044ee487 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/guilhermegor
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-pypi.yaml@4b5ade46afecfe57d5256ab7df741958044ee487 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file filings_b3-0.1.3-py3-none-any.whl.
File metadata
- Download URL: filings_b3-0.1.3-py3-none-any.whl
- Upload date:
- Size: 75.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
54451bcce9b7e7c5ec4cd8523b7dec3edae18cb0fe62fa6fc462ec2db5049383
|
|
| MD5 |
b9f09561d1b54d4f56a9b416a6340a39
|
|
| BLAKE2b-256 |
234ca455aa07eedb9e4ea8e084dc77d323aa5102ec7b892dc0a16d40e649fac7
|
Provenance
The following attestation bundles were made for filings_b3-0.1.3-py3-none-any.whl:
Publisher:
release-pypi.yaml on guilhermegor/filings-b3
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
filings_b3-0.1.3-py3-none-any.whl -
Subject digest:
54451bcce9b7e7c5ec4cd8523b7dec3edae18cb0fe62fa6fc462ec2db5049383 - Sigstore transparency entry: 2254104838
- Sigstore integration time:
-
Permalink:
guilhermegor/filings-b3@4b5ade46afecfe57d5256ab7df741958044ee487 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/guilhermegor
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-pypi.yaml@4b5ade46afecfe57d5256ab7df741958044ee487 -
Trigger Event:
workflow_dispatch
-
Statement type: