aboutsummaryrefslogtreecommitdiff
path: root/market.py
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2018-03-25 23:57:39 +0200
committerIsmaël Bouya <ismael.bouya@normalesup.org>2018-03-25 23:57:39 +0200
commitb47d7b54cca8ff142eaadf38c8bb425bf11af2cd (patch)
treee69f8f99ad47cfc3270192428fc2abee87eea65b /market.py
parentd004a2a5e15a78991870dcb90cd6db63ab40a4e6 (diff)
downloadTrader-b47d7b54cca8ff142eaadf38c8bb425bf11af2cd.tar.gz
Trader-b47d7b54cca8ff142eaadf38c8bb425bf11af2cd.tar.zst
Trader-b47d7b54cca8ff142eaadf38c8bb425bf11af2cd.zip
Handle invalid nonces
Diffstat (limited to 'market.py')
-rw-r--r--market.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/market.py b/market.py
index ca65bca..d0e6ab4 100644
--- a/market.py
+++ b/market.py
@@ -1,4 +1,4 @@
1from ccxt import ExchangeError, NotSupported, RequestTimeout 1from ccxt import ExchangeError, NotSupported, RequestTimeout, InvalidNonce
2import ccxt_wrapper as ccxt 2import ccxt_wrapper as ccxt
3import time 3import time
4import psycopg2 4import psycopg2
@@ -89,7 +89,7 @@ class Market:
89 finally: 89 finally:
90 self.store_report() 90 self.store_report()
91 91
92 @retry(RequestTimeout, tries=5) 92 @retry((RequestTimeout, InvalidNonce), tries=5)
93 def move_balances(self): 93 def move_balances(self):
94 needed_in_margin = {} 94 needed_in_margin = {}
95 moving_to_margin = {} 95 moving_to_margin = {}
@@ -114,7 +114,7 @@ class Market:
114 self.ccxt.transfer_balance(currency, delta, "exchange", "margin") 114 self.ccxt.transfer_balance(currency, delta, "exchange", "margin")
115 elif delta < 0: 115 elif delta < 0:
116 self.ccxt.transfer_balance(currency, -delta, "margin", "exchange") 116 self.ccxt.transfer_balance(currency, -delta, "margin", "exchange")
117 except RequestTimeout as e: 117 except (RequestTimeout, InvalidNonce) as e:
118 self.report.log_error(action, message="Retrying", exception=e) 118 self.report.log_error(action, message="Retrying", exception=e)
119 self.report.log_move_balances(needed_in_margin, moving_to_margin) 119 self.report.log_move_balances(needed_in_margin, moving_to_margin)
120 self.balances.fetch_balances() 120 self.balances.fetch_balances()