Kucoin balances with format similar to defi_mpc
This commit is contained in:
parent
63bffd9c63
commit
c42092137e
|
@ -36,16 +36,12 @@ class KucoinAccountBalances(Scraper):
|
||||||
deduplicate_ignore_columns = ['account.update_time']
|
deduplicate_ignore_columns = ['account.update_time']
|
||||||
|
|
||||||
def scrape(self) -> Iterator[Mapping[str, object]]:
|
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():
|
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 = {
|
yield frozendict(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)
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user