- Add check to ensure availableBalance >= 0
- Log warning when calculated value is negative
- Prevent false "insufficient balance" errors for users with USDC
Root cause: Hyperliquid's TotalMarginUsed may exceed AccountValue
in certain position states, causing negative available balance.
Related issue: Users with USDC seeing "no money" errors despite
having sufficient balance on Hyperliquid.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Add check for oldBalance <= 0 before calculating changePercent
- Directly update to actualBalance if initialBalance is invalid
- Add warning logs for database nil scenarios
- Prevent panic when initial_balance is 0 in database
Applies same critical fix from feat/auto-balance-sync (3a5dea7)
to z-dev branch with adapted database type handling.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Add Telegram channel monitoring for market news
- Integrate news sentiment into AI decision making
- Improve context awareness for trading decisions
- Fix missing InsideCoins field in ConfigFile structure
- Merge with existing partial_close and position tracking features
- Add position_snapshots table to track all closed positions
- Record both manual and auto-closed positions
- Fix data integrity issue where auto-closed positions were not recorded
- Improve trade history tracking and analysis
- Merge with existing partial_close functionality
- Clean up remaining conflict markers in SetMarginMode
- Add visual warnings for WebSocket stream limits in UI
- Prevent user from exceeding 250 symbols (1024 streams / 4 timeframes)
- Auto-sync server time every 30 seconds
- Add callWithTimeSync retry mechanism for all API calls
- Fix -1021 timestamp errors automatically
- Production-ready implementation
- Resolved merge conflict with PR #145
Source: https://github.com/NoFxAiOS/nofx/pull/313
1. Rename `traderRecord` to `trader` in handleCreateTrader
- Aligns with upstream naming convention (nofxaios/dev)
- Line 403: variable definition
- Line 424: CreateTrader call
2. Add Binance server time synchronization (PR #145 simple fix)
- Fixes timestamp errors (code=-1021)
- Sets UseTestnet=false (ensure production network)
- Syncs server time on trader initialization
- Based on commit 64299c1 from pr-145 branch
Both changes improve compatibility with upstream and prevent
timestamp-related API failures.
- Replace log.Printf() with log.Print() for static strings
- Fix 6 instances in trader/auto_trader.go (lines 262, 264, 351, 355, 359, 363)
- Eliminates 'non-constant format string' warnings from go vet
- No functional changes, output remains identical
This follows Go best practices and improves code security by using
appropriate logging functions for non-formatted strings.
Fixes#200
Previously, positions closed via stop-loss or take-profit were not
recorded in decision logs, causing inaccurate performance metrics
(win rate, profit factor, etc.) displayed in the frontend.
This commit implements a position snapshot mechanism to detect
auto-closed positions by comparing positions between trading cycles.
Changes:
- Add PositionSnapshot struct to track position state
- Add detectAutoClosedPositions() to detect disappeared positions
- Update position snapshots at cycle end (after AI execution)
- Support auto_close_long/auto_close_short action types in logger
- Ensure accurate performance analysis including auto-closed trades
Key fix:
- Snapshots are updated AFTER AI execution to avoid false positives
- AI manual closes won't be mistakenly detected as auto-closes
Added logic to automatically cancel all orders for a symbol when its position disappears, ensuring orphan stop-loss/take-profit orders are cleaned up. This improves order management and prevents unintended trades after a position is closed.
New Features:
- Add 'enabled' field to trader config for selective startup
- Only enabled traders will be initialized and run
- Display skip messages for disabled traders in logs
Bug Fixes:
- Fix Hyperliquid account value calculation
* AccountValue is total equity, no need to add TotalMarginUsed
* Correctly calculate wallet balance without unrealized PnL
* Fix available balance calculation (AccountValue - TotalMarginUsed)
- Fix frontend page refresh navigation issue
* Use URL hash to persist page state across refreshes
* Support browser back/forward buttons
* Prevent Details page from reverting to Competition on refresh
Technical Changes:
- config/config.go: Add Enabled bool field to TraderConfig
- main.go: Skip disabled traders during initialization
- trader/hyperliquid_trader.go: Correct account value logic
- web/src/App.tsx: Implement hash-based routing
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Major fixes:
1. Trade History data loss issue
- Root cause: Open records outside analysis window caused close matching failures
- Solution: Pre-populate position state by reading 3x window of historical records
- Ensures long-term positions (>5 hours) generate correct trade records
2. P&L calculation errors
- Remove incorrect leverage multiplication from absolute P&L
- Correct calculation: Futures P&L = quantity × price difference
- Leverage only affects P&L percentage (relative to margin)
3. Other fixes
- Break-even trades (pnl=0) no longer misclassified as losses
- Perfect strategy shows Profit Factor as 999.0 instead of 0.0
- Expand analysis window from 20 to 100 cycles (5 hours)
Files changed:
- logger/decision_logger.go: Core matching and calculation logic
- api/server.go: API analysis window
- trader/auto_trader.go: AI decision analysis window
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
## Features
- Add full Aster DEX integration with Binance-compatible API
- Support Web3 authentication with API wallet system
- Add comprehensive Aster integration guide (ASTER_INTEGRATION.md)
- Add example Aster configuration (config.aster.example.json)
## Bug Fixes
- Fix precision error (code -1111) for all order types
- Implement proper float-to-string conversion with exchange precision
- Add automatic precision fetching from /exchangeInfo endpoint
- Remove trailing zeros from formatted values
## Documentation
- Update README.md with Aster quick start guide
- Add detailed setup instructions for creating API wallet
- Include troubleshooting FAQ and security best practices
- Update core features to mention three supported exchanges
## Technical Details
- Added formatFloatWithPrecision() helper function
- Updated all order functions to use proper precision formatting
- Added precision logging for debugging
- Fully backward compatible with existing configurations
Closes #[issue number if applicable]
This update enables users to configure any OpenAI-compatible API endpoint,
allowing the use of:
- OpenAI official API (GPT-4, GPT-4o, etc.)
- OpenRouter (access to multiple models)
- Local deployed models (Ollama, LM Studio, etc.)
- Other OpenAI-format compatible API services
Changes:
- config: Add custom_api_url, custom_api_key, custom_model_name fields
- mcp: Add SetCustomAPI function and ProviderCustom constant
- trader: Update AI initialization logic to support custom API
- manager: Pass custom API config to trader instances
- Add CUSTOM_API.md documentation with usage examples
- Update config.json.example with custom API sample
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>