Skip to main content

pyrsb3

Arquivos públicos da B3 em Arrow — parser estrito do COTAHIST com preços em centavos inteiros, em Rust. B3 (Brazilian stock exchange) public files as Arrow: a strict COTAHIST parser with integer-cent prices, in Rust.

Bindings Python do crate rsb3. O parser, o download com cache e a escrita Parquet são do crate; este pacote só converte, e entrega o resultado como pyarrow.Table pela Arrow C Data Interface, sem cópia. O GIL é solto enquanto o Rust trabalha.

pip install pyrsb3
import datetime as dt
import pyarrow.compute as pc
import rsb3

table = rsb3.load(2025, cache_dir="data")          # download + cache + SHA-256 + manifesto + parse
petr4 = table.filter(pc.field("symbol") == "PETR4")
petr4.to_pandas()                                   # ou polars.from_arrow(petr4)

rsb3.load((2026, 9), "data")                        # arquivo mensal
rsb3.load(dt.date(2026, 10, 28), "data")            # arquivo diário
rsb3.to_parquet(table, "cotahist_2025.parquet")     # Parquet no esquema v1

Três decisões do crate valem aqui:

  1. O esquema é o contrato. rsb3.schema() é o esquema Arrow versionado (v1, 25 colunas, congelado): mudança de esquema gera versão nova.
  2. Preços são inteiros em centavos (open_cents, close_cents, …). Converter para float é decisão sua, nunca do parser.
  3. Nenhuma linha é descartada em silêncio. Largura errada, tipo de registro desconhecido ou arquivo truncado levantam rsb3.LayoutError; campo inválido levanta rsb3.RecordError; as duas com o número da linha.

API

Função O que faz
fetch(period, cache_dir="data") -> str baixa o ZIP oficial (ou reaproveita o cache) e devolve o caminho do TXT
parse(path) -> pyarrow.Table TXT posicional → Arrow
parse_bytes(data) -> pyarrow.Table idem, de bytes em memória
load(period, cache_dir="data") -> pyarrow.Table fetch + parse
to_parquet(table_or_batches, path) Parquet Snappy, exigindo o esquema v1
schema() -> pyarrow.Schema o contrato
file_name(period) -> str nome oficial do ZIP, como publicado pela B3

period é 2025 (anual), (2025, 6) (mensal) ou datetime.date (diário). CRATE_VERSION diz qual versão do rsb3 está compilada no pacote.

Validação

O crate é testado diferencialmente contra o pacote R {rb3} (rOpenSci), nas 25 colunas, sobre o ano de 2025 completo (3.174.698 linhas). Os testes deste pacote cobrem a conversão: esquema, nulls, exceções e o roundtrip Parquet.

uv venv -p 3.12 .venv && uv pip install -p .venv maturin pytest pyarrow
.venv/bin/maturin develop --release
.venv/bin/pytest                 # -m network inclui um download oficial

Licença

MIT.

Metadata

Release files for pyrsb3 0.1.0

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

Source distribution (sdist)

Source distribution for pyrsb3 0.1.0
File Size Uploaded Provenance Actions
pyrsb3-0.1.0.tar.gz 28.5 kB With provenance Details for pyrsb3-0.1.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for pyrsb3 0.1.0
File Actions
pyrsb3-0.1.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details for pyrsb3-0.1.0-cp310-abi3-win_amd64.whl
pyrsb3-0.1.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details for pyrsb3-0.1.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
pyrsb3-0.1.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details for pyrsb3-0.1.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
pyrsb3-0.1.0-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details for pyrsb3-0.1.0-cp310-abi3-macosx_11_0_arm64.whl
pyrsb3-0.1.0-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details for pyrsb3-0.1.0-cp310-abi3-macosx_10_12_x86_64.whl

Total release size: 18.9 MB

Release files / pyrsb3-0.1.0.tar.gz

Download URL pyrsb3-0.1.0.tar.gz
Size 28.5 kB
Tags Source
SHA-256 checksum
How to use checksums
34c7e1184d6577776f387d7b4b0664efac1f9dd3e43341a27faae8fb585d7183
BLAKE2b-256 checksum
How to use checksums
ca8fccab8e548cccd6776b31892662d004fa7ca637fb6a7f6b354dad2d8c9658
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 Oct 29, 2026.

Transparency log

Release files / pyrsb3-0.1.0-cp310-abi3-win_amd64.whl

Download URL pyrsb3-0.1.0-cp310-abi3-win_amd64.whl
Size 3.7 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
25f55dd047e2633d8557e0f1a9920713a5e0e5045fbb8a2b7ba9b3bf97e73a85
BLAKE2b-256 checksum
How to use checksums
02f25caa7ff9cd6aed33f11965f52ca30076e35e24835450b84421c6ef1df6db
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 Oct 29, 2026.

Transparency log

Release files / pyrsb3-0.1.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL pyrsb3-0.1.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 4.0 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
447a7e1ae9588b3abc49aded62cadbb9b04b3a0ddf25b030bbb03a8b65dac4c3
BLAKE2b-256 checksum
How to use checksums
06f75b575fe2dd83d738ae4e05f4c291f63207eaef49e326abd1bb70c4a1044a
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 Oct 29, 2026.

Transparency log

Release files / pyrsb3-0.1.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL pyrsb3-0.1.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 3.7 MB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
35a45642ffb48a112d6424f4f4d788ac0c56d2fc07d98a263981ffc5214d045d
BLAKE2b-256 checksum
How to use checksums
bd5b105caa0b021ab86bd831b574ad6e72dca769c89080064d284f26c05e2d63
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 Oct 29, 2026.

Transparency log

Release files / pyrsb3-0.1.0-cp310-abi3-macosx_11_0_arm64.whl

Download URL pyrsb3-0.1.0-cp310-abi3-macosx_11_0_arm64.whl
Size 3.6 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
97c44e00cccea631ba44aef69eeb3fe64a800b0f066b68fb4622c2d2f0f043c1
BLAKE2b-256 checksum
How to use checksums
6956dc96b0c7da3de66cafe77fa4cdec944cc96c7514bb56916db3d9b38ccb30
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 Oct 29, 2026.

Transparency log

Release files / pyrsb3-0.1.0-cp310-abi3-macosx_10_12_x86_64.whl

Download URL pyrsb3-0.1.0-cp310-abi3-macosx_10_12_x86_64.whl
Size 3.9 MB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
5ab6a2bf71ec95b5b5107d5899d1c45c4625d56251e84687bbbbe5ebf96146bd
BLAKE2b-256 checksum
How to use checksums
ae04a23073a32b2d794b9118d37f0ed03fa68d0cb4e77aaaf5fabff225f356e9
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 Oct 29, 2026.

Transparency log

Security for pyrsb3 0.1.0

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

All 6 files in this release have been uploaded with provenance metadata.

Select from 6 files

Attestation for pyrsb3-0.1.0.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 Oct 29, 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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

6 release files Full provenance

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