Filings B3 
Simple and efficient Python library to interact with B3 (Brazil's exchange) public datasets.
Each reader turns one trading session into a typed, contract-validated pandas.DataFrame
carrying provenance — money as exact Decimal, never a lossy float.
✨ Key Features
📊 Daily Bulletin (BDI) readers
BdiStocksSummaryReader— the per-session cash-equities summary (DailyAverageStocks).BdiBtbLendingOpenPositionsReader— the securities-lending (BTB) open-position snapshot (BTBLendingOpenPosition).
🔒 Fidelity by construction
- Explicit typing — every column typed on load, never pandas' inference.
- Exact decimals — money and any value whose fractional part matters is
decimal.Decimal, never a binaryfloat. - Contracts — a source that drops a required column fails loudly with
ContractError, verified against B3's own published layouts.
🧾 Provenance & bronze layer
- Six provenance columns on every frame (
url,updated_at,source_key,package_version,ingestion_run_id,content_hash). - Pass
path_raw=to retain each untouched source page for a datalake's bronze layer.
🚀 Getting Started
Prerequisites
- Python 3.10+
- Poetry (recommended)
- Optional: Makefile
Installation
Option 1: Pip (recommended)
pip install filings-b3
Option 2: Build from source
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
Basic usage
from datetime import date
from filings_b3 import BdiBtbLendingOpenPositionsReader
df = BdiBtbLendingOpenPositionsReader(date(2025, 1, 2)).read()
print(df[["TCKR_SYMB", "STOCK_BALANCE", "BALANCE"]].head())
date_ref is required — the BDI endpoint is date-addressed, so there is no "latest"
default. See the documentation for every reader
and more recipes.
Running Tests
poetry run pytest tests/unit/ -v
poetry run pytest tests/integration/ -v
📂 Project Structure
filings-b3/
├── .github/
│ ├── workflows/
│ ├── CODEOWNERS
│ └── PULL_REQUEST_TEMPLATE.md
├── assets/
│ └── b3-logo.jpg
├── bin/
├── docs/
├── src/filings_b3/
│ ├── daily_bulletin/ # Boletim Diário do Pregão (BDI) readers
│ ├── search_trading_session/ # Pesquisa por Pregão readers
│ └── _internal/ # private: contracts, utils, ports
├── tests/
│ ├── unit/
│ ├── integration/
│ └── performance/
├── LICENSE
├── Makefile
├── poetry.lock
├── pyproject.toml
├── README.md
└── requirements.txt
👨💻 Authors
📜 License
This project is licensed under the MIT License — see LICENSE.
🔗 Useful Links
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.2.tar.gz.
File metadata
- Download URL: filings_b3-0.1.2.tar.gz
- Upload date:
- Size: 54.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5ee3b055bd75fbec95d0b2535e55dc9cf1000ee68ec150b75c5af6ede3da6112
|
|
| MD5 |
c5aeb63b2c5657d400072a43ce5125b0
|
|
| BLAKE2b-256 |
dbd89e079f3702d5dcdc323310b17ed4bced7980dbd602efe15bd52e4bf32c90
|
Provenance
The following attestation bundles were made for filings_b3-0.1.2.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.2.tar.gz -
Subject digest:
5ee3b055bd75fbec95d0b2535e55dc9cf1000ee68ec150b75c5af6ede3da6112 - Sigstore transparency entry: 2241833400
- Sigstore integration time:
-
Permalink:
guilhermegor/filings-b3@bf8d7e54e70df81b697c832853871210946114fc -
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@bf8d7e54e70df81b697c832853871210946114fc -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file filings_b3-0.1.2-py3-none-any.whl.
File metadata
- Download URL: filings_b3-0.1.2-py3-none-any.whl
- Upload date:
- Size: 75.5 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 |
41f63242b42870f87e2c7e1f1b06bf387e4e05e37262246375d0863dc41ceea8
|
|
| MD5 |
601416440794fb38f1b5a27527124495
|
|
| BLAKE2b-256 |
489508510df5dbda839f85d32a9fcbb77126223be352339df798997491697f11
|
Provenance
The following attestation bundles were made for filings_b3-0.1.2-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.2-py3-none-any.whl -
Subject digest:
41f63242b42870f87e2c7e1f1b06bf387e4e05e37262246375d0863dc41ceea8 - Sigstore transparency entry: 2241833855
- Sigstore integration time:
-
Permalink:
guilhermegor/filings-b3@bf8d7e54e70df81b697c832853871210946114fc -
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@bf8d7e54e70df81b697c832853871210946114fc -
Trigger Event:
workflow_dispatch
-
Statement type: