|
|
@@ -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)
|