From a2ef81eab54b913a9155b6c7c3285937ae4c0923 Mon Sep 17 00:00:00 2001 From: agijsberts Date: Tue, 16 Jan 2024 00:58:43 +0100 Subject: [PATCH] Handle null next_funding_time and estimated_rate in HuobiSwap funding (#1004) --- CHANGES.md | 1 + cryptofeed/exchanges/huobi_swap.py | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index b6eda98fb..1708aceb3 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,6 +2,7 @@ ### 2.4.1 * Bugfix: Handle empty nextFundingRate in OKX + * Bugfix: Handle null next_funding_time and estimated_rate in HuobiSwap funding ### 2.4.0 (2024-01-07) * Update: Fix tests diff --git a/cryptofeed/exchanges/huobi_swap.py b/cryptofeed/exchanges/huobi_swap.py index 0b7ff4cca..ea206bd32 100644 --- a/cryptofeed/exchanges/huobi_swap.py +++ b/cryptofeed/exchanges/huobi_swap.py @@ -86,7 +86,7 @@ async def _funding(self, pairs): data = await self.http_conn.read(endpoint) data = json.loads(data, parse_float=Decimal) received = time.time() - update = (data['data']['funding_rate'], self.timestamp_normalize(int(data['data']['next_funding_time']))) + update = (data['data']['funding_rate'], self.timestamp_normalize(int(data['data']['funding_time']))) if pair in self.funding_updates and self.funding_updates[pair] == update: await asyncio.sleep(1) continue @@ -97,9 +97,9 @@ async def _funding(self, pairs): self.exchange_symbol_to_std_symbol(pair), None, Decimal(data['data']['funding_rate']), - self.timestamp_normalize(int(data['data']['next_funding_time'])), + self.timestamp_normalize(int(data['data']['next_funding_time'])) if data['data']['next_funding_time'] else None, self.timestamp_normalize(int(data['data']['funding_time'])), - predicted_rate=Decimal(data['data']['estimated_rate']), + predicted_rate=Decimal(data['data']['estimated_rate']) if data['data']['estimated_rate'] is not None else None, raw=data ) await self.callback(FUNDING, f, received)