Skip to content

Commit 8af8260

Browse files
committed
feat: initial "features" support
1 parent 7a17cd7 commit 8af8260

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

freqtrade/exchange/exchange.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from datetime import datetime, timedelta, timezone
1313
from math import floor, isnan
1414
from threading import Lock
15-
from typing import Any, Literal, TypeGuard
15+
from typing import Any, Literal, TypeGuard, TypeVar
1616

1717
import ccxt
1818
import ccxt.pro as ccxt_pro
@@ -112,6 +112,7 @@
112112

113113

114114
logger = logging.getLogger(__name__)
115+
T = TypeVar("T")
115116

116117

117118
class Exchange:
@@ -887,6 +888,24 @@ def exchange_has(self, endpoint: str) -> bool:
887888
return self._ft_has["exchange_has_overrides"][endpoint]
888889
return endpoint in self._api_async.has and self._api_async.has[endpoint]
889890

891+
def features(
892+
self, market_type: Literal["spot", "futures"], endpoint, attribute, default: T
893+
) -> T:
894+
"""
895+
Returns the exchange features for the given markettype
896+
https://docs.ccxt.com/#/README?id=features
897+
attributes are in a nested dict, with spot and swap.linear
898+
e.g. spot.fetchOHLCV.limit
899+
swap.linear.fetchOHLCV.limit
900+
"""
901+
feat = (
902+
self._api_async.features.get("spot", {})
903+
if market_type == "spot"
904+
else self._api_async.features.get("swap", {}).get("linear", {})
905+
)
906+
907+
return feat.get(endpoint, {}).get(attribute, default)
908+
890909
def get_precision_amount(self, pair: str) -> float | None:
891910
"""
892911
Returns the amount precision of the exchange.

0 commit comments

Comments
 (0)