- if delta > 0:
- self.ccxt.transfer_balance(currency, delta, "exchange", "margin")
- elif delta < 0:
- self.ccxt.transfer_balance(currency, -delta, "margin", "exchange")
+ try:
+ if delta > 0:
+ self.ccxt.transfer_balance(currency, delta, "exchange", "margin")
+ elif delta < 0:
+ self.ccxt.transfer_balance(currency, -delta, "margin", "exchange")
+ except (RequestTimeout, InvalidNonce) as e:
+ self.report.log_error(action, message="Retrying", exception=e)
+ self.report.log_move_balances(needed_in_margin, moving_to_margin)
+ self.balances.fetch_balances()
+ raise e