1
This commit is contained in:
parent
42c6904604
commit
60823b4056
|
|
@ -1248,14 +1248,14 @@ class BinanceClient:
|
||||||
current_leverage = config.TRADING_CONFIG.get('LEVERAGE', 10)
|
current_leverage = config.TRADING_CONFIG.get('LEVERAGE', 10)
|
||||||
try:
|
try:
|
||||||
# 尝试从持仓信息获取实际使用的杠杆
|
# 尝试从持仓信息获取实际使用的杠杆
|
||||||
|
# 注意:即使没有持仓(positionAmt=0),leverage 字段也是准确的(反映了当前该 symbol 设置的杠杆)
|
||||||
positions = await self.client.futures_position_information(symbol=symbol)
|
positions = await self.client.futures_position_information(symbol=symbol)
|
||||||
if positions and len(positions) > 0:
|
if positions and len(positions) > 0:
|
||||||
position = positions[0]
|
position = positions[0]
|
||||||
if float(position.get('positionAmt', 0)) != 0:
|
# 优先使用 API 返回的 leverage,不再限制必须有持仓
|
||||||
# 有持仓,使用持仓的杠杆
|
leverage_bracket = position.get('leverage')
|
||||||
leverage_bracket = position.get('leverage', current_leverage)
|
if leverage_bracket:
|
||||||
if leverage_bracket:
|
current_leverage = int(leverage_bracket)
|
||||||
current_leverage = int(leverage_bracket)
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.debug(f"无法获取 {symbol} 的杠杆信息,使用默认值: {current_leverage}x ({e})")
|
logger.debug(f"无法获取 {symbol} 的杠杆信息,使用默认值: {current_leverage}x ({e})")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user