glourencoffee / pycvm

Python library for processing data from CVM
MIT License
2 stars 0 forks source link

Error reading DFP/ITR statements: missing BPA/DRE #14

Closed glourencoffee closed 2 years ago

glourencoffee commented 2 years ago

Description

Reading DFP/ITR documents shows many failure messages of missing BPA and DRE statements.

Steps to reproduce

  1. Download the DFP/2010
  2. Create reader with cvm.dfpitr_reader()
  3. Iterate through reader until exhaustion
  4. See messages

Expected behavior

There should be no missing BPA or DRE, since these statements are required by CVM.

Actual behavior

Reading the DFP/2010 in a simple program that prints company names and versions results in the following messages being shown:

BCO BRASIL S.A. - version: 1
BCO BRASIL S.A. - version: 2
BCO BRASIL S.A. - version: 3
BRB BCO DE BRASILIA S.A. - version: 1
failed to read DFP statements from document #6775 ('BRB BCO DE BRASILIA S.A.' version 2): 'missing BPA'
...
SANESALTO SANEAMENTO S.A. - version: 1
failed to read DFP statements from document #10351 ('SANESALTO SANEAMENTO S.A.' version 2): 'missing BPA'
...
CETIP S.A. - BALCÃO ORGANIZADO DE ATIVOS E DERIVATIVOS - version: 1
failed to read DFP statements from document #5251 ('BERNA PARTICIPAÇÕES SA' version 1): 'missing DRE'
...
failed to read DFP statements from document #7251 ('PETRO RIO S.A.' version 3): 'missing DRE'
failed to read DFP statements from document #10261 ('VIARONDON CONCESSIONÁRIA DE RODOVIA S.A.' version 1): 'missing DRE'
CONC ROTA DAS BANDEIRAS S.A. - version: 1
failed to read DFP statements from document #5366 ('CONC ROTA DAS BANDEIRAS S.A.' version 2): 'missing DRE'
failed to read DFP statements from document #14743 ('CONC RODOVIAS DO TIETÊ S.A.- EM RECUPERAÇÃO JUDICIAL' version 1): 'missing DRE'
failed to read DFP statements from document #7066 ('ECO SECURITIZADORA DIREITOS CRED AGRONEGÓCIO S.A.' version 1): 'missing DRE'
failed to read DFP statements from document #6041 ('BRAZAL BRASIL ALIMENTOS SA' version 1): 'missing DRE'
CIA ENERGETICA DE PERNAMBUCO - CELPE - version: 1
...
glourencoffee commented 2 years ago

Analyzing the CSV file of BPA and DRE statements for the DFP of 2010, I noticed those messages are shown for statements that only have accounts for the last financial year. That is, while some statements have accounts for both the last and the previous financial years, some others only have for the last financial year, which is when the bug occurs.

It is possible that this bug was introduced with the refactoring implemented in commit 5a8c0178ee7d86638a6ea314c06e6bfa2ec172fd.

glourencoffee commented 2 years ago

Although BPA, BPP, DRE, and DFC statements are required by CVM, it seems there are side cases where companies will not report it. Among reasons for not reporting them are (1) having no financial movements in a period and (2) being a new company, and thus having no balances for the last period. This is the case with the following companies for the year of 2011:

the following companies for the year of 2014:

the following companies for the year of 2015:

the following company for the year of 2017:

the following companies for the year of 2018:

In some cases, CSV files have some statements while missing others, whereas the RAD webpage for a company's DFP shows no individual statements at all. It also happens for a company to have a statement filled with zero balances, while missing other statements. For example, in the year of 2018, "GP INVESTMENTS, LTD." reported an individual BPP filled with zeros, but reported no individual BPA.

glourencoffee commented 2 years ago

Although this bug has been fixed, messages "missing BPA" or "missing BPP" may still occur in cases when a company does not have a balance sheet of the previous year (such as for being a new company), as explained in the previous comment.

Another hidden bug fixed on this issue is that consolidated statements were being ignored if individual statements failed to be read. This is not the case anymore: if individual statements fail to be read, consolidated statements can still be read, and vice-versa.