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

@ -77,7 +77,7 @@ class AwesomeStrategy(IStrategy):
***
## Buy Tag
## Enter Tag
When your strategy has multiple buy signals, you can name the signal that triggered.
Then you can access you buy signal on `custom_sell`
@ -89,7 +89,7 @@ def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
(dataframe['rsi'] < 35) &
(dataframe['volume'] > 0)
),
['buy', 'buy_tag']] = (1, 'buy_signal_rsi')
['buy', 'enter_tag']] = (1, 'buy_signal_rsi')
return dataframe
@ -104,7 +104,7 @@ def custom_sell(self, pair: str, trade: Trade, current_time: datetime, current_r
```
!!! Note
`buy_tag` is limited to 100 characters, remaining data will be truncated.
`enter_tag` is limited to 100 characters, remaining data will be truncated.
## Exit tag

View File

@ -498,7 +498,7 @@ for more information.
&
(dataframe['volume'] > 0)
),
['buy', 'buy_tag']] = (1, 'buy_signal_rsi')
['buy', 'enter_tag']] = (1, 'buy_signal_rsi')
return dataframe
```

View File

@ -83,7 +83,7 @@ Possible parameters are:
* `fiat_currency`
* `order_type`
* `current_rate`
* `buy_tag`
* `enter_tag`
### Webhookbuycancel
@ -101,7 +101,7 @@ Possible parameters are:
* `fiat_currency`
* `order_type`
* `current_rate`
* `buy_tag`
* `enter_tag`
### Webhookbuyfill
@ -117,7 +117,7 @@ Possible parameters are:
* `stake_amount`
* `stake_currency`
* `fiat_currency`
* `buy_tag`
* `enter_tag`
### Webhooksell

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")

View File

@ -1602,6 +1602,7 @@ def test_to_json(default_conf, fee):
'max_rate': None,
'strategy': None,
'buy_tag': None,
'enter_tag': None,
'timeframe': None,
'exchange': 'binance',
'leverage': None,
@ -1675,6 +1676,7 @@ def test_to_json(default_conf, fee):
'sell_order_status': None,
'strategy': None,
'buy_tag': 'buys_signal_001',
'enter_tag': 'buys_signal_001',
'timeframe': None,
'exchange': 'binance',
'leverage': None,