mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-29 20:53:54 +00:00
* 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
45 lines
1.3 KiB
Python
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,
|
|
)
|