This commit is contained in:
parent
59b196348a
commit
5cc88e1d02
|
@ -41,16 +41,22 @@ class KrakenDepoFetcher(DepoFetcher):
|
|||
result = self.client.query_private('Balance')
|
||||
|
||||
assets: dict[fin_defs.Asset, Decimal] = {}
|
||||
for account_raw, balance_str in result['result'].items():
|
||||
account = account_raw.removesuffix('.HOLD')
|
||||
asset = fin_defs.WELL_KNOWN_SYMBOLS[account]
|
||||
for ticker, balance_str in result['result'].items():
|
||||
asset = parse_asset_from_ticker(ticker)
|
||||
|
||||
balance = Decimal(balance_str)
|
||||
if balance != 0:
|
||||
assets[asset] = assets.get(asset, Decimal(0)) + balance
|
||||
del account, account_raw, balance_str, asset, balance
|
||||
del ticker, balance_str, asset, balance
|
||||
|
||||
return DepoSingle(
|
||||
name='Kraken',
|
||||
_assets=assets,
|
||||
updated_time=now,
|
||||
)
|
||||
|
||||
def parse_asset_from_ticker(ticker: str) -> fin_defs.Asset:
|
||||
account = ticker.removesuffix('.HOLD')
|
||||
if account == 'ZEUR':
|
||||
return fin_defs.EUR
|
||||
asset = fin_defs.WELL_KNOWN_SYMBOLS[account]
|
||||
|
|
|
@ -12,6 +12,11 @@ from .data import DepoFetcher, DepoGroup, DepoSingle, TradeOrderDetails
|
|||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
def parse_asset_from_ticker(ticker: str) -> fin_defs.Asset:
|
||||
if ticker == 'KCS':
|
||||
return fin_defs.CryptoCurrency('KCS', coingecko_id='kucoin-shares')
|
||||
return fin_defs.WELL_KNOWN_SYMBOLS[ticker]
|
||||
|
||||
|
||||
class KucoinDepoFetcher(DepoFetcher):
|
||||
"""`Depo` fetcher for [Kucoin](https://www.kucoin.com), the online crypto currency exchange.
|
||||
|
@ -56,7 +61,7 @@ class KucoinDepoFetcher(DepoFetcher):
|
|||
assets_by_account_type: dict[str, dict[fin_defs.Asset, Decimal]] = {}
|
||||
|
||||
for account_data in self.kucoin_client.get_accounts():
|
||||
asset = fin_defs.WELL_KNOWN_SYMBOLS[account_data['currency']]
|
||||
asset = parse_asset_from_ticker(account_data['currency'])
|
||||
balance = Decimal(account_data['balance'])
|
||||
assets_for_account_type = assets_by_account_type.setdefault(
|
||||
account_data['type'],
|
||||
|
@ -164,7 +169,7 @@ class KucoinDepoFetcher(DepoFetcher):
|
|||
input_amount=input_amount_final,
|
||||
output_asset=output_asset,
|
||||
output_amount=output_amount_final,
|
||||
fee_asset=fin_defs.WELL_KNOWN_SYMBOLS[order_details['feeCurrency']],
|
||||
fee_asset=parse_asset_from_ticker(order_details['feeCurrency']),
|
||||
fee_amount=Decimal(order_details['fee']),
|
||||
executed_time=datetime.datetime.fromtimestamp(
|
||||
order_details['createdAt'] / 1000,
|
||||
|
|
Loading…
Reference in New Issue
Block a user