mirror of
https://github.com/freqtrade/freqtrade.git
synced 2026-01-20 14:00:38 +00:00
fix(kraken): consolidate balances from "rewards"
These currencies show up as <currency>.F - but can be traded normally - hence we should count them as "tradable" balance. closes #11007 closes #10925
This commit is contained in:
@@ -56,6 +56,22 @@ class Kraken(Exchange):
|
||||
symbols = list(self.get_markets(quote_currencies=[self._config["stake_currency"]]))
|
||||
return super().get_tickers(symbols=symbols, cached=cached)
|
||||
|
||||
def consolidate_balances(self, balances: CcxtBalances) -> CcxtBalances:
|
||||
"""
|
||||
Consolidate balances for the same currency.
|
||||
Kraken returns ".F" balances if rewards is enabled.
|
||||
"""
|
||||
consolidated = {}
|
||||
for currency, balance in balances.items():
|
||||
base_currency = currency[:-2] if currency.endswith(".F") else currency
|
||||
if base_currency in consolidated:
|
||||
consolidated[base_currency]["free"] += balance["free"]
|
||||
consolidated[base_currency]["used"] += balance["used"]
|
||||
consolidated[base_currency]["total"] += balance["total"]
|
||||
else:
|
||||
consolidated[base_currency] = balance
|
||||
return consolidated
|
||||
|
||||
@retrier
|
||||
def get_balances(self) -> CcxtBalances:
|
||||
if self._config["dry_run"]:
|
||||
@@ -69,6 +85,10 @@ class Kraken(Exchange):
|
||||
balances.pop("total", None)
|
||||
balances.pop("used", None)
|
||||
self._log_exchange_response("fetch_balances", balances)
|
||||
|
||||
# Consolidate balances
|
||||
balances = self.consolidate_balances(balances)
|
||||
|
||||
orders = self._api.fetch_open_orders()
|
||||
order_list = [
|
||||
(
|
||||
|
||||
Reference in New Issue
Block a user