Move fiatconvert init to RPC class

This commit is contained in:
Matthias 2020-12-24 08:36:35 +01:00
parent 48f7997a77
commit 1508e08ea5
4 changed files with 4 additions and 9 deletions

View File

@ -20,7 +20,6 @@ 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.fiat_convert import CryptoToFiatConverter
from freqtrade.rpc.rpc import RPC, RPCException
@ -117,9 +116,6 @@ class ApiServer(RPC):
# Register application handling
self.register_rest_rpc_urls()
if self._config.get('fiat_display_currency', None):
self._fiat_converter = CryptoToFiatConverter()
thread = threading.Thread(target=self.run, daemon=True)
thread.start()

View File

@ -69,7 +69,7 @@ class RPC:
"""
RPC class can be used to have extra feature, like bot data, and access to DB data
"""
# Bind _fiat_converter if needed in each RPC handler
# Bind _fiat_converter if needed
_fiat_converter: Optional[CryptoToFiatConverter] = None
def __init__(self, freqtrade) -> None:
@ -80,6 +80,8 @@ class RPC:
"""
self._freqtrade = freqtrade
self._config: Dict[str, Any] = freqtrade.config
if self._config.get('fiat_display_currency', None):
self._fiat_converter = CryptoToFiatConverter()
@property
def name(self) -> str:

View File

@ -19,7 +19,6 @@ 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.fiat_convert import CryptoToFiatConverter
logger = logging.getLogger(__name__)
@ -77,8 +76,6 @@ class Telegram(RPC):
self._updater: Updater
self._init_keyboard()
self._init()
if self._config.get('fiat_display_currency', None):
self._fiat_converter = CryptoToFiatConverter()
def _init_keyboard(self) -> None:
"""

View File

@ -185,7 +185,7 @@ def test_rpc_status_table(default_conf, ticker, fee, mocker) -> None:
fetch_ticker=ticker,
get_fee=fee,
)
del default_conf['fiat_display_currency']
freqtradebot = get_patched_freqtradebot(mocker, default_conf)
patch_get_signal(freqtradebot, (True, False))
rpc = RPC(freqtradebot)