Skip to content

Commit

Permalink
Stocks Suggestor Repair (#3477)
Browse files Browse the repository at this point in the history
* broken edition

* Fixed issue

* Update StockController

* Update choices generation

* Update parent_classes

* Update choices generation

* Update choices generation

* Update crypto_controller

* Update DefiController

* Update crypto/disc controller

* Update crypto/dd

* Update choices generation

* Update crypto : dd + nft

* Update crypto/onchain

* Update crypto_controller

* Linting

* Update crypto/ov

* Linting

* Update crypto/ov

* Update crypto/qa

* Update crypto/tools

* Update crypto/ta + dd

* Linting

* Update alt

* Tests fix crypto

* Update future

* Update futures

* Refactored through Options

* Tests + Linting

* finished stocks refactor

* Update stocks/sia

* finished stocks refactor

* Added fixes

* Added fix

* Tests

* Fix conditions

* Fix portfolio

* Prepare for merge

Co-authored-by: Chavithra PARANA <chavithra@gmail.com>
Co-authored-by: northern-64bit <75195383+northern-64bit@users.noreply.github.com>
  • Loading branch information
3 people authored and noubre committed Dec 13, 2022
1 parent 9821b25 commit 42a0d40
Showing 1 changed file with 106 additions and 71 deletions.
177 changes: 106 additions & 71 deletions openbb_terminal/cryptocurrency/onchain/onchain_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ class OnchainController(BaseController):
]

PATH = "/crypto/onchain/"
CHOICES_GENERATION = True

def __init__(self, queue: List[str] = None):
"""Constructor"""
Expand Down Expand Up @@ -275,9 +276,12 @@ def __init__(self, queue: List[str] = None):
"--address": None,
}
choices["info"]["--social"] = {}
choices: dict = self.choices_default

choices["support"] = self.SUPPORT_CHOICES
choices["about"] = self.ABOUT_CHOICES
choices["hr"].update({c: {} for c in GLASSNODE_SUPPORTED_HASHRATE_ASSETS})
choices["ds"].update(
{c: None for c in shroom_model.DAPP_STATS_PLATFORM_CHOICES}
)

self.completer = NestedCompleter.from_nested_dict(choices)

Expand Down Expand Up @@ -798,16 +802,17 @@ def call_balance(self, other_args: List[str]):
ns_parser = self.parse_known_args_and_warn(
parser, other_args, EXPORT_ONLY_RAW_DATA_ALLOWED
)
if ns_parser and self.address:
ethplorer_view.display_address_info(
limit=ns_parser.limit,
sortby=ns_parser.sortby,
ascend=ns_parser.reverse,
address=self.address,
export=ns_parser.export,
)
else:
console.print("You need to set an ethereum address\n")
if ns_parser:
if self.address:
ethplorer_view.display_address_info(
limit=ns_parser.limit,
sortby=ns_parser.sortby,
ascend=ns_parser.reverse,
address=self.address,
export=ns_parser.export,
)
else:
console.print("You need to set an ethereum address\n")

@log_start_end(log=logger)
def call_hist(self, other_args: List[str]):
Expand Down Expand Up @@ -854,16 +859,17 @@ def call_hist(self, other_args: List[str]):
ns_parser = self.parse_known_args_and_warn(
parser, other_args, EXPORT_ONLY_RAW_DATA_ALLOWED
)
if ns_parser and self.address:
ethplorer_view.display_address_history(
limit=ns_parser.limit,
sortby=ns_parser.sortby,
ascend=ns_parser.reverse,
address=self.address,
export=ns_parser.export,
)
else:
console.print("You need to set an ethereum address\n")
if ns_parser:
if self.address:
ethplorer_view.display_address_history(
limit=ns_parser.limit,
sortby=ns_parser.sortby,
ascend=ns_parser.reverse,
address=self.address,
export=ns_parser.export,
)
else:
console.print("You need to set an ethereum address\n")

@log_start_end(log=logger)
def call_holders(self, other_args: List[str]):
Expand Down Expand Up @@ -909,16 +915,17 @@ def call_holders(self, other_args: List[str]):
ns_parser = self.parse_known_args_and_warn(
parser, other_args, EXPORT_ONLY_RAW_DATA_ALLOWED
)
if ns_parser and self.address:
ethplorer_view.display_top_token_holders(
limit=ns_parser.limit,
sortby=ns_parser.sortby,
ascend=ns_parser.reverse,
address=self.address,
export=ns_parser.export,
)
else:
console.print("You need to set an ethereum address\n")
if ns_parser:
if self.address:
ethplorer_view.display_top_token_holders(
limit=ns_parser.limit,
sortby=ns_parser.sortby,
ascend=ns_parser.reverse,
address=self.address,
export=ns_parser.export,
)
else:
console.print("You need to set an ethereum address\n")

@log_start_end(log=logger)
def call_top(self, other_args: List[str]):
Expand Down Expand Up @@ -998,14 +1005,15 @@ def call_info(self, other_args: List[str]):
parser, other_args, EXPORT_ONLY_RAW_DATA_ALLOWED
)

if ns_parser and self.address:
ethplorer_view.display_token_info(
social=ns_parser.social,
address=self.address,
export=ns_parser.export,
)
else:
console.print("You need to set an ethereum address\n")
if ns_parser:
if self.address:
ethplorer_view.display_token_info(
social=ns_parser.social,
address=self.address,
export=ns_parser.export,
)
else:
console.print("You need to set an ethereum address\n")

@log_start_end(log=logger)
def call_th(self, other_args: List[str]):
Expand Down Expand Up @@ -1060,17 +1068,18 @@ def call_th(self, other_args: List[str]):
parser, other_args, EXPORT_ONLY_RAW_DATA_ALLOWED
)

if ns_parser and self.address:
ethplorer_view.display_token_history(
limit=ns_parser.limit,
hash_=ns_parser.hash,
sortby=ns_parser.sortby,
ascend=ns_parser.reverse,
address=self.address,
export=ns_parser.export,
)
else:
console.print("You need to set an ethereum address\n")
if ns_parser:
if self.address:
ethplorer_view.display_token_history(
limit=ns_parser.limit,
hash_=ns_parser.hash,
sortby=ns_parser.sortby,
ascend=ns_parser.reverse,
address=self.address,
export=ns_parser.export,
)
else:
console.print("You need to set an ethereum address\n")

@log_start_end(log=logger)
def call_tx(self, other_args: List[str]):
Expand All @@ -1090,13 +1099,14 @@ def call_tx(self, other_args: List[str]):
parser, other_args, EXPORT_ONLY_RAW_DATA_ALLOWED
)

if ns_parser and self.address:
ethplorer_view.display_tx_info(
tx_hash=self.address,
export=ns_parser.export,
)
else:
console.print("You need to set an ethereum address\n")
if ns_parser:
if self.address:
ethplorer_view.display_tx_info(
tx_hash=self.address,
export=ns_parser.export,
)
else:
console.print("You need to set an ethereum address\n")

@log_start_end(log=logger)
def call_prices(self, other_args: List[str]):
Expand Down Expand Up @@ -1142,16 +1152,17 @@ def call_prices(self, other_args: List[str]):
ns_parser = self.parse_known_args_and_warn(
parser, other_args, EXPORT_ONLY_RAW_DATA_ALLOWED
)
if ns_parser and self.address:
ethplorer_view.display_token_historical_prices(
limit=ns_parser.limit,
sortby=ns_parser.sortby,
ascend=ns_parser.reverse,
address=self.address,
export=ns_parser.export,
)
else:
console.print("You need to set an ethereum address\n")
if ns_parser:
if self.address:
ethplorer_view.display_token_historical_prices(
limit=ns_parser.limit,
sortby=ns_parser.sortby,
ascend=ns_parser.reverse,
address=self.address,
export=ns_parser.export,
)
else:
console.print("You need to set an ethereum address\n")

@log_start_end(log=logger)
def call_lt(self, other_args: List[str]):
Expand Down Expand Up @@ -1198,6 +1209,8 @@ def call_lt(self, other_args: List[str]):
type=check_positive,
help="Number of days to display data for.",
default=90,
choices=range(1, 360),
metavar="DAYS",
)
parser.add_argument(
"-s",
Expand Down Expand Up @@ -1255,7 +1268,13 @@ def call_dvcp(self, other_args: List[str]):
required="-h" not in other_args,
)
parser.add_argument(
"-vs", "--vs", dest="vs", type=str, help="Quote currency", default="USDT"
"-vs",
"--vs",
dest="vs",
type=str,
help="Quote currency",
default="USDT",
choices=bitquery_model.CURRENCIES,
)
parser.add_argument(
"-d",
Expand All @@ -1264,6 +1283,8 @@ def call_dvcp(self, other_args: List[str]):
type=check_positive,
help="Number of days to display data for.",
default=10,
choices=range(1, 100),
metavar="DAYS",
)
parser.add_argument(
"-s",
Expand Down Expand Up @@ -1400,6 +1421,8 @@ def call_ueat(self, other_args: List[str]):
"For interval: month, and number: 10, period of calculation equals to 300, "
"but because of max days limit: 90, it will only return last 3 months (3 records). ",
default=10,
choices=range(1, 90),
metavar="LIMIT",
)
parser.add_argument(
"-s",
Expand Down Expand Up @@ -1433,7 +1456,9 @@ def call_ueat(self, other_args: List[str]):
),
)
ns_parser = self.parse_known_args_and_warn(
parser, other_args, EXPORT_ONLY_RAW_DATA_ALLOWED
parser,
other_args,
EXPORT_ONLY_RAW_DATA_ALLOWED,
)

if ns_parser:
Expand Down Expand Up @@ -1480,6 +1505,8 @@ def call_ttcp(self, other_args: List[str]):
type=check_positive,
help="Number of days to display data for.",
default=30,
choices=range(1, 100),
metavar="DAYS",
)
parser.add_argument(
"-s",
Expand Down Expand Up @@ -1571,9 +1598,17 @@ def call_baas(self, other_args: List[str]):
dest="coin",
type=str,
help="ERC20 token symbol or address.",
choices=bitquery_model.POSSIBLE_CRYPTOS,
metavar="COIN",
)
parser.add_argument(
"-vs", "--vs", dest="vs", type=str, help="Quote currency", default="USDT"
"-vs",
"--vs",
dest="vs",
type=str,
help="Quote currency",
default="USDT",
choices=bitquery_model.CURRENCIES,
)
parser.add_argument(
"-l",
Expand Down

0 comments on commit 42a0d40

Please sign in to comment.