From a26bb2e85f07afecefa3e59e15d4a0c2ace62559 Mon Sep 17 00:00:00 2001 From: khushal Date: Thu, 26 Dec 2024 14:42:28 +0530 Subject: [PATCH] (20241226) Bug fixed when Zerodha's instruments are asked from an expired key. --- .../finstitutions/trading/symbols/list.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/api/blueprints/finstitutions/trading/symbols/list.py b/api/blueprints/finstitutions/trading/symbols/list.py index 3b52a30..168a1df 100644 --- a/api/blueprints/finstitutions/trading/symbols/list.py +++ b/api/blueprints/finstitutions/trading/symbols/list.py @@ -193,17 +193,18 @@ async def request_oauth_authorization_url( # ┛ # Handle time data: - data = [s.model_dump() for s in symbol_list.data] if symbol_list.data is not None else symbol_list.data - for d in data: - expiry_ts = d["expiryTs"] - if isinstance(expiry_ts, datetime.datetime): - d["expiryTs"] = expiry_ts.timestamp() + if symbol_list.data: + symbol_list.data = [s.model_dump() for s in symbol_list.data] + for d in symbol_list.data: + expiry_ts = d["expiryTs"] + if isinstance(expiry_ts, datetime.datetime): + d["expiryTs"] = expiry_ts.timestamp() # Done here: return ResponseModel( status_code = StatusCodes.OK if symbol_list.success else StatusCodes.FAILED, http_code = HttpCodes.SUCCESS if symbol_list.success else HttpCodes.INTERNAL_SERVER_ERROR, - data = data, + data = symbol_list.data, message = symbol_list.message )