mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-04 08:22:26 +00:00
* I missed some sheet_name ones :) * Move quote to main menu and combine yahoo finance commands * Update stocks for quote * First update to move yfinance away from main functionality * Small updates * Update tests to reflect changes * Fix some little things * Update docs a little too * Remove the Due Diligence menu * Update tests for new change * Update fa and stocks with new text and move some stuff around * Bye bye dd * Pls work * work.. * work.. * work.. * Work..| * Add tests back in * Remove tests * Fix fix fix * Remove tests to fix conflicts * Improve the `stocks/search` command (#4084) * Improve search command * Make it more intuitive * Fix tests * Update the docs * Ok done * Ok done 2 * Ok done 3 * Git update tests that failed * Update commands with --sheet-name that didn't work (#4088) * Update commands with --sheet-name that didn't work * Fix test * oops * Adds auto completion to `news` (#4089) * Fix plot look when using eval and add query to choices (#3881) * convert index to datetime and update choices * uncomment economy integration test * fix treasury concat bug * fix datasets concat on duplciates * Lock ruff version so that new lints dont break our CI (#3905) * Lock ruff version so that new lints dont break our CI * Bumped pre-commit ruff version * returning always a dataframe * Revert "returning always a dataframe" This reverts commitd5dbf3132f. * quick fix to auto complete args --------- Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com> Co-authored-by: Colin Delahunty <72827203+colin99d@users.noreply.github.com> Co-authored-by: James Maslek <jmaslek11@gmail.com> * Hotfix/Windows-CLI (#4087) * init * Update windows10_build.yml * Update windows10_build.yml * Update windows10_build.yml * Update windows10_build.yml * Update windows10_build.yml * Update windows10_build.yml * oops --------- Co-authored-by: James Maslek <jmaslek11@gmail.com> * Adds end date to `forex/load` (#4077) * Fix plot look when using eval and add query to choices (#3881) * convert index to datetime and update choices * uncomment economy integration test * fix treasury concat bug * fix datasets concat on duplciates * Lock ruff version so that new lints dont break our CI (#3905) * Lock ruff version so that new lints dont break our CI * Bumped pre-commit ruff version * returning always a dataframe * Revert "returning always a dataframe" This reverts commitd5dbf3132f. * adding end date to the forex load * added some tests * added example * always show msg * rewriting test * updating tests * updating tests * Redo load tests --------- Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com> Co-authored-by: Colin Delahunty <72827203+colin99d@users.noreply.github.com> Co-authored-by: James Maslek <jmaslek11@gmail.com> * Update tests to reflect changes * work.. * Remove tests * Fix fix fix * Remove tests * Update the whole test folder * Small updates * Revert change * Update eodhd to reflect it requires a paid plan and update tests * Fix all the tests * Update tests * Update integration tests * Removing tests so no whining happens * ADD ALL THE TESTS * Fix linting * gitignore. thanks jer * Add back dd and redirect to fa * Update to just display a message * Update OpenBB SDK commands * Fixing issues with exporting * Fix ruff messing up * Fix tests * Fix the tests by disabling isort to run on tests folder --------- Co-authored-by: Jeroen Bouma <jeroenbouma@Jeroens-MacBook-Pro.local> Co-authored-by: James Maslek <jmaslek11@gmail.com> Co-authored-by: Henrique Joaquim <h.joaquim@campus.fct.unl.pt> Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com> Co-authored-by: Colin Delahunty <72827203+colin99d@users.noreply.github.com> Co-authored-by: teh_coderer <me@tehcoderer.com>
170 lines
5.4 KiB
Python
170 lines
5.4 KiB
Python
import argparse
|
|
import logging
|
|
from typing import List
|
|
|
|
from openbb_terminal import feature_flags as obbff
|
|
from openbb_terminal.cryptocurrency.nft import (
|
|
nftpricefloor_model,
|
|
nftpricefloor_view,
|
|
opensea_view,
|
|
)
|
|
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
|
|
from openbb_terminal.menu import session
|
|
from openbb_terminal.parent_classes import BaseController
|
|
from openbb_terminal.rich_config import MenuText, console
|
|
|
|
# flake8: noqa
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
class NFTController(BaseController):
|
|
"""NFT Controller class"""
|
|
|
|
CHOICES_COMMANDS = [
|
|
"stats",
|
|
"collections",
|
|
"fp",
|
|
]
|
|
PATH = "/crypto/nft/"
|
|
CHOICES_GENERATION = True
|
|
|
|
def __init__(self, queue: List[str] = None):
|
|
"""Constructor"""
|
|
super().__init__(queue)
|
|
|
|
self.nft_price_floor_collections = nftpricefloor_model.get_collection_slugs()
|
|
|
|
if session and obbff.USE_PROMPT_TOOLKIT:
|
|
choices: dict = self.choices_default
|
|
|
|
choices["fp"].update({c: {} for c in self.nft_price_floor_collections})
|
|
|
|
self.completer = NestedCompleter.from_nested_dict(choices)
|
|
|
|
def print_help(self):
|
|
"""Print help"""
|
|
mt = MenuText("crypto/nft/", 70)
|
|
mt.add_cmd("stats")
|
|
mt.add_cmd("fp")
|
|
mt.add_cmd("collections")
|
|
console.print(text=mt.menu_text, menu="Cryptocurrency - Non Fungible Token")
|
|
|
|
@log_start_end(log=logger)
|
|
def call_fp(self, other_args: List[str]):
|
|
"""Process fp command"""
|
|
parser = argparse.ArgumentParser(
|
|
add_help=False,
|
|
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
|
|
prog="fp",
|
|
description="""
|
|
Display floor price of a certain NFT collection.
|
|
[Source: https://nftpricefloor.com/]
|
|
""",
|
|
)
|
|
|
|
parser.add_argument(
|
|
"-s",
|
|
"--slug",
|
|
type=str,
|
|
help="NFT floor price collection slug (e.g., bored-ape-yacht-club)",
|
|
dest="slug",
|
|
required="-h" not in other_args,
|
|
choices=self.nft_price_floor_collections,
|
|
metavar="SLUG",
|
|
)
|
|
if other_args and not other_args[0][0] == "-":
|
|
other_args.insert(0, "--slug")
|
|
|
|
ns_parser = self.parse_known_args_and_warn(
|
|
parser, other_args, EXPORT_ONLY_RAW_DATA_ALLOWED, raw=True, limit=10
|
|
)
|
|
|
|
if ns_parser:
|
|
nftpricefloor_view.display_floor_price(
|
|
slug=ns_parser.slug,
|
|
export=ns_parser.export,
|
|
sheet_name=" ".join(ns_parser.sheet_name)
|
|
if ns_parser.sheet_name
|
|
else None,
|
|
raw=ns_parser.raw,
|
|
limit=ns_parser.limit,
|
|
)
|
|
|
|
@log_start_end(log=logger)
|
|
def call_stats(self, other_args: List[str]):
|
|
"""Process stats command"""
|
|
parser = argparse.ArgumentParser(
|
|
add_help=False,
|
|
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
|
|
prog="info",
|
|
description="""
|
|
Display stats about an opensea nft collection. e.g. alien-frens
|
|
[Source: https://opensea.io]
|
|
""",
|
|
)
|
|
|
|
parser.add_argument(
|
|
"-s",
|
|
"--slug",
|
|
type=str,
|
|
help="Opensea collection slug (e.g., mutant-ape-yacht-club)",
|
|
dest="slug",
|
|
required="-h" not in other_args,
|
|
)
|
|
if other_args and not other_args[0][0] == "-":
|
|
other_args.insert(0, "--slug")
|
|
|
|
ns_parser = self.parse_known_args_and_warn(
|
|
parser, other_args, EXPORT_ONLY_RAW_DATA_ALLOWED
|
|
)
|
|
|
|
if ns_parser:
|
|
opensea_view.display_collection_stats(
|
|
slug=ns_parser.slug,
|
|
export=ns_parser.export,
|
|
sheet_name=" ".join(ns_parser.sheet_name)
|
|
if ns_parser.sheet_name
|
|
else None,
|
|
)
|
|
|
|
@log_start_end(log=logger)
|
|
def call_collections(self, other_args: List[str]):
|
|
"""Process collections command"""
|
|
parser = argparse.ArgumentParser(
|
|
add_help=False,
|
|
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
|
|
prog="collections",
|
|
description="NFT Collections [Source: https://nftpricefloor.com/]",
|
|
)
|
|
parser.add_argument(
|
|
"--fp",
|
|
dest="fp",
|
|
action="store_true",
|
|
default=False,
|
|
help="Flag to display floor price over time for top collections",
|
|
)
|
|
parser.add_argument(
|
|
"--sales",
|
|
dest="sales",
|
|
action="store_true",
|
|
default=False,
|
|
help="Flag to display sales over time for top collections",
|
|
)
|
|
ns_parser = self.parse_known_args_and_warn(
|
|
parser, other_args, EXPORT_ONLY_RAW_DATA_ALLOWED, limit=5
|
|
)
|
|
if ns_parser:
|
|
nftpricefloor_view.display_collections(
|
|
show_sales=ns_parser.sales,
|
|
show_fp=ns_parser.fp,
|
|
limit=ns_parser.limit,
|
|
export=ns_parser.export,
|
|
sheet_name=" ".join(ns_parser.sheet_name)
|
|
if ns_parser.sheet_name
|
|
else None,
|
|
)
|