|
|
@@ -308,17 +308,26 @@ class ArbitrageProcess:
|
|
|
self.already_sold_amount = Decimal(0)
|
|
|
while self.already_sold_amount < self.exchange_sell_amount and order_times < 5:
|
|
|
order_times = order_times + 1
|
|
|
- # 第一步直接买入,这个数量用固定数量
|
|
|
+ # 第一步直接卖出,这个数量用固定数量
|
|
|
pseudo_amount_to_sell = self.exchange_sell_amount - self.already_sold_amount
|
|
|
# 处理精度
|
|
|
pseudo_amount_to_sell = pseudo_amount_to_sell.quantize(self.coin_asset_precision, rounding=ROUND_DOWN)
|
|
|
-
|
|
|
+ # 初始化 quantity 变量
|
|
|
+ quantity_for_api = None
|
|
|
+ # 用求余法判断是否是整数
|
|
|
+ if pseudo_amount_to_sell % 1 == 0:
|
|
|
+ # 如果是整数,转换为 int 类型。某些API可能只接受整数交易对的整数数量
|
|
|
+ quantity_for_api = int(pseudo_amount_to_sell)
|
|
|
+ else:
|
|
|
+ # 如果是非整数,转换为 float 类型。这是最常见的API数量类型
|
|
|
+ quantity_for_api = float(pseudo_amount_to_sell)
|
|
|
order_params = {
|
|
|
"symbol": self.symbol.replace('_', ''),
|
|
|
"side": "SELL",
|
|
|
"type": "MARKET",
|
|
|
- "quantity": float(pseudo_amount_to_sell),
|
|
|
+ "quantity": quantity_for_api,
|
|
|
}
|
|
|
+
|
|
|
order_params_formated = pformat(order_params, indent=2)
|
|
|
|
|
|
exchange_sell_order = mexc.trade.post_order(order_params)
|
|
|
@@ -360,7 +369,7 @@ class ArbitrageProcess:
|
|
|
time.sleep(1)
|
|
|
waiting_times = waiting_times - 1
|
|
|
|
|
|
- if order_times <= 5:
|
|
|
+ if order_times < 5:
|
|
|
msg = 'mexc现货卖出流程完成'
|
|
|
logger.info(msg)
|
|
|
add_state_flow_entry(self.process_item, self.current_state, msg, "success")
|