Enable flake8 E226 rule

This commit is contained in:
Matthias
2022-04-11 18:02:02 +02:00
parent 1084787a38
commit baefda80d1
16 changed files with 50 additions and 46 deletions

View File

@@ -382,11 +382,11 @@ def test__get_stake_amount_limit(mocker, default_conf) -> None:
)
# min
result = exchange.get_min_pair_stake_amount('ETH/BTC', 1, stoploss)
expected_result = 2 * (1+0.05) / (1-abs(stoploss))
expected_result = 2 * (1 + 0.05) / (1 - abs(stoploss))
assert isclose(result, expected_result)
# With Leverage
result = exchange.get_min_pair_stake_amount('ETH/BTC', 1, stoploss, 3.0)
assert isclose(result, expected_result/3)
assert isclose(result, expected_result / 3)
# max
result = exchange.get_max_pair_stake_amount('ETH/BTC', 2)
assert result == 10000
@@ -401,11 +401,11 @@ def test__get_stake_amount_limit(mocker, default_conf) -> None:
PropertyMock(return_value=markets)
)
result = exchange.get_min_pair_stake_amount('ETH/BTC', 2, stoploss)
expected_result = 2 * 2 * (1+0.05) / (1-abs(stoploss))
expected_result = 2 * 2 * (1 + 0.05) / (1 - abs(stoploss))
assert isclose(result, expected_result)
# With Leverage
result = exchange.get_min_pair_stake_amount('ETH/BTC', 2, stoploss, 5.0)
assert isclose(result, expected_result/5)
assert isclose(result, expected_result / 5)
# max
result = exchange.get_max_pair_stake_amount('ETH/BTC', 2)
assert result == 20000
@@ -420,11 +420,11 @@ def test__get_stake_amount_limit(mocker, default_conf) -> None:
PropertyMock(return_value=markets)
)
result = exchange.get_min_pair_stake_amount('ETH/BTC', 2, stoploss)
expected_result = max(2, 2 * 2) * (1+0.05) / (1-abs(stoploss))
expected_result = max(2, 2 * 2) * (1 + 0.05) / (1 - abs(stoploss))
assert isclose(result, expected_result)
# With Leverage
result = exchange.get_min_pair_stake_amount('ETH/BTC', 2, stoploss, 10)
assert isclose(result, expected_result/10)
assert isclose(result, expected_result / 10)
# min amount and cost are set (amount is minial)
markets["ETH/BTC"]["limits"] = {
@@ -436,11 +436,11 @@ def test__get_stake_amount_limit(mocker, default_conf) -> None:
PropertyMock(return_value=markets)
)
result = exchange.get_min_pair_stake_amount('ETH/BTC', 2, stoploss)
expected_result = max(8, 2 * 2) * (1+0.05) / (1-abs(stoploss))
expected_result = max(8, 2 * 2) * (1 + 0.05) / (1 - abs(stoploss))
assert isclose(result, expected_result)
# With Leverage
result = exchange.get_min_pair_stake_amount('ETH/BTC', 2, stoploss, 7.0)
assert isclose(result, expected_result/7.0)
assert isclose(result, expected_result / 7.0)
# Max
result = exchange.get_max_pair_stake_amount('ETH/BTC', 2)
assert result == 1000
@@ -450,7 +450,7 @@ def test__get_stake_amount_limit(mocker, default_conf) -> None:
assert isclose(result, expected_result)
# With Leverage
result = exchange.get_min_pair_stake_amount('ETH/BTC', 2, -0.4, 8.0)
assert isclose(result, expected_result/8.0)
assert isclose(result, expected_result / 8.0)
# Max
result = exchange.get_max_pair_stake_amount('ETH/BTC', 2)
assert result == 1000
@@ -461,7 +461,7 @@ def test__get_stake_amount_limit(mocker, default_conf) -> None:
assert isclose(result, expected_result)
# With Leverage
result = exchange.get_min_pair_stake_amount('ETH/BTC', 2, -1, 12.0)
assert isclose(result, expected_result/12)
assert isclose(result, expected_result / 12)
# Max
result = exchange.get_max_pair_stake_amount('ETH/BTC', 2)
assert result == 1000
@@ -489,7 +489,7 @@ def test__get_stake_amount_limit(mocker, default_conf) -> None:
)
# With Leverage, Contract size 10
result = exchange.get_min_pair_stake_amount('ETH/BTC', 2, -1, 12.0)
assert isclose(result, (expected_result/12) * 10.0)
assert isclose(result, (expected_result / 12) * 10.0)
# Max
result = exchange.get_max_pair_stake_amount('ETH/BTC', 2)
assert result == 10000
@@ -510,7 +510,7 @@ def test_get_min_pair_stake_amount_real_data(mocker, default_conf) -> None:
PropertyMock(return_value=markets)
)
result = exchange.get_min_pair_stake_amount('ETH/BTC', 0.020405, stoploss)
expected_result = max(0.0001, 0.001 * 0.020405) * (1+0.05) / (1-abs(stoploss))
expected_result = max(0.0001, 0.001 * 0.020405) * (1 + 0.05) / (1 - abs(stoploss))
assert round(result, 8) == round(expected_result, 8)
# Max
result = exchange.get_max_pair_stake_amount('ETH/BTC', 2.0)
@@ -518,12 +518,12 @@ def test_get_min_pair_stake_amount_real_data(mocker, default_conf) -> None:
# Leverage
result = exchange.get_min_pair_stake_amount('ETH/BTC', 0.020405, stoploss, 3.0)
assert round(result, 8) == round(expected_result/3, 8)
assert round(result, 8) == round(expected_result / 3, 8)
# Contract_size
markets["ETH/BTC"]["contractSize"] = 0.1
result = exchange.get_min_pair_stake_amount('ETH/BTC', 0.020405, stoploss, 3.0)
assert round(result, 8) == round((expected_result/3), 8)
assert round(result, 8) == round((expected_result / 3), 8)
# Max
result = exchange.get_max_pair_stake_amount('ETH/BTC', 12.0)
@@ -2691,9 +2691,10 @@ async def test__async_get_trade_history_time(default_conf, mocker, caplog, excha
# Monkey-patch async function
exchange._api_async.fetch_trades = MagicMock(side_effect=mock_get_trade_hist)
pair = 'ETH/BTC'
ret = await exchange._async_get_trade_history_time(pair,
since=fetch_trades_result[0]['timestamp'],
until=fetch_trades_result[-1]['timestamp']-1)
ret = await exchange._async_get_trade_history_time(
pair,
since=fetch_trades_result[0]['timestamp'],
until=fetch_trades_result[-1]['timestamp'] - 1)
assert type(ret) is tuple
assert ret[0] == pair
assert type(ret[1]) is list
@@ -2729,7 +2730,7 @@ async def test__async_get_trade_history_time_empty(default_conf, mocker, caplog,
exchange._async_fetch_trades = MagicMock(side_effect=mock_get_trade_hist)
pair = 'ETH/BTC'
ret = await exchange._async_get_trade_history_time(pair, since=trades_history[0][0],
until=trades_history[-1][0]-1)
until=trades_history[-1][0] - 1)
assert type(ret) is tuple
assert ret[0] == pair
assert type(ret[1]) is list

View File

@@ -6,7 +6,7 @@ import pytest
from freqtrade.leverage import interest
ten_mins = Decimal(1/6)
ten_mins = Decimal(1 / 6)
five_hours = Decimal(5.0)
twentyfive_hours = Decimal(25.0)

View File

@@ -190,7 +190,7 @@ def test_store_backtest_stats(testdatadir, mocker):
assert dump_mock.call_count == 3
assert isinstance(dump_mock.call_args_list[0][0][0], Path)
assert str(dump_mock.call_args_list[0][0][0]).startswith(str(testdatadir/'backtest-result'))
assert str(dump_mock.call_args_list[0][0][0]).startswith(str(testdatadir / 'backtest-result'))
dump_mock.reset_mock()
filename = testdatadir / 'testresult.json'

View File

@@ -164,7 +164,7 @@ def test_stoploss_from_absolute():
assert pytest.approx(stoploss_from_absolute(90, 100, True)) == 0
assert pytest.approx(stoploss_from_absolute(100, 100, True)) == 0
assert pytest.approx(stoploss_from_absolute(110, 100, True)) == -(1 - (110/100))
assert pytest.approx(stoploss_from_absolute(110, 100, True)) == -(1 - (110 / 100))
assert pytest.approx(stoploss_from_absolute(110, 100, True)) == 0.1
assert pytest.approx(stoploss_from_absolute(105, 100, True)) == 0.05
assert pytest.approx(stoploss_from_absolute(100, 0, True)) == 1

View File

@@ -119,7 +119,7 @@ def test_set_stop_loss_isolated_liq(fee):
assert trade.stop_loss is None
assert trade.initial_stop_loss is None
trade._set_stop_loss(0.1, (1.0/9.0))
trade._set_stop_loss(0.1, (1.0 / 9.0))
assert trade.liquidation_price == 0.09
assert trade.stop_loss == 0.1
assert trade.initial_stop_loss == 0.1
@@ -160,7 +160,7 @@ def test_set_stop_loss_isolated_liq(fee):
assert trade.stop_loss is None
assert trade.initial_stop_loss is None
trade._set_stop_loss(0.08, (1.0/9.0))
trade._set_stop_loss(0.08, (1.0 / 9.0))
assert trade.liquidation_price == 0.09
assert trade.stop_loss == 0.08
assert trade.initial_stop_loss == 0.08
@@ -171,13 +171,13 @@ def test_set_stop_loss_isolated_liq(fee):
assert trade.initial_stop_loss == 0.08
trade.set_isolated_liq(0.07)
trade._set_stop_loss(0.1, (1.0/8.0))
trade._set_stop_loss(0.1, (1.0 / 8.0))
assert trade.liquidation_price == 0.07
assert trade.stop_loss == 0.07
assert trade.initial_stop_loss == 0.08
# Stop doesn't move stop higher
trade._set_stop_loss(0.1, (1.0/9.0))
trade._set_stop_loss(0.1, (1.0 / 9.0))
assert trade.liquidation_price == 0.07
assert trade.stop_loss == 0.07
assert trade.initial_stop_loss == 0.08