diff --git a/openbb_terminal/helper_funcs.py b/openbb_terminal/helper_funcs.py index 8a9e03c17e8..91b62c5fde0 100644 --- a/openbb_terminal/helper_funcs.py +++ b/openbb_terminal/helper_funcs.py @@ -1375,3 +1375,29 @@ def handle_error_code(requests_obj, error_code_map): for error_code, error_msg in error_code_map.items(): if requests_obj.status_code == error_code: console.print(error_msg) + + +def camel_case_split(string: str) -> str: + """Converts a camel case string to separate words + + Parameters + ---------- + string : str + The string to be converted + + Returns + ---------- + new_string: str + The formatted string + """ + + words = [[string[0]]] + + for c in string[1:]: + if words[-1][-1].islower() and c.isupper(): + words.append(list(c)) + else: + words[-1].append(c) + + results = ["".join(word) for word in words] + return " ".join(results).title() diff --git a/openbb_terminal/stocks/fundamental_analysis/av_view.py b/openbb_terminal/stocks/fundamental_analysis/av_view.py index 1e9b6762530..7fe8b95fb88 100644 --- a/openbb_terminal/stocks/fundamental_analysis/av_view.py +++ b/openbb_terminal/stocks/fundamental_analysis/av_view.py @@ -13,6 +13,7 @@ from openbb_terminal.helper_funcs import ( export_data, print_rich_table, plot_autoscale, + camel_case_split, ) from openbb_terminal.rich_config import console from openbb_terminal.stocks.fundamental_analysis import av_model @@ -91,6 +92,10 @@ def display_income_statement( if df_income.empty: return + indexes = df_income.index + new_indexes = [camel_case_split(ind) for ind in indexes] + df_income.index = new_indexes + print_rich_table( df_income, headers=list(df_income.columns), @@ -125,6 +130,10 @@ def display_balance_sheet( if df_balance.empty: return + indexes = df_balance.index + new_indexes = [camel_case_split(ind) for ind in indexes] + df_balance.index = new_indexes + print_rich_table( df_balance, headers=list(df_balance.columns), @@ -161,6 +170,10 @@ def display_cash_flow( if df_cash.empty: return + indexes = df_cash.index + new_indexes = [camel_case_split(ind) for ind in indexes] + df_cash.index = new_indexes + print_rich_table( df_cash, headers=list(df_cash.columns), diff --git a/tests/openbb_terminal/stocks/fundamental_analysis/txt/test_av_view/test_check_output[True-display_balance_sheet-kwargs_dict4].txt b/tests/openbb_terminal/stocks/fundamental_analysis/txt/test_av_view/test_check_output[True-display_balance_sheet-kwargs_dict4].txt index 3b29cf08978..e2a9ee10e90 100644 --- a/tests/openbb_terminal/stocks/fundamental_analysis/txt/test_av_view/test_check_output[True-display_balance_sheet-kwargs_dict4].txt +++ b/tests/openbb_terminal/stocks/fundamental_analysis/txt/test_av_view/test_check_output[True-display_balance_sheet-kwargs_dict4].txt @@ -1,39 +1,39 @@ -fiscalDateEnding 2020-12-31 2021-03-31 2021-06-30 2021-09-30 2021-12-31 -reportedCurrency USD USD USD USD USD -totalAssets 52.148 B 52.972 B 55.146 B 57.834 B 62.131 B -totalCurrentAssets 26.717 B 24.705 B 24.693 B 25.002 B 27.100 B -cashAndCashEquivalentsAtCarryingValue 19.384 B 17.141 B 16.229 B 16.065 B 17.576 B -cashAndShortTermInvestments 19.384 B 17.141 B 16.229 B 16.095 B 17.707 B -inventory 4.101 B 4.132 B 4.733 B 5.199 B 5.757 B -currentNetReceivables 1.895 B 1.900 B 2.140 B 1.973 B 1.924 B -totalNonCurrentAssets 18.134 B 17.884 B 19.781 B 21.886 B 25.281 B -propertyPlantEquipment 12.747 B 13.868 B 15.665 B 17.298 B 18.884 B -accumulatedDepreciationAmortizationPPE 5.117 B 5.389 B 5.824 B 6.232 B 6.731 B -intangibleAssets 520 M 505 M 486 M 470 M 457 M -intangibleAssetsExcludingGoodwill 313 M 299 M 283 M 269 M 257 M -goodwill 207 M 206 M 203 M 201 M 200 M -investments None None None 30 M 131 M -longTermInvestments None 1.331 B 1.311 B 1.260 B None -shortTermInvestments None None None 30 M 131 M -otherCurrentAssets 1.346 B 1.542 B 1.602 B 1.746 B 1.723 B -otherNonCurrrentAssets 1.536 B 1.587 B 1.626 B 1.854 B 2.138 B -totalLiabilities 28.418 B 28.507 B 28.896 B 29.340 B 30.548 B -totalCurrentLiabilities 14.248 B 14.877 B 16.371 B 18.051 B 19.705 B -currentAccountsPayable 6.051 B 6.648 B 7.558 B 8.260 B 10.025 B -deferredRevenue 4.668 B 4.886 B 5.141 B 5.386 B 5.881 B -currentDebt 1.758 B 1.415 B 1.082 B 1.207 B 1.088 B -shortTermDebt 1.384 B 1.011 B 634 M 698 M 587 M -totalNonCurrentLiabilities 6.962 B 6.941 B 7.054 B 7.479 B 8.260 B -capitalLeaseObligations 1.094 B 1.034 B 993 M 999 M 991 M -longTermDebt 8.462 B 8.019 B 6.878 B 5.439 B 4.254 B -currentLongTermDebt 2.132 B 1.415 B 1.082 B 1.716 B 1.088 B -longTermDebtNoncurrent None None None None None -shortLongTermDebtTotal 9.846 B 9.030 B 7.512 B 6.137 B 4.841 B -otherCurrentLiabilities 264 M 273 M 292 M 301 M 294 M -otherNonCurrentLiabilities 3.330 B 3.283 B 3.336 B 3.486 B 3.546 B -totalShareholderEquity 22.225 B 23.017 B 24.804 B 27.053 B 30.189 B -treasuryStock None None None None None -retainedEarnings -5.399 B -4.750 B -3.608 B -1.990 B 331 M -commonStock 1 M 1 M 1 M 1 M 1 M -commonStockSharesOutstanding 960 M 963 M 984 M 1.004 B 1.033 B +fiscalDateEnding 2020-12-31 2021-03-31 2021-06-30 2021-09-30 2021-12-31 +Reported Currency USD USD USD USD USD +Total Assets 52.148 B 52.972 B 55.146 B 57.834 B 62.131 B +Total Current Assets 26.717 B 24.705 B 24.693 B 25.002 B 27.100 B +Cash And Cash Equivalents At Carrying Value 19.384 B 17.141 B 16.229 B 16.065 B 17.576 B +Cash And Short Term Investments 19.384 B 17.141 B 16.229 B 16.095 B 17.707 B +Inventory 4.101 B 4.132 B 4.733 B 5.199 B 5.757 B +Current Net Receivables 1.895 B 1.900 B 2.140 B 1.973 B 1.924 B +Total Non Current Assets 18.134 B 17.884 B 19.781 B 21.886 B 25.281 B +Property Plant Equipment 12.747 B 13.868 B 15.665 B 17.298 B 18.884 B +Accumulated Depreciation Amortization Ppe 5.117 B 5.389 B 5.824 B 6.232 B 6.731 B +Intangible Assets 520 M 505 M 486 M 470 M 457 M +Intangible Assets Excluding Goodwill 313 M 299 M 283 M 269 M 257 M +Goodwill 207 M 206 M 203 M 201 M 200 M +Investments None None None 30 M 131 M +Long Term Investments None 1.331 B 1.311 B 1.260 B None +Short Term Investments None None None 30 M 131 M +Other Current Assets 1.346 B 1.542 B 1.602 B 1.746 B 1.723 B +Other Non Currrent Assets 1.536 B 1.587 B 1.626 B 1.854 B 2.138 B +Total Liabilities 28.418 B 28.507 B 28.896 B 29.340 B 30.548 B +Total Current Liabilities 14.248 B 14.877 B 16.371 B 18.051 B 19.705 B +Current Accounts Payable 6.051 B 6.648 B 7.558 B 8.260 B 10.025 B +Deferred Revenue 4.668 B 4.886 B 5.141 B 5.386 B 5.881 B +Current Debt 1.758 B 1.415 B 1.082 B 1.207 B 1.088 B +Short Term Debt 1.384 B 1.011 B 634 M 698 M 587 M +Total Non Current Liabilities 6.962 B 6.941 B 7.054 B 7.479 B 8.260 B +Capital Lease Obligations 1.094 B 1.034 B 993 M 999 M 991 M +Long Term Debt 8.462 B 8.019 B 6.878 B 5.439 B 4.254 B +Current Long Term Debt 2.132 B 1.415 B 1.082 B 1.716 B 1.088 B +Long Term Debt Noncurrent None None None None None +Short Long Term Debt Total 9.846 B 9.030 B 7.512 B 6.137 B 4.841 B +Other Current Liabilities 264 M 273 M 292 M 301 M 294 M +Other Non Current Liabilities 3.330 B 3.283 B 3.336 B 3.486 B 3.546 B +Total Shareholder Equity 22.225 B 23.017 B 24.804 B 27.053 B 30.189 B +Treasury Stock None None None None None +Retained Earnings -5.399 B -4.750 B -3.608 B -1.990 B 331 M +Common Stock 1 M 1 M 1 M 1 M 1 M +Common Stock Shares Outstanding 960 M 963 M 984 M 1.004 B 1.033 B diff --git a/tests/openbb_terminal/stocks/fundamental_analysis/txt/test_av_view/test_check_output[True-display_income_statement-kwargs_dict2].txt b/tests/openbb_terminal/stocks/fundamental_analysis/txt/test_av_view/test_check_output[True-display_income_statement-kwargs_dict2].txt index 813afee17b7..7ecf9d51542 100644 --- a/tests/openbb_terminal/stocks/fundamental_analysis/txt/test_av_view/test_check_output[True-display_income_statement-kwargs_dict2].txt +++ b/tests/openbb_terminal/stocks/fundamental_analysis/txt/test_av_view/test_check_output[True-display_income_statement-kwargs_dict2].txt @@ -1,27 +1,27 @@ -fiscalDateEnding 2020-12-31 2021-03-31 2021-06-30 2021-09-30 2021-12-31 -reportedCurrency USD USD USD USD USD -grossProfit 2.066 B 2.215 B 2.884 B 3.660 B 4.847 B -totalRevenue 10.744 B 10.389 B 11.958 B 13.757 B 17.719 B -costOfRevenue 8.678 B 8.174 B 9.074 B 10.097 B 12.872 B -costofGoodsAndServicesSold 149 M 75 M 36 M 35 M 149 M -operatingIncome 575 M 594 M 1.312 B 2.004 B 2.613 B -sellingGeneralAndAdministrative 969 M 1.056 B 973 M 994 M 1.494 B -researchAndDevelopment 522 M 666 M 576 M 611 M 740 M -operatingExpenses 1.491 B 1.621 B 1.572 B 1.656 B 2.234 B -investmentIncomeNet 6 M 10 M 11 M 10 M 25 M -netInterestIncome -246 M -99 M -75 M -126 M -71 M -interestIncome 6 M 10 M 11 M 10 M 25 M -interestExpense 246 M 99 M 75 M 126 M 71 M -nonInterestIncome -125 M -2 M 1 M -7 M -47 M -otherNonOperatingIncome 44 M 28 M 45 M -6 M 68 M -depreciation 440 M 424 M 461 M 495 M 530 M -depreciationAndAmortization 618 M 621 M 681 M 761 M 848 M -incomeBeforeTax 353 M 507 M 1.257 B 1.841 B 2.613 B -incomeTaxExpense 83 M 69 M 115 M 223 M 292 M -interestAndDebtExpense 351 M 99 M 75 M 126 M 71 M -netIncomeFromContinuingOperations 2.066 B 464 M 1.178 B 1.659 B 2.343 B -comprehensiveIncomeNetOfTax 508 M 218 M 1.205 B 1.532 B 2.255 B -ebit 599 M 606 M 1.332 B 1.967 B 2.684 B -ebitda 1.186 B 1.227 B 2.013 B 2.728 B 3.532 B -netIncome 270 M 438 M 1.142 B 1.618 B 2.321 B +fiscalDateEnding 2020-12-31 2021-03-31 2021-06-30 2021-09-30 2021-12-31 +Reported Currency USD USD USD USD USD +Gross Profit 2.066 B 2.215 B 2.884 B 3.660 B 4.847 B +Total Revenue 10.744 B 10.389 B 11.958 B 13.757 B 17.719 B +Cost Of Revenue 8.678 B 8.174 B 9.074 B 10.097 B 12.872 B +Costof Goods And Services Sold 149 M 75 M 36 M 35 M 149 M +Operating Income 575 M 594 M 1.312 B 2.004 B 2.613 B +Selling General And Administrative 969 M 1.056 B 973 M 994 M 1.494 B +Research And Development 522 M 666 M 576 M 611 M 740 M +Operating Expenses 1.491 B 1.621 B 1.572 B 1.656 B 2.234 B +Investment Income Net 6 M 10 M 11 M 10 M 25 M +Net Interest Income -246 M -99 M -75 M -126 M -71 M +Interest Income 6 M 10 M 11 M 10 M 25 M +Interest Expense 246 M 99 M 75 M 126 M 71 M +Non Interest Income -125 M -2 M 1 M -7 M -47 M +Other Non Operating Income 44 M 28 M 45 M -6 M 68 M +Depreciation 440 M 424 M 461 M 495 M 530 M +Depreciation And Amortization 618 M 621 M 681 M 761 M 848 M +Income Before Tax 353 M 507 M 1.257 B 1.841 B 2.613 B +Income Tax Expense 83 M 69 M 115 M 223 M 292 M +Interest And Debt Expense 351 M 99 M 75 M 126 M 71 M +Net Income From Continuing Operations 2.066 B 464 M 1.178 B 1.659 B 2.343 B +Comprehensive Income Net Of Tax 508 M 218 M 1.205 B 1.532 B 2.255 B +Ebit 599 M 606 M 1.332 B 1.967 B 2.684 B +Ebitda 1.186 B 1.227 B 2.013 B 2.728 B 3.532 B +Net Income 270 M 438 M 1.142 B 1.618 B 2.321 B diff --git a/tests/openbb_terminal/stocks/fundamental_analysis/txt/test_av_view/test_check_output[True-display_income_statement-kwargs_dict3].txt b/tests/openbb_terminal/stocks/fundamental_analysis/txt/test_av_view/test_check_output[True-display_income_statement-kwargs_dict3].txt index 265bf16a598..c7238bb5d27 100644 --- a/tests/openbb_terminal/stocks/fundamental_analysis/txt/test_av_view/test_check_output[True-display_income_statement-kwargs_dict3].txt +++ b/tests/openbb_terminal/stocks/fundamental_analysis/txt/test_av_view/test_check_output[True-display_income_statement-kwargs_dict3].txt @@ -1,27 +1,27 @@ -fiscalDateEnding 2017-12-31 2018-12-31 2019-12-31 2020-12-31 2021-12-31 -reportedCurrency USD USD USD USD USD -grossProfit 2.223 B 4.042 B 4.069 B 6.630 B 13.606 B -totalRevenue 11.759 B 21.461 B 24.578 B 31.536 B 53.823 B -costOfRevenue 9.536 B 17.419 B 20.509 B 24.906 B 40.217 B -costofGoodsAndServicesSold 7.797 B 85.272 M 193 M 289 M 374 M -operatingIncome -1.632 B -388 M -69 M 1.994 B 6.523 B -sellingGeneralAndAdministrative 2.477 B 2.835 B 2.646 B 3.145 B 4.517 B -researchAndDevelopment 1.378 B 1.460 B 1.343 B 1.491 B 2.593 B -operatingExpenses 3.855 B 4.430 B 4.138 B 4.636 B 7.083 B -investmentIncomeNet 19.686 M 24.533 M 44 M 30 M 56 M -netInterestIncome -471.259 M -663.071 M -685 M -748 M -371 M -interestIncome -259 K -71 K 44 M 30 M 56 M -interestExpense 471 M 663 M 685 M 748 M 371 M -nonInterestIncome 948.469 M 22.185 B -98 M -336 M -55 M -otherNonOperatingIncome -125 M 22 M 45 M -122 M 135 M -depreciation 769 M 1.110 B 1.370 B 1.570 B 1.910 B -depreciationAndAmortization 1.636 B 66 M 343 M 399 M 466 M -incomeBeforeTax -1.930 B -918 M -752 M 1.013 B 6.218 B -incomeTaxExpense 32 M 58 M 110 M 292 M 699 M -interestAndDebtExpense 471.259 M 663.071 M 685 M 853 M 371 M -netIncomeFromContinuingOperations -2.241 B -1.063 B -775 M 862 M 5.644 B -comprehensiveIncomeNetOfTax -1.905 B -1.018 B -890 M 1.120 B 5.210 B -ebit -1.459 B -255 M -67 M 1.761 B 6.589 B -ebitda 177.003 M -189 M 276 M 2.160 B 7.055 B -netIncome -1.962 B -976 M -862 M 721 M 5.519 B +fiscalDateEnding 2017-12-31 2018-12-31 2019-12-31 2020-12-31 2021-12-31 +Reported Currency USD USD USD USD USD +Gross Profit 2.223 B 4.042 B 4.069 B 6.630 B 13.606 B +Total Revenue 11.759 B 21.461 B 24.578 B 31.536 B 53.823 B +Cost Of Revenue 9.536 B 17.419 B 20.509 B 24.906 B 40.217 B +Costof Goods And Services Sold 7.797 B 85.272 M 193 M 289 M 374 M +Operating Income -1.632 B -388 M -69 M 1.994 B 6.523 B +Selling General And Administrative 2.477 B 2.835 B 2.646 B 3.145 B 4.517 B +Research And Development 1.378 B 1.460 B 1.343 B 1.491 B 2.593 B +Operating Expenses 3.855 B 4.430 B 4.138 B 4.636 B 7.083 B +Investment Income Net 19.686 M 24.533 M 44 M 30 M 56 M +Net Interest Income -471.259 M -663.071 M -685 M -748 M -371 M +Interest Income -259 K -71 K 44 M 30 M 56 M +Interest Expense 471 M 663 M 685 M 748 M 371 M +Non Interest Income 948.469 M 22.185 B -98 M -336 M -55 M +Other Non Operating Income -125 M 22 M 45 M -122 M 135 M +Depreciation 769 M 1.110 B 1.370 B 1.570 B 1.910 B +Depreciation And Amortization 1.636 B 66 M 343 M 399 M 466 M +Income Before Tax -1.930 B -918 M -752 M 1.013 B 6.218 B +Income Tax Expense 32 M 58 M 110 M 292 M 699 M +Interest And Debt Expense 471.259 M 663.071 M 685 M 853 M 371 M +Net Income From Continuing Operations -2.241 B -1.063 B -775 M 862 M 5.644 B +Comprehensive Income Net Of Tax -1.905 B -1.018 B -890 M 1.120 B 5.210 B +Ebit -1.459 B -255 M -67 M 1.761 B 6.589 B +Ebitda 177.003 M -189 M 276 M 2.160 B 7.055 B +Net Income -1.962 B -976 M -862 M 721 M 5.519 B