Adjust tests to use correctly trimmed amount

This commit is contained in:
Matthias 2020-07-15 20:51:52 +02:00
parent 3721736aaf
commit 98f2e79f27
5 changed files with 24 additions and 24 deletions

View File

@ -276,7 +276,7 @@ class Trade(_DECL_BASE):
'open_timestamp': int(self.open_date.timestamp() * 1000), 'open_timestamp': int(self.open_date.timestamp() * 1000),
'open_rate': self.open_rate, 'open_rate': self.open_rate,
'open_rate_requested': self.open_rate_requested, 'open_rate_requested': self.open_rate_requested,
'open_trade_price': self.open_trade_price, 'open_trade_price': round(self.open_trade_price, 8),
'close_date_hum': (arrow.get(self.close_date).humanize() 'close_date_hum': (arrow.get(self.close_date).humanize()
if self.close_date else None), if self.close_date else None),

View File

@ -79,8 +79,8 @@ def test_rpc_trade_status(default_conf, ticker, fee, mocker) -> None:
'open_rate': 1.098e-05, 'open_rate': 1.098e-05,
'close_rate': None, 'close_rate': None,
'current_rate': 1.099e-05, 'current_rate': 1.099e-05,
'amount': 91.07468124, 'amount': 91.07468123,
'amount_requested': 91.07468124, 'amount_requested': 91.07468123,
'stake_amount': 0.001, 'stake_amount': 0.001,
'close_profit': None, 'close_profit': None,
'close_profit_pct': None, 'close_profit_pct': None,
@ -143,8 +143,8 @@ def test_rpc_trade_status(default_conf, ticker, fee, mocker) -> None:
'open_rate': 1.098e-05, 'open_rate': 1.098e-05,
'close_rate': None, 'close_rate': None,
'current_rate': ANY, 'current_rate': ANY,
'amount': 91.07468124, 'amount': 91.07468123,
'amount_requested': 91.07468124, 'amount_requested': 91.07468123,
'stake_amount': 0.001, 'stake_amount': 0.001,
'close_profit': None, 'close_profit': None,
'close_profit_pct': None, 'close_profit_pct': None,

View File

@ -519,8 +519,8 @@ def test_api_status(botclient, mocker, ticker, fee, markets):
rc = client_get(client, f"{BASE_URI}/status") rc = client_get(client, f"{BASE_URI}/status")
assert_response(rc) assert_response(rc)
assert len(rc.json) == 1 assert len(rc.json) == 1
assert rc.json == [{'amount': 91.07468124, assert rc.json == [{'amount': 91.07468123,
'amount_requested': 91.07468124, 'amount_requested': 91.07468123,
'base_currency': 'BTC', 'base_currency': 'BTC',
'close_date': None, 'close_date': None,
'close_date_hum': None, 'close_date_hum': None,
@ -696,7 +696,7 @@ def test_api_forcebuy(botclient, mocker, fee):
'min_rate': None, 'min_rate': None,
'open_order_id': '123456', 'open_order_id': '123456',
'open_rate_requested': None, 'open_rate_requested': None,
'open_trade_price': 0.2460546025, 'open_trade_price': 0.24605460,
'sell_reason': None, 'sell_reason': None,
'sell_order_status': None, 'sell_order_status': None,
'strategy': None, 'strategy': None,

View File

@ -690,7 +690,7 @@ def test_reload_config_handle(default_conf, update, mocker) -> None:
assert 'reloading config' in msg_mock.call_args_list[0][0][0] assert 'reloading config' in msg_mock.call_args_list[0][0][0]
def test_forcesell_handle(default_conf, update, ticker, fee, def test_telegram_forcesell_handle(default_conf, update, ticker, fee,
ticker_sell_up, mocker) -> None: ticker_sell_up, mocker) -> None:
mocker.patch('freqtrade.rpc.rpc.CryptoToFiatConverter._find_price', return_value=15000.0) mocker.patch('freqtrade.rpc.rpc.CryptoToFiatConverter._find_price', return_value=15000.0)
rpc_mock = mocker.patch('freqtrade.rpc.telegram.Telegram.send_msg', MagicMock()) rpc_mock = mocker.patch('freqtrade.rpc.telegram.Telegram.send_msg', MagicMock())
@ -729,7 +729,7 @@ def test_forcesell_handle(default_conf, update, ticker, fee,
'pair': 'ETH/BTC', 'pair': 'ETH/BTC',
'gain': 'profit', 'gain': 'profit',
'limit': 1.173e-05, 'limit': 1.173e-05,
'amount': 91.07468123861567, 'amount': 91.07468123,
'order_type': 'limit', 'order_type': 'limit',
'open_rate': 1.098e-05, 'open_rate': 1.098e-05,
'current_rate': 1.173e-05, 'current_rate': 1.173e-05,
@ -743,8 +743,8 @@ def test_forcesell_handle(default_conf, update, ticker, fee,
} == last_msg } == last_msg
def test_forcesell_down_handle(default_conf, update, ticker, fee, def test_telegram_forcesell_down_handle(default_conf, update, ticker, fee,
ticker_sell_down, mocker) -> None: ticker_sell_down, mocker) -> None:
mocker.patch('freqtrade.rpc.fiat_convert.CryptoToFiatConverter._find_price', mocker.patch('freqtrade.rpc.fiat_convert.CryptoToFiatConverter._find_price',
return_value=15000.0) return_value=15000.0)
rpc_mock = mocker.patch('freqtrade.rpc.telegram.Telegram.send_msg', MagicMock()) rpc_mock = mocker.patch('freqtrade.rpc.telegram.Telegram.send_msg', MagicMock())
@ -788,7 +788,7 @@ def test_forcesell_down_handle(default_conf, update, ticker, fee,
'pair': 'ETH/BTC', 'pair': 'ETH/BTC',
'gain': 'loss', 'gain': 'loss',
'limit': 1.043e-05, 'limit': 1.043e-05,
'amount': 91.07468123861567, 'amount': 91.07468123,
'order_type': 'limit', 'order_type': 'limit',
'open_rate': 1.098e-05, 'open_rate': 1.098e-05,
'current_rate': 1.043e-05, 'current_rate': 1.043e-05,
@ -836,7 +836,7 @@ def test_forcesell_all_handle(default_conf, update, ticker, fee, mocker) -> None
'pair': 'ETH/BTC', 'pair': 'ETH/BTC',
'gain': 'loss', 'gain': 'loss',
'limit': 1.099e-05, 'limit': 1.099e-05,
'amount': 91.07468123861567, 'amount': 91.07468123,
'order_type': 'limit', 'order_type': 'limit',
'open_rate': 1.098e-05, 'open_rate': 1.098e-05,
'current_rate': 1.099e-05, 'current_rate': 1.099e-05,

View File

@ -595,7 +595,7 @@ def test_create_trade_minimal_amount(default_conf, ticker, limit_buy_order,
freqtrade.create_trade('ETH/BTC') freqtrade.create_trade('ETH/BTC')
rate, amount = buy_mock.call_args[1]['rate'], buy_mock.call_args[1]['amount'] rate, amount = buy_mock.call_args[1]['rate'], buy_mock.call_args[1]['amount']
assert rate * amount >= default_conf['stake_amount'] assert rate * amount <= default_conf['stake_amount']
def test_create_trade_too_small_stake_amount(default_conf, ticker, limit_buy_order, def test_create_trade_too_small_stake_amount(default_conf, ticker, limit_buy_order,
@ -782,7 +782,7 @@ def test_process_trade_creation(default_conf, ticker, limit_buy_order,
assert trade.open_date is not None assert trade.open_date is not None
assert trade.exchange == 'bittrex' assert trade.exchange == 'bittrex'
assert trade.open_rate == 0.00001098 assert trade.open_rate == 0.00001098
assert trade.amount == 91.07468123861567 assert trade.amount == 91.07468123
assert log_has( assert log_has(
'Buy signal found: about create a new trade with stake_amount: 0.001 ...', caplog 'Buy signal found: about create a new trade with stake_amount: 0.001 ...', caplog
@ -1009,7 +1009,7 @@ def test_execute_buy(mocker, default_conf, fee, limit_buy_order) -> None:
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'] == stake_amount / bid assert call_args['amount'] == round(stake_amount / bid, 8)
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
@ -1029,7 +1029,7 @@ def test_execute_buy(mocker, default_conf, fee, limit_buy_order) -> None:
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'] == stake_amount / fix_price assert call_args['amount'] == round(stake_amount / fix_price, 8)
# In case of closed order # In case of closed order
limit_buy_order['status'] = 'closed' limit_buy_order['status'] = 'closed'
@ -1407,7 +1407,7 @@ def test_handle_stoploss_on_exchange_trailing(mocker, default_conf, fee, caplog,
assert freqtrade.handle_stoploss_on_exchange(trade) is False assert freqtrade.handle_stoploss_on_exchange(trade) is False
cancel_order_mock.assert_called_once_with(100, 'ETH/BTC') cancel_order_mock.assert_called_once_with(100, 'ETH/BTC')
stoploss_order_mock.assert_called_once_with(amount=85.32423208191126, stoploss_order_mock.assert_called_once_with(amount=85.32423208,
pair='ETH/BTC', pair='ETH/BTC',
order_types=freqtrade.strategy.order_types, order_types=freqtrade.strategy.order_types,
stop_price=0.00002346 * 0.95) stop_price=0.00002346 * 0.95)
@ -1595,7 +1595,7 @@ def test_tsl_on_exchange_compatible_with_edge(mocker, edge_conf, fee, caplog,
# stoploss should be set to 1% as trailing is on # stoploss should be set to 1% as trailing is on
assert trade.stop_loss == 0.00002346 * 0.99 assert trade.stop_loss == 0.00002346 * 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(amount=2132892.491467577, stoploss_order_mock.assert_called_once_with(amount=2132892.49146757,
pair='NEO/BTC', pair='NEO/BTC',
order_types=freqtrade.strategy.order_types, order_types=freqtrade.strategy.order_types,
stop_price=0.00002346 * 0.99) stop_price=0.00002346 * 0.99)
@ -2577,7 +2577,7 @@ def test_execute_sell_up(default_conf, ticker, fee, ticker_sell_up, mocker) -> N
'pair': 'ETH/BTC', 'pair': 'ETH/BTC',
'gain': 'profit', 'gain': 'profit',
'limit': 1.172e-05, 'limit': 1.172e-05,
'amount': 91.07468123861567, 'amount': 91.07468123,
'order_type': 'limit', 'order_type': 'limit',
'open_rate': 1.098e-05, 'open_rate': 1.098e-05,
'current_rate': 1.173e-05, 'current_rate': 1.173e-05,
@ -2626,7 +2626,7 @@ def test_execute_sell_down(default_conf, ticker, fee, ticker_sell_down, mocker)
'pair': 'ETH/BTC', 'pair': 'ETH/BTC',
'gain': 'loss', 'gain': 'loss',
'limit': 1.044e-05, 'limit': 1.044e-05,
'amount': 91.07468123861567, 'amount': 91.07468123,
'order_type': 'limit', 'order_type': 'limit',
'open_rate': 1.098e-05, 'open_rate': 1.098e-05,
'current_rate': 1.043e-05, 'current_rate': 1.043e-05,
@ -2682,7 +2682,7 @@ def test_execute_sell_down_stoploss_on_exchange_dry_run(default_conf, ticker, fe
'pair': 'ETH/BTC', 'pair': 'ETH/BTC',
'gain': 'loss', 'gain': 'loss',
'limit': 1.08801e-05, 'limit': 1.08801e-05,
'amount': 91.07468123861567, 'amount': 91.07468123,
'order_type': 'limit', 'order_type': 'limit',
'open_rate': 1.098e-05, 'open_rate': 1.098e-05,
'current_rate': 1.043e-05, 'current_rate': 1.043e-05,
@ -2887,7 +2887,7 @@ def test_execute_sell_market_order(default_conf, ticker, fee,
'pair': 'ETH/BTC', 'pair': 'ETH/BTC',
'gain': 'profit', 'gain': 'profit',
'limit': 1.172e-05, 'limit': 1.172e-05,
'amount': 91.07468123861567, 'amount': 91.07468123,
'order_type': 'market', 'order_type': 'market',
'open_rate': 1.098e-05, 'open_rate': 1.098e-05,
'current_rate': 1.173e-05, 'current_rate': 1.173e-05,