From 6b9547a9ad354da5495d4279a96e76b31f1aac01 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 13 Aug 2023 14:56:05 +0200 Subject: [PATCH] Improve migrations --- freqtrade/persistence/migrations.py | 5 +++-- tests/strategy/test_default_strategy.py | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/freqtrade/persistence/migrations.py b/freqtrade/persistence/migrations.py index 32972e7ff..1270b85ac 100644 --- a/freqtrade/persistence/migrations.py +++ b/freqtrade/persistence/migrations.py @@ -88,8 +88,9 @@ def migrate_trades_and_orders_table( stop_loss_pct = get_column_def(cols, 'stop_loss_pct', 'null') initial_stop_loss = get_column_def(cols, 'initial_stop_loss', '0.0') initial_stop_loss_pct = get_column_def(cols, 'initial_stop_loss_pct', 'null') - is_stop_loss_trailing = get_column_def(cols, 'is_stop_loss_trailing', - 'stop_loss_pct <> initial_stop_loss_pct') + is_stop_loss_trailing = get_column_def( + cols, 'is_stop_loss_trailing', + f'coalesce({stop_loss_pct}, 0.0) <> coalesce({initial_stop_loss_pct}, 0.0)') stoploss_order_id = get_column_def(cols, 'stoploss_order_id', 'null') stoploss_last_update = get_column_def(cols, 'stoploss_last_update', 'null') max_rate = get_column_def(cols, 'max_rate', '0.0') diff --git a/tests/strategy/test_default_strategy.py b/tests/strategy/test_default_strategy.py index b5b07e0cd..afe7fc97a 100644 --- a/tests/strategy/test_default_strategy.py +++ b/tests/strategy/test_default_strategy.py @@ -52,4 +52,5 @@ def test_strategy_test_v3(dataframe_1m, fee, is_short, side): side=side) is True assert strategy.custom_stoploss(pair='ETH/BTC', trade=trade, current_time=datetime.now(), - current_rate=20_000, current_profit=0.05) == strategy.stoploss + current_rate=20_000, current_profit=0.05, after_fill=False + ) == strategy.stoploss