Files
OpenBB/gamestonk_terminal/cryptocurrency/nft/opensea_view.py
jose-donato c901bb9267 NFT feature opensea collection statistics (#1109)
* added statistics for opensea collection feature

* trying to fix json error

* trying to fix json error

* fixing vcr tests

* print to include 2 decimal cases

* fixing tests

* added to script, date format and require

* fix: linting
2021-12-30 11:34:25 +00:00

45 lines
1.3 KiB
Python

""" opensea.io View """
import os
from tabulate import tabulate
from gamestonk_terminal import feature_flags as gtff
from gamestonk_terminal.helper_funcs import export_data
from gamestonk_terminal.cryptocurrency.nft.opensea_model import get_collection_stats
def display_collection_stats(slug: str, export: str):
"""Display collection stats. [Source: opensea.io]
Parameters
----------
slug: str
Opensea collection slug. If the name of the collection is Mutant Ape Yacht Club the slug is mutant-ape-yacht-club
export : str
Export dataframe data to csv,json,xlsx file
"""
collection_stats_df = get_collection_stats(slug)
if collection_stats_df.empty:
print("No data found.", "\n")
else:
if gtff.USE_TABULATE_DF:
print(
tabulate(
collection_stats_df,
headers=collection_stats_df.columns,
floatfmt=".2f",
showindex=False,
tablefmt="fancy_grid",
),
"\n",
)
else:
print(collection_stats_df.to_string, "\n")
export_data(
export,
os.path.dirname(os.path.abspath(__file__)),
"stats",
collection_stats_df,
)