diff --git a/openbb_terminal/portfolio/portfolio_controller.py b/openbb_terminal/portfolio/portfolio_controller.py index 6a4c77d73019..69b6d21bebd1 100644 --- a/openbb_terminal/portfolio/portfolio_controller.py +++ b/openbb_terminal/portfolio/portfolio_controller.py @@ -341,7 +341,8 @@ def call_load(self, other_args: List[str]): self.portfolio.generate_portfolio_data() # Add in the Risk-free rate - self.portfolio.set_risk_free_rate(ns_parser.risk_free_rate) + self.portfolio.set_risk_free_rate(ns_parser.risk_free_rate / 100) + self.risk_free_rate = ns_parser.risk_free_rate / 100 # Load benchmark self.call_bench(["-b", "SPDR S&P 500 ETF Trust (SPY)"]) @@ -350,7 +351,7 @@ def call_load(self, other_args: List[str]): f"\n[bold][param]Portfolio:[/param][/bold] {self.portfolio_name}" ) console.print( - f"[bold][param]Risk Free Rate:[/param][/bold] {self.portfolio.risk_free_rate}" + f"[bold][param]Risk Free Rate:[/param][/bold] {self.risk_free_rate:.2%}" ) console.print( f"[bold][param]Benchmark:[/param][/bold] {self.benchmark_name}\n" @@ -371,12 +372,13 @@ def call_show(self, other_args: List[str]): export_allowed=EXPORT_BOTH_RAW_DATA_AND_FIGURES, limit=10, ) - portfolio_view.display_orderbook( - self.portfolio, - show_index=False, - limit=ns_parser.limit, - export=ns_parser.export, - ) + if ns_parser and self.portfolio is not None: + portfolio_view.display_orderbook( + self.portfolio, + show_index=False, + limit=ns_parser.limit, + export=ns_parser.export, + ) @log_start_end(log=logger) def call_bench(self, other_args: List[str]): @@ -1025,7 +1027,7 @@ def call_rsharpe(self, other_args: List[str]): portfolio_view.display_rolling_sharpe( self.portfolio, window=ns_parser.period, - risk_free_rate=ns_parser.risk_free_rate, + risk_free_rate=ns_parser.risk_free_rate / 100, export=ns_parser.export, ) @@ -1065,9 +1067,9 @@ def call_rsort(self, other_args: List[str]): self.portfolio_name, self.benchmark_name ): portfolio_view.display_rolling_sortino( - portfolio=self.portfolio.benchmark_returns, + portfolio=self.portfolio, window=ns_parser.period, - risk_free_rate=ns_parser.risk_free_rate, + risk_free_rate=ns_parser.risk_free_rate / 100, export=ns_parser.export, ) diff --git a/openbb_terminal/portfolio/portfolio_optimization/optimizer_model.py b/openbb_terminal/portfolio/portfolio_optimization/optimizer_model.py index 9ac6fcda70c5..604f214180e1 100644 --- a/openbb_terminal/portfolio/portfolio_optimization/optimizer_model.py +++ b/openbb_terminal/portfolio/portfolio_optimization/optimizer_model.py @@ -1620,8 +1620,6 @@ def get_ef( method=method, ) - risk_free_rate = risk_free_rate / time_factor[freq.upper()] - # Building the portfolio object port = rp.Portfolio(returns=stock_returns, alpha=alpha) diff --git a/openbb_terminal/portfolio/portfolio_optimization/optimizer_view.py b/openbb_terminal/portfolio/portfolio_optimization/optimizer_view.py index 7b0ff7d8ff71..f2fdd9b27bcf 100644 --- a/openbb_terminal/portfolio/portfolio_optimization/optimizer_view.py +++ b/openbb_terminal/portfolio/portfolio_optimization/optimizer_view.py @@ -2204,6 +2204,8 @@ def display_ef( Whether to plot the tickers for the assets """ + risk_free_rate = risk_free_rate / time_factor[freq.upper()] + frontier, mu, cov, stock_returns, weights, X1, Y1, port = optimizer_model.get_ef( symbols, interval,