mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-29 13:32:08 +00:00
Fix bugs for fetching crypto prices on chain and displaying very small numbers in tables (#1762)
* Fix bugs fetching token prices #1741 * Fix bug displaying very small floats in tables #1741 Co-authored-by: Alex Ferrari <a.ferrari88@gmail.com> Co-authored-by: Theodore Aptekarev <aptekarev@gmail.com>
This commit is contained in:
@@ -161,7 +161,7 @@ def make_request(
|
||||
if response.status_code == 200:
|
||||
result = response.json()
|
||||
|
||||
if result:
|
||||
if not result:
|
||||
console.print("No data found")
|
||||
|
||||
elif response.status_code == 401:
|
||||
@@ -532,7 +532,8 @@ def get_token_historical_price(address) -> pd.DataFrame:
|
||||
|
||||
prices_df = pd.DataFrame(prices)
|
||||
prices_df["ts"] = prices_df["ts"].apply(lambda x: datetime.fromtimestamp(x))
|
||||
prices_df.drop("tmp", axis=1, inplace=True)
|
||||
if "tmp" in prices_df.columns:
|
||||
prices_df.drop("tmp", axis=1, inplace=True)
|
||||
|
||||
return prices_df[
|
||||
["date", "open", "close", "high", "low", "volumeConverted", "cap", "average"]
|
||||
|
||||
@@ -190,7 +190,9 @@ def print_rich_table(
|
||||
for idx, values in zip(df.index.tolist(), df.values.tolist()):
|
||||
row = [str(idx)] if show_index else []
|
||||
row += [
|
||||
str(x) if not isinstance(x, float) else f"{x:{floatfmt[idx]}}"
|
||||
str(x)
|
||||
if not isinstance(x, float)
|
||||
else (f"{x:{floatfmt[idx]}}" if x >= 0.01 else f"{x:.2e}")
|
||||
for idx, x in enumerate(values)
|
||||
]
|
||||
table.add_row(*row)
|
||||
|
||||
Reference in New Issue
Block a user