Allow forcebuy to also buy more when trade is already open.

This commit is contained in:
Reigo Reinmets 2021-12-23 11:57:53 +02:00
parent 2e23e88fc1
commit ace0a83c0c

View File

@ -721,7 +721,8 @@ class RPC:
# check if pair already has an open pair
trade = Trade.get_trades([Trade.is_open.is_(True), Trade.pair == pair]).first()
if trade:
raise RPCException(f'position for {pair} already open - id: {trade.id}')
if not self._config.get('position_adjustment_enable', False):
raise RPCException(f'position for {pair} already open - id: {trade.id}')
# gen stake amount
stakeamount = self._freqtrade.wallets.get_trade_stake_amount(pair)
@ -730,7 +731,8 @@ class RPC:
if not order_type:
order_type = self._freqtrade.strategy.order_types.get(
'forcebuy', self._freqtrade.strategy.order_types['buy'])
if self._freqtrade.execute_entry(pair, stakeamount, price, ordertype=order_type):
if self._freqtrade.execute_entry(pair, stakeamount, price,
ordertype=order_type, trade=trade):
Trade.commit()
trade = Trade.get_trades([Trade.is_open.is_(True), Trade.pair == pair]).first()
return trade