1
0

Kucoin account information

This commit is contained in:
Jon Michael Aanes 2024-05-17 00:24:01 +02:00
parent 123106a5fd
commit 63bffd9c63
Signed by: Jmaa
SSH Key Fingerprint: SHA256:Ab0GfHGCblESJx7JRE4fj4bFy/KRpeLhi41y4pF3sNA
5 changed files with 59 additions and 1 deletions

View File

@ -8,6 +8,7 @@ Supported fetchers:
- FFXIV Lodestone achivement history
- Partisia Blockchain BYOC and MPC trackers
- Playstation achievements by way of PSN Profiles.
- [Kraken Account Balances](https://docs.kraken.com/rest/#tag/Account-Data/operation/getAccountBalance)
## Usage
@ -22,7 +23,6 @@ python -m personal_data
- [ ] fredagscafeen.dk
- [ ] [WaniKani](https://docs.api.wanikani.com)
- [ ] Ledger (Live?) Account Balances
- [ ] Kraken Account Balances: https://docs.kraken.com/rest/#tag/Account-Data/operation/getAccountBalance
- [ ] Kucoin Account Balances: https://www.kucoin.com/docs/rest/account/basic-info/get-account-list-spot-margin-trade_hf
## License

View File

@ -0,0 +1,51 @@
import dataclasses
import datetime
import email.utils
import json
from frozendict import frozendict
import logging
from collections.abc import Iterator, Mapping
from decimal import Decimal
from frozendict import frozendict
from personal_data.data import DeduplicateMode, Scraper
from .. import secrets
import kucoin.client
logger = logging.getLogger(__name__)
HOSTNAME = 'api.kucoin.com'
URL_ACCOUNTS = 'https://{hostname}/api/v1/accounts'
# TODO: Move these into secrets!
client = kucoin.client.Client(
secrets.KUCOIN_KEY,
secrets.KUCOIN_SECRET,
secrets.KUCOIN_PASS,
)
@dataclasses.dataclass(frozen=True)
class KucoinAccountBalances(Scraper):
dataset_name = 'defi_kucoin_balance'
deduplicate_mode = DeduplicateMode.ONLY_LATEST
deduplicate_ignore_columns = ['account.update_time']
def scrape(self) -> Iterator[Mapping[str, object]]:
time = datetime.datetime.now()
for account in client.get_accounts():
print(account)
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)

View File

@ -26,6 +26,7 @@ URL_ACCOUNT_PLUGIN_GLOBAL = 'https://{hostname}/{shard}blockchain/accountPlugin/
MPC_DECIMALS = 10000
def shard_id_for_address(address: str) -> str:
return 'shards/Shard2/' # TODO

View File

@ -29,6 +29,7 @@ import personal_data.fetchers.crunchyroll
import personal_data.fetchers.ffxiv_lodestone
import personal_data.fetchers.partisia_blockchain
import personal_data.fetchers.psnprofiles
import personal_data.fetchers.kucoin
from . import mailgun

View File

@ -34,6 +34,11 @@ PLAYSTATION_PSN_ID = load_secret('PLAYSTATION_PSN_ID')
# Partisia Blockchain
PBC_ACCOUNT_ADDRESS = load_secret('PBC_ACCOUNT_ADDRESS')
# Kucoin
KUCOIN_KEY = load_secret('KUCOIN_KEY')
KUCOIN_SECRET = load_secret('KUCOIN_SECRET')
KUCOIN_PASS = load_secret('KUCOIN_PASS')
# Email configuration
MAILGUN_API_KEY = load_secret('MAILGUN_API_KEY')
MAILGUN_DOMAIN = load_secret('MAILGUN_DOMAIN')