Skip to content

Commit

Permalink
Merge branch 'develop' into release/3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jmaslek authored Apr 26, 2023
2 parents 93bd0ea + 45a0609 commit 0c8bcc9
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 19 deletions.
7 changes: 5 additions & 2 deletions openbb_terminal/cryptocurrency/defi/cryptosaurio_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

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__)

Expand All @@ -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"]))
Expand Down
31 changes: 17 additions & 14 deletions openbb_terminal/cryptocurrency/defi/cryptosaurio_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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
3 changes: 1 addition & 2 deletions openbb_terminal/cryptocurrency/due_diligence/messari_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,15 +340,14 @@ 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):
if x > df_prices.index[0]:
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,
Expand Down
2 changes: 1 addition & 1 deletion openbb_terminal/helper_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down

0 comments on commit 0c8bcc9

Please sign in to comment.