Git Product home page Git Product logo

fundamentus-api's Introduction

Python Fundamentus

version   pyversions license   TravisCI  Actions   Coverage  Dependabot

Python API to load data from Fundamentus website.

API usage

Main functions are named after each website functionality:

A specific list function is built from the following setor parameter:

Examples

get_resultado

Return: -> DataFrame

>>> import fundamentus
>>> df = fundamentus.get_resultado()
>>> print(df.columns)

  Index(['cotacao', 'pl', 'pvp', 'psr', 'dy', 'pa', 'pcg', 'pebit', 'pacl',
         'evebit', 'evebitda', 'mrgebit', 'mrgliq', 'roic', 'roe', 'liqc',
         'liq2m', 'patrliq', 'divbpatr', 'c5y'],
        dtype='object', name='Multiples')

>>> print( df[ df.pl > 0] )

    papel   cotacao     pl   pvp  ...  divbpatr     c5y
    ABCB4     15.81   9.66  0.83  ...      0.00 -0.5287
    ABEV3     15.95  28.87  3.22  ...      0.09  0.0455
    AEDU11    37.35  20.13  1.13  ...      0.30  0.2090
    ...         ...    ...   ...  ...       ...     ...
    WIZS3      7.95   5.96  3.61  ...      0.00  0.1737
    WSON33    45.45  34.29  1.34  ...      1.11  0.0131
    YDUQ3     33.26  39.71  3.10  ...      1.45  0.0449

Columns names were simplified from the original web page to allow DataFrame filtering in a simplified way:

# filter on DataFrame
df = df[ df.pl  > 0   ]
df = df[ df.pl  < 100 ]
df = df[ df.pvp > 0   ]

get_resultado_raw

Return: -> DataFrame

>>> import fundamentus
>>> df = fundamentus.get_resultado_raw()
>>> print(df.columns)

Index(['Cotação', 'P/L', 'P/VP', 'PSR', 'Div.Yield', 'P/Ativo', 'P/Cap.Giro',
       'P/EBIT', 'P/Ativ Circ.Liq', 'EV/EBIT', 'EV/EBITDA', 'Mrg Ebit',
       'Mrg. Líq.', 'Liq. Corr.', 'ROIC', 'ROE', 'Liq.2meses', 'Patrim. Líq',
       'Dív.Brut/ Patrim.', 'Cresc. Rec.5a'],
      dtype='object', name='Multiples')

>>> print( df[ df['P/L'] > 0] )

    papel   Cotação    P/L  P/VP  ...  Dív.Brut/ Patrim.  Cresc. Rec.5a
    ABCB4     15.81   9.66  0.83  ...               0.00        -0.5287
    ABEV3     15.95  28.87  3.22  ...               0.09         0.0455
    AEDU11    37.35  20.13  1.13  ...               0.30         0.2090
    ...         ...    ...   ...  ...                ...            ...
    WIZS3      7.95   5.96  3.61  ...               0.00         0.1737
    WSON33    45.45  34.29  1.34  ...               1.11         0.0131
    YDUQ3     33.26  39.71  3.10  ...               1.45         0.0449

In the _raw function, columns names are preserved as captured from the web page. Be aware that names are in pt-br and contain spaces and accents. Filtering must be made explicitly:

# filter on DataFrame
df = df[ df['P/L'] > 0   ]
df = df[ df['P/L'] < 100 ]
df = df[ df['P/VP'] > 0  ]

The renaming list can be found here.

get_papel

Return: -> DataFrame

>>> import fundamentus

>>> df = fundamentus.get_papel('WEGE3')  ## or...
>>> df = fundamentus.get_papel(['ITSA4','WEGE3'])

>>> print(df)

        Tipo       Empresa        Setor ... Receita_Liquida_3m    EBIT_3m Lucro_Liquido_3m
ITSA4  PN N1  ITAÚSA PN N1  Financeiros ...         1778000000  257000000       1784000000
WEGE3  ON N1  WEG SA ON N1  Máquinas e  ...         4801260000  946670000        644246000

list_papel_setor

Return: -> list

>>> import fundamentus

>>> fin = fundamentus.list_papel_setor(35)  # finance
>>> seg = fundamentus.list_papel_setor(38)  # seguradoras

>>> print(fin)
   ['ABCB4', 'BBAS3', 'BBDC3', 'BBDC4', ... ]

>>> print(seg)
   ['BBSE3', 'IRBR3', 'SULA4', 'WIZS3', ... ]

The full list of companies by setor can be found here

License

The MIT License (MIT)

fundamentus-api's People

Contributors

dependabot-preview[bot] avatar mv avatar phoemur avatar victorcorcos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

fundamentus-api's Issues

Dados desatualizados

Estou usando a lib hj 12/10/2023, mas os dados que estão sendo carregados são da data de 23/09/2023

Ausência de ponto separando casas decimais em múltiplos de papeis individuais

Prezado Marcos,

antes de tudo, parabéns pelo excelente trabalho. Eu abri esta issue pois ao pegar múltiplos de um determinado papel, o mesmo vem sem o ponto separando as casas decimais. Por exemplo, ao executar

acao = fundamentus.get_papel('MGLU3')

E em seguida:

acao.PL

o resultado é -50319, enquanto deveria ser -503.19

Ao se trabalhar com o método fundamentus.get_resultado(), o resultado aparece corretamente separado por vírgula (-503.19), como no exemplo abaixo.

acoes = fundamentus.get_resultado()
acoes[acoes.index == 'MGLU3'].pl

Desejo sucesso em seu trabalho!

Warning ao rodar o código

Primeiramente, parabéns pelo código e obrigado por disponibiliza-lo a comunidade.

Essa Issue é um aviso que não gera consequências no momento, além de poluir o terminal, mas provavelmente gerará no futuro.

Ao rodar o comando

fundamentus.get_papel('WEGE3')

recebo o seguinte FutureWarning, avisando que uma implementação será removida em versão futura e o código ficará quebrado:

2024-01-01 12:38:46,386 [detalhes.get_papel] INFO: detalhes: call: get..._papel()
C:\Users{omitido}\detalhes.py:232: FutureWarning: Passing literal html to 'read_html' is deprecated and will be removed in a future version. To read from a literal string, wrap it in a 'StringIO' object.
tables_html = pd.read_html(content.text, decimal=",", thousands='.')

Carregamento de lista de papéis lento

Ao fazer uma consulta a uma lista de papéis, são feitas múltiplas requisições de maneira sequencial, o que demora, dependendo da lista.

Sugestão: utilizar a API threadpoolexecutor para fazer as requisições em paralelo, otimizando o tempo de busca. Essa alternativa seria substitutiva ao atual processo que utiliza a iteração usando for.

Indicadores financeiros de anos anteriores

Boa noite. Primeiramente, gostaria de parabenizar o Fundamentus por tornas acessível os indicadores das empresas por meio desse biblioteca.

Uma dúvida: há alguma forma de recuperar indicadores de anos anteriores? Por exemplo: recuperar o P/L de uma empresa no ano de 2020.

Obrigado.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.