Added minor changes from lev-exchange review

This commit is contained in:
Sam Germain
2021-09-10 13:39:42 -06:00
parent 1fa318c52a
commit b0e05b92d3
6 changed files with 51 additions and 38 deletions

View File

@@ -9,19 +9,18 @@ from tests.conftest import get_patched_exchange
from tests.exchange.test_exchange import ccxt_exceptionhandlers
@pytest.mark.parametrize('limitratio,exchangelimitratio,expected,side', [
(None, 1.05, 220 * 0.99, "sell"),
(0.99, 1.05, 220 * 0.99, "sell"),
(0.98, 1.05, 220 * 0.98, "sell"),
(None, 0.95, 220 * 1.01, "buy"),
(1.01, 0.95, 220 * 1.01, "buy"),
(1.02, 0.95, 220 * 1.02, "buy"),
@pytest.mark.parametrize('limitratio,expected,side', [
(None, 220 * 0.99, "sell"),
(0.99, 220 * 0.99, "sell"),
(0.98, 220 * 0.98, "sell"),
(None, 220 * 1.01, "buy"),
(0.99, 220 * 1.01, "buy"),
(0.98, 220 * 1.02, "buy"),
])
def test_stoploss_order_binance(
default_conf,
mocker,
limitratio,
exchangelimitratio,
expected,
side
):
@@ -47,7 +46,7 @@ def test_stoploss_order_binance(
amount=1,
stop_price=190,
side=side,
order_types={'stoploss_on_exchange_limit_ratio': exchangelimitratio}
order_types={'stoploss_on_exchange_limit_ratio': 1.05}
)
api_mock.create_order.reset_mock()

View File

@@ -166,11 +166,11 @@ def test_get_balances_prod(default_conf, mocker):
@pytest.mark.parametrize('ordertype', ['market', 'limit'])
@pytest.mark.parametrize('side,limitratio,adjustedprice', [
("buy", 0.99, 217.8),
("sell", 1.01, 222.2),
@pytest.mark.parametrize('side,adjustedprice', [
("sell", 217.8),
("buy", 222.2),
])
def test_stoploss_order_kraken(default_conf, mocker, ordertype, side, limitratio, adjustedprice):
def test_stoploss_order_kraken(default_conf, mocker, ordertype, side, adjustedprice):
api_mock = MagicMock()
order_id = 'test_prod_buy_{}'.format(randint(0, 10 ** 6))
@@ -187,10 +187,15 @@ def test_stoploss_order_kraken(default_conf, mocker, ordertype, side, limitratio
exchange = get_patched_exchange(mocker, default_conf, api_mock, 'kraken')
order = exchange.stoploss(pair='ETH/BTC', amount=1, stop_price=220, side=side,
order_types={'stoploss': ordertype,
'stoploss_on_exchange_limit_ratio': limitratio
})
order = exchange.stoploss(
pair='ETH/BTC',
amount=1,
stop_price=220,
side=side,
order_types={
'stoploss': ordertype,
'stoploss_on_exchange_limit_ratio': 0.99
})
assert 'id' in order
assert 'info' in order
@@ -199,7 +204,9 @@ def test_stoploss_order_kraken(default_conf, mocker, ordertype, side, limitratio
if ordertype == 'limit':
assert api_mock.create_order.call_args_list[0][1]['type'] == STOPLOSS_LIMIT_ORDERTYPE
assert api_mock.create_order.call_args_list[0][1]['params'] == {
'trading_agreement': 'agree', 'price2': adjustedprice}
'trading_agreement': 'agree',
'price2': adjustedprice
}
else:
assert api_mock.create_order.call_args_list[0][1]['type'] == STOPLOSS_ORDERTYPE
assert api_mock.create_order.call_args_list[0][1]['params'] == {