mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 10:21:59 +00:00
reload_conf & reload_config now both accepted, code is more consistent now
This commit is contained in:
parent
9380cf484a
commit
ac92834693
|
@ -110,7 +110,7 @@ python3 scripts/rest_client.py --config rest_config.json <command> [optional par
|
|||
| `start` | | Starts the trader
|
||||
| `stop` | | Stops the trader
|
||||
| `stopbuy` | | Stops the trader from opening new trades. Gracefully closes open trades according to their rules.
|
||||
| `reload_conf` | | Reloads the configuration file
|
||||
| `reload_config` | | Reloads the configuration file
|
||||
| `show_config` | | Shows part of the current configuration with relevant settings to operation
|
||||
| `status` | | Lists all open trades
|
||||
| `count` | | Displays number of trades used and available
|
||||
|
@ -174,7 +174,7 @@ profit
|
|||
Returns the profit summary
|
||||
:returns: json object
|
||||
|
||||
reload_conf
|
||||
reload_config
|
||||
Reload configuration
|
||||
:returns: json object
|
||||
|
||||
|
@ -196,7 +196,7 @@ stop
|
|||
|
||||
stopbuy
|
||||
Stop buying (but handle sells gracefully).
|
||||
use reload_conf to reset
|
||||
use reload_config to reset
|
||||
:returns: json object
|
||||
|
||||
version
|
||||
|
|
|
@ -101,7 +101,7 @@ Simplified example:
|
|||
|
||||
## Changing stoploss on open trades
|
||||
|
||||
A stoploss on an open trade can be changed by changing the value in the configuration or strategy and use the `/reload_conf` command (alternatively, completely stopping and restarting the bot also works).
|
||||
A stoploss on an open trade can be changed by changing the value in the configuration or strategy and use the `/reload_config` command (alternatively, completely stopping and restarting the bot also works).
|
||||
|
||||
The new stoploss value will be applied to open trades (and corresponding log-messages will be generated).
|
||||
|
||||
|
|
|
@ -557,7 +557,7 @@ Locks can also be lifted manually, by calling `self.unlock_pair(pair)`.
|
|||
To verify if a pair is currently locked, use `self.is_pair_locked(pair)`.
|
||||
|
||||
!!! Note
|
||||
Locked pairs are not persisted, so a restart of the bot, or calling `/reload_conf` will reset locked pairs.
|
||||
Locked pairs are not persisted, so a restart of the bot, or calling `/reload_config` will reset locked pairs.
|
||||
|
||||
!!! Warning
|
||||
Locking pairs is not functioning during backtesting.
|
||||
|
|
|
@ -52,7 +52,7 @@ official commands. You can ask at any moment for help with `/help`.
|
|||
| `/start` | | Starts the trader
|
||||
| `/stop` | | Stops the trader
|
||||
| `/stopbuy` | | Stops the trader from opening new trades. Gracefully closes open trades according to their rules.
|
||||
| `/reload_conf` | | Reloads the configuration file
|
||||
| `/reload_config` | | Reloads the configuration file
|
||||
| `/show_config` | | Shows part of the current configuration with relevant settings to operation
|
||||
| `/status` | | Lists all open trades
|
||||
| `/status table` | | List all open trades in a table format. Pending buy orders are marked with an asterisk (*) Pending sell orders are marked with a double asterisk (**)
|
||||
|
@ -85,14 +85,14 @@ Below, example of Telegram message you will receive for each command.
|
|||
|
||||
### /stopbuy
|
||||
|
||||
> **status:** `Setting max_open_trades to 0. Run /reload_conf to reset.`
|
||||
> **status:** `Setting max_open_trades to 0. Run /reload_config to reset.`
|
||||
|
||||
Prevents the bot from opening new trades by temporarily setting "max_open_trades" to 0. Open trades will be handled via their regular rules (ROI / Sell-signal, stoploss, ...).
|
||||
|
||||
After this, give the bot time to close off open trades (can be checked via `/status table`).
|
||||
Once all positions are sold, run `/stop` to completely stop the bot.
|
||||
|
||||
`/reload_conf` resets "max_open_trades" to the value set in the configuration and resets this command.
|
||||
`/reload_config` resets "max_open_trades" to the value set in the configuration and resets this command.
|
||||
|
||||
!!! Warning
|
||||
The stop-buy signal is ONLY active while the bot is running, and is not persisted anyway, so restarting the bot will cause this to reset.
|
||||
|
@ -209,7 +209,7 @@ Shows the current whitelist
|
|||
Shows the current blacklist.
|
||||
If Pair is set, then this pair will be added to the pairlist.
|
||||
Also supports multiple pairs, seperated by a space.
|
||||
Use `/reload_conf` to reset the blacklist.
|
||||
Use `/reload_config` to reset the blacklist.
|
||||
|
||||
> Using blacklist `StaticPairList` with 2 pairs
|
||||
>`DODGE/BTC`, `HOT/BTC`.
|
||||
|
|
|
@ -172,8 +172,8 @@ class ApiServer(RPC):
|
|||
self.app.add_url_rule(f'{BASE_URI}/stop', 'stop', view_func=self._stop, methods=['POST'])
|
||||
self.app.add_url_rule(f'{BASE_URI}/stopbuy', 'stopbuy',
|
||||
view_func=self._stopbuy, methods=['POST'])
|
||||
self.app.add_url_rule(f'{BASE_URI}/reload_conf', 'reload_conf',
|
||||
view_func=self._reload_conf, methods=['POST'])
|
||||
self.app.add_url_rule(f'{BASE_URI}/reload_config', 'reload_config',
|
||||
view_func=self._reload_config, methods=['POST'])
|
||||
# Info commands
|
||||
self.app.add_url_rule(f'{BASE_URI}/balance', 'balance',
|
||||
view_func=self._balance, methods=['GET'])
|
||||
|
@ -304,12 +304,12 @@ class ApiServer(RPC):
|
|||
|
||||
@require_login
|
||||
@rpc_catch_errors
|
||||
def _reload_conf(self):
|
||||
def _reload_config(self):
|
||||
"""
|
||||
Handler for /reload_conf.
|
||||
Handler for /reload_config.
|
||||
Triggers a config file reload
|
||||
"""
|
||||
msg = self._rpc_reload_conf()
|
||||
msg = self._rpc_reload_config()
|
||||
return self.rest_dump(msg)
|
||||
|
||||
@require_login
|
||||
|
|
|
@ -418,9 +418,9 @@ class RPC:
|
|||
|
||||
return {'status': 'already stopped'}
|
||||
|
||||
def _rpc_reload_conf(self) -> Dict[str, str]:
|
||||
""" Handler for reload_conf. """
|
||||
self._freqtrade.state = State.RELOAD_CONF
|
||||
def _rpc_reload_config(self) -> Dict[str, str]:
|
||||
""" Handler for reload_config. """
|
||||
self._freqtrade.state = State.RELOAD_CONFIG
|
||||
return {'status': 'reloading config ...'}
|
||||
|
||||
def _rpc_stopbuy(self) -> Dict[str, str]:
|
||||
|
@ -431,7 +431,7 @@ class RPC:
|
|||
# Set 'max_open_trades' to 0
|
||||
self._freqtrade.config['max_open_trades'] = 0
|
||||
|
||||
return {'status': 'No more buy will occur from now. Run /reload_conf to reset.'}
|
||||
return {'status': 'No more buy will occur from now. Run /reload_config to reset.'}
|
||||
|
||||
def _rpc_forcesell(self, trade_id: str) -> Dict[str, str]:
|
||||
"""
|
||||
|
|
|
@ -95,7 +95,9 @@ class Telegram(RPC):
|
|||
CommandHandler('performance', self._performance),
|
||||
CommandHandler('daily', self._daily),
|
||||
CommandHandler('count', self._count),
|
||||
CommandHandler('reload_conf', self._reload_conf),
|
||||
CommandHandler('reload_conf', self._reload_config),
|
||||
CommandHandler('reload_config', self._reload_config),
|
||||
CommandHandler('show_conf', self._reload_config),
|
||||
CommandHandler('show_config', self._show_config),
|
||||
CommandHandler('stopbuy', self._stopbuy),
|
||||
CommandHandler('whitelist', self._whitelist),
|
||||
|
@ -436,15 +438,15 @@ class Telegram(RPC):
|
|||
self._send_msg('Status: `{status}`'.format(**msg))
|
||||
|
||||
@authorized_only
|
||||
def _reload_conf(self, update: Update, context: CallbackContext) -> None:
|
||||
def _reload_config(self, update: Update, context: CallbackContext) -> None:
|
||||
"""
|
||||
Handler for /reload_conf.
|
||||
Handler for /reload_config.
|
||||
Triggers a config file reload
|
||||
:param bot: telegram bot
|
||||
:param update: message update
|
||||
:return: None
|
||||
"""
|
||||
msg = self._rpc_reload_conf()
|
||||
msg = self._rpc_reload_config()
|
||||
self._send_msg('Status: `{status}`'.format(**msg))
|
||||
|
||||
@authorized_only
|
||||
|
@ -617,7 +619,7 @@ class Telegram(RPC):
|
|||
"\n"
|
||||
"*/balance:* `Show account balance per currency`\n"
|
||||
"*/stopbuy:* `Stops buying, but handles open trades gracefully` \n"
|
||||
"*/reload_conf:* `Reload configuration file` \n"
|
||||
"*/reload_config:* `Reload configuration file` \n"
|
||||
"*/show_config:* `Show running configuration` \n"
|
||||
"*/whitelist:* `Show current whitelist` \n"
|
||||
"*/blacklist [pair]:* `Show current blacklist, or adds one or more pairs "
|
||||
|
|
|
@ -12,7 +12,7 @@ class State(Enum):
|
|||
"""
|
||||
RUNNING = 1
|
||||
STOPPED = 2
|
||||
RELOAD_CONF = 3
|
||||
RELOAD_CONFIG = 3
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.name.lower()}"
|
||||
|
|
|
@ -71,7 +71,7 @@ class Worker:
|
|||
state = None
|
||||
while True:
|
||||
state = self._worker(old_state=state)
|
||||
if state == State.RELOAD_CONF:
|
||||
if state == State.RELOAD_CONFIG:
|
||||
self._reconfigure()
|
||||
|
||||
def _worker(self, old_state: Optional[State]) -> State:
|
||||
|
|
|
@ -592,7 +592,7 @@ def test_rpc_stopbuy(mocker, default_conf) -> None:
|
|||
|
||||
assert freqtradebot.config['max_open_trades'] != 0
|
||||
result = rpc._rpc_stopbuy()
|
||||
assert {'status': 'No more buy will occur from now. Run /reload_conf to reset.'} == result
|
||||
assert {'status': 'No more buy will occur from now. Run /reload_config to reset.'} == result
|
||||
assert freqtradebot.config['max_open_trades'] == 0
|
||||
|
||||
|
||||
|
|
|
@ -251,10 +251,10 @@ def test_api_cleanup(default_conf, mocker, caplog):
|
|||
def test_api_reloadconf(botclient):
|
||||
ftbot, client = botclient
|
||||
|
||||
rc = client_post(client, f"{BASE_URI}/reload_conf")
|
||||
rc = client_post(client, f"{BASE_URI}/reload_config")
|
||||
assert_response(rc)
|
||||
assert rc.json == {'status': 'reloading config ...'}
|
||||
assert ftbot.state == State.RELOAD_CONF
|
||||
assert ftbot.state == State.RELOAD_CONFIG
|
||||
|
||||
|
||||
def test_api_stopbuy(botclient):
|
||||
|
@ -263,7 +263,7 @@ def test_api_stopbuy(botclient):
|
|||
|
||||
rc = client_post(client, f"{BASE_URI}/stopbuy")
|
||||
assert_response(rc)
|
||||
assert rc.json == {'status': 'No more buy will occur from now. Run /reload_conf to reset.'}
|
||||
assert rc.json == {'status': 'No more buy will occur from now. Run /reload_config to reset.'}
|
||||
assert ftbot.config['max_open_trades'] == 0
|
||||
|
||||
|
||||
|
|
|
@ -73,8 +73,9 @@ def test_init(default_conf, mocker, caplog) -> None:
|
|||
|
||||
message_str = ("rpc.telegram is listening for following commands: [['status'], ['profit'], "
|
||||
"['balance'], ['start'], ['stop'], ['forcesell'], ['forcebuy'], "
|
||||
"['performance'], ['daily'], ['count'], ['reload_conf'], ['show_config'], "
|
||||
"['stopbuy'], ['whitelist'], ['blacklist'], ['edge'], ['help'], ['version']]")
|
||||
"['performance'], ['daily'], ['count'], ['reload_conf'], ['reload_config'], "
|
||||
"['show_conf'], ['show_config'], ['stopbuy'], ['whitelist'], "
|
||||
"['blacklist'], ['edge'], ['help'], ['version']]")
|
||||
|
||||
assert log_has(message_str, caplog)
|
||||
|
||||
|
@ -666,11 +667,11 @@ def test_stopbuy_handle(default_conf, update, mocker) -> None:
|
|||
telegram._stopbuy(update=update, context=MagicMock())
|
||||
assert freqtradebot.config['max_open_trades'] == 0
|
||||
assert msg_mock.call_count == 1
|
||||
assert 'No more buy will occur from now. Run /reload_conf to reset.' \
|
||||
assert 'No more buy will occur from now. Run /reload_config to reset.' \
|
||||
in msg_mock.call_args_list[0][0][0]
|
||||
|
||||
|
||||
def test_reload_conf_handle(default_conf, update, mocker) -> None:
|
||||
def test_reload_config_handle(default_conf, update, mocker) -> None:
|
||||
msg_mock = MagicMock()
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.rpc.telegram.Telegram',
|
||||
|
@ -683,8 +684,8 @@ def test_reload_conf_handle(default_conf, update, mocker) -> None:
|
|||
|
||||
freqtradebot.state = State.RUNNING
|
||||
assert freqtradebot.state == State.RUNNING
|
||||
telegram._reload_conf(update=update, context=MagicMock())
|
||||
assert freqtradebot.state == State.RELOAD_CONF
|
||||
telegram._reload_config(update=update, context=MagicMock())
|
||||
assert freqtradebot.state == State.RELOAD_CONFIG
|
||||
assert msg_mock.call_count == 1
|
||||
assert 'reloading config' in msg_mock.call_args_list[0][0][0]
|
||||
|
||||
|
|
|
@ -141,12 +141,12 @@ def test_main_operational_exception1(mocker, default_conf, caplog) -> None:
|
|||
assert log_has_re(r'SIGINT.*', caplog)
|
||||
|
||||
|
||||
def test_main_reload_conf(mocker, default_conf, caplog) -> None:
|
||||
def test_main_reload_config(mocker, default_conf, caplog) -> None:
|
||||
patch_exchange(mocker)
|
||||
mocker.patch('freqtrade.freqtradebot.FreqtradeBot.cleanup', MagicMock())
|
||||
# Simulate Running, reload, running workflow
|
||||
worker_mock = MagicMock(side_effect=[State.RUNNING,
|
||||
State.RELOAD_CONF,
|
||||
State.RELOAD_CONFIG,
|
||||
State.RUNNING,
|
||||
OperationalException("Oh snap!")])
|
||||
mocker.patch('freqtrade.worker.Worker._worker', worker_mock)
|
||||
|
|
Loading…
Reference in New Issue
Block a user