Add some compatibility around buy_tag

This commit is contained in:
Matthias
2021-11-21 09:24:20 +01:00
parent 97ff7d1223
commit 7d77aff289
8 changed files with 20 additions and 11 deletions

View File

@@ -755,6 +755,7 @@ class FreqtradeBot(LoggingMixin):
'trade_id': trade.id,
'type': RPCMessageType.SHORT if trade.is_short else RPCMessageType.BUY,
'buy_tag': trade.buy_tag,
'enter_tag': trade.buy_tag,
'exchange': self.exchange.name.capitalize(),
'pair': trade.pair,
'limit': trade.open_rate,
@@ -780,6 +781,7 @@ class FreqtradeBot(LoggingMixin):
'trade_id': trade.id,
'type': msg_type,
'buy_tag': trade.buy_tag,
'enter_tag': trade.buy_tag,
'exchange': self.exchange.name.capitalize(),
'pair': trade.pair,
'limit': trade.open_rate,
@@ -802,6 +804,7 @@ class FreqtradeBot(LoggingMixin):
'trade_id': trade.id,
'type': msg_type,
'buy_tag': trade.buy_tag,
'enter_tag': trade.buy_tag,
'exchange': self.exchange.name.capitalize(),
'pair': trade.pair,
'open_rate': trade.open_rate,
@@ -1384,6 +1387,7 @@ class FreqtradeBot(LoggingMixin):
'current_rate': current_rate,
'profit_amount': profit_trade,
'profit_ratio': profit_ratio,
'enter_tag': trade.buy_tag,
'buy_tag': trade.buy_tag,
'sell_reason': trade.sell_reason,
'open_date': trade.open_date,
@@ -1428,6 +1432,7 @@ class FreqtradeBot(LoggingMixin):
'current_rate': current_rate,
'profit_amount': profit_trade,
'profit_ratio': profit_ratio,
'enter_tag': trade.buy_tag,
'buy_tag': trade.buy_tag,
'sell_reason': trade.sell_reason,
'open_date': trade.open_date,

View File

@@ -390,6 +390,7 @@ class LocalTrade():
'stake_amount': round(self.stake_amount, 8),
'strategy': self.strategy,
'buy_tag': self.buy_tag,
'enter_tag': self.buy_tag,
'timeframe': self.timeframe,
'fee_open': self.fee_open,

View File

@@ -185,6 +185,7 @@ class TradeSchema(BaseModel):
stake_amount: float
strategy: str
buy_tag: Optional[str]
enter_tag: Optional[str]
timeframe: int
fee_open: Optional[float]
fee_open_cost: Optional[float]

View File

@@ -226,7 +226,7 @@ class Telegram(RPCHandler):
f"{emoji} *{msg['exchange']}:* {'Bought' if is_fill else 'Buying'} {msg['pair']}"
f" (#{msg['trade_id']})\n"
)
message += f"*Buy Tag:* `{msg['buy_tag']}`\n" if msg.get('buy_tag', None) else ""
message += f"*Enter Tag:* `{msg['enter_tag']}`\n" if msg.get('enter_tag', None) else ""
message += f"*Amount:* `{msg['amount']:.8f}`\n"
if msg['type'] == RPCMessageType.BUY_FILL:
@@ -251,7 +251,7 @@ class Telegram(RPCHandler):
microsecond=0) - msg['open_date'].replace(microsecond=0)
msg['duration_min'] = msg['duration'].total_seconds() / 60
msg['buy_tag'] = msg['buy_tag'] if "buy_tag" in msg.keys() else None
msg['enter_tag'] = msg['enter_tag'] if "enter_tag" in msg.keys() else None
msg['emoji'] = self._get_sell_emoji(msg)
# Check if all sell properties are available.
@@ -397,7 +397,7 @@ class Telegram(RPCHandler):
"*Trade ID:* `{trade_id}` `(since {open_date_hum})`",
"*Current Pair:* {pair}",
"*Amount:* `{amount} ({stake_amount} {base_currency})`",
"*Buy Tag:* `{buy_tag}`" if r['buy_tag'] else "",
"*Enter Tag:* `{enter_tag}`" if r['enter_tag'] else "",
"*Open Rate:* `{open_rate:.8f}`",
"*Close Rate:* `{close_rate}`" if r['close_rate'] else "",
"*Current Rate:* `{current_rate:.8f}`",
@@ -989,7 +989,7 @@ class Telegram(RPCHandler):
output = "<b>Buy Tag Performance:</b>\n"
for i, trade in enumerate(trades):
stat_line = (
f"{i+1}.\t <code>{trade['buy_tag']}\t"
f"{i+1}.\t <code>{trade['enter_tag']}\t"
f"{round_coin_value(trade['profit_abs'], self._config['stake_currency'])} "
f"({trade['profit_ratio']:.2%}) "
f"({trade['count']})</code>\n")