nofx icon indicating copy to clipboard operation
nofx copied to clipboard

[BUG] duplicate method CancelStopOrders

Open KonHao0813 opened this issue 1 year ago • 1 comments

🐛 Bug Description 後端服務 (nofx) 在執行 docker compose up --build 時建置失敗。Go 語言編譯器在 trader/interface.go 檔案中回報了 duplicate method CancelStopOrders (重複的方法定義) 錯誤。

🔍 Bug Category [ ] Trading execution (orders not executing, wrong position size, etc.)

[ ] AI decision issues (unexpected decisions, only opening one direction, etc.)

[ ] Exchange connection (API errors, authentication failures, etc.)

[ ] UI/Frontend (display issues, buttons not working, data not updating, etc.)

[x] Backend/API (server errors, crashes, performance issues, etc.)

[ ] Configuration (settings not saving, database errors, etc.)

[ ] Other: _________________

📋 Steps to Reproduce 在一台乾淨的 Ubuntu 22.04 伺服器上 (GCP)。

執行 git clone https://github.com/NoFxAiOS/nofx.git

cd nofx

執行 sudo docker compose up --build

觀察到 nofx (後端) 服務建置失敗。

✅ Expected Behavior Docker 建置應該成功完成,nofx-trading 容器應該啟動。

❌ Actual Behavior 建置過程在 [nofx backend-builder 8/8] 步驟中失敗,並顯示 Go 語言編譯錯誤。

📸 Screenshots & Logs Backend Logs (if applicable) Backend Log Output:


[nofx backend-builder 8/8] RUN CGO_ENABLED=1 GOOS=linux CGO_CFLAGS="-D_LARGEFILE64_SOURCE" go build -trimpath -ldflags="-s -w" -o nofx .: 597.2 # nofx/trader 597.2 trader/aster_trader.go:1179:23: method AsterTrader.CancelStopOrders already declared at trader/aster_trader.go:1014:23 597.2 trader/binance_futures.go:624:25: method FuturesTrader.CancelStopOrders already declared at trader/binance_futures.go:479:25 597.2 trader/hyperliquid_trader.go:627:29: method HyperliquidTrader.CancelStopOrders already declared at trader/hyperliquid_trader.go:553:29 597.2 trader/interface.go:53:2: duplicate method CancelStopOrders 597.2 trader/interface.go:41:2: other declaration of method CancelStopOrders


Dockerfile.backend:50

49 | COPY . . 50 | >>> RUN CGO_ENABLED=1 GOOS=linux
51 | >>> CGO_CFLAGS="-D_LARGEFILE64_SOURCE"
52 | >>> go build -trimpath -ldflags="-s -w" -o nofx . 53 |

target nofx: failed to solve: process "/bin/sh -c CGO_ENABLED=1 GOOS=linux CGO_CFLAGS="-D_LARGEFILE64_SOURCE" go build -trimpath -ldflags="-s -w" -o nofx ." did not complete successfully: exit code: 1 💻 Environment System:

OS: Ubuntu 22.04 LTS (GCP)

Deployment: Docker

Backend:

Go Version: (由 Dockerfile.backend 中的 golang:1.21-alpine 映像檔定義)

NOFX Version: (請在此貼上 git log -1 --oneline 的執行結果)

Trading Setup:

N/A (尚未執行到此階段)

📊 Additional Context Frequency:

[x] Happens every time

Timeline:

Did this work before? [x] No (這是在 git clone 專案後的第一次建置)

When did it break? On first build

Impact:

[x] System cannot start

💡 Possible Solution (暫時的解決方法) 錯誤是由 trader/interface.go 檔案中的重複方法定義引起的(第 41 行和第 53 行)。

手動編輯 trader/interface.go 並刪除第 53 行的 CancelStopOrders(symbol string, orderIDs []string) (bool, error),可以讓建置成功完成。

KonHao0813 avatar Nov 05 '25 08:11 KonHao0813

🐛 Bug Description 後端服務 (nofx) 在執行 docker compose up --build 時建置失敗。Go 語言編譯器回報 CancelStopOrders (取消止損單) 這個函式在多個檔案中被重複定義。

這個 Bug 不只出現在介面檔案 (trader/interface.go),也同時出現在所有實作該介面的檔案中 (aster_trader.go, binance_futures.go, hyperliquid_trader.go),導致 Go build 失敗。

🔍 Bug Category [ ] Trading execution (orders not executing, wrong position size, etc.)

[ ] AI decision issues (unexpected decisions, only opening one direction, etc.)

[ ] Exchange connection (API errors, authentication failures, etc.)

[ ] UI/Frontend (display issues, buttons not working, data not updating, etc.)

[x] Backend/API (server errors, crashes, performance issues, etc.)

[ ] Configuration (settings not saving, database errors, etc.)

[ ] Other: _________________

📋 Steps to Reproduce 在一台乾淨的 Ubuntu 22.04 伺服器上。

執行 git clone https://github.com/NoFxAiOS/nofx.git

cd nofx

執行 sudo docker compose up --build

觀察到 nofx (後端) 服務建置失敗。

✅ Expected Behavior Docker 建置應該成功完成,nofx-trading 容器應該啟動。

❌ Actual Behavior 建置過程在 [nofx backend-builder 8/8] 步驟中失敗,並顯示 Go 語言編譯錯誤。

(註:我手動修復 trader/interface.go 後,錯誤仍然存在於以下檔案中)

📸 Screenshots & Logs Backend Logs (if applicable) Backend Log Output:


[nofx backend-builder 8/8] RUN CGO_ENABLED=1 GOOS=linux CGO_CFLAGS="-D_LARGEFILE64_SOURCE" go build -trimpath -ldflags="-s -w" -o nofx .: 323.2 # nofx/trader 323.2 trader/aster_trader.go:1179:23: method AsterTrader.CancelStopOrders already declared at trader/aster_trader.go:1014:23 323.2 trader/binance_futures.go:624:25: method FuturesTrader.CancelStopOrders already declared at trader/binance_futures.go:479:25 323.2 trader/hyperliquid_trader.go:627:29: method HyperliquidTrader.CancelStopOrders already declared at trader/hyperliquid_trader.go:553:29


Dockerfile.backend:50


49 | COPY . .

50 | >>> RUN CGO_ENABLED=1 GOOS=linux \

51 | >>> CGO_CFLAGS="-D_LARGEFILE64_SOURCE" \

52 | >>> go build -trimpath -ldflags="-s -w" -o nofx .

53 |


target nofx: failed to solve: process "/bin/sh -c CGO_ENABLED=1 GOOS=linux CGO_CFLAGS="-D_LARGEFILE64_SOURCE" go build -trimpath -ldflags="-s -w" -o nofx ." did not complete successfully: exit code: 1 💻 Environment System:

OS: Ubuntu 22.04 LTS (GCP)

Deployment: Docker

Backend:

Go Version: (由 Dockerfile.backend 中的 golang:1.21-alpine 映像檔定義)

NOFX Version: (請在此貼上 git log -1 --oneline 的執行結果)

Trading Setup:

N/A (尚未執行到此階段)

📊 Additional Context Frequency:

[x] Happens every time

Timeline:

Did this work before? [x] No (這是在 git clone 專案後的第一次建置)

When did it break? On first build

Impact:

[x] System cannot start

💡 Possible Solution (暫時的解決方法) CancelStopOrders 函式被重複定義了。需要手動編輯以下檔案,刪除重複的函式定義:

trader/interface.go (刪除第 53 行附近的重複宣告)

trader/aster_trader.go (刪除第 1179 行附近的重複函式實作)

trader/binance_futures.go (刪除第 624 行附近的重複函式實作)

trader/hyperliquid_trader.go (刪除第 627 行附近的重複函式實作)

KonHao0813 avatar Nov 05 '25 09:11 KonHao0813