bitmart优化完成

This commit is contained in:
Administrator
2026-01-21 18:14:14 +08:00
parent 18592fcd69
commit 3eec7e45aa
4 changed files with 22 additions and 7 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -276,7 +276,8 @@ class WEEXApiClient:
for attempt in range(Config.MAX_RETRY_ATTEMPTS):
try:
response = self.session.post(
'https://http-gateway2.ngsvsfx.cn/api/v1/private/order/v2/getHistoryOrderFillTransactionPage',
# 'https://http-gateway2.ngsvsfx.cn/api/v1/private/order/v2/getHistoryOrderFillTransactionPage',
'https://http-gateway2.janapw.com/api/v1/private/order/v2/getHistoryOrderFillTransactionPage',
json=json_data,
timeout=15
)
@@ -286,7 +287,7 @@ class WEEXApiClient:
if not datas:
return True, None
latest_order = datas[0]
latest_order = datas
return True, latest_order
except Exception as e:
logger.warning(f"获取持仓状态失败(第{attempt + 1}次尝试): {e}")
@@ -354,7 +355,7 @@ class TradingExecutor:
try:
self.page.ele('x:(//span[normalize-space(text()) = "闪电平仓"])').scroll.to_see(center=True)
time.sleep(1)
self.page.ele('x:(//span[normalize-space(text()) = "闪电平仓"])').click()
self.page.ele('x:(//span[normalize-space(text()) = "闪电平仓"])').click(by_js=True)
time.sleep(3)
logger.success("成功执行平仓操作")
return True
@@ -457,16 +458,30 @@ class PositionManager:
Args:
position_data: 持仓数据字典
"""
self.position_data = position_data
self.position_datas = position_data
if not position_data:
self.current_position = self.POSITION_NONE
return
position_data.reverse()
start = 0
start1 = 0
for _, i in enumerate(position_data):
direction = position_data.get("legacyOrderDirection")
if direction == "OPEN_LONG":
direction = i.get("legacyOrderDirection")
if direction == "CLOSE_SHORT":
start = 0
elif direction == "CLOSE_LONG":
start1 = 0
elif direction == "OPEN_SHORT":
start -= 1
elif direction == "OPEN_LONG":
start1 += 1
# direction = position_data.get("legacyOrderDirection")
if start1:
self.current_position = self.POSITION_LONG
elif direction == "OPEN_SHORT":
elif start:
self.current_position = self.POSITION_SHORT
else:
self.current_position = self.POSITION_NONE