_rpc_forcebuy

This commit is contained in:
Matthias
2022-01-26 19:08:37 +01:00
parent 4998f3bdd7
commit 48d8cd82af
7 changed files with 23 additions and 21 deletions

View File

@@ -141,13 +141,14 @@ 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, order_side=payload.side,
order_type=ordertype, stake_amount=stake_amount)
trade = rpc._rpc_force_entry(payload.pair, payload.price, order_side=payload.side,
order_type=ordertype, stake_amount=stake_amount)
if trade:
return ForceEnterResponse.parse_obj(trade.to_json())
else:
return ForceEnterResponse.parse_obj({"status": f"Error entering {payload.side} trade for pair {payload.pair}."})
return ForceEnterResponse.parse_obj(
{"status": f"Error entering {payload.side} trade for pair {payload.pair}."})
@router.post('/forcesell', response_model=ResultMsg, tags=['trading'])

View File

@@ -714,9 +714,10 @@ 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,
order_side: SignalDirection = SignalDirection.LONG,
stake_amount: Optional[float] = None) -> Optional[Trade]:
def _rpc_force_entry(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 <asset> <price>
Buys a pair trade at the given or current price

View File

@@ -868,7 +868,7 @@ class Telegram(RPCHandler):
def _forcebuy_action(self, pair, price=None):
try:
self._rpc._rpc_forcebuy(pair, price)
self._rpc._rpc_force_entry(pair, price)
except RPCException as e:
self._send_msg(str(e))