diff --git a/freqtrade/tests/conftest.py b/freqtrade/tests/conftest.py index f1af74348..85ce3b35d 100644 --- a/freqtrade/tests/conftest.py +++ b/freqtrade/tests/conftest.py @@ -583,6 +583,6 @@ def buy_order_fee(): 'price': 0.245441, 'amount': 8.0, 'remaining': 90.99181073, - 'status': 'open', + 'status': 'closed', 'fee': None } diff --git a/freqtrade/tests/test_freqtradebot.py b/freqtrade/tests/test_freqtradebot.py index 45c6620df..8c3c1302a 100644 --- a/freqtrade/tests/test_freqtradebot.py +++ b/freqtrade/tests/test_freqtradebot.py @@ -1344,6 +1344,32 @@ def test_get_real_amount_quote(default_conf, trades_for_order, buy_order_fee, ca caplog.record_tuples) +def test_get_real_amount_no_trade(default_conf, buy_order_fee, caplog, mocker): + """ + Test get_real_amount - fee in quote currency + """ + + mocker.patch('freqtrade.exchange.get_trades_for_order', return_value=[]) + + patch_get_signal(mocker) + patch_RPCManager(mocker) + patch_coinmarketcap(mocker) + mocker.patch('freqtrade.exchange.validate_pairs', MagicMock(return_value=True)) + amount = buy_order_fee['amount'] + trade = Trade( + pair='LTC/ETH', + amount=amount, + exchange='binance', + open_rate=0.245441, + open_order_id="123456" + ) + freqtrade = FreqtradeBot(default_conf, create_engine('sqlite://')) + # Amount is reduced by "fee" + assert freqtrade.get_real_amount(trade, buy_order_fee) == amount + assert log_has('Applying fee on amount for Trade(id=None, pair=LTC/ETH, amount=8.00000000, ' + 'open_rate=0.24544100, open_since=closed) failed: myTrade-Dict empty found', + caplog.record_tuples) + def test_get_real_amount_stake(default_conf, trades_for_order, buy_order_fee, caplog, mocker): """ Test get_real_amount - fees in Stake currency