Esempio n. 1
0
# Chame a função main de acordo com qual formula você quer aplicar: roe OU roic
# Formula ROE:  Utiliza ROE  e P/L
# Formula ROIC: Utiliza ROIC e EV/EBIT (EV/EBITDA não tem no fundamentus)
# ================ Exemplos ================
# python3 greenblatt.py "{ 'formula': 'ROE', 'year': 2013 }"
if __name__ == '__main__':
    from waitingbar import WaitingBar
    progress_bar = WaitingBar('[*] Calculating...')

    year = None
    formula = None
    if len(sys.argv) > 1:
        arguments = eval(sys.argv[1])
        year = int(arguments.get('year', None))
        formula = arguments.get('formula', None)

    if year == None:
        shares = bovespa.shares()
    else:
        shares = fundamentus.get_data(year)

    shares = setup(shares, formula, year)

    shares.sort_values(by=['Magic Formula', 'Cotação'],
                       ascending=[True, True],
                       inplace=True)

    backtest.display_shares(shares, year)

    progress_bar.stop()
Esempio n. 2
0
    try:
        sg = SendGridAPIClient(os.environ.get('SENDGRID_API_KEY'))
        response = sg.send(message)
        print(response.status_code)
    except Exception as e:
        print("Deu erro na hora de enviar o email", str(e))


try:
    if __name__ == '__main__':
        from waitingbar import WaitingBar

        THE_BAR = WaitingBar('[*] Downloading...')

        lista = get_data()
        THE_BAR.stop()
        # print("Get all stocks data")

        #Transform em uma lista, agora preciso passar para formato JSON
        array_format = list(lista.items())

        # print(array_format, len(array_format))

        hashes_list = []
        # First include the list of all hashes
        for i in range(0, len(array_format)):
            hashes_list.append(array_format[i][1])

        stocks = []
        # Then from a list of hashes we will transform to a list of stocks
        for i in range(0, len(hashes_list)):
Esempio n. 3
0
def output(lst):
    ranked = rank(lst)

    print('{0:<7} {1:<10} {2:<7} {3:<10} {4:<10} {5:<10}'.format(
        'Papel',
        'EV/EBIT',
        'ROIC',
        'EV/EBIT Rank',
        'ROIC Rank',
        'Final Rank'
    ))

    for item in ranked:
        print('{0:<7} {1:<10} {2:<7} {3:<10} {4:<10} {5:<10}'.format(
            item['name'],
            item['ev_ebit'],
            item['roic'],
            item['ev_ebit_rank'],
            item['roic_rank'],
            item['final_rank'],
        ))

if __name__ == '__main__':
    from waitingbar import WaitingBar
    
    THE_BAR = WaitingBar('[*] Downloading...')
    lst = get_data()
    THE_BAR.stop()
    
    output(lst)