Skip to main content

Calculates fundamental analysis indicators of Brazilian companies

Project description

About

ibr is a Python library that calculates fundamental analysis indicators of Brazilian companies registered at CVM.

The reason for creating this library is that CVM things must belong to the cvm library, whereas fundamental analysis indicators, insofar they are something greater than CVM, should be separated.

Moreover, valuation indicators depend on market data, which is beyond CVM's responsibility, since CVM is not a stock exchange.

Usage

Financial Indicators

The code below opens a DFP/ITR document and shows financial indicators of companies in that document:

import ibr

for result in ibr.reader('/path/to/dfp_or_itr.zip', (ibr.Indebtedness, ibr.Profitability, ibr.Efficiency)):
    indebtedness, profitability, efficiency = result.indicators

    print('----------------------------')
    print('Company:', result.dfpitr.company_name)
    
    print('\nIndebtedness:')
    print(indebtedness)
    
    print('\nEfficiency:')
    print(efficiency)
    
    print('\nProfitability:')
    print(profitability)

Valuation Indicators

As for valuation indicators, they need market data. Since market data is not provided in a DFP/ITR file, because this is beyond CVM's scope, such data must be obtained from the internet or some other source.

For that, the library ibr provides a class YfinanceValuation, which is based on the libraries b3 and yfinance:

import ibr

for result in ibr.reader('/path/to/dfp_or_itr.zip', [ibr.YfinanceValuation]):
    print('------------------')
    print('Company:', result.dfpitr.company_name)
    
    valuations = result.indicators[0]

    for valuation in valuations:
        print('\nValuation:')
        print(valuation)

Note that valuation indicators return a list, because it is possible that a company has more than one security. An example is the company Eletrobrás, which has three securities on B3: ELET3, ELET5 e ELET6. Since each security results in different valuation indicators, valuations would have 3 objects for company Eletrobrás.

Another point is that using YfinanceValuation is very slow. This is because the library yfinance takes a while to retrieve the shares outstanding of a company, which is required for calculation.

Examples

More elaborated examples of usage are in the directory samples:

python -m samples.financial '/path/to/dfp_or_itr.zip'
python -m samples.valuation '/path/to/dfp_or_itr.zip'

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

pyibr-0.1.1.tar.gz (26.4 kB view hashes)

Uploaded Source

Built Distribution

pyibr-0.1.1-py3-none-any.whl (8.2 kB view hashes)

Uploaded Python 3

Supported by

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