Refactor RPC modules so handlers don't inherit RPC directly
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
# flake8: noqa: F401
|
||||
from .rpc import RPC, RPCException, RPCMessageType
|
||||
from .rpc import RPC, RPCException, RPCHandler, RPCMessageType
|
||||
from .rpc_manager import RPCManager
|
||||
|
@@ -20,7 +20,7 @@ from freqtrade.__init__ import __version__
|
||||
from freqtrade.constants import DATETIME_PRINT_FORMAT, USERPATH_STRATEGIES
|
||||
from freqtrade.exceptions import OperationalException
|
||||
from freqtrade.persistence import Trade
|
||||
from freqtrade.rpc.rpc import RPC, RPCException
|
||||
from freqtrade.rpc.rpc import RPC, RPCException, RPCHandler
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -78,7 +78,7 @@ def shutdown_session(exception=None):
|
||||
Trade.session.remove()
|
||||
|
||||
|
||||
class ApiServer(RPC):
|
||||
class ApiServer(RPCHandler):
|
||||
"""
|
||||
This class runs api server and provides rpc.rpc functionality to it
|
||||
|
||||
@@ -89,13 +89,14 @@ class ApiServer(RPC):
|
||||
return (safe_str_cmp(username, self._config['api_server'].get('username')) and
|
||||
safe_str_cmp(password, self._config['api_server'].get('password')))
|
||||
|
||||
def __init__(self, freqtrade) -> None:
|
||||
def __init__(self, rpc: RPC, config: Dict[str, Any]) -> None:
|
||||
"""
|
||||
Init the api server, and init the super class RPC
|
||||
:param freqtrade: Instance of a freqtrade bot
|
||||
Init the api server, and init the super class RPCHandler
|
||||
:param rpc: instance of RPC Helper class
|
||||
:param config: Configuration object
|
||||
:return: None
|
||||
"""
|
||||
super().__init__(freqtrade)
|
||||
super().__init__(rpc, config)
|
||||
|
||||
self.app = Flask(__name__)
|
||||
self._cors = CORS(self.app,
|
||||
@@ -282,7 +283,7 @@ class ApiServer(RPC):
|
||||
Handler for /start.
|
||||
Starts TradeThread in bot if stopped.
|
||||
"""
|
||||
msg = self._rpc_start()
|
||||
msg = self._rpc._rpc_start()
|
||||
return jsonify(msg)
|
||||
|
||||
@require_login
|
||||
@@ -292,7 +293,7 @@ class ApiServer(RPC):
|
||||
Handler for /stop.
|
||||
Stops TradeThread in bot if running
|
||||
"""
|
||||
msg = self._rpc_stop()
|
||||
msg = self._rpc._rpc_stop()
|
||||
return jsonify(msg)
|
||||
|
||||
@require_login
|
||||
@@ -302,7 +303,7 @@ class ApiServer(RPC):
|
||||
Handler for /stopbuy.
|
||||
Sets max_open_trades to 0 and gracefully sells all open trades
|
||||
"""
|
||||
msg = self._rpc_stopbuy()
|
||||
msg = self._rpc._rpc_stopbuy()
|
||||
return jsonify(msg)
|
||||
|
||||
@rpc_catch_errors
|
||||
@@ -326,7 +327,7 @@ class ApiServer(RPC):
|
||||
"""
|
||||
Prints the bot's version
|
||||
"""
|
||||
return jsonify(RPC._rpc_show_config(self._config, self._freqtrade.state))
|
||||
return jsonify(RPC._rpc_show_config(self._config, self._rpc._freqtrade.state))
|
||||
|
||||
@require_login
|
||||
@rpc_catch_errors
|
||||
@@ -335,7 +336,7 @@ class ApiServer(RPC):
|
||||
Handler for /reload_config.
|
||||
Triggers a config file reload
|
||||
"""
|
||||
msg = self._rpc_reload_config()
|
||||
msg = self._rpc._rpc_reload_config()
|
||||
return jsonify(msg)
|
||||
|
||||
@require_login
|
||||
@@ -345,7 +346,7 @@ class ApiServer(RPC):
|
||||
Handler for /count.
|
||||
Returns the number of trades running
|
||||
"""
|
||||
msg = self._rpc_count()
|
||||
msg = self._rpc._rpc_count()
|
||||
return jsonify(msg)
|
||||
|
||||
@require_login
|
||||
@@ -355,7 +356,7 @@ class ApiServer(RPC):
|
||||
Handler for /locks.
|
||||
Returns the currently active locks.
|
||||
"""
|
||||
return jsonify(self._rpc_locks())
|
||||
return jsonify(self._rpc._rpc_locks())
|
||||
|
||||
@require_login
|
||||
@rpc_catch_errors
|
||||
@@ -368,10 +369,10 @@ class ApiServer(RPC):
|
||||
timescale = request.args.get('timescale', 7)
|
||||
timescale = int(timescale)
|
||||
|
||||
stats = self._rpc_daily_profit(timescale,
|
||||
self._config['stake_currency'],
|
||||
self._config.get('fiat_display_currency', '')
|
||||
)
|
||||
stats = self._rpc._rpc_daily_profit(timescale,
|
||||
self._config['stake_currency'],
|
||||
self._config.get('fiat_display_currency', '')
|
||||
)
|
||||
|
||||
return jsonify(stats)
|
||||
|
||||
@@ -394,7 +395,7 @@ class ApiServer(RPC):
|
||||
Returns information related to Edge.
|
||||
:return: edge stats
|
||||
"""
|
||||
stats = self._rpc_edge()
|
||||
stats = self._rpc._rpc_edge()
|
||||
|
||||
return jsonify(stats)
|
||||
|
||||
@@ -408,9 +409,9 @@ class ApiServer(RPC):
|
||||
:return: stats
|
||||
"""
|
||||
|
||||
stats = self._rpc_trade_statistics(self._config['stake_currency'],
|
||||
self._config.get('fiat_display_currency')
|
||||
)
|
||||
stats = self._rpc._rpc_trade_statistics(self._config['stake_currency'],
|
||||
self._config.get('fiat_display_currency')
|
||||
)
|
||||
|
||||
return jsonify(stats)
|
||||
|
||||
@@ -422,7 +423,7 @@ class ApiServer(RPC):
|
||||
Returns a Object with "durations" and "sell_reasons" as keys.
|
||||
"""
|
||||
|
||||
stats = self._rpc_stats()
|
||||
stats = self._rpc._rpc_stats()
|
||||
|
||||
return jsonify(stats)
|
||||
|
||||
@@ -435,7 +436,7 @@ class ApiServer(RPC):
|
||||
Returns a cumulative performance statistics
|
||||
:return: stats
|
||||
"""
|
||||
stats = self._rpc_performance()
|
||||
stats = self._rpc._rpc_performance()
|
||||
|
||||
return jsonify(stats)
|
||||
|
||||
@@ -448,7 +449,7 @@ class ApiServer(RPC):
|
||||
Returns the current status of the trades in json format
|
||||
"""
|
||||
try:
|
||||
results = self._rpc_trade_status()
|
||||
results = self._rpc._rpc_trade_status()
|
||||
return jsonify(results)
|
||||
except RPCException:
|
||||
return jsonify([])
|
||||
@@ -461,8 +462,8 @@ class ApiServer(RPC):
|
||||
|
||||
Returns the current status of the trades in json format
|
||||
"""
|
||||
results = self._rpc_balance(self._config['stake_currency'],
|
||||
self._config.get('fiat_display_currency', ''))
|
||||
results = self._rpc._rpc_balance(self._config['stake_currency'],
|
||||
self._config.get('fiat_display_currency', ''))
|
||||
return jsonify(results)
|
||||
|
||||
@require_login
|
||||
@@ -474,7 +475,7 @@ class ApiServer(RPC):
|
||||
Returns the X last trades in json format
|
||||
"""
|
||||
limit = int(request.args.get('limit', 0))
|
||||
results = self._rpc_trade_history(limit)
|
||||
results = self._rpc._rpc_trade_history(limit)
|
||||
return jsonify(results)
|
||||
|
||||
@require_login
|
||||
@@ -487,7 +488,7 @@ class ApiServer(RPC):
|
||||
param:
|
||||
tradeid: Numeric trade-id assigned to the trade.
|
||||
"""
|
||||
result = self._rpc_delete(tradeid)
|
||||
result = self._rpc._rpc_delete(tradeid)
|
||||
return jsonify(result)
|
||||
|
||||
@require_login
|
||||
@@ -496,7 +497,7 @@ class ApiServer(RPC):
|
||||
"""
|
||||
Handler for /whitelist.
|
||||
"""
|
||||
results = self._rpc_whitelist()
|
||||
results = self._rpc._rpc_whitelist()
|
||||
return jsonify(results)
|
||||
|
||||
@require_login
|
||||
@@ -506,7 +507,7 @@ class ApiServer(RPC):
|
||||
Handler for /blacklist.
|
||||
"""
|
||||
add = request.json.get("blacklist", None) if request.method == 'POST' else None
|
||||
results = self._rpc_blacklist(add)
|
||||
results = self._rpc._rpc_blacklist(add)
|
||||
return jsonify(results)
|
||||
|
||||
@require_login
|
||||
@@ -519,7 +520,7 @@ class ApiServer(RPC):
|
||||
price = request.json.get("price", None)
|
||||
price = float(price) if price is not None else price
|
||||
|
||||
trade = self._rpc_forcebuy(asset, price)
|
||||
trade = self._rpc._rpc_forcebuy(asset, price)
|
||||
if trade:
|
||||
return jsonify(trade.to_json())
|
||||
else:
|
||||
@@ -532,7 +533,7 @@ class ApiServer(RPC):
|
||||
Handler for /forcesell.
|
||||
"""
|
||||
tradeid = request.json.get("tradeid")
|
||||
results = self._rpc_forcesell(tradeid)
|
||||
results = self._rpc._rpc_forcesell(tradeid)
|
||||
return jsonify(results)
|
||||
|
||||
@require_login
|
||||
@@ -554,7 +555,7 @@ class ApiServer(RPC):
|
||||
if not pair or not timeframe:
|
||||
return self.rest_error("Mandatory parameter missing.", 400)
|
||||
|
||||
results = self._rpc_analysed_dataframe(pair, timeframe, limit)
|
||||
results = self._rpc._rpc_analysed_dataframe(pair, timeframe, limit)
|
||||
return jsonify(results)
|
||||
|
||||
@require_login
|
||||
@@ -593,7 +594,7 @@ class ApiServer(RPC):
|
||||
"""
|
||||
Handler for /plot_config.
|
||||
"""
|
||||
return jsonify(self._rpc_plot_config())
|
||||
return jsonify(self._rpc._rpc_plot_config())
|
||||
|
||||
@require_login
|
||||
@rpc_catch_errors
|
||||
|
@@ -65,6 +65,32 @@ class RPCException(Exception):
|
||||
}
|
||||
|
||||
|
||||
class RPCHandler:
|
||||
|
||||
def __init__(self, rpc: 'RPC', config: Dict[str, Any]) -> None:
|
||||
"""
|
||||
Initializes RPCHandlers
|
||||
:param rpc: instance of RPC Helper class
|
||||
:param config: Configuration object
|
||||
:return: None
|
||||
"""
|
||||
self._rpc = rpc
|
||||
self._config: Dict[str, Any] = config
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
""" Returns the lowercase name of the implementation """
|
||||
return self.__class__.__name__.lower()
|
||||
|
||||
@abstractmethod
|
||||
def cleanup(self) -> None:
|
||||
""" Cleanup pending module resources """
|
||||
|
||||
@abstractmethod
|
||||
def send_msg(self, msg: Dict[str, str]) -> None:
|
||||
""" Sends a message to all registered rpc modules """
|
||||
|
||||
|
||||
class RPC:
|
||||
"""
|
||||
RPC class can be used to have extra feature, like bot data, and access to DB data
|
||||
@@ -83,19 +109,6 @@ class RPC:
|
||||
if self._config.get('fiat_display_currency', None):
|
||||
self._fiat_converter = CryptoToFiatConverter()
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
""" Returns the lowercase name of the implementation """
|
||||
return self.__class__.__name__.lower()
|
||||
|
||||
@abstractmethod
|
||||
def cleanup(self) -> None:
|
||||
""" Cleanup pending module resources """
|
||||
|
||||
@abstractmethod
|
||||
def send_msg(self, msg: Dict[str, str]) -> None:
|
||||
""" Sends a message to all registered rpc modules """
|
||||
|
||||
@staticmethod
|
||||
def _rpc_show_config(config, botstate: State) -> Dict[str, Any]:
|
||||
"""
|
||||
|
@@ -4,7 +4,7 @@ This module contains class to manage RPC communications (Telegram, Slack, ...)
|
||||
import logging
|
||||
from typing import Any, Dict, List
|
||||
|
||||
from freqtrade.rpc import RPC, RPCMessageType
|
||||
from freqtrade.rpc import RPC, RPCHandler, RPCMessageType
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -16,25 +16,26 @@ class RPCManager:
|
||||
"""
|
||||
def __init__(self, freqtrade) -> None:
|
||||
""" Initializes all enabled rpc modules """
|
||||
self.registered_modules: List[RPC] = []
|
||||
|
||||
self.registered_modules: List[RPCHandler] = []
|
||||
self._rpc = RPC(freqtrade)
|
||||
config = freqtrade.config
|
||||
# Enable telegram
|
||||
if freqtrade.config.get('telegram', {}).get('enabled', False):
|
||||
if config.get('telegram', {}).get('enabled', False):
|
||||
logger.info('Enabling rpc.telegram ...')
|
||||
from freqtrade.rpc.telegram import Telegram
|
||||
self.registered_modules.append(Telegram(freqtrade))
|
||||
self.registered_modules.append(Telegram(self._rpc, config))
|
||||
|
||||
# Enable Webhook
|
||||
if freqtrade.config.get('webhook', {}).get('enabled', False):
|
||||
if config.get('webhook', {}).get('enabled', False):
|
||||
logger.info('Enabling rpc.webhook ...')
|
||||
from freqtrade.rpc.webhook import Webhook
|
||||
self.registered_modules.append(Webhook(freqtrade))
|
||||
self.registered_modules.append(Webhook(self._rpc, config))
|
||||
|
||||
# Enable local rest api server for cmd line control
|
||||
if freqtrade.config.get('api_server', {}).get('enabled', False):
|
||||
if config.get('api_server', {}).get('enabled', False):
|
||||
logger.info('Enabling rpc.api_server')
|
||||
from freqtrade.rpc.api_server import ApiServer
|
||||
self.registered_modules.append(ApiServer(freqtrade))
|
||||
self.registered_modules.append(ApiServer(self._rpc, config))
|
||||
|
||||
def cleanup(self) -> None:
|
||||
""" Stops all enabled rpc modules """
|
||||
|
@@ -18,7 +18,7 @@ from telegram.utils.helpers import escape_markdown
|
||||
|
||||
from freqtrade.__init__ import __version__
|
||||
from freqtrade.exceptions import OperationalException
|
||||
from freqtrade.rpc import RPC, RPCException, RPCMessageType
|
||||
from freqtrade.rpc import RPC, RPCException, RPCHandler, RPCMessageType
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -62,16 +62,18 @@ def authorized_only(command_handler: Callable[..., None]) -> Callable[..., Any]:
|
||||
return wrapper
|
||||
|
||||
|
||||
class Telegram(RPC):
|
||||
class Telegram(RPCHandler):
|
||||
""" This class handles all telegram communication """
|
||||
|
||||
def __init__(self, freqtrade) -> None:
|
||||
def __init__(self, rpc: RPC, config: Dict[str, Any]) -> None:
|
||||
|
||||
"""
|
||||
Init the Telegram call, and init the super class RPC
|
||||
:param freqtrade: Instance of a freqtrade bot
|
||||
Init the Telegram call, and init the super class RPCHandler
|
||||
:param rpc: instance of RPC Helper class
|
||||
:param config: Configuration object
|
||||
:return: None
|
||||
"""
|
||||
super().__init__(freqtrade)
|
||||
super().__init__(rpc, config)
|
||||
|
||||
self._updater: Updater
|
||||
self._init_keyboard()
|
||||
@@ -181,8 +183,8 @@ class Telegram(RPC):
|
||||
return
|
||||
|
||||
if msg['type'] == RPCMessageType.BUY_NOTIFICATION:
|
||||
if self._fiat_converter:
|
||||
msg['stake_amount_fiat'] = self._fiat_converter.convert_amount(
|
||||
if self._rpc._fiat_converter:
|
||||
msg['stake_amount_fiat'] = self._rpc._fiat_converter.convert_amount(
|
||||
msg['stake_amount'], msg['stake_currency'], msg['fiat_currency'])
|
||||
else:
|
||||
msg['stake_amount_fiat'] = 0
|
||||
@@ -222,8 +224,8 @@ class Telegram(RPC):
|
||||
# Check if all sell properties are available.
|
||||
# This might not be the case if the message origin is triggered by /forcesell
|
||||
if (all(prop in msg for prop in ['gain', 'fiat_currency', 'stake_currency'])
|
||||
and self._fiat_converter):
|
||||
msg['profit_fiat'] = self._fiat_converter.convert_amount(
|
||||
and self._rpc._fiat_converter):
|
||||
msg['profit_fiat'] = self._rpc._fiat_converter.convert_amount(
|
||||
msg['profit_amount'], msg['stake_currency'], msg['fiat_currency'])
|
||||
message += (' `({gain}: {profit_amount:.8f} {stake_currency}'
|
||||
' / {profit_fiat:.3f} {fiat_currency})`').format(**msg)
|
||||
@@ -275,7 +277,7 @@ class Telegram(RPC):
|
||||
return
|
||||
|
||||
try:
|
||||
results = self._rpc_trade_status()
|
||||
results = self._rpc._rpc_trade_status()
|
||||
|
||||
messages = []
|
||||
for r in results:
|
||||
@@ -325,8 +327,9 @@ class Telegram(RPC):
|
||||
:return: None
|
||||
"""
|
||||
try:
|
||||
statlist, head = self._rpc_status_table(self._config['stake_currency'],
|
||||
self._config.get('fiat_display_currency', ''))
|
||||
statlist, head = self._rpc._rpc_status_table(
|
||||
self._config['stake_currency'], self._config.get('fiat_display_currency', ''))
|
||||
|
||||
message = tabulate(statlist, headers=head, tablefmt='simple')
|
||||
self._send_msg(f"<pre>{message}</pre>", parse_mode=ParseMode.HTML)
|
||||
except RPCException as e:
|
||||
@@ -348,7 +351,7 @@ class Telegram(RPC):
|
||||
except (TypeError, ValueError, IndexError):
|
||||
timescale = 7
|
||||
try:
|
||||
stats = self._rpc_daily_profit(
|
||||
stats = self._rpc._rpc_daily_profit(
|
||||
timescale,
|
||||
stake_cur,
|
||||
fiat_disp_cur
|
||||
@@ -382,7 +385,7 @@ class Telegram(RPC):
|
||||
stake_cur = self._config['stake_currency']
|
||||
fiat_disp_cur = self._config.get('fiat_display_currency', '')
|
||||
|
||||
stats = self._rpc_trade_statistics(
|
||||
stats = self._rpc._rpc_trade_statistics(
|
||||
stake_cur,
|
||||
fiat_disp_cur)
|
||||
profit_closed_coin = stats['profit_closed_coin']
|
||||
@@ -433,7 +436,7 @@ class Telegram(RPC):
|
||||
Handler for /stats
|
||||
Show stats of recent trades
|
||||
"""
|
||||
stats = self._rpc_stats()
|
||||
stats = self._rpc._rpc_stats()
|
||||
|
||||
reason_map = {
|
||||
'roi': 'ROI',
|
||||
@@ -473,8 +476,8 @@ class Telegram(RPC):
|
||||
def _balance(self, update: Update, context: CallbackContext) -> None:
|
||||
""" Handler for /balance """
|
||||
try:
|
||||
result = self._rpc_balance(self._config['stake_currency'],
|
||||
self._config.get('fiat_display_currency', ''))
|
||||
result = self._rpc._rpc_balance(self._config['stake_currency'],
|
||||
self._config.get('fiat_display_currency', ''))
|
||||
|
||||
output = ''
|
||||
if self._config['dry_run']:
|
||||
@@ -517,7 +520,7 @@ class Telegram(RPC):
|
||||
:param update: message update
|
||||
:return: None
|
||||
"""
|
||||
msg = self._rpc_start()
|
||||
msg = self._rpc._rpc_start()
|
||||
self._send_msg('Status: `{status}`'.format(**msg))
|
||||
|
||||
@authorized_only
|
||||
@@ -529,7 +532,7 @@ class Telegram(RPC):
|
||||
:param update: message update
|
||||
:return: None
|
||||
"""
|
||||
msg = self._rpc_stop()
|
||||
msg = self._rpc._rpc_stop()
|
||||
self._send_msg('Status: `{status}`'.format(**msg))
|
||||
|
||||
@authorized_only
|
||||
@@ -541,7 +544,7 @@ class Telegram(RPC):
|
||||
:param update: message update
|
||||
:return: None
|
||||
"""
|
||||
msg = self._rpc_reload_config()
|
||||
msg = self._rpc._rpc_reload_config()
|
||||
self._send_msg('Status: `{status}`'.format(**msg))
|
||||
|
||||
@authorized_only
|
||||
@@ -553,7 +556,7 @@ class Telegram(RPC):
|
||||
:param update: message update
|
||||
:return: None
|
||||
"""
|
||||
msg = self._rpc_stopbuy()
|
||||
msg = self._rpc._rpc_stopbuy()
|
||||
self._send_msg('Status: `{status}`'.format(**msg))
|
||||
|
||||
@authorized_only
|
||||
@@ -571,7 +574,7 @@ class Telegram(RPC):
|
||||
self._send_msg("You must specify a trade-id or 'all'.")
|
||||
return
|
||||
try:
|
||||
msg = self._rpc_forcesell(trade_id)
|
||||
msg = self._rpc._rpc_forcesell(trade_id)
|
||||
self._send_msg('Forcesell Result: `{result}`'.format(**msg))
|
||||
|
||||
except RPCException as e:
|
||||
@@ -590,7 +593,7 @@ class Telegram(RPC):
|
||||
pair = context.args[0]
|
||||
price = float(context.args[1]) if len(context.args) > 1 else None
|
||||
try:
|
||||
self._rpc_forcebuy(pair, price)
|
||||
self._rpc._rpc_forcebuy(pair, price)
|
||||
except RPCException as e:
|
||||
self._send_msg(str(e))
|
||||
|
||||
@@ -609,7 +612,7 @@ class Telegram(RPC):
|
||||
except (TypeError, ValueError, IndexError):
|
||||
nrecent = 10
|
||||
try:
|
||||
trades = self._rpc_trade_history(
|
||||
trades = self._rpc._rpc_trade_history(
|
||||
nrecent
|
||||
)
|
||||
trades_tab = tabulate(
|
||||
@@ -642,7 +645,7 @@ class Telegram(RPC):
|
||||
if not context.args or len(context.args) == 0:
|
||||
raise RPCException("Trade-id not set.")
|
||||
trade_id = int(context.args[0])
|
||||
msg = self._rpc_delete(trade_id)
|
||||
msg = self._rpc._rpc_delete(trade_id)
|
||||
self._send_msg((
|
||||
'`{result_msg}`\n'
|
||||
'Please make sure to take care of this asset on the exchange manually.'
|
||||
@@ -661,7 +664,7 @@ class Telegram(RPC):
|
||||
:return: None
|
||||
"""
|
||||
try:
|
||||
trades = self._rpc_performance()
|
||||
trades = self._rpc._rpc_performance()
|
||||
stats = '\n'.join('{index}.\t<code>{pair}\t{profit:.2f}% ({count})</code>'.format(
|
||||
index=i + 1,
|
||||
pair=trade['pair'],
|
||||
@@ -683,7 +686,7 @@ class Telegram(RPC):
|
||||
:return: None
|
||||
"""
|
||||
try:
|
||||
counts = self._rpc_count()
|
||||
counts = self._rpc._rpc_count()
|
||||
message = tabulate({k: [v] for k, v in counts.items()},
|
||||
headers=['current', 'max', 'total stake'],
|
||||
tablefmt='simple')
|
||||
@@ -700,7 +703,7 @@ class Telegram(RPC):
|
||||
Returns the currently active locks
|
||||
"""
|
||||
try:
|
||||
locks = self._rpc_locks()
|
||||
locks = self._rpc._rpc_locks()
|
||||
message = tabulate([[
|
||||
lock['pair'],
|
||||
lock['lock_end_time'],
|
||||
@@ -720,7 +723,7 @@ class Telegram(RPC):
|
||||
Shows the currently active whitelist
|
||||
"""
|
||||
try:
|
||||
whitelist = self._rpc_whitelist()
|
||||
whitelist = self._rpc._rpc_whitelist()
|
||||
|
||||
message = f"Using whitelist `{whitelist['method']}` with {whitelist['length']} pairs\n"
|
||||
message += f"`{', '.join(whitelist['whitelist'])}`"
|
||||
@@ -738,7 +741,7 @@ class Telegram(RPC):
|
||||
"""
|
||||
try:
|
||||
|
||||
blacklist = self._rpc_blacklist(context.args)
|
||||
blacklist = self._rpc._rpc_blacklist(context.args)
|
||||
errmsgs = []
|
||||
for pair, error in blacklist['errors'].items():
|
||||
errmsgs.append(f"Error adding `{pair}` to blacklist: `{error['error_msg']}`")
|
||||
@@ -792,7 +795,7 @@ class Telegram(RPC):
|
||||
Shows information related to Edge
|
||||
"""
|
||||
try:
|
||||
edge_pairs = self._rpc_edge()
|
||||
edge_pairs = self._rpc._rpc_edge()
|
||||
edge_pairs_tab = tabulate(edge_pairs, headers='keys', tablefmt='simple')
|
||||
message = f'<b>Edge only validated following pairs:</b>\n<pre>{edge_pairs_tab}</pre>'
|
||||
self._send_msg(message, parse_mode=ParseMode.HTML)
|
||||
@@ -862,7 +865,7 @@ class Telegram(RPC):
|
||||
:param update: message update
|
||||
:return: None
|
||||
"""
|
||||
val = RPC._rpc_show_config(self._freqtrade.config, self._freqtrade.state)
|
||||
val = RPC._rpc_show_config(self._config, self._rpc._freqtrade.state)
|
||||
|
||||
if val['trailing_stop']:
|
||||
sl_info = (
|
||||
|
@@ -6,7 +6,7 @@ from typing import Any, Dict
|
||||
|
||||
from requests import RequestException, post
|
||||
|
||||
from freqtrade.rpc import RPC, RPCMessageType
|
||||
from freqtrade.rpc import RPC, RPCHandler, RPCMessageType
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -14,16 +14,17 @@ logger = logging.getLogger(__name__)
|
||||
logger.debug('Included module rpc.webhook ...')
|
||||
|
||||
|
||||
class Webhook(RPC):
|
||||
class Webhook(RPCHandler):
|
||||
""" This class handles all webhook communication """
|
||||
|
||||
def __init__(self, freqtrade) -> None:
|
||||
def __init__(self, rpc: RPC, config: Dict[str, Any]) -> None:
|
||||
"""
|
||||
Init the Webhook class, and init the super class RPC
|
||||
:param freqtrade: Instance of a freqtrade bot
|
||||
Init the Webhook class, and init the super class RPCHandler
|
||||
:param rpc: instance of RPC Helper class
|
||||
:param config: Configuration object
|
||||
:return: None
|
||||
"""
|
||||
super().__init__(freqtrade)
|
||||
super().__init__(rpc, config)
|
||||
|
||||
self._url = self._config['webhook']['url']
|
||||
|
||||
|
Reference in New Issue
Block a user