Skip to content

Commit

Permalink
Apply fix for #94
Browse files Browse the repository at this point in the history
  • Loading branch information
JerBouma committed Jan 4, 2024
1 parent c385607 commit 8a7f49a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
21 changes: 18 additions & 3 deletions financetoolkit/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def convert_currencies(
financial_statement_data: pd.DataFrame,
financial_statement_currencies: pd.Series,
exchange_rate_data: pd.DataFrame,
items_not_to_adjust: list[str] | None = None,
):
"""
Based on the retrieved currency definitions (e.g. EURUSD=X) for each ticker, obtained
Expand All @@ -148,6 +149,7 @@ def convert_currencies(
financial_statement_data (pd.DataFrame): A DataFrame containing the financial statement data.
financial_statement_currencies (pd.Series): A Series containing the currency symbols per ticker.
exchange_rate_data (pd.DataFrame): A DataFrame containing the exchange rate data.
items_not_to_adjust (list[str]): A list containing the items that should not be adjusted. Defaults to None.
Returns:
pd.DataFrame: A DataFrame containing the converted financial statement data.
Expand All @@ -170,9 +172,22 @@ def convert_currencies(
if currency not in currencies:
currencies[currency] = []

financial_statement_data.loc[ticker] = (
financial_statement_data.loc[ticker].mul(
exchange_rate_data.loc[periods, currency]
if items_not_to_adjust is not None:
items_to_adjust = [
item
for item in financial_statement_data.index.get_level_values(
level=1
)
if item not in items_not_to_adjust
]
else:
items_to_adjust = (
financial_statement_data.index.get_level_values(level=1)
)

financial_statement_data.loc[(ticker, items_to_adjust), :] = (
financial_statement_data.loc[(ticker, items_to_adjust), :].mul(
exchange_rate_data.loc[periods, currency], axis=1
)
).to_numpy()

Expand Down
3 changes: 1 addition & 2 deletions financetoolkit/models/models_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,8 +436,7 @@ def get_weighted_average_cost_of_capital(
lag (int | str, optional): The lag to use for the growth calculation. Defaults to 1.
Returns:
pd.DataFrame: DataFrame containing Dupont analysis results, including Profit Margin, Asset
Turnover, Financial Leverage, and the calculated ROE values.
pd.DataFrame: DataFrame containing the WACC values.
Notes:
- The Cost of Equity is approximated with the Capital Asset Pricing Model (CAPM).
Expand Down
11 changes: 11 additions & 0 deletions financetoolkit/toolkit_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -3059,6 +3059,17 @@ def get_income_statement(
exchange_rate_data=self.get_exchange_rates(
period="quarterly" if self._quarterly else "yearly"
)["Adj Close"],
items_not_to_adjust=[
"Gross Profit Ratio",
"EBITDA Ratio",
"Operating Income Ratio",
"Income Before Tax Ratio",
"Net Income Ratio",
"EPS",
"EPS Diluted",
"Weighted Average Shares",
"Weighted Average Shares Diluted",
],
)

income_statement = income_statement.round(
Expand Down

0 comments on commit 8a7f49a

Please sign in to comment.