From 0c5098bb63efb1841614221b159fd33570f1e01b Mon Sep 17 00:00:00 2001 From: Colin Delahunty <72827203+colin99d@users.noreply.github.com> Date: Fri, 26 Nov 2021 19:50:59 -0500 Subject: [PATCH] Added dcf bug fix (#989) --- .../stocks/fundamental_analysis/dcf_view.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/gamestonk_terminal/stocks/fundamental_analysis/dcf_view.py b/gamestonk_terminal/stocks/fundamental_analysis/dcf_view.py index 13ecc802193..b5c33fdcd45 100644 --- a/gamestonk_terminal/stocks/fundamental_analysis/dcf_view.py +++ b/gamestonk_terminal/stocks/fundamental_analysis/dcf_view.py @@ -491,8 +491,15 @@ class CreateExcelFA: r + 2, "Average return of the S&P 500 is 8% [Investopedia]", 2, f"{c3}" ) dcf_model.set_cell(self.ws2, f"{c1}{r+3}", "Beta") - dcf_model.set_cell(self.ws2, f"{c2}{r+3}", float(self.info["beta"])) - self.custom_exp(r + 3, "Beta from yahoo finance", 2, f"{c3}") + if self.info["beta"] is None: + dcf_model.set_cell(self.ws2, f"{c2}{r+3}", float(1)) + self.custom_exp( + r + 3, "Warning: Beta not found. Assumed a beta of one.", 2, f"{c3}" + ) + self.info["beta"] = 1 + else: + dcf_model.set_cell(self.ws2, f"{c2}{r+3}", float(self.info["beta"])) + self.custom_exp(r + 3, "Beta from yahoo finance", 2, f"{c3}") dcf_model.set_cell(self.ws2, f"{c1}{r+4}", "r (CAPM)") dcf_model.set_cell( self.ws2,