Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] nft price model #2475

Merged
merged 6 commits into from
Sep 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions openbb_terminal/cryptocurrency/nft/nftpricefloor_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ def get_collections() -> pd.DataFrame:
pd.DataFrame
nft collections
"""
res = requests.get(f"{API_URL}/nfts")
res = requests.get(f"{API_URL}/projects")
if res.status_code == 200:
data = res.json()
df = pd.DataFrame(data)
df_stats = pd.json_normalize(df["stats"])
df = pd.concat([df, df_stats], axis=1)
return df
return pd.DataFrame()

Expand All @@ -54,13 +56,13 @@ def get_floor_price(slug) -> pd.DataFrame:
pd.DataFrame
nft collections
"""
res = requests.get(f"{API_URL}/nft/{slug}/chart/pricefloor?interval=all")
res = requests.get(f"{API_URL}/projects/{slug}/charts/all")
if res.status_code == 200:
data = res.json()
df = pd.DataFrame(
data, columns=["dates", "dataPriceFloorETH", "dataVolumeETH", "sales"]
data, columns=["timestamps", "floorEth", "volumeEth", "salesCount"]
)
df = df.set_index("dates")
df.index = pd.to_datetime(df.index)
df = df.set_index("timestamps")
df.index = pd.to_datetime(df.index * 1_000_000)
return df
return pd.DataFrame()
13 changes: 6 additions & 7 deletions openbb_terminal/cryptocurrency/nft/nftpricefloor_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,9 @@ def display_collections(
df = df[
[
"slug",
"name",
"floorPriceETH",
"floorInfo.currentFloorEth",
"totalSupply",
"countOnSale",
"listedCount",
"blockchain",
]
]
Expand All @@ -59,9 +58,9 @@ def display_collections(
df_collection = nftpricefloor_model.get_floor_price(collection)
if not df_collection.empty:
values = (
df_collection["dataPriceFloorETH"]
df_collection["floorEth"]
if show_fp
else df_collection["sales"]
else df_collection["salesCount"]
)
ax.plot(df_collection.index, values, label=collection)
ax.set_ylabel("Floor Price [ETH]" if show_fp else "Sales")
Expand Down Expand Up @@ -125,14 +124,14 @@ def display_floor_price(
_, ax = plt.subplots(figsize=plot_autoscale(), dpi=PLOT_DPI)
elif is_valid_axes_count(external_axes, 1):
(ax,) = external_axes
ax.bar(df.index, df["sales"], color=theme.down_color, label="Sales")
ax.bar(df.index, df["salesCount"], color=theme.down_color, label="Sales")
ax.set_xlim(
df.index[0],
df.index[-1],
)

ax2 = ax.twinx()
ax2.plot(df["dataPriceFloorETH"], color=theme.up_color, label="Floor Price")
ax2.plot(df["floorEth"], color=theme.up_color, label="Floor Price")
ax2.set_ylabel("Sales", labelpad=20)
ax2.set_zorder(ax2.get_zorder() + 1)
ax.patch.set_visible(False)
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Loading