From dbaa3ecb417789ea657dd00c526004ed08ffcf96 Mon Sep 17 00:00:00 2001 From: minhhoang1023 <40023817+minhhoang1023@users.noreply.github.com> Date: Sun, 13 Mar 2022 01:24:24 +0700 Subject: [PATCH] Fix bug Real Time Performance (#1454) * Fix bug percentage Real time performance * Update ticker format * Update tests Co-authored-by: didierlopes.eth Co-authored-by: jose-donato <43375532+jose-donato@users.noreply.github.com> Co-authored-by: jmaslek --- .../economy/alphavantage_view.py | 4 ++++ ...est_realtime_performance_sector[True0].txt | 22 +++++++++---------- ...est_realtime_performance_sector[True1].txt | 22 +++++++++---------- 3 files changed, 26 insertions(+), 22 deletions(-) diff --git a/gamestonk_terminal/economy/alphavantage_view.py b/gamestonk_terminal/economy/alphavantage_view.py index effef99d1ec..b380b3b23c5 100644 --- a/gamestonk_terminal/economy/alphavantage_view.py +++ b/gamestonk_terminal/economy/alphavantage_view.py @@ -5,6 +5,7 @@ from typing import List, Optional import logging import os +import matplotlib import matplotlib.pyplot as plt from gamestonk_terminal.decorators import check_api_key from gamestonk_terminal.config_terminal import theme @@ -48,6 +49,8 @@ def realtime_performance_sector( # pylint: disable=invalid-sequence-index df_rtp = df_sectors["Rank A: Real-Time Performance"] + df_rtp = df_rtp.apply(lambda x: x * 100) + if raw: print_rich_table( df_rtp.to_frame(), @@ -61,6 +64,7 @@ def realtime_performance_sector( theme.style_primary_axis(ax) ax.set_title("Real Time Performance (%) per Sector") ax.tick_params(axis="x", labelrotation=90) + ax.xaxis.set_major_formatter(matplotlib.ticker.FormatStrFormatter("%.2f")) if external_axes is None: theme.visualize_output() diff --git a/tests/gamestonk_terminal/economy/txt/test_alphavantage_view/test_realtime_performance_sector[True0].txt b/tests/gamestonk_terminal/economy/txt/test_alphavantage_view/test_realtime_performance_sector[True0].txt index 89b478e54b7..9d934acb4c2 100644 --- a/tests/gamestonk_terminal/economy/txt/test_alphavantage_view/test_realtime_performance_sector[True0].txt +++ b/tests/gamestonk_terminal/economy/txt/test_alphavantage_view/test_realtime_performance_sector[True0].txt @@ -1,12 +1,12 @@ Rank A: Real-Time Performance -Consumer Staples 0.0002 -Real Estate -0.0004 -Utilities -0.0018 -Industrials -0.0097 -Health Care -0.0106 -Information Technology -0.0193 -Energy -0.0195 -Financials -0.0202 -Materials -0.0249 -Consumer Discretionary -0.0310 -Communication Services -0.0388 +Consumer Staples 0.02 +Real Estate -0.04 +Utilities -0.18 +Industrials -0.97 +Health Care -1.06 +Information Technology -1.93 +Energy -1.95 +Financials -2.02 +Materials -2.49 +Consumer Discretionary -3.10 +Communication Services -3.88 diff --git a/tests/gamestonk_terminal/economy/txt/test_alphavantage_view/test_realtime_performance_sector[True1].txt b/tests/gamestonk_terminal/economy/txt/test_alphavantage_view/test_realtime_performance_sector[True1].txt index 89b478e54b7..9d934acb4c2 100644 --- a/tests/gamestonk_terminal/economy/txt/test_alphavantage_view/test_realtime_performance_sector[True1].txt +++ b/tests/gamestonk_terminal/economy/txt/test_alphavantage_view/test_realtime_performance_sector[True1].txt @@ -1,12 +1,12 @@ Rank A: Real-Time Performance -Consumer Staples 0.0002 -Real Estate -0.0004 -Utilities -0.0018 -Industrials -0.0097 -Health Care -0.0106 -Information Technology -0.0193 -Energy -0.0195 -Financials -0.0202 -Materials -0.0249 -Consumer Discretionary -0.0310 -Communication Services -0.0388 +Consumer Staples 0.02 +Real Estate -0.04 +Utilities -0.18 +Industrials -0.97 +Health Care -1.06 +Information Technology -1.93 +Energy -1.95 +Financials -2.02 +Materials -2.49 +Consumer Discretionary -3.10 +Communication Services -3.88