Flushing only at the end of all trades handling
This commit is contained in:
parent
cfe8043e87
commit
9e8a03b6ef
@ -92,6 +92,7 @@ def _process(nb_assets: Optional[int] = 0) -> bool:
|
|||||||
if trade.is_open and trade.open_order_id is None:
|
if trade.is_open and trade.open_order_id is None:
|
||||||
# Check if we can sell our current pair
|
# Check if we can sell our current pair
|
||||||
state_changed = handle_trade(trade) or state_changed
|
state_changed = handle_trade(trade) or state_changed
|
||||||
|
Trade.session.flush()
|
||||||
|
|
||||||
except (requests.exceptions.RequestException, json.JSONDecodeError) as error:
|
except (requests.exceptions.RequestException, json.JSONDecodeError) as error:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
@ -106,7 +107,6 @@ def _process(nb_assets: Optional[int] = 0) -> bool:
|
|||||||
))
|
))
|
||||||
logger.exception('Got OperationalException. Stopping trader ...')
|
logger.exception('Got OperationalException. Stopping trader ...')
|
||||||
update_state(State.STOPPED)
|
update_state(State.STOPPED)
|
||||||
Trade.session.flush()
|
|
||||||
return state_changed
|
return state_changed
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user