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)