Skip to content

Commit

Permalink
[bug] nft price model (OpenBB-finance#2475)
Browse files Browse the repository at this point in the history
* Update nftpricefloor_model.py

* fixes to match new api

Co-authored-by: James Maslek <[email protected]>
Co-authored-by: Colin Delahunty <[email protected]>
  • Loading branch information
3 people authored Sep 14, 2022
1 parent f4bbcbc commit 4049005
Show file tree
Hide file tree
Showing 9 changed files with 6,700 additions and 5,493 deletions.
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

0 comments on commit 4049005

Please sign in to comment.