Update migrations

This commit is contained in:
Matthias
2024-01-19 06:49:49 +01:00
parent 9f3c6f2dcc
commit 59b3486574
2 changed files with 12 additions and 15 deletions

View File

@@ -276,23 +276,20 @@ def fix_old_dry_orders(engine):
with engine.begin() as connection:
# Update current dry-run Orders where
# - stoploss order is Open (will be replaced eventually)
# 2nd query:
# - current Order is open
# - current Trade is closed
# - current Order trade_id not equal to current Trade.id
# - current Order not stoploss
# TODO: is this still necessary ? how can this be done now ?
# stmt = update(Order).where(
# Order.ft_is_open.is_(True),
# tuple_(Order.ft_trade_id, Order.order_id).not_in(
# select(
# Trade.id, Trade.stoploss_order_id
# ).where(Trade.stoploss_order_id.is_not(None))
# ),
# Order.ft_order_side == 'stoploss',
# Order.order_id.like('dry%'),
# ).values(ft_is_open=False)
# connection.execute(stmt)
stmt = update(Order).where(
Order.ft_is_open.is_(True),
Order.ft_order_side == 'stoploss',
Order.order_id.like('dry%'),
).values(ft_is_open=False)
connection.execute(stmt)
# Close dry-run orders for closed trades.
stmt = update(Order).where(

View File

@@ -74,7 +74,7 @@ def test_init_dryrun_db(default_conf, tmpdir):
assert Path(filename).is_file()
def test_migrate_new(mocker, default_conf, fee, caplog):
def test_migrate(mocker, default_conf, fee, caplog):
"""
Test Database migration (starting with new pairformat)
"""
@@ -277,7 +277,6 @@ def test_migrate_new(mocker, default_conf, fee, caplog):
assert trade.exit_reason is None
assert trade.strategy is None
assert trade.timeframe == '5m'
assert trade.stoploss_order_id == 'dry_stop_order_id222'
assert trade.stoploss_last_update is None
assert log_has("trying trades_bak1", caplog)
assert log_has("trying trades_bak2", caplog)
@@ -294,9 +293,10 @@ def test_migrate_new(mocker, default_conf, fee, caplog):
assert orders[0].order_id == 'dry_buy_order'
assert orders[0].ft_order_side == 'buy'
# All dry-run stoploss orders will be closed
assert orders[-1].order_id == 'dry_stop_order_id222'
assert orders[-1].ft_order_side == 'stoploss'
assert orders[-1].ft_is_open is True
assert orders[-1].ft_is_open is False
assert orders[1].order_id == 'dry_buy_order22'
assert orders[1].ft_order_side == 'buy'