|
@@ -288,11 +288,14 @@ class TradingStrategy:
|
|
|
close_price = min(binance_price, lighter_price)
|
|
close_price = min(binance_price, lighter_price)
|
|
|
is_ask = True # 卖出
|
|
is_ask = True # 卖出
|
|
|
|
|
|
|
|
- logger.info(f"开始平仓:方向={'做空' if self.position_side == 'short' else '做多'},价格={close_price}")
|
|
|
|
|
|
|
+ # 获取实际持仓数量
|
|
|
|
|
+ position_quantity = abs(int(self.current_position.position)) if self.current_position else self.trade_quantity
|
|
|
|
|
+
|
|
|
|
|
+ logger.info(f"开始平仓:方向={'做空' if self.position_side == 'short' else '做多'},价格={close_price},数量={position_quantity}")
|
|
|
|
|
|
|
|
tx_hash, error = await self.create_order_and_send_tx(
|
|
tx_hash, error = await self.create_order_and_send_tx(
|
|
|
orderbook=orderbook,
|
|
orderbook=orderbook,
|
|
|
- quantity=self.trade_quantity,
|
|
|
|
|
|
|
+ quantity=position_quantity,
|
|
|
price=close_price,
|
|
price=close_price,
|
|
|
is_ask=is_ask,
|
|
is_ask=is_ask,
|
|
|
reduce_only=True
|
|
reduce_only=True
|