Don't call amount_to_precision twice on entry

This commit is contained in:
Matthias 2022-02-27 15:57:44 +01:00
parent fdbd75501f
commit 0ebf40f390
3 changed files with 7 additions and 8 deletions

View File

@ -542,7 +542,6 @@ class FreqtradeBot(LoggingMixin):
entry_tag=buy_tag): entry_tag=buy_tag):
logger.info(f"User requested abortion of buying {pair}") logger.info(f"User requested abortion of buying {pair}")
return False return False
amount = self.exchange.amount_to_precision(pair, amount)
order = self.exchange.create_order(pair=pair, ordertype=order_type, side="buy", order = self.exchange.create_order(pair=pair, ordertype=order_type, side="buy",
amount=amount, rate=enter_limit_requested, amount=amount, rate=enter_limit_requested,
time_in_force=time_in_force) time_in_force=time_in_force)

View File

@ -79,7 +79,7 @@ def test_rpc_trade_status(default_conf, ticker, fee, mocker) -> None:
'close_rate': None, 'close_rate': None,
'current_rate': 1.099e-05, 'current_rate': 1.099e-05,
'amount': 91.07468123, 'amount': 91.07468123,
'amount_requested': 91.07468123, 'amount_requested': 91.07468124,
'stake_amount': 0.001, 'stake_amount': 0.001,
'trade_duration': None, 'trade_duration': None,
'trade_duration_s': None, 'trade_duration_s': None,
@ -154,7 +154,7 @@ def test_rpc_trade_status(default_conf, ticker, fee, mocker) -> None:
'close_rate': None, 'close_rate': None,
'current_rate': ANY, 'current_rate': ANY,
'amount': 91.07468123, 'amount': 91.07468123,
'amount_requested': 91.07468123, 'amount_requested': 91.07468124,
'trade_duration': ANY, 'trade_duration': ANY,
'trade_duration_s': ANY, 'trade_duration_s': ANY,
'stake_amount': 0.001, 'stake_amount': 0.001,

View File

@ -727,7 +727,7 @@ def test_execute_entry(mocker, default_conf_usdt, fee, limit_buy_order_usdt,
call_args = buy_mm.call_args_list[0][1] call_args = buy_mm.call_args_list[0][1]
assert call_args['pair'] == pair assert call_args['pair'] == pair
assert call_args['rate'] == bid assert call_args['rate'] == bid
assert call_args['amount'] == round(stake_amount / bid, 8) assert call_args['amount'] == stake_amount / bid
buy_rate_mock.reset_mock() buy_rate_mock.reset_mock()
# Should create an open trade with an open order id # Should create an open trade with an open order id
@ -748,7 +748,7 @@ def test_execute_entry(mocker, default_conf_usdt, fee, limit_buy_order_usdt,
call_args = buy_mm.call_args_list[1][1] call_args = buy_mm.call_args_list[1][1]
assert call_args['pair'] == pair assert call_args['pair'] == pair
assert call_args['rate'] == fix_price assert call_args['rate'] == fix_price
assert call_args['amount'] == round(stake_amount / fix_price, 8) assert call_args['amount'] == stake_amount / fix_price
# In case of closed order # In case of closed order
limit_buy_order_usdt['status'] = 'closed' limit_buy_order_usdt['status'] = 'closed'
@ -1266,7 +1266,7 @@ def test_handle_stoploss_on_exchange_trailing(mocker, default_conf_usdt, fee,
cancel_order_mock.assert_called_once_with(100, 'ETH/USDT') cancel_order_mock.assert_called_once_with(100, 'ETH/USDT')
stoploss_order_mock.assert_called_once_with( stoploss_order_mock.assert_called_once_with(
amount=27.39726027, amount=pytest.approx(27.39726027),
pair='ETH/USDT', pair='ETH/USDT',
order_types=freqtrade.strategy.order_types, order_types=freqtrade.strategy.order_types,
stop_price=4.4 * 0.95 stop_price=4.4 * 0.95
@ -1458,7 +1458,7 @@ def test_handle_stoploss_on_exchange_custom_stop(
cancel_order_mock.assert_called_once_with(100, 'ETH/USDT') cancel_order_mock.assert_called_once_with(100, 'ETH/USDT')
stoploss_order_mock.assert_called_once_with( stoploss_order_mock.assert_called_once_with(
amount=31.57894736, amount=pytest.approx(31.57894736),
pair='ETH/USDT', pair='ETH/USDT',
order_types=freqtrade.strategy.order_types, order_types=freqtrade.strategy.order_types,
stop_price=4.4 * 0.96 stop_price=4.4 * 0.96
@ -1583,7 +1583,7 @@ def test_tsl_on_exchange_compatible_with_edge(mocker, edge_conf, fee,
assert trade.stop_loss == 4.4 * 0.99 assert trade.stop_loss == 4.4 * 0.99
cancel_order_mock.assert_called_once_with(100, 'NEO/BTC') cancel_order_mock.assert_called_once_with(100, 'NEO/BTC')
stoploss_order_mock.assert_called_once_with( stoploss_order_mock.assert_called_once_with(
amount=11.41438356, amount=pytest.approx(11.41438356),
pair='NEO/BTC', pair='NEO/BTC',
order_types=freqtrade.strategy.order_types, order_types=freqtrade.strategy.order_types,
stop_price=4.4 * 0.99 stop_price=4.4 * 0.99