Lock execute_entry to prevent timing hickups
This commit is contained in:
parent
c593cdc438
commit
1b3e62bcbc
@ -381,15 +381,16 @@ class FreqtradeBot(LoggingMixin):
|
|||||||
|
|
||||||
trades = Trade.get_open_trades_without_assigned_fees()
|
trades = Trade.get_open_trades_without_assigned_fees()
|
||||||
for trade in trades:
|
for trade in trades:
|
||||||
if trade.is_open and not trade.fee_updated(trade.entry_side):
|
with self._exit_lock:
|
||||||
order = trade.select_order(trade.entry_side, False)
|
if trade.is_open and not trade.fee_updated(trade.entry_side):
|
||||||
open_order = trade.select_order(trade.entry_side, True)
|
order = trade.select_order(trade.entry_side, False)
|
||||||
if order and open_order is None:
|
open_order = trade.select_order(trade.entry_side, True)
|
||||||
logger.info(
|
if order and open_order is None:
|
||||||
f"Updating {trade.entry_side}-fee on trade {trade}"
|
logger.info(
|
||||||
f"for order {order.order_id}."
|
f"Updating {trade.entry_side}-fee on trade {trade}"
|
||||||
)
|
f"for order {order.order_id}."
|
||||||
self.update_trade_state(trade, order.order_id, send_msg=False)
|
)
|
||||||
|
self.update_trade_state(trade, order.order_id, send_msg=False)
|
||||||
|
|
||||||
def handle_insufficient_funds(self, trade: Trade):
|
def handle_insufficient_funds(self, trade: Trade):
|
||||||
"""
|
"""
|
||||||
|
@ -789,17 +789,18 @@ class RPC:
|
|||||||
if not order_type:
|
if not order_type:
|
||||||
order_type = self._freqtrade.strategy.order_types.get(
|
order_type = self._freqtrade.strategy.order_types.get(
|
||||||
'force_entry', self._freqtrade.strategy.order_types['entry'])
|
'force_entry', self._freqtrade.strategy.order_types['entry'])
|
||||||
if self._freqtrade.execute_entry(pair, stake_amount, price,
|
with self._freqtrade._exit_lock:
|
||||||
ordertype=order_type, trade=trade,
|
if self._freqtrade.execute_entry(pair, stake_amount, price,
|
||||||
is_short=is_short,
|
ordertype=order_type, trade=trade,
|
||||||
enter_tag=enter_tag,
|
is_short=is_short,
|
||||||
leverage_=leverage,
|
enter_tag=enter_tag,
|
||||||
):
|
leverage_=leverage,
|
||||||
Trade.commit()
|
):
|
||||||
trade = Trade.get_trades([Trade.is_open.is_(True), Trade.pair == pair]).first()
|
Trade.commit()
|
||||||
return trade
|
trade = Trade.get_trades([Trade.is_open.is_(True), Trade.pair == pair]).first()
|
||||||
else:
|
return trade
|
||||||
raise RPCException(f'Failed to enter position for {pair}.')
|
else:
|
||||||
|
raise RPCException(f'Failed to enter position for {pair}.')
|
||||||
|
|
||||||
def _rpc_delete(self, trade_id: int) -> Dict[str, Union[str, int]]:
|
def _rpc_delete(self, trade_id: int) -> Dict[str, Union[str, int]]:
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user