Add test for "no trades found" case

This commit is contained in:
Matthias Voppichler 2018-04-25 09:08:02 +02:00
parent 483415cd65
commit 72c17e29c0
2 changed files with 27 additions and 1 deletions

View File

@ -583,6 +583,6 @@ def buy_order_fee():
'price': 0.245441, 'price': 0.245441,
'amount': 8.0, 'amount': 8.0,
'remaining': 90.99181073, 'remaining': 90.99181073,
'status': 'open', 'status': 'closed',
'fee': None 'fee': None
} }

View File

@ -1344,6 +1344,32 @@ def test_get_real_amount_quote(default_conf, trades_for_order, buy_order_fee, ca
caplog.record_tuples) 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): def test_get_real_amount_stake(default_conf, trades_for_order, buy_order_fee, caplog, mocker):
""" """
Test get_real_amount - fees in Stake currency Test get_real_amount - fees in Stake currency