mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-11-29 00:23:07 +00:00
chore: improve typing for balance endpoint
This commit is contained in:
@@ -88,7 +88,7 @@ from freqtrade.exchange.exchange_utils_timeframe import (
|
||||
timeframe_to_seconds,
|
||||
)
|
||||
from freqtrade.exchange.exchange_ws import ExchangeWS
|
||||
from freqtrade.exchange.types import OHLCVResponse, OrderBook, Ticker, Tickers
|
||||
from freqtrade.exchange.types import CcxtBalances, OHLCVResponse, OrderBook, Ticker, Tickers
|
||||
from freqtrade.misc import (
|
||||
chunks,
|
||||
deep_merge_dicts,
|
||||
@@ -1663,7 +1663,7 @@ class Exchange:
|
||||
return order
|
||||
|
||||
@retrier
|
||||
def get_balances(self) -> dict:
|
||||
def get_balances(self) -> CcxtBalances:
|
||||
try:
|
||||
balances = self._api.fetch_balance()
|
||||
# Remove additional info from ccxt results
|
||||
|
||||
@@ -12,7 +12,7 @@ from freqtrade.enums import MarginMode, TradingMode
|
||||
from freqtrade.exceptions import DDosProtection, OperationalException, TemporaryError
|
||||
from freqtrade.exchange import Exchange
|
||||
from freqtrade.exchange.common import retrier
|
||||
from freqtrade.exchange.types import Tickers
|
||||
from freqtrade.exchange.types import CcxtBalances, Tickers
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -57,7 +57,7 @@ class Kraken(Exchange):
|
||||
return super().get_tickers(symbols=symbols, cached=cached)
|
||||
|
||||
@retrier
|
||||
def get_balances(self) -> dict:
|
||||
def get_balances(self) -> CcxtBalances:
|
||||
if self._config["dry_run"]:
|
||||
return {}
|
||||
|
||||
|
||||
@@ -25,6 +25,14 @@ class OrderBook(TypedDict):
|
||||
nonce: Optional[int]
|
||||
|
||||
|
||||
class CcxtBalance(TypedDict):
|
||||
free: float
|
||||
used: float
|
||||
total: float
|
||||
|
||||
|
||||
CcxtBalances = Dict[str, CcxtBalance]
|
||||
|
||||
Tickers = Dict[str, Ticker]
|
||||
|
||||
# pair, timeframe, candleType, OHLCV, drop last?,
|
||||
|
||||
@@ -139,9 +139,9 @@ class Wallets:
|
||||
if isinstance(balances[currency], dict):
|
||||
self._wallets[currency] = Wallet(
|
||||
currency,
|
||||
balances[currency].get("free"),
|
||||
balances[currency].get("used"),
|
||||
balances[currency].get("total"),
|
||||
balances[currency].get("free", 0),
|
||||
balances[currency].get("used", 0),
|
||||
balances[currency].get("total", 0),
|
||||
)
|
||||
# Remove currencies no longer in get_balances output
|
||||
for currency in deepcopy(self._wallets):
|
||||
|
||||
Reference in New Issue
Block a user