def populate_shares(sys): year = None if len(sys.argv) > 1: arguments = eval(sys.argv[1]) year = int(arguments['year']) globals()['year'] = year globals()['infos'] = {} if year == None: shares = bovespa.shares() else: shares = fundamentus.shares(year) shares = shares[shares['Cotação'] > 0] shares = shares[shares['Liquidez 2 meses'] > 500] shares['Ranking'] = 0 fill_infos(shares) shares = add_ratings(shares) shares = reorder_columns(shares) return shares
# 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()