Kucoin account information
This commit is contained in:
parent
123106a5fd
commit
63bffd9c63
|
@ -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
|
||||
|
|
51
personal_data/fetchers/kucoin.py
Normal file
51
personal_data/fetchers/kucoin.py
Normal 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)
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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')
|
||||
|
|
Loading…
Reference in New Issue
Block a user