Ruff
This commit is contained in:
parent
a4be3e49ed
commit
e68b3b539d
|
@ -1,4 +1,3 @@
|
|||
__all__ = ['defi_kraken', 'defi_kucoin']
|
||||
|
||||
from . import defi_kraken
|
||||
from . import defi_kucoin
|
||||
from . import defi_kraken, defi_kucoin
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import dataclasses
|
||||
import datetime
|
||||
from collections.abc import Mapping
|
||||
from decimal import Decimal
|
||||
|
||||
import enforce_typing
|
||||
import dataclasses
|
||||
from decimal import Decimal
|
||||
from collections.abc import Mapping
|
||||
from fin_defs import Asset
|
||||
import datetime
|
||||
|
||||
|
||||
@enforce_typing.enforce_types
|
||||
@dataclasses.dataclass
|
||||
|
@ -12,11 +13,13 @@ class Depo:
|
|||
name: str
|
||||
updated_time: datetime.datetime
|
||||
|
||||
|
||||
@enforce_typing.enforce_types
|
||||
@dataclasses.dataclass
|
||||
class DepoSingle(Depo):
|
||||
assets: Mapping[Asset, Decimal]
|
||||
|
||||
|
||||
@enforce_typing.enforce_types
|
||||
@dataclasses.dataclass
|
||||
class DepoGroup(Depo):
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
from .data import Depo, DepoSingle
|
||||
from decimal import Decimal
|
||||
import fin_defs
|
||||
import datetime
|
||||
import krakenex
|
||||
import logging
|
||||
from decimal import Decimal
|
||||
|
||||
import fin_defs
|
||||
import krakenex
|
||||
|
||||
from .data import Depo, DepoSingle
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class KrakenDepoFetcher:
|
||||
|
||||
class KrakenDepoFetcher:
|
||||
def __init__(self, kraken_key: str, kraken_secret: str):
|
||||
self.client = krakenex.API(
|
||||
kraken_key,
|
||||
|
|
|
@ -1,20 +1,16 @@
|
|||
from .data import DepoSingle, DepoGroup
|
||||
import dataclasses
|
||||
import datetime
|
||||
import fin_defs
|
||||
import logging
|
||||
from collections.abc import Iterator, Mapping
|
||||
from decimal import Decimal
|
||||
|
||||
import fin_defs
|
||||
import kucoin.client
|
||||
from frozendict import frozendict
|
||||
|
||||
from personal_data.data import DeduplicateMode, Scraper
|
||||
from .data import DepoGroup, DepoSingle
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class KucoinDepoFetcher:
|
||||
|
||||
class KucoinDepoFetcher:
|
||||
def __init__(self, kucoin_key: str, kucoin_secret: str, kucoin_pass: str):
|
||||
self.client = kucoin.client.Client(
|
||||
kucoin_key,
|
||||
|
@ -28,10 +24,18 @@ class KucoinDepoFetcher:
|
|||
for account_data in self.client.get_accounts():
|
||||
asset = fin_defs.WELL_KNOWN_SYMBOLS[account_data['currency']]
|
||||
balance = Decimal(account_data['balance'])
|
||||
assets_for_account_type = assets_by_account_type.get(account_data['type'], {})
|
||||
assets_for_account_type[asset] = assets_for_account_type.get(asset, Decimal(0)) +balance
|
||||
assets_for_account_type = assets_by_account_type.get(
|
||||
account_data['type'], {},
|
||||
)
|
||||
assets_for_account_type[asset] = (
|
||||
assets_for_account_type.get(asset, Decimal(0)) + balance
|
||||
)
|
||||
del account_data, asset, balance
|
||||
return DepoGroup("Kucoin", now, [
|
||||
DepoSingle("Kucoin " + account_type, now, assets) for account_type,
|
||||
assets in assets_by_account_type.items()
|
||||
])
|
||||
return DepoGroup(
|
||||
'Kucoin',
|
||||
now,
|
||||
[
|
||||
DepoSingle('Kucoin ' + account_type, now, assets)
|
||||
for account_type, assets in assets_by_account_type.items()
|
||||
],
|
||||
)
|
||||
|
|
3
setup.py
3
setup.py
|
@ -15,6 +15,7 @@ PACKAGE_NAME = 'fin_depo'
|
|||
with open('README.md') as f:
|
||||
readme = f.read()
|
||||
|
||||
|
||||
def parse_version_file(text: str) -> str:
|
||||
match = re.match(r'^__version__\s*=\s*(["\'])([\d\.]+)\1$', text)
|
||||
if match is None:
|
||||
|
@ -22,9 +23,11 @@ def parse_version_file(text: str) -> str:
|
|||
raise Exception(msg)
|
||||
return match.group(2)
|
||||
|
||||
|
||||
with open(PACKAGE_NAME + '/_version.py') as f:
|
||||
version = parse_version_file(f.read())
|
||||
|
||||
|
||||
def parse_requirements(text: str) -> list[str]:
|
||||
return text.strip().split('\n')
|
||||
|
||||
|
|
|
@ -1,6 +1,2 @@
|
|||
import pytest
|
||||
|
||||
import fin_depo
|
||||
|
||||
def test_nothing():
|
||||
pass
|
||||
|
|
Loading…
Reference in New Issue
Block a user