From 230dd15ee73500d9c9af27deb6d6c73d4b217933 Mon Sep 17 00:00:00 2001 From: Sam Germain Date: Fri, 31 Dec 2021 06:40:12 -0600 Subject: [PATCH] fixed test_amount_to_precision --- tests/exchange/test_exchange.py | 40 +++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/tests/exchange/test_exchange.py b/tests/exchange/test_exchange.py index 94aee0e14..268da5b69 100644 --- a/tests/exchange/test_exchange.py +++ b/tests/exchange/test_exchange.py @@ -225,22 +225,31 @@ def test_validate_order_time_in_force(default_conf, mocker, caplog): ex.validate_order_time_in_force(tif2) -@pytest.mark.parametrize("amount,precision_mode,precision,contract_size,expected", [ - (2.34559, 2, 4, 1, 2.3455), - (2.34559, 2, 5, 1, 2.34559), - (2.34559, 2, 3, 1, 2.345), - (2.9999, 2, 3, 1, 2.999), - (2.9909, 2, 3, 1, 2.990), +@pytest.mark.parametrize("amount,precision_mode,precision,contract_size,expected,trading_mode", [ + (2.34559, 2, 4, 1, 2.3455, 'spot'), + (2.34559, 2, 5, 1, 2.34559, 'spot'), + (2.34559, 2, 3, 1, 2.345, 'spot'), + (2.9999, 2, 3, 1, 2.999, 'spot'), + (2.9909, 2, 3, 1, 2.990, 'spot'), # Tests for Tick-size - (2.34559, 4, 0.0001, 1, 2.3455), - (2.34559, 4, 0.00001, 1, 2.34559), - (2.34559, 4, 0.001, 1, 2.345), - (2.9999, 4, 0.001, 1, 2.999), - (2.9909, 4, 0.001, 1, 2.990), - (2.9909, 4, 0.005, 0.01, 299.09), - (2.9999, 4, 0.005, 10, 0.295), + (2.34559, 4, 0.0001, 1, 2.3455, 'spot'), + (2.34559, 4, 0.00001, 1, 2.34559, 'spot'), + (2.34559, 4, 0.001, 1, 2.345, 'spot'), + (2.9999, 4, 0.001, 1, 2.999, 'spot'), + (2.9909, 4, 0.001, 1, 2.990, 'spot'), + (2.9909, 4, 0.005, 0.01, 299.09, 'futures'), + (2.9999, 4, 0.005, 10, 0.295, 'futures'), ]) -def test_amount_to_precision(default_conf, mocker, amount, precision_mode, precision, contract_size, expected): +def test_amount_to_precision( + default_conf, + mocker, + amount, + precision_mode, + precision, + contract_size, + expected, + trading_mode +): """ Test rounds down """ @@ -254,6 +263,9 @@ def test_amount_to_precision(default_conf, mocker, amount, precision_mode, preci } }) + default_conf['trading_mode'] = trading_mode + default_conf['collateral'] = 'isolated' + exchange = get_patched_exchange(mocker, default_conf, id="binance") # digits counting mode # DECIMAL_PLACES = 2