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 nove 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.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.

🔗 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

filings_b3-0.2.0.tar.gz (78.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

filings_b3-0.2.0-py3-none-any.whl (128.0 kB view details)

Uploaded Python 3

File details

Details for the file filings_b3-0.2.0.tar.gz.

File metadata

  • Download URL: filings_b3-0.2.0.tar.gz
  • Upload date:
  • Size: 78.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for filings_b3-0.2.0.tar.gz
Algorithm Hash digest
SHA256 0fa20fe27c072f7ca5c49e0535046d6cd941ebd733805a55bcfd9ed2f9a2523e
MD5 9ac41f83901caf3030b7a6601f83c17b
BLAKE2b-256 ee4a9b0b347d74b68406d008093fccfbc21178f5a51fa9093e4d58849d2e76ce

See more details on using hashes here.

Provenance

The following attestation bundles were made for filings_b3-0.2.0.tar.gz:

Publisher: release-pypi.yaml on guilhermegor/filings-b3

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file filings_b3-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: filings_b3-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 128.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for filings_b3-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 58bd0c3bf46f9ce57508efeb4723300e094259e9c7df50a7a33fbd5740b13eb6
MD5 68e4e5712d896ca0a85587bd73a1b195
BLAKE2b-256 f5a3c1331bcd891c4cd5cd650db4725625ff0691b456a2c7212ab9d2a0a3f4f1

See more details on using hashes here.

Provenance

The following attestation bundles were made for filings_b3-0.2.0-py3-none-any.whl:

Publisher: release-pypi.yaml on guilhermegor/filings-b3

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.3.5

2 files

0.3.4

2 files

0.3.3

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

0.2.1

2 files

This release

0.2.0 This release

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

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