Merge pull request #5929 from dvdmchl/develop

Telegram and log prints strategy version.
This commit is contained in:
Matthias
2021-12-04 15:16:42 +01:00
committed by GitHub
9 changed files with 49 additions and 5 deletions

View File

@@ -145,6 +145,7 @@ class OrderTypes(BaseModel):
class ShowConfig(BaseModel):
version: str
strategy_version: Optional[str]
api_version: float
dry_run: bool
stake_currency: str

View File

@@ -121,9 +121,11 @@ def edge(rpc: RPC = Depends(get_rpc)):
@router.get('/show_config', response_model=ShowConfig, tags=['info'])
def show_config(rpc: Optional[RPC] = Depends(get_rpc_optional), config=Depends(get_config)):
state = ''
strategy_version = None
if rpc:
state = rpc._freqtrade.state
resp = RPC._rpc_show_config(config, state)
strategy_version = rpc._freqtrade.strategy.version()
resp = RPC._rpc_show_config(config, state, strategy_version)
resp['api_version'] = API_VERSION
return resp

View File

@@ -98,7 +98,8 @@ class RPC:
self._fiat_converter = CryptoToFiatConverter()
@staticmethod
def _rpc_show_config(config, botstate: Union[State, str]) -> Dict[str, Any]:
def _rpc_show_config(config, botstate: Union[State, str],
strategy_version: Optional[str] = None) -> Dict[str, Any]:
"""
Return a dict of config options.
Explicitly does NOT return the full config to avoid leakage of sensitive
@@ -106,6 +107,7 @@ class RPC:
"""
val = {
'version': __version__,
'strategy_version': strategy_version,
'dry_run': config['dry_run'],
'stake_currency': config['stake_currency'],
'stake_currency_decimals': decimals_per_coin(config['stake_currency']),

View File

@@ -1305,7 +1305,12 @@ class Telegram(RPCHandler):
:param update: message update
:return: None
"""
self._send_msg('*Version:* `{}`'.format(__version__))
strategy_version = self._rpc._freqtrade.strategy.version()
version_string = f'*Version:* `{__version__}`'
if strategy_version is not None:
version_string += f', *Strategy version: * `{strategy_version}`'
self._send_msg(version_string)
@authorized_only
def _show_config(self, update: Update, context: CallbackContext) -> None:

View File

@@ -394,6 +394,12 @@ class IStrategy(ABC, HyperStrategyMixin):
"""
return []
def version(self) -> Optional[str]:
"""
Returns version of the strategy.
"""
return None
###
# END - Intended to be overridden by strategy
###

View File

@@ -113,8 +113,12 @@ class Worker:
if self._heartbeat_interval:
now = time.time()
if (now - self._heartbeat_msg) > self._heartbeat_interval:
version = __version__
strategy_version = self.freqtrade.strategy.version()
if (strategy_version is not None):
version += ', strategy_version: ' + strategy_version
logger.info(f"Bot heartbeat. PID={getpid()}, "
f"version='{__version__}', state='{state.name}'")
f"version='{version}', state='{state.name}'")
self._heartbeat_msg = now
return state