mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-28 04:52:07 +00:00
Merge branch 'develop' into release/3.0.0
This commit is contained in:
@@ -8,6 +8,7 @@ import pandas as pd
|
||||
|
||||
from openbb_terminal.decorators import log_start_end
|
||||
from openbb_terminal.helper_funcs import request
|
||||
from openbb_terminal.rich_config import console
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -33,13 +34,15 @@ def get_anchor_data(address: str = "") -> Tuple[pd.DataFrame, pd.DataFrame, str]
|
||||
"""
|
||||
|
||||
if not address.startswith("terra"):
|
||||
raise Exception(
|
||||
console.print(
|
||||
"Select a valid address. Valid terra addresses start with 'terra'"
|
||||
)
|
||||
return pd.DataFrame(), pd.DataFrame(), ""
|
||||
|
||||
response = request(f"{api_url}/get-anchor-protocol-data-v2/{address}")
|
||||
if response.status_code != 200:
|
||||
raise Exception(f"Status code: {response.status_code}. Reason: {response.text}")
|
||||
console.print(f"Status code: {response.status_code}. Reason: {response.reason}")
|
||||
return pd.DataFrame(), pd.DataFrame(), ""
|
||||
|
||||
data = response.json()
|
||||
df = pd.DataFrame(reversed(data["historicalData"]))
|
||||
|
||||
@@ -41,9 +41,10 @@ def display_anchor_data(
|
||||
|
||||
df, df_deposits, stats_str = cryptosaurio_model.get_anchor_data(address=address)
|
||||
|
||||
console.print(f"\n{stats_str}\n")
|
||||
if stats_str:
|
||||
console.print(f"\n{stats_str}\n")
|
||||
|
||||
if show_transactions:
|
||||
if not df_deposits.empty and show_transactions:
|
||||
print_rich_table(
|
||||
df_deposits,
|
||||
headers=list(df_deposits.columns),
|
||||
@@ -52,18 +53,20 @@ def display_anchor_data(
|
||||
export=bool(export),
|
||||
)
|
||||
|
||||
fig = OpenBBFigure(yaxis_title="Earnings Value [UST]")
|
||||
fig.set_title("Earnings in Anchor Earn")
|
||||
if not df.empty:
|
||||
fig = OpenBBFigure(yaxis_title="Earnings Value [UST]")
|
||||
fig.set_title("Earnings in Anchor Earn")
|
||||
|
||||
fig.add_scatter(x=df["time"], y=df["yield"], name="Earnings")
|
||||
fig.add_scatter(x=df["time"], y=df["yield"], name="Earnings")
|
||||
|
||||
export_data(
|
||||
export,
|
||||
os.path.dirname(os.path.abspath(__file__)),
|
||||
"anchor",
|
||||
df,
|
||||
sheet_name,
|
||||
fig,
|
||||
)
|
||||
export_data(
|
||||
export,
|
||||
os.path.dirname(os.path.abspath(__file__)),
|
||||
"anchor",
|
||||
df,
|
||||
sheet_name,
|
||||
fig,
|
||||
)
|
||||
|
||||
return fig.show(external=external_axes)
|
||||
return fig.show(external=external_axes)
|
||||
return None
|
||||
|
||||
@@ -340,7 +340,6 @@ def display_roadmap(
|
||||
)
|
||||
|
||||
df_copy = df_copy[df_copy["Date"].notnull()]
|
||||
titles = list(df_copy[df_copy["Date"] > df_prices.index[0]]["Title"])
|
||||
|
||||
max_price = df_prices["Close"].max()
|
||||
for counter, x in enumerate(roadmap_dates):
|
||||
@@ -348,7 +347,7 @@ def display_roadmap(
|
||||
fig.add_annotation(
|
||||
x=x,
|
||||
y=max_price * 0.7,
|
||||
text=titles[counter],
|
||||
text=df.iloc[counter]["Title"],
|
||||
textangle=90,
|
||||
font=dict(size=15),
|
||||
xshift=10,
|
||||
|
||||
@@ -307,7 +307,7 @@ def print_rich_table(
|
||||
try:
|
||||
if not isinstance(df[col].iloc[0], pd.Timestamp):
|
||||
df[col] = pd.to_numeric(df[col])
|
||||
except ValueError:
|
||||
except (ValueError, TypeError):
|
||||
pass
|
||||
|
||||
def _get_headers(_headers: Union[List[str], pd.Index]) -> List[str]:
|
||||
|
||||
Reference in New Issue
Block a user