Flushing only at the end of all trades handling

This commit is contained in:
Jean-Baptiste LE STANG 2017-12-31 16:15:54 +01:00
parent cfe8043e87
commit 9e8a03b6ef

View File

@ -92,6 +92,7 @@ def _process(nb_assets: Optional[int] = 0) -> bool:
if trade.is_open and trade.open_order_id is None:
# Check if we can sell our current pair
state_changed = handle_trade(trade) or state_changed
Trade.session.flush()
except (requests.exceptions.RequestException, json.JSONDecodeError) as error:
logger.warning(
@ -106,7 +107,6 @@ def _process(nb_assets: Optional[int] = 0) -> bool:
))
logger.exception('Got OperationalException. Stopping trader ...')
update_state(State.STOPPED)
Trade.session.flush()
return state_changed