Skip to content

Commit

Permalink
add error logging
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrtye committed Feb 9, 2024
1 parent 6e9be23 commit 9323b3f
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions apiserver/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ def get_ticker_info(symbol, trend=False):

if not trend:
return current_price

old_info = tickers.tickers[symbol].history(period="2d", interval="60m")
old_price = old_info["Close"][old_info["Close"].keys().max()]
old_price = old_info["Close"][old_info["Close"].keys().max()]

return ((old_price - current_price) / current_price) * 100

Expand All @@ -141,7 +141,10 @@ def update_exchange_status():
"CAD_TREND": format_number(get_ticker_info("CADCNY=X", trend=True)),
}
except Exception as e:
pass
print(
datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
"Error occurred when fetching exchange status",
)


def update_stock_status():
Expand All @@ -159,7 +162,10 @@ def update_stock_status():
"SS_TREND": format_number(get_ticker_info("000001.SS", trend=True)),
}
except Exception as e:
pass
print(
datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
"Error occurred when fetching stock status",
)


if __name__ == "__main__":
Expand Down

0 comments on commit 9323b3f

Please sign in to comment.