Skip to content

Commit 8e26a08

Browse files
committed
Restructure to standard Go project layout
- Move main.go → cmd/bot/main.go (entry point per Go conventions) - Update Makefile, Dockerfile, CI workflow to build from ./cmd/bot/ - Remove stale root binaries (arbitrage_bot, bot, bot-linux) - Delete orphaned configs/ directory (unreferenced) - Add /logs.bak/ to .gitignore - Remove dead methods from internal/market/manager.go - Fix README commands (build-all-platforms, make cover)
1 parent 3e27f02 commit 8e26a08

8 files changed

Lines changed: 9 additions & 107 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
-X triangular-arbitrage-bot/internal/version.Version=${GITHUB_REF_NAME} \
5959
-X triangular-arbitrage-bot/internal/version.Commit=${{ steps.vars.outputs.sha_short }} \
6060
-X triangular-arbitrage-bot/internal/version.BuildTime=${{ steps.vars.outputs.build_time }}" \
61-
./
61+
./cmd/bot/
6262
6363
docker:
6464
if: github.ref == 'refs/heads/main'

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ coverage.html
2828
# Logs
2929
*.log
3030
/logs/
31+
/logs.bak/
3132

3233
# Generated
3334
CLAUDE.md

‎Dockerfile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ ARG VERSION=dev
1313
ARG COMMIT=unknown
1414
ARG BUILD_TIME=unknown
1515

16-
RUN CGO_ENABLED=0 go build -trimpath -ldflags="-s -w -X triangular-arbitrage-bot/internal/version.Version=${VERSION} -X triangular-arbitrage-bot/internal/version.Commit=${COMMIT} -X triangular-arbitrage-bot/internal/version.BuildTime=${BUILD_TIME}" -o /build/bot .
16+
RUN CGO_ENABLED=0 go build -trimpath -ldflags="-s -w -X triangular-arbitrage-bot/internal/version.Version=${VERSION} -X triangular-arbitrage-bot/internal/version.Commit=${COMMIT} -X triangular-arbitrage-bot/internal/version.BuildTime=${BUILD_TIME}" -o /build/bot ./cmd/bot/
1717

1818
FROM alpine:3.21
1919

‎Makefile‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ all: fmt vet lint test build
1919

2020
build:
2121
@mkdir -p $(BUILD_DIR)
22-
go build $(GO_FLAGS) $(LD_FLAGS) -o $(BUILD_DIR)/$(BINARY) .
22+
go build $(GO_FLAGS) $(LD_FLAGS) -o $(BUILD_DIR)/$(BINARY) ./cmd/bot/
2323

2424
run: build
2525
./$(BUILD_DIR)/$(BINARY) -config config.json
@@ -76,11 +76,11 @@ clean:
7676
# Cross-compilation
7777
build-linux:
7878
@mkdir -p $(BUILD_DIR)
79-
GOOS=linux GOARCH=amd64 go build $(GO_FLAGS) $(LD_FLAGS) -o $(BUILD_DIR)/$(BINARY)-linux-amd64 .
79+
GOOS=linux GOARCH=amd64 go build $(GO_FLAGS) $(LD_FLAGS) -o $(BUILD_DIR)/$(BINARY)-linux-amd64 ./cmd/bot/
8080

8181
build-darwin:
8282
@mkdir -p $(BUILD_DIR)
83-
GOOS=darwin GOARCH=arm64 go build $(GO_FLAGS) $(LD_FLAGS) -o $(BUILD_DIR)/$(BINARY)-darwin-arm64 .
83+
GOOS=darwin GOARCH=arm64 go build $(GO_FLAGS) $(LD_FLAGS) -o $(BUILD_DIR)/$(BINARY)-darwin-arm64 ./cmd/bot/
8484

8585
build-all-platforms: build-linux build-darwin
8686
@echo "Cross-platform builds complete"

‎README.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,14 @@ make run
8181
### Cross-platform builds
8282

8383
```bash
84-
make build-all # builds for linux/amd64, windows/amd64, darwin/amd64, darwin/arm64
84+
make build-all-platforms # builds for linux/amd64 and darwin/arm64
8585
```
8686

8787
## Testing
8888

8989
```bash
90-
make test # run all tests
91-
make test-coverage # run with coverage report
90+
make test # run all tests with race detector
91+
make cover # run with coverage report (HTML)
9292
go test -race ./... # run with race detector
9393
```
9494

File renamed without changes.

‎configs/config.json‎

Lines changed: 0 additions & 54 deletions
This file was deleted.

‎internal/market/manager.go‎

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ package market
33
import (
44
"encoding/json"
55
"fmt"
6-
"strconv"
7-
"strings"
86
"time"
97

108
"triangular-arbitrage-bot/internal/config"
@@ -155,46 +153,3 @@ func (m *Manager) GetOrderBookREST(market string) (*models.OrderBook, error) {
155153

156154
return OrderBook, nil
157155
}
158-
159-
// GetBestPrice returns the best price for a given market and side
160-
// For buys, we check bids[0] (highest bid)
161-
// For sells, we check asks[0] (lowest ask)
162-
func (m *Manager) GetBestPrice(market string, side string) (float64, error) {
163-
OrderBook, exists := m.marketDepths.Load(market)
164-
if !exists {
165-
return 0, fmt.Errorf("no order book data for market: %s", market)
166-
}
167-
168-
switch strings.ToLower(side) {
169-
case "buy":
170-
// For buys, we want the highest bid (bids[0])
171-
if len(OrderBook.Bids) > 0 {
172-
price, err := strconv.ParseFloat(OrderBook.Bids[0].Price, 64)
173-
if err != nil {
174-
return 0, fmt.Errorf("failed to parse bid price: %w", err)
175-
}
176-
return price, nil
177-
}
178-
case "sell":
179-
// For sells, we want the lowest ask (asks[0])
180-
if len(OrderBook.Asks) > 0 {
181-
price, err := strconv.ParseFloat(OrderBook.Asks[0].Price, 64)
182-
if err != nil {
183-
return 0, fmt.Errorf("failed to parse ask price: %w", err)
184-
}
185-
return price, nil
186-
}
187-
}
188-
189-
return 0, fmt.Errorf("no %s orders available for market: %s", side, market)
190-
}
191-
192-
// GetMarketDepth returns the order book depth for a market
193-
func (m *Manager) GetMarketDepth(market string) (*models.OrderBook, bool) {
194-
return m.marketDepths.Load(market)
195-
}
196-
197-
// GetAvailableMarkets returns all markets with available order book data
198-
func (m *Manager) GetAvailableMarkets() []string {
199-
return m.marketDepths.GetAvailableMarkets()
200-
}

0 commit comments

Comments
 (0)