From c42092137eff37ca85f372dab64200be8a999c6d Mon Sep 17 00:00:00 2001 From: Jon Michael Aanes Date: Fri, 17 May 2024 00:29:02 +0200 Subject: [PATCH] Kucoin balances with format similar to defi_mpc --- personal_data/fetchers/kucoin.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/personal_data/fetchers/kucoin.py b/personal_data/fetchers/kucoin.py index 64be6f7..81d46ba 100644 --- a/personal_data/fetchers/kucoin.py +++ b/personal_data/fetchers/kucoin.py @@ -36,16 +36,12 @@ class KucoinAccountBalances(Scraper): deduplicate_ignore_columns = ['account.update_time'] def scrape(self) -> Iterator[Mapping[str, object]]: - time = datetime.datetime.now() + data_point = { + 'account.update_time': datetime.datetime.now(tz=datetime.UTC), + } + for account in client.get_accounts(): - print(account) + key = f"balance.{account['currency']}" + data_point[key] = data_point.get(key, Decimal(0)) + Decimal(account['balance']) - data_point = { - 'account.id': account['id'], - 'account.currency': account['currency'], - 'account.type': account['type'], - 'account.balance': account['balance'], - 'account.update_time': time, - } - - yield frozendict(data_point) + yield frozendict(data_point)