Skip to content

Commit

Permalink
fix: improve binance service
Browse files Browse the repository at this point in the history
  • Loading branch information
adagora committed Nov 29, 2023
1 parent 872e2fb commit 8141c57
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions solarathon/pages/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,13 @@ def format_price(price):

def get_binance_ticket(symbol: str) -> TickerData:
binance_url = f"https://api.binance.us/api/v3/ticker/24hr?symbol={symbol}"
return TickerData.model_validate_json(
json_data=requests.get(binance_url).content
)
response = requests.get(binance_url)
if response.status_code == 200:
return TickerData.model_validate_json(json_data=response.content)
else:
solara.Error(f"Failed to retrieve data from API: {response.content}")
return TickerData(symbol=f"{symbol} no data", last_price='0', price_change_percent='0', high_price='0', low_price='0')



@solara.component
Expand Down

0 comments on commit 8141c57

Please sign in to comment.