From 09f9aa313c299b082d8c4d3f7b4c10c346859653 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20S=C3=A1nchez?= Date: Sat, 20 Sep 2025 19:18:32 -0300 Subject: [PATCH] 2025.09.20 --- changelog.txt | 3 ++ exchange_wrapper.py | 68 ++------------------------------------------- main.py | 2 +- trader.py | 4 +-- 4 files changed, 8 insertions(+), 69 deletions(-) diff --git a/changelog.txt b/changelog.txt index 0777595..918b024 100755 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,6 @@ +2025.09.20: +. Fixed bug that caused short traders to initialize using the same workflow as a long one. + 2025.09.19: . Added pageSize parameter to the open order requests when querying Kucoin. diff --git a/exchange_wrapper.py b/exchange_wrapper.py index e56fb4f..f060dc8 100755 --- a/exchange_wrapper.py +++ b/exchange_wrapper.py @@ -503,28 +503,6 @@ class Broker: return [] - # def fetch_full_orders(self,pairs=None) -> list: - # ''' - # Returns a list of all orders on the exchange - - # :param pairs: list of pairs to get orders for - # :return: list of orders - # ''' - - # if pairs is None: - # pairs = [] - # try: - # orders = [] - # if self.get_exchange_name()=="binance": - # orders = self.get_opened_orders_binance(pairs) - # else: - # orders = self.get_opened_orders() - # return [] if orders is None else orders - # except Exception as e: - # self.logger.log_this(f"Exception in fetch_full_orders: {e}",2) - # return [] - - def fetch_open_orders(self,pairs=None) -> list: ''' Returns a list of all open orders on the exchange @@ -572,27 +550,6 @@ class Broker: return [] - # def get_opened_orders(self,no_retries=False): #It should return a list of all opened orders - # ''' - # Returns a list of all the open orders on the exchange - - # :param pairs: list of pairs - # :return: list of all the open orders on the exchange - # ''' - - # retries = self.retries - # while retries>0: - # try: - # return self.exchange.fetch_open_orders() - # except Exception as e: - # self.logger.log_this(f"Exception in get_opened_orders: {e}",1) - # if no_retries: - # break - # time.sleep(self.wait_time) - # retries-=1 - # return [] - - def get_closed_orders(self,pair=None,no_retries=False): #It should return a list of all opened orders ''' Returns a list of all the open orders on the exchange @@ -614,27 +571,6 @@ class Broker: return [] - # def get_opened_orders_binance(self,pairs): - # ''' - # Returns a list of all the open orders on the exchange - - # :param pairs: list of pairs - # :return: list of all the open orders on the exchange - # ''' - - # try: - # if "unified_order_query" in self.broker_config and self.broker_config["unified_order_query"] is True: - # return self.exchange.fetch_open_orders() - # result = [] - # for pair in pairs: - # a = self.exchange.fetch_open_orders(pair) - # result.extend(iter(a)) - # return result - # except Exception as e: - # self.logger.log_this(f"Exception in get_opened_orders_binance: {e}",1) - # return [] - - def get_closed_orders_binance(self,pairs): ''' Returns a list of all the closed orders on the exchange @@ -1025,9 +961,9 @@ class Broker: if self.get_exchange_name() in ["okex","bybit"]: return float(market["limits"]["amount"]["min"]) elif self.get_exchange_name() in ["kucoin"]: - return (float(market["limits"]["cost"]["min"])+.1)/self.get_ticker_price(pair) - elif self.get_exchange_name() in ["gateio"]: return (float(market["limits"]["cost"]["min"])+.25)/self.get_ticker_price(pair) + elif self.get_exchange_name() in ["gateio"]: + return (float(market["limits"]["cost"]["min"])+.1)/self.get_ticker_price(pair) elif self.get_exchange_name()=="binance": for line in market["info"]["filters"]: if line["filterType"] == "NOTIONAL": diff --git a/main.py b/main.py index f460896..4b79af1 100644 --- a/main.py +++ b/main.py @@ -18,7 +18,7 @@ import exchange_wrapper import trader -version = "2025.09.19" +version = "2025.09.20" ''' Color definitions. If you want to change them, check the reference at https://en.wikipedia.org/wiki/ANSI_escape_code#Colors diff --git a/trader.py b/trader.py index e9c989f..6fbd4d0 100755 --- a/trader.py +++ b/trader.py @@ -125,7 +125,7 @@ class trader: self.set_pause(True, "start_trader") - if self.status.get_is_short(): + if self.config.get_is_short(): self.broker.logger.log_this("Calculating optimal order size...",2,self.status.get_pair()) #Get minimum order size from exchange @@ -774,7 +774,7 @@ class trader: self.status.set_safety_orders([]) #Handle the partial fills - if not self.status.get_is_short(): + if not self.config.get_is_short(): #With short traders is just an accounting issue, since when the trader restarts it will be buying cheaper what it sold more expensive in the partially filled safety order(s) if partial_filled_amount!=0 and len(partial_filled_price)>0 and partial_filled_amount>self.broker.get_min_base_size(self.status.get_pair()): #send a market order and sum the profits and wait for it to be filled