Improve order catchup
This commit is contained in:
parent
95efc0d688
commit
8458a380b8
@ -134,6 +134,8 @@ class FreqtradeBot:
|
||||
# Adjust stoploss if it was changed
|
||||
Trade.stoploss_reinitialization(self.strategy.stoploss)
|
||||
|
||||
self.update_open_orders()
|
||||
|
||||
def process(self) -> None:
|
||||
"""
|
||||
Queries the persistence layer for open trades and handles them,
|
||||
@ -235,11 +237,13 @@ class FreqtradeBot:
|
||||
logger.info(f"Updating {len(orders)} open orders.")
|
||||
for order in orders:
|
||||
try:
|
||||
if order.ft_order_side == 'stoposs':
|
||||
if order.ft_order_side == 'stoploss':
|
||||
fo = self.exchange.fetch_stoploss_order(order.order_id, order.ft_pair)
|
||||
else:
|
||||
fo = self.exchange.fetch_order(order.order_id, order.ft_pair)
|
||||
order.update_from_ccxt_object(fo)
|
||||
|
||||
self.update_trade_state(order.trade, fo, sl_order=order.ft_order_side == 'stoploss')
|
||||
|
||||
except ExchangeError:
|
||||
logger.warning(f"Error updating {order.order_id}")
|
||||
|
||||
|
@ -144,7 +144,6 @@ def check_migrate(engine, decl_base, previous_tables) -> None:
|
||||
logger.info('Moving open orders to Orders table.')
|
||||
migrate_open_orders_to_trades(engine)
|
||||
else:
|
||||
logger.info(f'Running database migration for orders - backup: {table_back_name}')
|
||||
pass
|
||||
# Empty for now - as there is only one iteration of the orders table so far.
|
||||
# table_back_name = get_backup_name(tabs, 'orders_bak')
|
||||
|
@ -109,6 +109,8 @@ class Order(_DECL_BASE):
|
||||
id = Column(Integer, primary_key=True)
|
||||
ft_trade_id = Column(Integer, ForeignKey('trades.id'), index=True)
|
||||
|
||||
trade = relationship("Trade", back_populates="orders")
|
||||
|
||||
ft_order_side = Column(String, nullable=False)
|
||||
ft_pair = Column(String, nullable=False)
|
||||
ft_is_open = Column(Boolean, nullable=False, default=True, index=True)
|
||||
@ -179,7 +181,7 @@ class Order(_DECL_BASE):
|
||||
return o
|
||||
|
||||
@staticmethod
|
||||
def get_open_orders():
|
||||
def get_open_orders() -> List['Order']:
|
||||
"""
|
||||
"""
|
||||
return Order.query.filter(Order.ft_is_open.is_(True)).all()
|
||||
|
Loading…
Reference in New Issue
Block a user