Kucoin use fin_depo
This commit is contained in:
parent
9a1900b5d4
commit
526e5eee02
|
@ -6,6 +6,7 @@ from decimal import Decimal
|
|||
|
||||
import kucoin.client
|
||||
from frozendict import frozendict
|
||||
from fin_depo.defi_kucoin import KucoinDepoFetcher
|
||||
|
||||
from personal_data.data import DeduplicateMode, Scraper
|
||||
|
||||
|
@ -21,7 +22,6 @@ client = kucoin.client.Client(
|
|||
secrets.KUCOIN_PASS,
|
||||
)
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class KucoinAccountBalances(Scraper):
|
||||
dataset_name = 'defi_kucoin_balance'
|
||||
|
@ -29,20 +29,28 @@ class KucoinAccountBalances(Scraper):
|
|||
deduplicate_ignore_columns = ['account.update_time']
|
||||
|
||||
def scrape(self) -> Iterator[Mapping[str, object]]:
|
||||
fetcher = KucoinDepoFetcher(
|
||||
kucoin_key = secrets.KUCOIN_KEY,
|
||||
kucoin_secret = secrets.KUCOIN_SECRET,
|
||||
kucoin_pass = secrets.KUCOIN_PASS,
|
||||
)
|
||||
|
||||
depo = fetcher.get_depo()
|
||||
|
||||
data_point = {
|
||||
'account.update_time': datetime.datetime.now(tz=datetime.UTC),
|
||||
'account.update_time': depo.updated_time,
|
||||
}
|
||||
|
||||
for account in client.get_accounts():
|
||||
key = f"balance.{account['currency']}"
|
||||
data_point[key] = data_point.get(key, Decimal(0)) + Decimal(
|
||||
account['balance'],
|
||||
)
|
||||
for asset in depo.assets():
|
||||
key = f"balance.{asset}"
|
||||
data_point[key] = depo.get_amount_of_asset(asset)
|
||||
|
||||
print(data_point)
|
||||
|
||||
yield frozendict(data_point)
|
||||
|
||||
|
||||
def addresses_to_data_points(addresses) -> frozendict:
|
||||
def addresses_to_data_points(addresses: list[dict[str,str]]) -> frozendict:
|
||||
data_point = {}
|
||||
data_point['account.update_time'] = datetime.datetime.now(tz=datetime.UTC)
|
||||
data_point['account.num_deposit_addresses'] = len(addresses)
|
||||
|
|
|
@ -7,3 +7,4 @@ cfscrape
|
|||
frozendict
|
||||
python-kucoin
|
||||
krakenex
|
||||
fin-depo
|
||||
|
|
Loading…
Reference in New Issue
Block a user