Flushing once for all case scenarios

This commit is contained in:
Jean-Baptiste LE STANG 2017-12-31 15:04:56 +01:00
parent 9803130848
commit cfe8043e87

View File

@ -93,7 +93,6 @@ def _process(nb_assets: Optional[int] = 0) -> bool:
# 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(
'Got %s in _process(), retrying in 30 seconds...',
@ -107,6 +106,7 @@ def _process(nb_assets: Optional[int] = 0) -> bool:
))
logger.exception('Got OperationalException. Stopping trader ...')
update_state(State.STOPPED)
Trade.session.flush()
return state_changed