Improve dry-run calculations
This commit is contained in:
@@ -3485,3 +3485,33 @@ def test_process_i_am_alive(default_conf, mocker, caplog):
|
||||
|
||||
ftbot.process()
|
||||
assert log_has_re(message, caplog)
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("init_persistence")
|
||||
def test_sync_wallet_dry_run(mocker, default_conf, ticker, fee, limit_buy_order):
|
||||
default_conf['dry_run'] = True
|
||||
# Initialize to 2 times stake amount
|
||||
default_conf['dry_run_wallet'] = 0.002
|
||||
default_conf['max_open_trades'] = 2
|
||||
patch_exchange(mocker)
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
get_ticker=ticker,
|
||||
buy=MagicMock(return_value={'id': limit_buy_order['id']}),
|
||||
get_fee=fee,
|
||||
)
|
||||
|
||||
bot = get_patched_freqtradebot(mocker, default_conf)
|
||||
patch_get_signal(bot)
|
||||
assert bot.wallets.get_free('BTC') == 0.002
|
||||
|
||||
bot.create_trades()
|
||||
trades = Trade.query.all()
|
||||
assert len(trades) == 2
|
||||
|
||||
bot.config['max_open_trades'] = 3
|
||||
with pytest.raises(
|
||||
DependencyException,
|
||||
match=r"Available balance \(0 BTC\) is lower than stake amount \(0.001 BTC\)"):
|
||||
bot.create_trades()
|
||||
|
||||
|
@@ -71,6 +71,7 @@ def test_may_execute_sell_stoploss_on_exchange_multi(default_conf, ticker, fee,
|
||||
)
|
||||
mocker.patch("freqtrade.strategy.interface.IStrategy.should_sell", should_sell_mock)
|
||||
wallets_mock = mocker.patch("freqtrade.wallets.Wallets.update", MagicMock())
|
||||
mocker.patch("freqtrade.wallets.Wallets.get_free", MagicMock(return_value=1))
|
||||
|
||||
freqtrade = get_patched_freqtradebot(mocker, default_conf)
|
||||
freqtrade.strategy.order_types['stoploss_on_exchange'] = True
|
||||
|
Reference in New Issue
Block a user