Improve msgtypes

This commit is contained in:
Matthias 2023-03-24 20:47:17 +01:00
parent e8cffeeffd
commit 8928d3616a
3 changed files with 13 additions and 1 deletions

View File

@ -973,6 +973,7 @@ class FreqtradeBot(LoggingMixin):
'order_type': order_type, 'order_type': order_type,
'stake_amount': trade.stake_amount, 'stake_amount': trade.stake_amount,
'stake_currency': self.config['stake_currency'], 'stake_currency': self.config['stake_currency'],
'base_currency': self.exchange.get_pair_base_currency(trade.pair),
'fiat_currency': self.config.get('fiat_display_currency', None), 'fiat_currency': self.config.get('fiat_display_currency', None),
'amount': order.safe_amount_after_fee if fill else (order.amount or trade.amount), 'amount': order.safe_amount_after_fee if fill else (order.amount or trade.amount),
'open_date': trade.open_date or datetime.utcnow(), 'open_date': trade.open_date or datetime.utcnow(),
@ -1005,6 +1006,7 @@ class FreqtradeBot(LoggingMixin):
'stake_amount': trade.stake_amount, 'stake_amount': trade.stake_amount,
'open_rate': trade.open_rate, 'open_rate': trade.open_rate,
'stake_currency': self.config['stake_currency'], 'stake_currency': self.config['stake_currency'],
'base_currency': self.exchange.get_pair_base_currency(trade.pair),
'fiat_currency': self.config.get('fiat_display_currency', None), 'fiat_currency': self.config.get('fiat_display_currency', None),
'amount': trade.amount, 'amount': trade.amount,
'open_date': trade.open_date, 'open_date': trade.open_date,
@ -1695,6 +1697,7 @@ class FreqtradeBot(LoggingMixin):
'close_date': trade.close_date or datetime.utcnow(), 'close_date': trade.close_date or datetime.utcnow(),
'stake_amount': trade.stake_amount, 'stake_amount': trade.stake_amount,
'stake_currency': self.config['stake_currency'], 'stake_currency': self.config['stake_currency'],
'base_currency': self.exchange.get_pair_base_currency(trade.pair),
'fiat_currency': self.config.get('fiat_display_currency'), 'fiat_currency': self.config.get('fiat_display_currency'),
'sub_trade': sub_trade, 'sub_trade': sub_trade,
'cumulative_profit': trade.realized_profit, 'cumulative_profit': trade.realized_profit,
@ -1747,6 +1750,7 @@ class FreqtradeBot(LoggingMixin):
'open_date': trade.open_date, 'open_date': trade.open_date,
'close_date': trade.close_date or datetime.now(timezone.utc), 'close_date': trade.close_date or datetime.now(timezone.utc),
'stake_currency': self.config['stake_currency'], 'stake_currency': self.config['stake_currency'],
'base_currency': self.exchange.get_pair_base_currency(trade.pair),
'fiat_currency': self.config.get('fiat_display_currency', None), 'fiat_currency': self.config.get('fiat_display_currency', None),
'reason': reason, 'reason': reason,
'sub_trade': sub_trade, 'sub_trade': sub_trade,

View File

@ -15,6 +15,12 @@ class RPCStatusMsg(RPCSendMsgBase):
status: str status: str
class RPCStrategyMsg(RPCSendMsgBase):
"""Used for Status, Startup and Warning messages"""
type: Literal[RPCMessageType.STRATEGY_MSG]
msg: str
class RPCProtectionMsg(RPCSendMsgBase): class RPCProtectionMsg(RPCSendMsgBase):
type: Literal[RPCMessageType.PROTECTION_TRIGGER, RPCMessageType.PROTECTION_TRIGGER_GLOBAL] type: Literal[RPCMessageType.PROTECTION_TRIGGER, RPCMessageType.PROTECTION_TRIGGER_GLOBAL]
id: int id: int
@ -40,6 +46,7 @@ class __RPCBuyMsgBase(RPCSendMsgBase):
enter_tag: Optional[str] enter_tag: Optional[str]
exchange: str exchange: str
pair: str pair: str
base_currency: str
leverage: Optional[float] leverage: Optional[float]
direction: str direction: str
limit: float limit: float
@ -90,6 +97,7 @@ class RPCSellCancelMsg(__RPCBuyMsgBase):
RPCSendMsg = Union[ RPCSendMsg = Union[
RPCStatusMsg, RPCStatusMsg,
RPCStrategyMsg,
RPCProtectionMsg, RPCProtectionMsg,
RPCWhitelistMsg, RPCWhitelistMsg,
RPCBuyMsg, RPCBuyMsg,

View File

@ -437,7 +437,7 @@ class Telegram(RPCHandler):
msg_type = msg['type'] msg_type = msg['type']
noti = '' noti = ''
if msg_type == RPCMessageType.EXIT: if msg['type'] == RPCMessageType.EXIT:
sell_noti = self._config['telegram'] \ sell_noti = self._config['telegram'] \
.get('notification_settings', {}).get(str(msg_type), {}) .get('notification_settings', {}).get(str(msg_type), {})
# For backward compatibility sell still can be string # For backward compatibility sell still can be string