From 53c208197d12560f2e4b39338831ac509f3960bf Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 16 Jan 2021 16:19:49 +0100 Subject: [PATCH] Add bot_name setting allows naming the bot to simply differentiate when running different bots. --- config.json.example | 1 + config_binance.json.example | 1 + config_full.json.example | 1 + config_kraken.json.example | 1 + docs/configuration.md | 1 + freqtrade/constants.py | 1 + freqtrade/rpc/api_server/api_schemas.py | 1 + freqtrade/rpc/rpc.py | 1 + freqtrade/templates/base_config.json.j2 | 1 + tests/rpc/test_rpc_apiserver.py | 1 + 10 files changed, 10 insertions(+) diff --git a/config.json.example b/config.json.example index fc59a4d5b..0f0bbec4b 100644 --- a/config.json.example +++ b/config.json.example @@ -85,6 +85,7 @@ "username": "freqtrader", "password": "SuperSecurePassword" }, + "bot_name": "freqtrade", "initial_state": "running", "forcebuy_enable": false, "internals": { diff --git a/config_binance.json.example b/config_binance.json.example index 954634def..83c9748d7 100644 --- a/config_binance.json.example +++ b/config_binance.json.example @@ -90,6 +90,7 @@ "username": "freqtrader", "password": "SuperSecurePassword" }, + "bot_name": "freqtrade", "initial_state": "running", "forcebuy_enable": false, "internals": { diff --git a/config_full.json.example b/config_full.json.example index ef791d267..6593750b4 100644 --- a/config_full.json.example +++ b/config_full.json.example @@ -177,6 +177,7 @@ "username": "freqtrader", "password": "SuperSecurePassword" }, + "bot_name": "freqtrade", "db_url": "sqlite:///tradesv3.sqlite", "initial_state": "running", "forcebuy_enable": false, diff --git a/config_kraken.json.example b/config_kraken.json.example index 4b33eb592..3cd90e5d3 100644 --- a/config_kraken.json.example +++ b/config_kraken.json.example @@ -95,6 +95,7 @@ "username": "freqtrader", "password": "SuperSecurePassword" }, + "bot_name": "freqtrade", "initial_state": "running", "forcebuy_enable": false, "internals": { diff --git a/docs/configuration.md b/docs/configuration.md index 6a05fc3a3..9a3126618 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -110,6 +110,7 @@ Mandatory parameters are marked as **Required**, which means that they are requi | `api_server.verbosity` | Logging verbosity. `info` will print all RPC Calls, while "error" will only display errors.
**Datatype:** Enum, either `info` or `error`. Defaults to `info`. | `api_server.username` | Username for API server. See the [API Server documentation](rest-api.md) for more details.
**Keep it in secret, do not disclose publicly.**
**Datatype:** String | `api_server.password` | Password for API server. See the [API Server documentation](rest-api.md) for more details.
**Keep it in secret, do not disclose publicly.**
**Datatype:** String +| `bot_name` | Name of the bot. Passed via API to a client - can be shown to distinguish / name bots.
*Defaults to `freqtrade`*
**Datatype:** String | `db_url` | Declares database URL to use. NOTE: This defaults to `sqlite:///tradesv3.dryrun.sqlite` if `dry_run` is `true`, and to `sqlite:///tradesv3.sqlite` for production instances.
**Datatype:** String, SQLAlchemy connect string | `initial_state` | Defines the initial application state. More information below.
*Defaults to `stopped`.*
**Datatype:** Enum, either `stopped` or `running` | `forcebuy_enable` | Enables the RPC Commands to force a buy. More information below.
**Datatype:** Boolean diff --git a/freqtrade/constants.py b/freqtrade/constants.py index d48ab635e..69301ca0e 100644 --- a/freqtrade/constants.py +++ b/freqtrade/constants.py @@ -116,6 +116,7 @@ CONF_SCHEMA = { 'trailing_stop_positive': {'type': 'number', 'minimum': 0, 'maximum': 1}, 'trailing_stop_positive_offset': {'type': 'number', 'minimum': 0, 'maximum': 1}, 'trailing_only_offset_is_reached': {'type': 'boolean'}, + 'bot_name': {'type': 'string'}, 'unfilledtimeout': { 'type': 'object', 'properties': { diff --git a/freqtrade/rpc/api_server/api_schemas.py b/freqtrade/rpc/api_server/api_schemas.py index 45f160008..c9e8aaceb 100644 --- a/freqtrade/rpc/api_server/api_schemas.py +++ b/freqtrade/rpc/api_server/api_schemas.py @@ -131,6 +131,7 @@ class ShowConfig(BaseModel): forcebuy_enabled: bool ask_strategy: Dict[str, Any] bid_strategy: Dict[str, Any] + bot_name: str state: str runmode: str diff --git a/freqtrade/rpc/rpc.py b/freqtrade/rpc/rpc.py index 1e304f01b..bee04ddb6 100644 --- a/freqtrade/rpc/rpc.py +++ b/freqtrade/rpc/rpc.py @@ -129,6 +129,7 @@ class RPC: 'trailing_stop_positive': config.get('trailing_stop_positive'), 'trailing_stop_positive_offset': config.get('trailing_stop_positive_offset'), 'trailing_only_offset_is_reached': config.get('trailing_only_offset_is_reached'), + 'bot_name': config.get('bot_name', 'freqtrade'), 'timeframe': config.get('timeframe'), 'timeframe_ms': timeframe_to_msecs(config['timeframe'] ) if 'timeframe' in config else '', diff --git a/freqtrade/templates/base_config.json.j2 b/freqtrade/templates/base_config.json.j2 index b362690f9..f920843b2 100644 --- a/freqtrade/templates/base_config.json.j2 +++ b/freqtrade/templates/base_config.json.j2 @@ -63,6 +63,7 @@ "username": "", "password": "" }, + "bot_name": "freqtrade", "initial_state": "running", "forcebuy_enable": false, "internals": { diff --git a/tests/rpc/test_rpc_apiserver.py b/tests/rpc/test_rpc_apiserver.py index c782f5431..935f43885 100644 --- a/tests/rpc/test_rpc_apiserver.py +++ b/tests/rpc/test_rpc_apiserver.py @@ -414,6 +414,7 @@ def test_api_show_config(botclient, mocker): assert rc.json()['timeframe_ms'] == 300000 assert rc.json()['timeframe_min'] == 5 assert rc.json()['state'] == 'running' + assert rc.json()['bot_name'] == 'freqtrade' assert not rc.json()['trailing_stop'] assert 'bid_strategy' in rc.json() assert 'ask_strategy' in rc.json()