Skip to content

Commit

Permalink
health check only fails when no ticker responses
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrtye committed Oct 11, 2024
1 parent f69dddf commit 866900e
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions apiserver/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,20 +202,19 @@ def get_info_by_ticker(tickers):
info = dict()
tickers = tickers.split(" ")

try:
for ticker in tickers:
for ticker in tickers:
try:
price, old_price = get_ticker_prices(ticker)
trend = ((price - old_price) / old_price) * 100
info[ticker] = format_number(price)
info[ticker + "_TREND"] = format_number(trend)

except Exception as e:
print(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"), repr(e))

if info:
global last_updated_time
last_updated_time = time.time()
except Exception as e:
print(
datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
"Error occurred when fetching information",
)

return info

Expand Down

0 comments on commit 866900e

Please sign in to comment.