Removed exit_tag from Trade objects.

This commit is contained in:
theluxaz 2021-10-20 17:58:50 +03:00
parent 1fdc4425dd
commit 905f3a1a50
7 changed files with 6 additions and 15 deletions

View File

@ -30,7 +30,7 @@ BT_DATA_COLUMNS = ['pair', 'stake_amount', 'amount', 'open_date', 'close_date',
'fee_open', 'fee_close', 'trade_duration',
'profit_ratio', 'profit_abs', 'sell_reason',
'initial_stop_loss_abs', 'initial_stop_loss_ratio', 'stop_loss_abs',
'stop_loss_ratio', 'min_rate', 'max_rate', 'is_open', 'buy_tag', 'exit_tag']
'stop_loss_ratio', 'min_rate', 'max_rate', 'is_open', 'buy_tag']
def get_latest_optimize_filename(directory: Union[Path, str], variant: str) -> str:

View File

@ -1151,7 +1151,6 @@ class FreqtradeBot(LoggingMixin):
trade.sell_reason = sell_reason.sell_reason
if(exit_tag is not None):
trade.sell_reason = exit_tag
trade.exit_tag = exit_tag
# In case of market sell orders the order can be closed immediately
if order.get('status', 'unknown') in ('closed', 'expired'):
self.update_trade_state(trade, trade.open_order_id, order)

View File

@ -363,7 +363,6 @@ class Backtesting:
trade.sell_reason = sell.sell_reason
if(sell_row[EXIT_TAG_IDX] is not None):
trade.sell_reason = sell_row[EXIT_TAG_IDX]
trade.exit_tag = sell_row[EXIT_TAG_IDX]
trade_dur = int((trade.close_date_utc - trade.open_date_utc).total_seconds() // 60)
closerate = self._get_close_rate(sell_row, trade, sell, trade_dur)
@ -437,7 +436,6 @@ class Backtesting:
if stake_amount and (not min_stake_amount or stake_amount > min_stake_amount):
# Enter trade
has_buy_tag = len(row) >= BUY_TAG_IDX + 1
has_exit_tag = len(row) >= EXIT_TAG_IDX + 1
trade = LocalTrade(
pair=pair,
open_rate=row[OPEN_IDX],
@ -448,7 +446,6 @@ class Backtesting:
fee_close=self.fee,
is_open=True,
buy_tag=row[BUY_TAG_IDX] if has_buy_tag else None,
exit_tag=row[EXIT_TAG_IDX] if has_exit_tag else None,
exchange='backtesting',
)
return trade

View File

@ -48,7 +48,6 @@ def migrate_trades_table(decl_base, inspector, engine, table_back_name: str, col
sell_reason = get_column_def(cols, 'sell_reason', 'null')
strategy = get_column_def(cols, 'strategy', 'null')
buy_tag = get_column_def(cols, 'buy_tag', 'null')
exit_tag = get_column_def(cols, 'exit_tag', 'null')
# If ticker-interval existed use that, else null.
if has_column(cols, 'ticker_interval'):
timeframe = get_column_def(cols, 'timeframe', 'ticker_interval')
@ -83,7 +82,7 @@ def migrate_trades_table(decl_base, inspector, engine, table_back_name: str, col
stake_amount, amount, amount_requested, open_date, close_date, open_order_id,
stop_loss, stop_loss_pct, initial_stop_loss, initial_stop_loss_pct,
stoploss_order_id, stoploss_last_update,
max_rate, min_rate, sell_reason, sell_order_status, strategy, buy_tag, exit_tag,
max_rate, min_rate, sell_reason, sell_order_status, strategy, buy_tag,
timeframe, open_trade_value, close_profit_abs
)
select id, lower(exchange), pair,
@ -99,7 +98,7 @@ def migrate_trades_table(decl_base, inspector, engine, table_back_name: str, col
{stoploss_order_id} stoploss_order_id, {stoploss_last_update} stoploss_last_update,
{max_rate} max_rate, {min_rate} min_rate, {sell_reason} sell_reason,
{sell_order_status} sell_order_status,
{strategy} strategy, {buy_tag} buy_tag, {exit_tag} exit_tag, {timeframe} timeframe,
{strategy} strategy, {buy_tag} buy_tag, {timeframe} timeframe,
{open_trade_value} open_trade_value, {close_profit_abs} close_profit_abs
from {table_back_name}
"""))
@ -158,7 +157,7 @@ def check_migrate(engine, decl_base, previous_tables) -> None:
table_back_name = get_backup_name(tabs, 'trades_bak')
# Check for latest column
if not has_column(cols, 'exit_tag'):
if not has_column(cols, 'buy_tag'):
logger.info(f'Running database migration for trades - backup: {table_back_name}')
migrate_trades_table(decl_base, inspector, engine, table_back_name, cols)
# Reread columns - the above recreated the table!

View File

@ -258,7 +258,6 @@ class LocalTrade():
sell_order_status: str = ''
strategy: str = ''
buy_tag: Optional[str] = None
exit_tag: Optional[str] = None
timeframe: Optional[int] = None
def __init__(self, **kwargs):
@ -326,7 +325,6 @@ class LocalTrade():
'profit_abs': self.close_profit_abs,
'sell_reason': (f' ({self.sell_reason})' if self.sell_reason else ''),
'exit_tag': (f' ({self.exit_tag})' if self.exit_tag else ''),
'sell_order_status': self.sell_order_status,
'stop_loss_abs': self.stop_loss,
'stop_loss_ratio': self.stop_loss_pct if self.stop_loss_pct else None,
@ -708,7 +706,6 @@ class Trade(_DECL_BASE, LocalTrade):
sell_order_status = Column(String(100), nullable=True)
strategy = Column(String(100), nullable=True)
buy_tag = Column(String(100), nullable=True)
exit_tag = Column(String(100), nullable=True)
timeframe = Column(Integer, nullable=True)
def __init__(self, **kwargs):

View File

@ -711,7 +711,7 @@ class RPC:
def _rpc_mix_tag_performance(self, pair: str) -> List[Dict[str, Any]]:
"""
Handler for mix tag (buy_tag + exit_tag) performance.
Handler for mix tag (buy_tag + sell_reason) performance.
Shows a performance statistic from finished trades
"""
mix_tags = Trade.get_mix_tag_performance(pair)

View File

@ -180,7 +180,7 @@ class Telegram(RPCHandler):
CallbackQueryHandler(self._balance, pattern='update_balance'),
CallbackQueryHandler(self._performance, pattern='update_performance'),
CallbackQueryHandler(self._performance, pattern='update_buy_tag_performance'),
CallbackQueryHandler(self._performance, pattern='update_exit_tag_performance'),
CallbackQueryHandler(self._performance, pattern='update_sell_reason_performance'),
CallbackQueryHandler(self._performance, pattern='update_mix_tag_performance'),
CallbackQueryHandler(self._count, pattern='update_count'),
CallbackQueryHandler(self._forcebuy_inline),
@ -963,7 +963,6 @@ class Telegram(RPCHandler):
trades = self._rpc._rpc_mix_tag_performance(pair)
output = "<b>Mix Tag Performance:</b>\n"
for i, trade in enumerate(trades):
print(str(trade))
stat_line = (
f"{i+1}.\t <code>{trade['mix_tag']}\t"
f"{round_coin_value(trade['profit_abs'], self._config['stake_currency'])} "