Skip to content

Commit 4679318

Browse files
committed
Add some additional robustness
1 parent 6863f9c commit 4679318

File tree

2 files changed

+6
-24
lines changed

2 files changed

+6
-24
lines changed

financetoolkit/normalization_model.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ def read_normalization_file(statement: str, format_location: str = ""):
4747
f"normalization/{statement}.csv"
4848
)
4949

50-
return pd.read_csv(file_location, index_col=[0]).iloc[:, 0]
50+
try:
51+
return pd.read_csv(file_location, index_col=[0]).iloc[:, 0]
52+
except FileNotFoundError:
53+
return pd.Series()
5154

5255

5356
def convert_financial_statements(
@@ -73,7 +76,8 @@ def convert_financial_statements(
7376
naming = {}
7477

7578
if statement_format.empty:
76-
raise ValueError("Please provide a non-empty format DataFrame.")
79+
# If not format is provided, simply use the original financial statements
80+
return financial_statements
7781

7882
for name in financial_statements.index.unique(level=1):
7983
try:

financetoolkit/toolkit_controller.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3626,28 +3626,6 @@ def get_income_statement(
36263626
# The rolling window is calculated for the rest of the income statement.
36273627
income_statement = self._income_statement.T.rolling(trailing).sum().T
36283628

3629-
# Ratios can't be simply added together and should be recalculated.
3630-
income_statement.loc[:, "Gross Profit Ratio", :] = (
3631-
income_statement.loc[:, "Gross Profit", :]
3632-
/ income_statement.loc[:, "Revenue", :]
3633-
).to_numpy()
3634-
income_statement.loc[:, "EBITDA Ratio", :] = (
3635-
income_statement.loc[:, "EBITDA", :]
3636-
/ income_statement.loc[:, "Revenue", :]
3637-
).to_numpy()
3638-
income_statement.loc[:, "Operating Income Ratio", :] = (
3639-
income_statement.loc[:, "Operating Income", :]
3640-
/ income_statement.loc[:, "Revenue", :]
3641-
).to_numpy()
3642-
income_statement.loc[:, "Income Before Tax Ratio", :] = (
3643-
income_statement.loc[:, "Income Before Tax", :]
3644-
/ income_statement.loc[:, "Revenue", :]
3645-
).to_numpy()
3646-
income_statement.loc[:, "Net Income Ratio", :] = (
3647-
income_statement.loc[:, "Net Income", :]
3648-
/ income_statement.loc[:, "Revenue", :]
3649-
).to_numpy()
3650-
36513629
# The Weighted Average Shares and Weighted Average Shares Diluted should
36523630
# not be summed up but rather kept equal to the current value.
36533631
income_statement.loc[weighted_average_shares.index] = (

0 commit comments

Comments
 (0)