From 9951461df8dab4acf703c205a67dc59ecfc1b0a8 Mon Sep 17 00:00:00 2001 From: montezdesousa <79287829+montezdesousa@users.noreply.github.com> Date: Wed, 9 Nov 2022 21:37:27 +0000 Subject: [PATCH] remove -p from perf (#3344) Co-authored-by: Jeroen Bouma Co-authored-by: James Maslek --- openbb_terminal/portfolio/portfolio_controller.py | 14 -------------- openbb_terminal/portfolio/portfolio_model.py | 14 ++++---------- openbb_terminal/portfolio/portfolio_view.py | 11 +++-------- website/content/terminal/portfolio/perf/_index.md | 12 ++++++------ 4 files changed, 13 insertions(+), 38 deletions(-) diff --git a/openbb_terminal/portfolio/portfolio_controller.py b/openbb_terminal/portfolio/portfolio_controller.py index 156b8362343..622aa09bfa4 100644 --- a/openbb_terminal/portfolio/portfolio_controller.py +++ b/openbb_terminal/portfolio/portfolio_controller.py @@ -241,8 +241,6 @@ class PortfolioController(BaseController): choices["metric"]["--rfr"] = None choices["metric"]["-r"] = "--rfr" choices["perf"] = { - "--period": {c: {} for c in portfolio_helper.PERIODS}, - "-p": "--period", "--show_trades": {}, "-t": "--show_trades", } @@ -655,17 +653,6 @@ class PortfolioController(BaseController): dest="show_trades", help="Whether to show performance on all trades in comparison to the benchmark.", ) - parser.add_argument( - "-p", - "--period", - type=str, - choices=portfolio_helper.PERIODS, - dest="period", - default="all", - help="The file to be loaded", - ) - if other_args and "-" not in other_args[0][0]: - other_args.insert(0, "-p") ns_parser = self.parse_known_args_and_warn(parser, other_args) @@ -676,7 +663,6 @@ class PortfolioController(BaseController): portfolio_view.display_performance_vs_benchmark( self.portfolio, - ns_parser.period, ns_parser.show_trades, ) diff --git a/openbb_terminal/portfolio/portfolio_model.py b/openbb_terminal/portfolio/portfolio_model.py index 162659da472..54935fcbfe4 100644 --- a/openbb_terminal/portfolio/portfolio_model.py +++ b/openbb_terminal/portfolio/portfolio_model.py @@ -582,7 +582,7 @@ class PortfolioModel: "Portfolio Investment", "Close", "Portfolio Value", - "% Portfolio Return", + "Portfolio % Return", "Abs Portfolio Return", ] ] = float(0) @@ -593,7 +593,7 @@ class PortfolioModel: self.portfolio_trades["Portfolio Value"][index] = ( self.portfolio_trades["Close"][index] * trade["Quantity"] ) - self.portfolio_trades["% Portfolio Return"][index] = ( + self.portfolio_trades["Portfolio % Return"][index] = ( self.portfolio_trades["Portfolio Value"][index] / self.portfolio_trades["Portfolio Investment"][index] ) - 1 @@ -1577,7 +1577,6 @@ def get_rolling_beta( @log_start_end(log=logger) def get_performance_vs_benchmark( portfolio: PortfolioModel, - interval: str = "all", show_all_trades: bool = False, ) -> pd.DataFrame: @@ -1587,8 +1586,6 @@ def get_performance_vs_benchmark( ---------- portfolio: Portfolio Portfolio object with trades loaded - interval : str - interval to consider performance. From: mtd, qtd, ytd, 3m, 6m, 1y, 3y, 5y, 10y, all show_all_trades: bool Whether to also show all trades made and their performance (default is False) Returns @@ -1601,17 +1598,14 @@ def get_performance_vs_benchmark( benchmark_trades = portfolio.benchmark_trades portfolio_trades.index = pd.to_datetime(portfolio_trades["Date"].values) - portfolio_trades = portfolio_helper.filter_df_by_period(portfolio_trades, interval) - benchmark_trades.index = pd.to_datetime(benchmark_trades["Date"].values) - benchmark_trades = portfolio_helper.filter_df_by_period(benchmark_trades, interval) if show_all_trades: # Combine DataFrames combined = pd.concat( [ portfolio_trades[ - ["Date", "Ticker", "Portfolio Value", "% Portfolio Return"] + ["Date", "Ticker", "Portfolio Value", "Portfolio % Return"] ], benchmark_trades[["Benchmark Value", "Benchmark % Return"]], ], @@ -1620,7 +1614,7 @@ def get_performance_vs_benchmark( # Calculate alpha combined["Alpha"] = ( - combined["% Portfolio Return"] - combined["Benchmark % Return"] + combined["Portfolio % Return"] - combined["Benchmark % Return"] ) combined["Date"] = pd.to_datetime(combined["Date"]).dt.date diff --git a/openbb_terminal/portfolio/portfolio_view.py b/openbb_terminal/portfolio/portfolio_view.py index 79bc370c45a..c21335ac5ac 100644 --- a/openbb_terminal/portfolio/portfolio_view.py +++ b/openbb_terminal/portfolio/portfolio_view.py @@ -252,7 +252,6 @@ def display_category_allocation( @log_start_end(log=logger) def display_performance_vs_benchmark( portfolio: portfolio_model.PortfolioModel, - interval: str = "all", show_all_trades: bool = False, ): """Display portfolio performance vs the benchmark @@ -263,20 +262,16 @@ def display_performance_vs_benchmark( Object containing trades made within the portfolio. benchmark_trades: pd.DataFrame Object containing trades made within the benchmark. - interval : str - interval to consider performance. From: mtd, qtd, ytd, 3m, 6m, 1y, 3y, 5y, 10y, all show_all_trades: bool Whether to also show all trades made and their performance (default is False) """ - df = portfolio_model.get_performance_vs_benchmark( - portfolio, interval, show_all_trades - ) + df = portfolio_model.get_performance_vs_benchmark(portfolio, show_all_trades) if show_all_trades: print_rich_table( df, - title=f"Portfolio vs. Benchmark - Individual Trades in period: {interval}", + title="Portfolio vs. Benchmark - Individual Trades in period", headers=list(df.columns), show_index=False, floatfmt=[".2f", ".2f", ".2f", ".2%", ".2f", ".2%", ".2%"], @@ -284,7 +279,7 @@ def display_performance_vs_benchmark( else: print_rich_table( df, - title=f"Portfolio vs. Benchmark - Totals in period: {interval}", + title="Portfolio vs. Benchmark", headers=list(df.columns), show_index=True, ) diff --git a/website/content/terminal/portfolio/perf/_index.md b/website/content/terminal/portfolio/perf/_index.md index 169d3c87973..393aaf160b3 100644 --- a/website/content/terminal/portfolio/perf/_index.md +++ b/website/content/terminal/portfolio/perf/_index.md @@ -1,20 +1,20 @@ ``` -usage: performance [-s] [-t] [-h] +usage: performance [-t] [-h] ``` Shows performance of each trade and total performance of the portfolio versus the benchmark. ``` optional arguments: - -s, --full_shares Whether to only make a trade with the benchmark when a full share can be bought (no partial shares). (default: False) - -t, --show_trades Whether to show performance on all trades in comparison to the benchmark. (default: False) + -t, --show_trades Whether to show performance on all trades in comparison to the + benchmark. (default: False) -h, --help show this help message (default: False) ``` Example: ``` 2022 May 12, 06:22 (๐Ÿฆ‹) /portfolio/ $ perf -t - Portfolio vs. Benchmark - Totals + Portfolio vs. Benchmark - Totals โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“ โ”ƒ โ”ƒ Portfolio โ”ƒ Benchmark โ”ƒ Difference โ”ƒ โ”กโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ฉ @@ -27,7 +27,7 @@ Example: โ”‚ Total Abs Return โ”‚ 34637.53 โ”‚ 20608.20 โ”‚ 14029.33 โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ - Portfolio vs. Benchmark - Individual Trades + Portfolio vs. Benchmark - Individual Trades โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“ โ”ƒ Date โ”ƒ Name โ”ƒ Portfolio Value โ”ƒ % Portfolio Return โ”ƒ Benchmark Value โ”ƒ % Benchmark Return โ”ƒ Alpha โ”ƒ โ”กโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ฉ @@ -111,4 +111,4 @@ Example: โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค โ”‚ 2022-05-02 00:00:00 โ”‚ YUM โ”‚ 1197.90 โ”‚ -5.93% โ”‚ 1194.00 โ”‚ -6.23% โ”‚ 0.31% โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ -``` \ No newline at end of file +```