Fix crypto/disc/top sort (#4167)

* fix sort choices

* fix unit tests
This commit is contained in:
montezdesousa
2023-02-08 00:43:31 +00:00
committed by GitHub
parent 1e1f19ead4
commit 93dd0bce2f
4 changed files with 2468 additions and 2708 deletions

View File

@@ -19,7 +19,10 @@ from openbb_terminal.cryptocurrency.discovery import (
)
from openbb_terminal.custom_prompt_toolkit import NestedCompleter
from openbb_terminal.decorators import log_start_end
from openbb_terminal.helper_funcs import EXPORT_ONLY_RAW_DATA_ALLOWED, check_positive
from openbb_terminal.helper_funcs import (
EXPORT_ONLY_RAW_DATA_ALLOWED,
check_positive,
)
from openbb_terminal.menu import session
from openbb_terminal.parent_classes import BaseController
from openbb_terminal.rich_config import MenuText, console, get_ordered_list_sources
@@ -52,6 +55,16 @@ class DiscoveryController(BaseController):
if session and obbff.USE_PROMPT_TOOLKIT:
choices: dict = self.choices_default
ordered_list_sources_top = get_ordered_list_sources(f"{self.PATH}top")
if ordered_list_sources_top and ordered_list_sources_top[0] == "CoinGecko":
choices["top"]["--sort"] = {
c: {} for c in pycoingecko_view.COINS_COLUMNS
}
else:
choices["top"]["--sort"] = {c: {} for c in coinmarketcap_model.FILTERS}
choices["top"]["-s"] = choices["top"]["--sort"]
self.completer = NestedCompleter.from_nested_dict(choices)
def print_help(self):
@@ -78,11 +91,6 @@ class DiscoveryController(BaseController):
else:
argument_sort_default = "CMC_Rank"
if ordered_list_sources_top and ordered_list_sources_top[0] == "CoinGecko":
argument_sort_choices = pycoingecko_view.COINS_COLUMNS
else:
argument_sort_choices = coinmarketcap_model.FILTERS
parser = argparse.ArgumentParser(
prog="top",
add_help=False,
@@ -121,7 +129,6 @@ class DiscoveryController(BaseController):
nargs="+",
help="Sort by given column. Default: Market Cap Rank",
default=argument_sort_default,
choices=argument_sort_choices,
metavar="SORTBY",
)
parser.add_argument(

View File

@@ -1,4 +1,4 @@
Loading Daily data for TSLA with starting period 2020-02-03.
Loading Daily data for TSLA with starting period 2020-02-04.
Company Rating Price Target
Date
2023-02-06 Wedbush Morgan Securities Inc. BUY 225.000000