test: add test for exchange.features

This commit is contained in:
Matthias
2025-01-31 06:57:03 +01:00
parent 8af8260b7c
commit d530527f11
2 changed files with 24 additions and 0 deletions

View File

@@ -112,6 +112,7 @@ from freqtrade.util.periodic_cache import PeriodicCache
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
T = TypeVar("T") T = TypeVar("T")

View File

@@ -6259,3 +6259,26 @@ def test_price_to_precision_with_default_conf(default_conf, mocker):
prec_price = patched_ex.price_to_precision("XRP/USDT", 1.0000000101) prec_price = patched_ex.price_to_precision("XRP/USDT", 1.0000000101)
assert prec_price == 1.00000001 assert prec_price == 1.00000001
assert prec_price == 1.00000001 assert prec_price == 1.00000001
def test_exchange_features(default_conf, mocker):
conf = copy.deepcopy(default_conf)
exchange = get_patched_exchange(mocker, conf)
exchange._api_async.features = {
"spot": {
"fetchOHLCV": {
"limit": 995,
}
},
"swap": {
"linear": {
"fetchOHLCV": {
"limit": 997,
}
}
},
}
assert exchange.features("spot", "fetchOHLCV", "limit", 500) == 995
assert exchange.features("futures", "fetchOHLCV", "limit", 500) == 997
# Fall back to default
assert exchange.features("futures", "fetchOHLCV_else", "limit", 601) == 601