bitmart优化完成

This commit is contained in:
Administrator
2025-12-18 16:42:26 +08:00
parent 6d5abb1ced
commit b61c0926bd
5 changed files with 47 additions and 31 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -536,7 +536,7 @@ async def build_sign_message(user_id: int, username: str) -> str:
return (
f"✅ @{username} check-in succeed! Earned {SIGN_POINTS} points.\n"
f"Current total points: {total}\n\n"
f"100 points can be exchanged for a 5 USDT experience gold."
f"100 points can be exchanged for a 5 (USDT) $ trial bonus."
)
@@ -565,7 +565,7 @@ async def build_points_message(user_id: int, username: str) -> str:
f"💰 @{username} Points Overview\n\n"
f"📊 Current points: {total_pts}\n"
f"👥 Invited users: {invite_count}\n\n"
f"💡 100 points can be exchanged for a 5 USDT experience gold."
f"💡 100 points can be exchanged for a 5 (USDT) $ trial bonus."
)
@@ -575,7 +575,7 @@ def get_command_list_text() -> str:
info = COMMAND_DEFINITIONS[key]
msg += f"`{info['display']}` → {info['description']}\n"
msg += (
f"\nSign-in Reward: {SIGN_POINTS} points each time, and 100 points can be redeemed for a 5 USDT experience gold.\n"
f"\nSign-in Reward: {SIGN_POINTS} points each time, and 100 points can be exchanged for a 5 (USDT) $ trial bonus.\n"
f"Chat Reward: The top {DAILY_SPEAK_TOP_N} users in daily chat activity each receive {DAILY_SPEAK_REWARD} points.\n"
f"Invitation Reward: Each invited user grants {INVITE_POINTS} points.\n"
f"Daily Settlement Time: Every day at 12:00 PM (America/New_York timezone)."

Binary file not shown.

View File

@@ -399,8 +399,14 @@ class TradingExecutor:
amount: 交易金额
Returns:
是否成功
是否成功如果已持有相同方向仓位返回True但不执行操作
"""
# 检查是否已经持有相同方向的仓位
if (direction == "long" and current_position == PositionManager.POSITION_LONG) or \
(direction == "short" and current_position == PositionManager.POSITION_SHORT):
logger.info(f"已持有{direction}方向仓位,无需重复开仓")
return True # 返回True表示"状态正常",虽然没有执行交易
if not self.navigate_to_trading_page():
return False
@@ -781,38 +787,48 @@ class WeexTransaction:
)
if direction:
# 获取可用余额
balance = self.api_client.get_available_balance()
if balance is None:
logger.error("获取可用余额失败")
MessageSender.send_dingtalk_message("获取可用余额失败", is_error=True)
return
# 检查是否已经持有相同方向的仓位
current_pos = self.position_manager.current_position
if (direction == "long" and current_pos == PositionManager.POSITION_LONG) or \
(direction == "short" and current_pos == PositionManager.POSITION_SHORT):
logger.info(f"已持有{direction}方向仓位,继续持仓,不执行新开仓操作")
# 继续持仓,不发送开仓信息,直接返回继续执行后续的持仓信息发送
else:
# 需要执行交易(新开仓或反手)
# 获取可用余额
balance = self.api_client.get_available_balance()
if balance is None:
logger.error("获取可用余额失败")
MessageSender.send_dingtalk_message("获取可用余额失败", is_error=True)
return
amount = balance / Config.POSITION_RATIO
amount = balance / Config.POSITION_RATIO
# 执行交易
if not self.trading_executor.execute_trade(
direction=direction,
current_position=self.position_manager.current_position,
amount=amount
):
MessageSender.send_dingtalk_message(
f"交易执行失败,方向:{direction}",
is_error=True
# 执行交易
trade_executed = self.trading_executor.execute_trade(
direction=direction,
current_position=self.position_manager.current_position,
amount=amount
)
return
# 更新持仓状态
if direction == "long":
self.position_manager.current_position = PositionManager.POSITION_LONG
elif direction == "short":
self.position_manager.current_position = PositionManager.POSITION_SHORT
if not trade_executed:
MessageSender.send_dingtalk_message(
f"交易执行失败,方向:{direction}",
is_error=True
)
return
# 发送交易消息
MessageSender.send_dingtalk_message(
f"信号:{direction},开仓金额:{amount:.2f}",
is_error=False
)
# 更新持仓状态
if direction == "long":
self.position_manager.current_position = PositionManager.POSITION_LONG
elif direction == "short":
self.position_manager.current_position = PositionManager.POSITION_SHORT
# 发送交易消息(只有真正执行了开仓或反手操作才发送)
MessageSender.send_dingtalk_message(
f"信号:{direction},开仓金额:{amount:.2f}",
is_error=False
)
# 再次同步持仓状态(交易后)
if not self.sync_position_status():