2025.09.11
This commit is contained in:
parent
29dbdce95e
commit
885797db01
|
|
@ -1,3 +1,6 @@
|
||||||
|
2025.09.11:
|
||||||
|
. Fixed bug in start_trader that called amount_to_precision with very low amounts and spammed logs.
|
||||||
|
|
||||||
2025.09.10:
|
2025.09.10:
|
||||||
. Deal order history now stores only the id of each order instead of the full order object.
|
. Deal order history now stores only the id of each order instead of the full order object.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -172,7 +172,7 @@ class Broker:
|
||||||
|
|
||||||
query = f"SELECT * FROM profits_table WHERE pair = ? ORDER BY timestamp DESC LIMIT 1;"
|
query = f"SELECT * FROM profits_table WHERE pair = ? ORDER BY timestamp DESC LIMIT 1;"
|
||||||
with self._cur() as cur:
|
with self._cur() as cur:
|
||||||
cur.execute(query, (order['symbol'],))
|
cur.execute(query, (order["symbol"],))
|
||||||
result = cur.fetchone()
|
result = cur.fetchone()
|
||||||
if result is None:
|
if result is None:
|
||||||
return False
|
return False
|
||||||
|
|
|
||||||
14
trader.py
14
trader.py
|
|
@ -147,12 +147,13 @@ class trader:
|
||||||
self.broker.logger.log_this("Can't fetch the amount of base at the exchange",1,self.status.get_pair())
|
self.broker.logger.log_this("Can't fetch the amount of base at the exchange",1,self.status.get_pair())
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
#Buy missing base sold because of rounding errors (rare)
|
#Buy missing base sold because of errors (unaccounted filled orders, crashes, etc)
|
||||||
if self.status.get_old_long()!={}:
|
if self.status.get_old_long()!={}:
|
||||||
diff = self.broker.amount_to_precision(self.status.get_pair(), self.status.get_old_long()["tp_amount"] - free_base)
|
#diff = self.broker.amount_to_precision(self.status.get_pair(), self.status.get_old_long()["tp_amount"] - free_base)
|
||||||
if diff>min_base_size:
|
if self.status.get_old_long()["tp_amount"]-free_base>min_base_size:
|
||||||
self.broker.logger.log_this(f"Buying missing {diff} {self.base}",1,self.status.get_pair())
|
amount_to_buy = self.broker.amount_to_precision(self.status.get_pair(),self.status.get_old_long()["tp_amount"]-free_base)
|
||||||
self.broker.new_market_order(self.status.get_pair(),diff,"buy",amount_in_base=True)
|
self.broker.logger.log_this(f"Buying missing {amount_to_buy} {self.base}",1,self.status.get_pair())
|
||||||
|
self.broker.new_market_order(self.status.get_pair(),amount_to_buy,"buy",amount_in_base=True)
|
||||||
time.sleep(self.broker.get_wait_time()*2)
|
time.sleep(self.broker.get_wait_time()*2)
|
||||||
#Re-quering for the amount of base currency on the exchange
|
#Re-quering for the amount of base currency on the exchange
|
||||||
free_base = self.fetch_free_base()
|
free_base = self.fetch_free_base()
|
||||||
|
|
@ -858,8 +859,6 @@ class trader:
|
||||||
if abs(filled_order["price"]-price_to_compare)/filled_order["price"]>self.broker.get_slippage_default_threshold():
|
if abs(filled_order["price"]-price_to_compare)/filled_order["price"]>self.broker.get_slippage_default_threshold():
|
||||||
self.broker.logger.log_this(f"Slippage threshold exceeded, waiting for cooldown and restarting trader",1,self.status.get_pair())
|
self.broker.logger.log_this(f"Slippage threshold exceeded, waiting for cooldown and restarting trader",1,self.status.get_pair())
|
||||||
time.sleep(self.broker.get_wait_time()*self.broker.get_cooldown_multiplier())
|
time.sleep(self.broker.get_wait_time()*self.broker.get_cooldown_multiplier())
|
||||||
#The trader is restarted by the instance instead of by itself to allow a couple of more seconds for the price to return to normal.
|
|
||||||
#This could also be the default behavior.
|
|
||||||
self.pause = False
|
self.pause = False
|
||||||
self.restart = True
|
self.restart = True
|
||||||
return 1
|
return 1
|
||||||
|
|
@ -874,7 +873,6 @@ class trader:
|
||||||
self.status.set_pause_reason("take_profit_routine - restart_trader call")
|
self.status.set_pause_reason("take_profit_routine - restart_trader call")
|
||||||
restart_trader = self.start_trader()
|
restart_trader = self.start_trader()
|
||||||
self.status.set_pause_reason("take_profit_routine - restart_trader call - start_trader() called")
|
self.status.set_pause_reason("take_profit_routine - restart_trader call - start_trader() called")
|
||||||
#retries = self.broker.get_retries()
|
|
||||||
if restart_trader in self.trader_restart_errors.keys():
|
if restart_trader in self.trader_restart_errors.keys():
|
||||||
self.pause = False
|
self.pause = False
|
||||||
self.restart = True
|
self.restart = True
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue