shinchan-zhai
6911bc3e2b
fix: prevent panics from unsafe type assertions in trading code + add request body limit
...
Security & Reliability:
- Add requestBodyLimitMiddleware (1MB) to prevent OOM from oversized API payloads
- Fix defer resp.Body.Close() inside loop in getPublicIPFromAPI (connection leak)
- Add posFloat64/posString safe helpers for position map access
Panic Prevention (critical for trading):
- Convert 30+ unsafe type assertions (pos["key"].(type)) to safe comma-ok
pattern across all exchange traders: OKX, Hyperliquid, Aster, Bybit,
KuCoin, Gate, Bitget, Binance
- Fix auto_trader_risk.go: drawdown monitor could panic and silently stop
monitoring, leaving positions unprotected
- Fix auto_trader_decision.go & auto_trader_loop.go: core trading loop
position parsing now crash-proof
- All trader/ code now has zero unsafe type assertions
Frontend:
- Fix config.ts: rejected promise cached forever on network error (never retries)
2026-03-25 01:05:54 +08:00
shinchan-zhai
a5ac1b300b
perf: reuse shared HTTP client in Hyperliquid trader
...
Previously each direct API call (orders, sync, account) created a new
http.Client, preventing TCP/TLS connection reuse. Now all calls share
a single client on the HyperliquidTrader struct (30s timeout).
2026-03-25 01:05:54 +08:00
shinchan-zhai
456570c37c
security: add safe.ReadAllLimited — bound all HTTP response body reads to 10MB
...
- Created safe/io.go with ReadAllLimited helper (default 10MB limit)
- Replaced 62 unbounded io.ReadAll(resp.Body) calls across 32 files
- Covers all exchange traders (Hyperliquid, Bybit, Binance, OKX, Aster,
KuCoin, Gate, Bitget, Lighter, Indodax), providers (CoinAnk, Alpaca,
TwelveData), MCP client/x402, market data, wallet, telegram, kernel
- Prevents OOM from malicious/buggy exchange API responses
- Previously fixed: brain.go, sentinel.go already had manual LimitReader
2026-03-25 01:05:54 +08:00
tinkle-community
cb31782be4
refactor: split large files and clean up project structure
...
- Rename experience/ to telemetry/ for clarity
- Split 15+ large Go files (800-2200 lines) into focused modules:
kernel/engine.go, backtest/runner.go, market/data.go, store/position.go,
api/handler_trader.go, trader/auto_trader_grid.go, and 9 exchange traders
- Split frontend monoliths: types.ts, api.ts, AITradersPage.tsx, BacktestPage.tsx
into domain-specific modules with barrel re-exports
- Remove stale files: screenshots, .yml.old, pyproject.toml
- Remove unused scripts/ and cmd/ directories
- Remove broken/outdated test files (network-dependent, stale expectations)
2026-03-12 12:53:57 +08:00