Improve compatibility

This commit is contained in:
Matthias 2022-03-24 20:53:22 +01:00
parent ec63cfd656
commit e894f620c2
9 changed files with 16 additions and 11 deletions

View File

@ -65,7 +65,7 @@ SET is_open=0,
close_rate=<close_rate>, close_rate=<close_rate>,
close_profit = close_rate / open_rate - 1, close_profit = close_rate / open_rate - 1,
close_profit_abs = (amount * <close_rate> * (1 - fee_close) - (amount * (open_rate * (1 - fee_open)))), close_profit_abs = (amount * <close_rate> * (1 - fee_close) - (amount * (open_rate * (1 - fee_open)))),
sell_reason=<sell_reason> exit_reason=<exit_reason>
WHERE id=<trade_ID_to_update>; WHERE id=<trade_ID_to_update>;
``` ```
@ -78,7 +78,7 @@ SET is_open=0,
close_rate=0.19638016, close_rate=0.19638016,
close_profit=0.0496, close_profit=0.0496,
close_profit_abs = (amount * 0.19638016 * (1 - fee_close) - (amount * (open_rate * (1 - fee_open)))), close_profit_abs = (amount * 0.19638016 * (1 - fee_close) - (amount * (open_rate * (1 - fee_open)))),
sell_reason='force_sell' exit_reason='force_sell'
WHERE id=31; WHERE id=31;
``` ```

View File

@ -24,8 +24,12 @@ You can use the quick summary as checklist. Please refer to the detailed section
* [`sell` -> `exit_long`](#populate_sell_trend) * [`sell` -> `exit_long`](#populate_sell_trend)
* [`buy_tag` -> `enter_tag` (used for both long and short trades)](#populate_buy_trend) * [`buy_tag` -> `enter_tag` (used for both long and short trades)](#populate_buy_trend)
* [New column `enter_short` and corresponding new column `exit_short`](#populate_sell_trend) * [New column `enter_short` and corresponding new column `exit_short`](#populate_sell_trend)
* trade-object now has the following new properties: `is_short`, `enter_side`, `exit_side` and `trade_direction`. * trade-object now has the following new properties:
* `sell_reason` -> `exit_reason` * `is_short`
* `enter_side`
* `exit_side`
* `trade_direction`
* renamed: `sell_reason` -> `exit_reason`
* [Renamed `trade.nr_of_successful_buys` to `trade.nr_of_successful_entries` (mostly relevant for `adjust_trade_position()`)](#adjust-trade-position-changes) * [Renamed `trade.nr_of_successful_buys` to `trade.nr_of_successful_entries` (mostly relevant for `adjust_trade_position()`)](#adjust-trade-position-changes)
* Introduced new [`leverage` callback](strategy-callbacks.md#leverage-callback). * Introduced new [`leverage` callback](strategy-callbacks.md#leverage-callback).
* Informative pairs can now pass a 3rd element in the Tuple, defining the candle type. * Informative pairs can now pass a 3rd element in the Tuple, defining the candle type.

View File

@ -1416,7 +1416,7 @@ class FreqtradeBot(LoggingMixin):
trade.open_order_id = order['id'] trade.open_order_id = order['id']
trade.sell_order_status = '' trade.sell_order_status = ''
trade.close_rate_requested = limit trade.close_rate_requested = limit
trade.exit_reason = exit_tag or exit_check.sell_reason trade.exit_reason = exit_tag or exit_check.exit_reason
# Lock pair for one candle to prevent immediate re-trading # Lock pair for one candle to prevent immediate re-trading
self.strategy.lock_pair(trade.pair, datetime.now(timezone.utc), self.strategy.lock_pair(trade.pair, datetime.now(timezone.utc),

View File

@ -590,7 +590,7 @@ def text_table_exit_reason(exit_reason_stats: List[Dict[str, Any]], stake_curren
] ]
output = [[ output = [[
t.get('exit_reason', t['sell_reason']), t['trades'], t.get('exit_reason', t.get('sell_reason')), t['trades'],
_generate_wins_draws_losses(t['wins'], t['draws'], t['losses']), _generate_wins_draws_losses(t['wins'], t['draws'], t['losses']),
t['profit_mean_pct'], t['profit_sum_pct'], t['profit_mean_pct'], t['profit_sum_pct'],
round_coin_value(t['profit_total_abs'], stake_currency, False), round_coin_value(t['profit_total_abs'], stake_currency, False),

View File

@ -953,7 +953,6 @@ class LocalTrade():
""" DEPRECATED! Please use exit_reason instead.""" """ DEPRECATED! Please use exit_reason instead."""
return self.exit_reason return self.exit_reason
@staticmethod @staticmethod
def get_trades_proxy(*, pair: str = None, is_open: bool = None, def get_trades_proxy(*, pair: str = None, is_open: bool = None,
open_date: datetime = None, close_date: datetime = None, open_date: datetime = None, close_date: datetime = None,

View File

@ -240,7 +240,7 @@ def plot_trades(fig, trades: pd.DataFrame) -> make_subplots:
trades['desc'] = trades.apply( trades['desc'] = trades.apply(
lambda row: f"{row['profit_ratio']:.2%}, " + lambda row: f"{row['profit_ratio']:.2%}, " +
(f"{row['enter_tag']}, " if row['enter_tag'] is not None else "") + (f"{row['enter_tag']}, " if row['enter_tag'] is not None else "") +
f"{row['sell_reason']}, " + f"{row['exit_reason']}, " +
f"{row['trade_duration']} min", f"{row['trade_duration']} min",
axis=1) axis=1)
trade_buys = go.Scatter( trade_buys = go.Scatter(

View File

@ -237,6 +237,8 @@ def test_edge_overrides_stoploss(limit_order, fee, caplog, mocker,
if not ignore_strat_sl: if not ignore_strat_sl:
assert log_has_re('Exit for NEO/BTC detected. Reason: stop_loss.*', caplog) assert log_has_re('Exit for NEO/BTC detected. Reason: stop_loss.*', caplog)
assert trade.exit_reason == ExitType.STOP_LOSS.value assert trade.exit_reason == ExitType.STOP_LOSS.value
# Test compatibility ...
assert trade.sell_reason == ExitType.STOP_LOSS.value
def test_total_open_trades_stakes(mocker, default_conf_usdt, ticker_usdt, fee) -> None: def test_total_open_trades_stakes(mocker, default_conf_usdt, ticker_usdt, fee) -> None:
@ -2985,7 +2987,7 @@ def test_handle_cancel_exit_limit(mocker, default_conf_usdt, fee) -> None:
fee_close=fee.return_value, fee_close=fee.return_value,
close_rate=0.555, close_rate=0.555,
close_date=arrow.utcnow().datetime, close_date=arrow.utcnow().datetime,
sell_reason="sell_reason_whatever", exit_reason="sell_reason_whatever",
) )
order = {'remaining': 1, order = {'remaining': 1,
'amount': 1, 'amount': 1,

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long