mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-12-15 20:31:43 +00:00
refactor: type fetch_positions response
This commit is contained in:
@@ -88,7 +88,14 @@ from freqtrade.exchange.exchange_utils_timeframe import (
|
|||||||
timeframe_to_seconds,
|
timeframe_to_seconds,
|
||||||
)
|
)
|
||||||
from freqtrade.exchange.exchange_ws import ExchangeWS
|
from freqtrade.exchange.exchange_ws import ExchangeWS
|
||||||
from freqtrade.exchange.types import CcxtBalances, OHLCVResponse, OrderBook, Ticker, Tickers
|
from freqtrade.exchange.types import (
|
||||||
|
CcxtBalances,
|
||||||
|
CcxtPosition,
|
||||||
|
OHLCVResponse,
|
||||||
|
OrderBook,
|
||||||
|
Ticker,
|
||||||
|
Tickers,
|
||||||
|
)
|
||||||
from freqtrade.misc import (
|
from freqtrade.misc import (
|
||||||
chunks,
|
chunks,
|
||||||
deep_merge_dicts,
|
deep_merge_dicts,
|
||||||
@@ -1683,7 +1690,7 @@ class Exchange:
|
|||||||
raise OperationalException(e) from e
|
raise OperationalException(e) from e
|
||||||
|
|
||||||
@retrier
|
@retrier
|
||||||
def fetch_positions(self, pair: Optional[str] = None) -> List[Dict]:
|
def fetch_positions(self, pair: Optional[str] = None) -> List[CcxtPosition]:
|
||||||
"""
|
"""
|
||||||
Fetch positions from the exchange.
|
Fetch positions from the exchange.
|
||||||
If no pair is given, all positions are returned.
|
If no pair is given, all positions are returned.
|
||||||
@@ -1695,7 +1702,7 @@ class Exchange:
|
|||||||
symbols = []
|
symbols = []
|
||||||
if pair:
|
if pair:
|
||||||
symbols.append(pair)
|
symbols.append(pair)
|
||||||
positions: List[Dict] = self._api.fetch_positions(symbols)
|
positions: List[CcxtPosition] = self._api.fetch_positions(symbols)
|
||||||
self._log_exchange_response("fetch_positions", positions)
|
self._log_exchange_response("fetch_positions", positions)
|
||||||
return positions
|
return positions
|
||||||
except ccxt.DDoSProtection as e:
|
except ccxt.DDoSProtection as e:
|
||||||
|
|||||||
@@ -37,5 +37,15 @@ class CcxtBalance(TypedDict):
|
|||||||
CcxtBalances = Dict[str, CcxtBalance]
|
CcxtBalances = Dict[str, CcxtBalance]
|
||||||
|
|
||||||
|
|
||||||
|
class CcxtPosition(TypedDict):
|
||||||
|
symbol: str
|
||||||
|
side: str
|
||||||
|
contracts: float
|
||||||
|
leverage: float
|
||||||
|
collateral: Optional[float]
|
||||||
|
initialMargin: Optional[float]
|
||||||
|
liquidationPrice: Optional[float]
|
||||||
|
|
||||||
|
|
||||||
# pair, timeframe, candleType, OHLCV, drop last?,
|
# pair, timeframe, candleType, OHLCV, drop last?,
|
||||||
OHLCVResponse = Tuple[str, str, CandleType, List, bool]
|
OHLCVResponse = Tuple[str, str, CandleType, List, bool]
|
||||||
|
|||||||
Reference in New Issue
Block a user