Add tests for update_real_amount
This commit is contained in:
parent
02f0f22621
commit
f69e8458f4
@ -1374,3 +1374,53 @@ def test_get_real_amount_multi(default_conf, trades_for_order2, mocker):
|
|||||||
freqtrade = FreqtradeBot(default_conf, create_engine('sqlite://'))
|
freqtrade = FreqtradeBot(default_conf, create_engine('sqlite://'))
|
||||||
# Amount is reduced by "fee"
|
# Amount is reduced by "fee"
|
||||||
assert freqtrade.get_real_amount(trade) == amount - (amount * 0.001)
|
assert freqtrade.get_real_amount(trade) == amount - (amount * 0.001)
|
||||||
|
|
||||||
|
|
||||||
|
def test_maybe_update_real_amount(default_conf, trades_for_order, mocker):
|
||||||
|
"""
|
||||||
|
Test get_real_amount with split trades (multiple trades for this order)
|
||||||
|
"""
|
||||||
|
|
||||||
|
patch_get_signal(mocker)
|
||||||
|
patch_RPCManager(mocker)
|
||||||
|
patch_coinmarketcap(mocker)
|
||||||
|
mocker.patch('freqtrade.exchange.validate_pairs', MagicMock(return_value=True))
|
||||||
|
mocker.patch('freqtrade.exchange.get_trades_for_order', return_value=trades_for_order)
|
||||||
|
amount = float(sum(x['amount'] for x in trades_for_order))
|
||||||
|
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.maybe_update_real_amount(trade) is True
|
||||||
|
assert trade.amount == amount - (amount * 0.001)
|
||||||
|
|
||||||
|
|
||||||
|
def test_maybe_update_real_amount_stake(default_conf, trades_for_order, mocker):
|
||||||
|
"""
|
||||||
|
Test get_real_amount with split trades (multiple trades for this order)
|
||||||
|
"""
|
||||||
|
trades_for_order[0]['fee']['currency'] = 'ETH'
|
||||||
|
|
||||||
|
patch_get_signal(mocker)
|
||||||
|
patch_RPCManager(mocker)
|
||||||
|
patch_coinmarketcap(mocker)
|
||||||
|
|
||||||
|
mocker.patch('freqtrade.exchange.validate_pairs', MagicMock(return_value=True))
|
||||||
|
mocker.patch('freqtrade.exchange.get_trades_for_order', return_value=trades_for_order)
|
||||||
|
amount = float(sum(x['amount'] for x in trades_for_order))
|
||||||
|
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.maybe_update_real_amount(trade) is True
|
||||||
|
assert trade.amount == amount
|
||||||
|
Loading…
Reference in New Issue
Block a user