Skip to main content

Package to read and process data from the CVM website.

Project description

CVM Data Reader

Overview

The CVM Data Reader is a powerful tool designed to read and process datasets from the Comissão de Valores Mobiliários (CVM). It simplifies access to financial information, making it easier for users to conduct research and financial analysis. The project supports the following data categories:

  • Companhias: ITR (Quarterly Information), DFP (Financial Statements), and more.
  • Fundos de Investimento (FI): Informe Diário, Composição e Diversificação de Aplicações.
  • Fundos de Investimento (FII): Demonstrações Financeiras, Informe Mensal, and more.

Installation

To install the package via pip, run the following command:

pip install cvm

Usage

Example: Fetching FI Static and Historical Data

To fetch data, you can use the following methods:

  • fetch_historical_data(dataset_name, start_date, end_date) for panel datasets.
  • fetch_static_data(dataset_name) for static datasets.

Available Datasets

  • cadastro (registration)
  • extrato (statement)
  • registro_fundo_classe (fund class registration)
  • informe_diario (daily report)
  • composicao_diversificacao (composition and diversification)
  • balancete (trial balance)
  • perfil_mensal (monthly profile)
import cvm

# Create an instance of FI datasets
fi = cvm.FI()

# Fetch static data (e.g., cadastro)
fi.fetch_static_data("cadastro")

# Fetch historical data (e.g., informe_diario)
fi.fetch_historical_data("informe_diario", "2024-11-05", "2024-12-23")

The fetched datasets become attributes of the FI instance. For example:

# Display the first few rows of Informe Diário data
print(fi.informe_diario.inf_diario_fi.head())

Informe Diário Example

Handling Large Data with Parsers

For long historical data, memory issues may arise. In such cases, you can apply a parser function to filter data as it is being read. Here’s an example of filtering by specific CNPJs:

list_cnpjs = [
    "37.916.879/0001-26",  # DYNAMO COUGAR MASTER FIA
    "11.188.572/0001-62",  # ATMOS MASTER FIA
    "06.964.937/0001-63",  # OPPORTUNITY SELECTION MASTER FIA
]

# Fetch data with a parser function to filter by CNPJ
fi.fetch_historical_data(
    "composicao_diversificacao",
    "2024-01-31",
    "2024-03-31",
    parser=lambda df: (
        df[df["CNPJ_FUNDO_CLASSE"].isin(list_cnpjs)]
        if "CNPJ_FUNDO_CLASSE" in df.columns
        else df
    ),
)

In this example, only the specified CNPJs are retained in the dataset.


Contributing

We welcome contributions! To contribute:

  1. Fork the repository.
  2. Create a new branch: git checkout -b feature/your-feature-name.
  3. Commit changes: git commit -m "Add your feature".
  4. Push to your branch: git push origin feature/your-feature-name.
  5. Open a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.


Contact

If you encounter issues or have feedback, feel free to open an issue or reach out via the repository’s discussions tab.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cvmpy-0.1.0.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

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

cvmpy-0.1.0-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file cvmpy-0.1.0.tar.gz.

File metadata

  • Download URL: cvmpy-0.1.0.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.7

File hashes

Hashes for cvmpy-0.1.0.tar.gz
Algorithm Hash digest
SHA256 09b57e00e51fcaa63d49ff02ca4dbfcf3417774326e70a2779903effb975c6f1
MD5 6fe3a7bf922d5ee1a2b06330e11dc050
BLAKE2b-256 56e43673f0d7cdcacd0289ae74672aa35c1e03ad623b6944ea77c3f8584108e3

See more details on using hashes here.

File details

Details for the file cvmpy-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: cvmpy-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.7

File hashes

Hashes for cvmpy-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 93041b5712fc16f8d50cd563d66677ff41e7d94c6a1560a3111bb79e227d6f03
MD5 017d1505bdcf07f12ae7efc863a56acf
BLAKE2b-256 24b2eb0c6d07102cbef02c4e38dac87e719e1c04d2bc2b8a83704655b77cdfc1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page