diff --git a/openbb_terminal/helper_funcs.py b/openbb_terminal/helper_funcs.py index f09cb1f1407..d698bc7c275 100644 --- a/openbb_terminal/helper_funcs.py +++ b/openbb_terminal/helper_funcs.py @@ -683,7 +683,12 @@ def lambda_long_number_format(num, round_decimal=3) -> str: return f"{num_str} {' KMBTP'[magnitude]}".strip() if isinstance(num, int): num = str(num) - if isinstance(num, str) and num.lstrip("-").isdigit(): + if ( + isinstance(num, str) + and num.lstrip("-").isdigit() + and not num.lstrip("-").startswith("0") + and not is_valid_date(num) + ): num = int(num) num /= 1.0 magnitude = 0 diff --git a/openbb_terminal/stocks/fundamental_analysis/fmp_model.py b/openbb_terminal/stocks/fundamental_analysis/fmp_model.py index 3375029e31d..70932411383 100644 --- a/openbb_terminal/stocks/fundamental_analysis/fmp_model.py +++ b/openbb_terminal/stocks/fundamental_analysis/fmp_model.py @@ -540,9 +540,20 @@ def clean_metrics_df(data: pd.DataFrame, num: int, mask: bool = True) -> pd.Data # iloc will fail if number is greater than number of columns num = min(num, data.shape[1]) data = data.iloc[:, 0:num] + if mask: data = data.mask(data.astype(object).eq(num * ["None"])).dropna() data = data.mask(data.astype(object).eq(num * ["0"])).dropna() + + date_rows = { + "calendarYear": "%Y", + "fillingDate": "%Y-%m-%d", + "acceptedDate": "%Y-%m-%d %H:%M:%S", + } + for row, dt_type in date_rows.items(): + if row in data.index: + data.loc[row] = pd.to_datetime(data.loc[row], format=dt_type) + data = data.applymap(lambda x: lambda_long_number_format(x)) clean_df_index(data) data.columns.name = "Fiscal Date Ending" diff --git a/tests/openbb_terminal/stocks/fundamental_analysis/txt/test_fmp_view/test_check_output[False-display_balance_sheet-kwargs_dict4].txt b/tests/openbb_terminal/stocks/fundamental_analysis/txt/test_fmp_view/test_check_output[False-display_balance_sheet-kwargs_dict4].txt index 8cb731f7bcd..0594fb1f6e4 100644 --- a/tests/openbb_terminal/stocks/fundamental_analysis/txt/test_fmp_view/test_check_output[False-display_balance_sheet-kwargs_dict4].txt +++ b/tests/openbb_terminal/stocks/fundamental_analysis/txt/test_fmp_view/test_check_output[False-display_balance_sheet-kwargs_dict4].txt @@ -1,9 +1,9 @@ Fiscal Date Ending 2017 2018 2019 2020 2021 Reported currency USD USD USD USD USD -Cik 1.413 M 1.413 M 1.413 M 1.413 M 1.413 M -Filling date 2018-02-13 2019-02-07 2020-02-07 2021-02-09 2022-02-11 +Cik 0001413329 0001413329 0001413329 0001413329 0001413329 +Filling date 2018-02-13 00:00:00 2019-02-07 00:00:00 2020-02-07 00:00:00 2021-02-09 00:00:00 2022-02-11 00:00:00 Accepted date 2018-02-13 08:07:16 2019-02-07 15:09:20 2020-02-07 06:47:13 2021-02-09 16:20:37 2022-02-11 08:29:22 -Calendar year 2.017 K 2.018 K 2.019 K 2.020 K 2.021 K +Calendar year 2017-01-01 00:00:00 2018-01-01 00:00:00 2019-01-01 00:00:00 2020-01-01 00:00:00 2021-01-01 00:00:00 Period FY FY FY FY FY Cash and cash equivalents 8.447 B 6.593 B 6.861 B 7.280 B 4.496 B Short term investments 0 0 0 0 0 diff --git a/tests/openbb_terminal/stocks/fundamental_analysis/txt/test_fmp_view/test_check_output[False-display_cash_flow-kwargs_dict5].txt b/tests/openbb_terminal/stocks/fundamental_analysis/txt/test_fmp_view/test_check_output[False-display_cash_flow-kwargs_dict5].txt index b77f7895e8a..b2f90639b06 100644 --- a/tests/openbb_terminal/stocks/fundamental_analysis/txt/test_fmp_view/test_check_output[False-display_cash_flow-kwargs_dict5].txt +++ b/tests/openbb_terminal/stocks/fundamental_analysis/txt/test_fmp_view/test_check_output[False-display_cash_flow-kwargs_dict5].txt @@ -1,9 +1,9 @@ Fiscal Date Ending 2017 2018 2019 2020 2021 Reported currency USD USD USD USD USD -Cik 1.413 M 1.413 M 1.413 M 1.413 M 1.413 M -Filling date 2018-02-13 2019-02-07 2020-02-07 2021-02-09 2022-02-11 +Cik 0001413329 0001413329 0001413329 0001413329 0001413329 +Filling date 2018-02-13 00:00:00 2019-02-07 00:00:00 2020-02-07 00:00:00 2021-02-09 00:00:00 2022-02-11 00:00:00 Accepted date 2018-02-13 08:07:16 2019-02-07 15:09:20 2020-02-07 06:47:13 2021-02-09 16:20:37 2022-02-11 08:29:22 -Calendar year 2.017 K 2.018 K 2.019 K 2.020 K 2.021 K +Calendar year 2017-01-01 00:00:00 2018-01-01 00:00:00 2019-01-01 00:00:00 2020-01-01 00:00:00 2021-01-01 00:00:00 Period FY FY FY FY FY Net income 6.035 B 7.911 B 7.185 B 8.056 B 9.109 B Depreciation and amortization 875 M 989 M 964 M 981 M 998 M diff --git a/tests/openbb_terminal/stocks/fundamental_analysis/txt/test_fmp_view/test_check_output[False-display_income_statement-kwargs_dict3].txt b/tests/openbb_terminal/stocks/fundamental_analysis/txt/test_fmp_view/test_check_output[False-display_income_statement-kwargs_dict3].txt index 764289d936e..3ec21ed78ea 100644 --- a/tests/openbb_terminal/stocks/fundamental_analysis/txt/test_fmp_view/test_check_output[False-display_income_statement-kwargs_dict3].txt +++ b/tests/openbb_terminal/stocks/fundamental_analysis/txt/test_fmp_view/test_check_output[False-display_income_statement-kwargs_dict3].txt @@ -1,9 +1,9 @@ Fiscal Date Ending 2017 2018 2019 2020 2021 Reported currency USD USD USD USD USD -Cik 1.413 M 1.413 M 1.413 M 1.413 M 1.413 M -Filling date 2018-02-13 2019-02-07 2020-02-07 2021-02-09 2022-02-11 +Cik 0001413329 0001413329 0001413329 0001413329 0001413329 +Filling date 2018-02-13 00:00:00 2019-02-07 00:00:00 2020-02-07 00:00:00 2021-02-09 00:00:00 2022-02-11 00:00:00 Accepted date 2018-02-13 08:07:16 2019-02-07 15:09:20 2020-02-07 06:47:13 2021-02-09 16:20:37 2022-02-11 08:29:22 -Calendar year 2.017 K 2.018 K 2.019 K 2.020 K 2.021 K +Calendar year 2017-01-01 00:00:00 2018-01-01 00:00:00 2019-01-01 00:00:00 2020-01-01 00:00:00 2021-01-01 00:00:00 Period FY FY FY FY FY Revenue 28.748 B 29.625 B 29.805 B 28.694 B 31.405 B Cost of revenue 10.432 B 10.758 B 10.513 B 9.569 B 10.030 B diff --git a/tests/openbb_terminal/stocks/fundamental_analysis/txt/test_fmp_view/test_check_output[True-display_balance_sheet-kwargs_dict4].txt b/tests/openbb_terminal/stocks/fundamental_analysis/txt/test_fmp_view/test_check_output[True-display_balance_sheet-kwargs_dict4].txt index 8cb731f7bcd..0594fb1f6e4 100644 --- a/tests/openbb_terminal/stocks/fundamental_analysis/txt/test_fmp_view/test_check_output[True-display_balance_sheet-kwargs_dict4].txt +++ b/tests/openbb_terminal/stocks/fundamental_analysis/txt/test_fmp_view/test_check_output[True-display_balance_sheet-kwargs_dict4].txt @@ -1,9 +1,9 @@ Fiscal Date Ending 2017 2018 2019 2020 2021 Reported currency USD USD USD USD USD -Cik 1.413 M 1.413 M 1.413 M 1.413 M 1.413 M -Filling date 2018-02-13 2019-02-07 2020-02-07 2021-02-09 2022-02-11 +Cik 0001413329 0001413329 0001413329 0001413329 0001413329 +Filling date 2018-02-13 00:00:00 2019-02-07 00:00:00 2020-02-07 00:00:00 2021-02-09 00:00:00 2022-02-11 00:00:00 Accepted date 2018-02-13 08:07:16 2019-02-07 15:09:20 2020-02-07 06:47:13 2021-02-09 16:20:37 2022-02-11 08:29:22 -Calendar year 2.017 K 2.018 K 2.019 K 2.020 K 2.021 K +Calendar year 2017-01-01 00:00:00 2018-01-01 00:00:00 2019-01-01 00:00:00 2020-01-01 00:00:00 2021-01-01 00:00:00 Period FY FY FY FY FY Cash and cash equivalents 8.447 B 6.593 B 6.861 B 7.280 B 4.496 B Short term investments 0 0 0 0 0 diff --git a/tests/openbb_terminal/stocks/fundamental_analysis/txt/test_fmp_view/test_check_output[True-display_cash_flow-kwargs_dict5].txt b/tests/openbb_terminal/stocks/fundamental_analysis/txt/test_fmp_view/test_check_output[True-display_cash_flow-kwargs_dict5].txt index b77f7895e8a..b2f90639b06 100644 --- a/tests/openbb_terminal/stocks/fundamental_analysis/txt/test_fmp_view/test_check_output[True-display_cash_flow-kwargs_dict5].txt +++ b/tests/openbb_terminal/stocks/fundamental_analysis/txt/test_fmp_view/test_check_output[True-display_cash_flow-kwargs_dict5].txt @@ -1,9 +1,9 @@ Fiscal Date Ending 2017 2018 2019 2020 2021 Reported currency USD USD USD USD USD -Cik 1.413 M 1.413 M 1.413 M 1.413 M 1.413 M -Filling date 2018-02-13 2019-02-07 2020-02-07 2021-02-09 2022-02-11 +Cik 0001413329 0001413329 0001413329 0001413329 0001413329 +Filling date 2018-02-13 00:00:00 2019-02-07 00:00:00 2020-02-07 00:00:00 2021-02-09 00:00:00 2022-02-11 00:00:00 Accepted date 2018-02-13 08:07:16 2019-02-07 15:09:20 2020-02-07 06:47:13 2021-02-09 16:20:37 2022-02-11 08:29:22 -Calendar year 2.017 K 2.018 K 2.019 K 2.020 K 2.021 K +Calendar year 2017-01-01 00:00:00 2018-01-01 00:00:00 2019-01-01 00:00:00 2020-01-01 00:00:00 2021-01-01 00:00:00 Period FY FY FY FY FY Net income 6.035 B 7.911 B 7.185 B 8.056 B 9.109 B Depreciation and amortization 875 M 989 M 964 M 981 M 998 M diff --git a/tests/openbb_terminal/stocks/fundamental_analysis/txt/test_fmp_view/test_check_output[True-display_income_statement-kwargs_dict3].txt b/tests/openbb_terminal/stocks/fundamental_analysis/txt/test_fmp_view/test_check_output[True-display_income_statement-kwargs_dict3].txt index 764289d936e..3ec21ed78ea 100644 --- a/tests/openbb_terminal/stocks/fundamental_analysis/txt/test_fmp_view/test_check_output[True-display_income_statement-kwargs_dict3].txt +++ b/tests/openbb_terminal/stocks/fundamental_analysis/txt/test_fmp_view/test_check_output[True-display_income_statement-kwargs_dict3].txt @@ -1,9 +1,9 @@ Fiscal Date Ending 2017 2018 2019 2020 2021 Reported currency USD USD USD USD USD -Cik 1.413 M 1.413 M 1.413 M 1.413 M 1.413 M -Filling date 2018-02-13 2019-02-07 2020-02-07 2021-02-09 2022-02-11 +Cik 0001413329 0001413329 0001413329 0001413329 0001413329 +Filling date 2018-02-13 00:00:00 2019-02-07 00:00:00 2020-02-07 00:00:00 2021-02-09 00:00:00 2022-02-11 00:00:00 Accepted date 2018-02-13 08:07:16 2019-02-07 15:09:20 2020-02-07 06:47:13 2021-02-09 16:20:37 2022-02-11 08:29:22 -Calendar year 2.017 K 2.018 K 2.019 K 2.020 K 2.021 K +Calendar year 2017-01-01 00:00:00 2018-01-01 00:00:00 2019-01-01 00:00:00 2020-01-01 00:00:00 2021-01-01 00:00:00 Period FY FY FY FY FY Revenue 28.748 B 29.625 B 29.805 B 28.694 B 31.405 B Cost of revenue 10.432 B 10.758 B 10.513 B 9.569 B 10.030 B