diff --git a/freqtrade/rpc/api_server/api_v1.py b/freqtrade/rpc/api_server/api_v1.py index d0b39aec3..78ef65ef5 100644 --- a/freqtrade/rpc/api_server/api_v1.py +++ b/freqtrade/rpc/api_server/api_v1.py @@ -141,7 +141,8 @@ def forceentry(payload: ForceEnterPayload, rpc: RPC = Depends(get_rpc)): ordertype = payload.ordertype.value if payload.ordertype else None stake_amount = payload.stakeamount if payload.stakeamount else None - trade = rpc._rpc_forcebuy(payload.pair, payload.price, ordertype, stake_amount) + trade = rpc._rpc_forcebuy(payload.pair, payload.price, order_side=payload.side, + order_type=ordertype, stake_amount=stake_amount) if trade: return ForceEnterResponse.parse_obj(trade.to_json()) diff --git a/freqtrade/rpc/rpc.py b/freqtrade/rpc/rpc.py index 20f7a6b38..90759857e 100644 --- a/freqtrade/rpc/rpc.py +++ b/freqtrade/rpc/rpc.py @@ -18,6 +18,7 @@ from freqtrade.configuration.timerange import TimeRange from freqtrade.constants import CANCEL_REASON, DATETIME_PRINT_FORMAT from freqtrade.data.history import load_data from freqtrade.enums import SellType, State +from freqtrade.enums.signaltype import SignalDirection from freqtrade.exceptions import ExchangeError, PricingError from freqtrade.exchange import timeframe_to_minutes, timeframe_to_msecs from freqtrade.loggers import bufferHandler @@ -713,7 +714,8 @@ class RPC: self._freqtrade.wallets.update() return {'result': f'Created sell order for trade {trade_id}.'} - def _rpc_forcebuy(self, pair: str, price: Optional[float], order_type: Optional[str] = None, + def _rpc_forcebuy(self, pair: str, price: Optional[float], *, order_type: Optional[str] = None, + order_side: SignalDirection = SignalDirection.LONG, stake_amount: Optional[float] = None) -> Optional[Trade]: """ Handler for forcebuy @@ -721,7 +723,7 @@ class RPC: """ if not self._freqtrade.config.get('forcebuy_enable', False): - raise RPCException('Forcebuy not enabled.') + raise RPCException('Forceentry not enabled.') if self._freqtrade.state != State.RUNNING: raise RPCException('trader is not running') @@ -748,7 +750,9 @@ class RPC: order_type = self._freqtrade.strategy.order_types.get( 'forcebuy', self._freqtrade.strategy.order_types['buy']) if self._freqtrade.execute_entry(pair, stake_amount, price, - ordertype=order_type, trade=trade): + ordertype=order_type, trade=trade, + is_short=(order_side == SignalDirection.SHORT) + ): Trade.commit() trade = Trade.get_trades([Trade.is_open.is_(True), Trade.pair == pair]).first() return trade