Skip to content
This repository was archived by the owner on Nov 21, 2025. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions strategies/grid_trader.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,13 +361,7 @@ def check_ws_connection(self):
# 嘗試關閉現有連接
if self.ws:
try:
if hasattr(self.ws, 'running') and self.ws.running:
self.ws.running = False
if hasattr(self.ws, 'ws') and self.ws.ws:
try:
self.ws.ws.close()
except:
pass
# 使用 BackpackWebSocket 的 close 方法以確保完全斷開
self.ws.close()
time.sleep(0.5)
except Exception as e:
Expand Down
4 changes: 3 additions & 1 deletion ws_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,12 @@ def reconnect(self):
on_pong=self.on_pong
)

# 創建新線程
# 創建新線程並重新啟動心跳
self.running = True
self.ws_thread = threading.Thread(target=self.ws_run_forever)
self.ws_thread.daemon = True
self.ws_thread.start()
self.start_heartbeat()

# 更新最後心跳時間,避免重連後立即觸發心跳檢測
self.last_heartbeat = time.time()
Expand Down