skyfffire 5 meses atrás
pai
commit
5c64726dc7
3 arquivos alterados com 17 adições e 9 exclusões
  1. 13 6
      arbitrage_process.py
  2. 1 1
      price_checker_ok.py
  3. 3 2
      price_view1.py

+ 13 - 6
arbitrage_process.py

@@ -71,6 +71,9 @@ class ArbitrageProcess:
         self.base_coin = symbol.split('_')[1]
         self.process_item = process_item
 
+        self.sell_price = Decimal(0)
+        self.buy_price = Decimal(0)
+
         # 存储当前套利交易的细节信息,例如买入数量、价格等
         self.arbitrage_details = {
             "chain_buy_tx_hash": None,                                          # 链上买入的tx hash
@@ -341,10 +344,11 @@ class ArbitrageProcess:
                 if order['status'] in ["FILLED", "PARTIALLY_CANCELED"]:
                     money = Decimal(order['cummulativeQuoteQty'])
                     amount = self.arbitrage_details["exchange_out_amount"]
-                    price = money / amount
-                    price = price.quantize(Decimal('1e-8'), rounding=ROUND_DOWN)
 
-                    msg = f"交易所现货卖出订单已完成, 价格:{price}。{order}"
+                    self.sell_price = money / amount
+                    self.sell_price = self.sell_price.quantize(Decimal('1e-8'), rounding=ROUND_DOWN)
+
+                    msg = f"交易所现货卖出订单已完成, 价格:{self.sell_price}。{order}"
                     logging.info(msg)
                     add_state_flow_entry(self.process_item, self.current_state, msg, "success")
 
@@ -425,10 +429,13 @@ class ArbitrageProcess:
                 sell_amount_human = self.arbitrage_details["chain_usdt_use"]
                 self.arbitrage_details["chain_buy_amount"] = buy_amount_human # 存储实际买入数量
 
-                price_human = sell_amount_human / buy_amount_human
-                price_human = price_human.quantize(Decimal('1e-8'), rounding=ROUND_DOWN)
+                self.buy_price = sell_amount_human / buy_amount_human
+                self.buy_price = self.buy_price.quantize(Decimal('1e-8'), rounding=ROUND_DOWN)
+
+                rate = self.sell_price / self.buy_price
+                rate = rate.quantize(Decimal('1e-4'), rounding=ROUND_DOWN)
 
-                msg = f"链上交易已确认。用{sell_amount_human}买入{buy_amount_human},价格{price_human}。"
+                msg = f"【比率{rate}】。链上交易已确认。用{sell_amount_human}买入{buy_amount_human},价格{self.buy_price}。"
                 logging.info(msg)
                 add_state_flow_entry(self.process_item, self.current_state, msg, "success")
                 self._set_state(self.STATE_WAITING_TRANSFER_ARRIVE)

+ 1 - 1
price_checker_ok.py

@@ -27,7 +27,7 @@ ARB_EXECUTOR_URL = "http://localhost:5002/submit_process"
 # --- 配置部分 ---
 IN_AMOUNT_TO_QUERY = decimal.Decimal('350')
 EXCHANGE_OUT_AMOUNT = decimal.Decimal('30000000')
-PROFIT_LIMIT = 0.03                                                 # 触发交易的利润阈值
+PROFIT_LIMIT = 0.02                                                 # 触发交易的利润阈值
 IN_TOKEN_ADDRESS = '0xdAC17F958D2ee523a2206206994597C13D831ec7'     # USDT on Ethereum
 IN_TOKEN_DECIMALS = 6
 OUT_TOKEN_ADDRESS = '0xf816507E690f5Aa4E29d164885EB5fa7a5627860'    # RATO on Ethereum

+ 3 - 2
price_view1.py

@@ -26,8 +26,8 @@ ARB_EXECUTOR_URL = "http://localhost:5002/submit_process"
 
 # --- 配置部分 ---
 IN_AMOUNT_TO_QUERY = decimal.Decimal('350')
-EXCHANGE_OUT_AMOUNT = decimal.Decimal('430000')
-PROFIT_LIMIT = 0.02                                                 # 触发交易的利润阈值
+EXCHANGE_OUT_AMOUNT = decimal.Decimal('800000')
+PROFIT_LIMIT = 0.01                                                 # 触发交易的利润阈值
 IN_TOKEN_ADDRESS = '0xdAC17F958D2ee523a2206206994597C13D831ec7'     # USDT on Ethereum
 IN_TOKEN_DECIMALS = 6
 OUT_TOKEN_ADDRESS = '0x292fcDD1B104DE5A00250fEBbA9bC6A5092A0076'    # out on Ethereum
@@ -186,6 +186,7 @@ def send_arb_msg(profit, data):
         else:
             logging.info(f"\n请求失败! 状态码: {response.status_code}")
 
+        # 打印响应体
         logging.info(response.text)
 
     except requests.exceptions.ConnectionError as e: