OKX pauses
This commit is contained in:
parent
9771f76dd4
commit
4175c5c018
|
|
@ -1,4 +1,6 @@
|
|||
2024.11.13: Fixed bug handling timestamps.
|
||||
2024.11.13:
|
||||
. Fixed bug handling timestamps.
|
||||
. Added a couple of pauses for OKX.
|
||||
|
||||
2024.11.11:
|
||||
. Refactored boost check to optimize CPU usage.
|
||||
|
|
|
|||
|
|
@ -775,6 +775,32 @@ class broker:
|
|||
return "insufficient" in error_text.lower() or "BALANCE_NOT_ENOUGH" in error_text or "Low available balance" in error_text
|
||||
|
||||
|
||||
def price_too_high_error(self, error_object):
|
||||
'''
|
||||
Checks if the error is a price too high error.
|
||||
Receives an error object.
|
||||
Returns True if the error is a price too high error, False otherwise.
|
||||
|
||||
:param error_object: The error object.
|
||||
:return: Boolean value
|
||||
'''
|
||||
|
||||
return "the highest price limit for buy orders is" in str(error_object).lower()
|
||||
|
||||
|
||||
def price_too_low_error(self, error_object):
|
||||
'''
|
||||
Checks if the error is a price too low error.
|
||||
Receives an error object.
|
||||
Returns True if the error is a price too low error, False otherwise.
|
||||
|
||||
:param error_object: The error object.
|
||||
:return: Boolean value
|
||||
'''
|
||||
|
||||
return "the lowest price limit for sell orders is" in str(error_object).lower()
|
||||
|
||||
|
||||
def new_limit_order(self,symbol,size,side,price,no_retries=False):
|
||||
'''
|
||||
Sends a new limit order.
|
||||
|
|
@ -809,6 +835,10 @@ class broker:
|
|||
#instead of guesstimating the fees, it's easier and more precise to query the exchange for the remaining base currency
|
||||
#and send the order with that amount.
|
||||
tries-=1
|
||||
elif self.price_too_high_error(e): #In high volatility moments, OKX sometimes just needs a bit of extra thinking time.
|
||||
time.sleep(self.wait_time)
|
||||
elif self.price_too_low_error(e):
|
||||
time.sleep(self.wait_time)
|
||||
if no_retries:
|
||||
break
|
||||
tries-=1
|
||||
|
|
|
|||
Loading…
Reference in New Issue