Fix migrations to use unique key
This commit is contained in:
parent
2ca6547baf
commit
1a305ea8b0
@ -1263,7 +1263,9 @@ class FreqtradeBot:
|
|||||||
except InvalidOrderException as exception:
|
except InvalidOrderException as exception:
|
||||||
logger.warning('Unable to fetch order %s: %s', order_id, exception)
|
logger.warning('Unable to fetch order %s: %s', order_id, exception)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
trade.update_order(order)
|
trade.update_order(order)
|
||||||
|
|
||||||
# Try update amount (binance-fix)
|
# Try update amount (binance-fix)
|
||||||
try:
|
try:
|
||||||
new_amount = self.get_real_amount(trade, order, order_amount)
|
new_amount = self.get_real_amount(trade, order, order_amount)
|
||||||
|
@ -108,14 +108,14 @@ def migrate_trades_table(decl_base, inspector, engine, table_back_name: str, col
|
|||||||
|
|
||||||
def migrate_open_orders_to_trades(engine):
|
def migrate_open_orders_to_trades(engine):
|
||||||
engine.execute("""
|
engine.execute("""
|
||||||
insert into orders (trade_id, order_id, ft_order_side)
|
insert into orders (trade_id, ft_pair, order_id, ft_order_side)
|
||||||
select id, open_order_id,
|
select id trade_id, pair ft_pair, open_order_id,
|
||||||
case when close_rate_requested is null then 'buy'
|
case when close_rate_requested is null then 'buy'
|
||||||
else 'sell' end ft_order_side
|
else 'sell' end ft_order_side
|
||||||
from trades
|
from trades
|
||||||
where open_order_id is not null
|
where open_order_id is not null
|
||||||
union all
|
union all
|
||||||
select id, stoploss_order_id, 'stoploss'
|
select id trade_id, pair ft_pair, stoploss_order_id order_id, 'stoploss' ft_order_side
|
||||||
from trades
|
from trades
|
||||||
where stoploss_order_id is not null
|
where stoploss_order_id is not null
|
||||||
""")
|
""")
|
||||||
|
@ -1396,7 +1396,7 @@ def test_handle_stoploss_on_exchange_trailing(mocker, default_conf, fee,
|
|||||||
}))
|
}))
|
||||||
|
|
||||||
cancel_order_mock = MagicMock()
|
cancel_order_mock = MagicMock()
|
||||||
stoploss_order_mock = MagicMock()
|
stoploss_order_mock = MagicMock(return_value={'id': 13434334})
|
||||||
mocker.patch('freqtrade.exchange.Exchange.cancel_stoploss_order', cancel_order_mock)
|
mocker.patch('freqtrade.exchange.Exchange.cancel_stoploss_order', cancel_order_mock)
|
||||||
mocker.patch('freqtrade.exchange.Exchange.stoploss', stoploss_order_mock)
|
mocker.patch('freqtrade.exchange.Exchange.stoploss', stoploss_order_mock)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user