mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-12-01 17:43:06 +00:00
test: refactor _get_params test for simpler reading
This commit is contained in:
@@ -5942,32 +5942,32 @@ def test_get_max_leverage_futures(default_conf, mocker, leverage_tiers):
|
||||
assert exchange.get_max_leverage("TIA/USDT:USDT", 130.008) == 40
|
||||
|
||||
|
||||
@pytest.mark.parametrize("exchange_name", ["binance", "kraken", "gate", "okx", "bybit", "bitget"])
|
||||
def test__get_params(mocker, default_conf, exchange_name):
|
||||
@pytest.mark.parametrize(
|
||||
"exchange_name, add_params_spot, add_params_futures",
|
||||
[
|
||||
("binance", {}, {}),
|
||||
("kraken", {}, {"leverage": 3.0}),
|
||||
("gate", {}, {}),
|
||||
("okx", {}, {"tdMode": "isolated", "posSide": "net"}),
|
||||
("bybit", {}, {"position_idx": 0}),
|
||||
("bitget", {}, {"marginMode": "isolated"}),
|
||||
],
|
||||
)
|
||||
def test__get_params(mocker, default_conf, exchange_name, add_params_spot, add_params_futures):
|
||||
api_mock = MagicMock()
|
||||
mocker.patch(f"{EXMS}.exchange_has", return_value=True)
|
||||
exchange = get_patched_exchange(mocker, default_conf, api_mock, exchange=exchange_name)
|
||||
exchange._params = {"test": True}
|
||||
|
||||
params1 = {"test": True}
|
||||
params2 = {
|
||||
params1.update(add_params_spot)
|
||||
|
||||
params_fut = {
|
||||
"test": True,
|
||||
"timeInForce": "IOC",
|
||||
"reduceOnly": True,
|
||||
}
|
||||
|
||||
if exchange_name == "kraken":
|
||||
params2["leverage"] = 3.0
|
||||
|
||||
if exchange_name == "okx":
|
||||
params2["tdMode"] = "isolated"
|
||||
params2["posSide"] = "net"
|
||||
|
||||
if exchange_name == "bybit":
|
||||
params2["position_idx"] = 0
|
||||
|
||||
if exchange_name == "bitget":
|
||||
params2["marginMode"] = "isolated"
|
||||
params_fut.update(add_params_futures)
|
||||
|
||||
assert (
|
||||
exchange._get_params(
|
||||
@@ -6015,7 +6015,7 @@ def test__get_params(mocker, default_conf, exchange_name):
|
||||
time_in_force="IOC",
|
||||
leverage=3.0,
|
||||
)
|
||||
== params2
|
||||
== params_fut
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user