parent
e9abe3cb68
commit
fb3d408338
@ -773,6 +773,9 @@ class RPC:
|
|||||||
is_short = trade.is_short
|
is_short = trade.is_short
|
||||||
if not self._freqtrade.strategy.position_adjustment_enable:
|
if not self._freqtrade.strategy.position_adjustment_enable:
|
||||||
raise RPCException(f'position for {pair} already open - id: {trade.id}')
|
raise RPCException(f'position for {pair} already open - id: {trade.id}')
|
||||||
|
else:
|
||||||
|
if Trade.get_open_trade_count() >= self._config['max_open_trades']:
|
||||||
|
raise RPCException("Maximum number of trades is reached.")
|
||||||
|
|
||||||
if not stake_amount:
|
if not stake_amount:
|
||||||
# gen stake amount
|
# gen stake amount
|
||||||
|
@ -1030,6 +1030,7 @@ def test_rpc_count(mocker, default_conf, ticker, fee) -> None:
|
|||||||
|
|
||||||
def test_rpc_force_entry(mocker, default_conf, ticker, fee, limit_buy_order_open) -> None:
|
def test_rpc_force_entry(mocker, default_conf, ticker, fee, limit_buy_order_open) -> None:
|
||||||
default_conf['force_entry_enable'] = True
|
default_conf['force_entry_enable'] = True
|
||||||
|
default_conf['max_open_trades'] = 0
|
||||||
mocker.patch('freqtrade.rpc.telegram.Telegram', MagicMock())
|
mocker.patch('freqtrade.rpc.telegram.Telegram', MagicMock())
|
||||||
buy_mm = MagicMock(return_value=limit_buy_order_open)
|
buy_mm = MagicMock(return_value=limit_buy_order_open)
|
||||||
mocker.patch.multiple(
|
mocker.patch.multiple(
|
||||||
@ -1044,6 +1045,10 @@ def test_rpc_force_entry(mocker, default_conf, ticker, fee, limit_buy_order_open
|
|||||||
patch_get_signal(freqtradebot)
|
patch_get_signal(freqtradebot)
|
||||||
rpc = RPC(freqtradebot)
|
rpc = RPC(freqtradebot)
|
||||||
pair = 'ETH/BTC'
|
pair = 'ETH/BTC'
|
||||||
|
with pytest.raises(RPCException, match='Maximum number of trades is reached.'):
|
||||||
|
rpc._rpc_force_entry(pair, None)
|
||||||
|
freqtradebot.config['max_open_trades'] = 5
|
||||||
|
|
||||||
trade = rpc._rpc_force_entry(pair, None)
|
trade = rpc._rpc_force_entry(pair, None)
|
||||||
assert isinstance(trade, Trade)
|
assert isinstance(trade, Trade)
|
||||||
assert trade.pair == pair
|
assert trade.pair == pair
|
||||||
|
Loading…
Reference in New Issue
Block a user