mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-12-17 05:11:15 +00:00
chore: update function naming
This commit is contained in:
@@ -372,8 +372,8 @@ def stop(rpc: RPC = Depends(get_rpc)):
|
||||
@router.post("/pause", response_model=StatusMsg, tags=["botcontrol"])
|
||||
@router.post("/stopentry", response_model=StatusMsg, tags=["botcontrol"])
|
||||
@router.post("/stopbuy", response_model=StatusMsg, tags=["botcontrol"])
|
||||
def stop_buy(rpc: RPC = Depends(get_rpc)):
|
||||
return rpc._rpc_stopentry()
|
||||
def pause(rpc: RPC = Depends(get_rpc)):
|
||||
return rpc._rpc_pause()
|
||||
|
||||
|
||||
@router.post("/reload_config", response_model=StatusMsg, tags=["botcontrol"])
|
||||
|
||||
@@ -849,9 +849,9 @@ class RPC:
|
||||
self._freqtrade.state = State.RELOAD_CONFIG
|
||||
return {"status": "Reloading config ..."}
|
||||
|
||||
def _rpc_stopentry(self) -> dict[str, str]:
|
||||
def _rpc_pause(self) -> dict[str, str]:
|
||||
"""
|
||||
Handler to stop buying, but handle open trades gracefully.
|
||||
Handler to pause trading (stop entering new trades), but handle open trades gracefully.
|
||||
"""
|
||||
if self._freqtrade.state == State.RUNNING:
|
||||
self._freqtrade.state = State.PAUSED
|
||||
|
||||
@@ -294,7 +294,7 @@ class Telegram(RPCHandler):
|
||||
CommandHandler(["unlock", "delete_locks"], self._delete_locks),
|
||||
CommandHandler(["reload_config", "reload_conf"], self._reload_config),
|
||||
CommandHandler(["show_config", "show_conf"], self._show_config),
|
||||
CommandHandler(["stopbuy", "stopentry", "pause"], self._stopentry),
|
||||
CommandHandler(["stopbuy", "stopentry", "pause"], self._pause),
|
||||
CommandHandler("whitelist", self._whitelist),
|
||||
CommandHandler("blacklist", self._blacklist),
|
||||
CommandHandler(["blacklist_delete", "bl_delete"], self._blacklist_delete),
|
||||
@@ -1270,7 +1270,7 @@ class Telegram(RPCHandler):
|
||||
await self._send_msg(f"Status: `{msg['status']}`")
|
||||
|
||||
@authorized_only
|
||||
async def _stopentry(self, update: Update, context: CallbackContext) -> None:
|
||||
async def _pause(self, update: Update, context: CallbackContext) -> None:
|
||||
"""
|
||||
Handler for /stop_buy /stop_entry and /pause.
|
||||
Sets bot state to paused
|
||||
@@ -1278,7 +1278,7 @@ class Telegram(RPCHandler):
|
||||
:param update: message update
|
||||
:return: None
|
||||
"""
|
||||
msg = self._rpc._rpc_stopentry()
|
||||
msg = self._rpc._rpc_pause()
|
||||
await self._send_msg(f"Status: `{msg['status']}`")
|
||||
|
||||
@authorized_only
|
||||
|
||||
@@ -806,7 +806,7 @@ def test_rpc_stop(mocker, default_conf) -> None:
|
||||
assert freqtradebot.state == State.STOPPED
|
||||
|
||||
|
||||
def test_rpc_stopentry(mocker, default_conf) -> None:
|
||||
def test_rpc_pause(mocker, default_conf) -> None:
|
||||
mocker.patch("freqtrade.rpc.telegram.Telegram", MagicMock())
|
||||
mocker.patch.multiple(EXMS, fetch_ticker=MagicMock())
|
||||
|
||||
@@ -815,7 +815,7 @@ def test_rpc_stopentry(mocker, default_conf) -> None:
|
||||
rpc = RPC(freqtradebot)
|
||||
freqtradebot.state = State.PAUSED
|
||||
|
||||
result = rpc._rpc_stopentry()
|
||||
result = rpc._rpc_pause()
|
||||
assert {
|
||||
"status": "No more entries will occur from now. Run /start to enable entries."
|
||||
} == result
|
||||
|
||||
@@ -533,14 +533,14 @@ def test_api_reloadconf(botclient):
|
||||
assert ftbot.state == State.RELOAD_CONFIG
|
||||
|
||||
|
||||
def test_api_stopentry(botclient):
|
||||
def test_api_pause(botclient):
|
||||
ftbot, client = botclient
|
||||
|
||||
rc = client_post(client, f"{BASE_URI}/stopbuy")
|
||||
rc = client_post(client, f"{BASE_URI}/pause")
|
||||
assert_response(rc)
|
||||
assert rc.json() == {"status": "pausing trader ..."}
|
||||
|
||||
rc = client_post(client, f"{BASE_URI}/stopbuy")
|
||||
rc = client_post(client, f"{BASE_URI}/pause")
|
||||
assert_response(rc)
|
||||
assert rc.json() == {
|
||||
"status": "No more entries will occur from now. Run /start to enable entries."
|
||||
|
||||
@@ -1222,11 +1222,11 @@ async def test_stop_handle_already_stopped(default_conf, update, mocker) -> None
|
||||
assert "already stopped" in msg_mock.call_args_list[0][0][0]
|
||||
|
||||
|
||||
async def test_stopbuy_handle(default_conf, update, mocker) -> None:
|
||||
async def test_pause_handle(default_conf, update, mocker) -> None:
|
||||
telegram, freqtradebot, msg_mock = get_telegram_testobject(mocker, default_conf)
|
||||
|
||||
assert freqtradebot.state == State.RUNNING
|
||||
await telegram._stopentry(update=update, context=MagicMock())
|
||||
await telegram._pause(update=update, context=MagicMock())
|
||||
assert freqtradebot.state == State.PAUSED
|
||||
assert msg_mock.call_count == 1
|
||||
assert "pausing trader ..." in msg_mock.call_args_list[0][0][0]
|
||||
|
||||
Reference in New Issue
Block a user