1083 Commits

Author SHA1 Message Date
tinkle-community 319ccb8ca3 fix: initial balance calculation and UI improvements
- Fix initial balance using available_balance instead of total_equity
- Fix WSMonitor nil pointer by starting market monitor before loading traders
- Add strategy name display on traders list and dashboard pages
- Various position sync and trading improvements
2025-12-10 14:40:08 +08:00
tinkle-community c19ee51dee fix: update docker-compose.yml to use data directory
Changed volume mount from ./data.db:/app/data.db to ./data:/app/data
Removed decision_logs mount (logs now stored in data directory)
2025-12-09 21:32:40 +08:00
tinkle-community 8be44cdf6e fix: return default models and exchanges when database is empty
API now returns default AI models (deepseek, qwen, openai, claude, gemini, grok) and exchanges (binance, bybit, okx, hyperliquid, aster, lighter) when database has no data.
2025-12-09 21:11:51 +08:00
tinkle-community fa88bac812 feat: write logs to data directory
- Log files are saved to data/nofx_YYYY-MM-DD.log
- Removed decision_logs mount from docker-compose
2025-12-09 20:50:00 +08:00
tinkle-community 94abf1d491 fix: remove problematic volume mount that caused 502 error
The ./data:/app mount was overwriting the entire /app directory
including application binaries, causing the backend to fail.
2025-12-09 20:34:48 +08:00
tinkle-community 0c744c4954 fix: use bind mount instead of named volume for data persistence
- Changed from Docker named volume to bind mount (./data:/app/data)
- Data files now visible in deployment directory (/root/nofx/data/)
- Easier to backup, inspect, and manage data files directly
2025-12-09 20:09:48 +08:00
tinkle-community 32d420dace fix: change database path to data/data.db for Docker volume persistence
- Changed default dbPath from 'data.db' to 'data/data.db'
- This ensures database is stored in /app/data/ which is mounted as Docker volume
- Added automatic creation of data directory if it doesn't exist
- Fixes issue where database was lost on container restart
2025-12-09 20:01:45 +08:00
tinkle-community e6f4c9a0ef fix: remove FOREIGN KEY constraint from traders table
- Remove FK constraint that was causing 'FOREIGN KEY constraint failed' error
- Add migration to automatically remove FK from existing databases
- FK constraint was problematic when database is reset while user has cached JWT token
2025-12-09 19:52:27 +08:00
tinkle-community 6546264df9 fix: backend respect TRANSPORT_ENCRYPTION config for model/exchange updates 2025-12-09 19:30:00 +08:00
tinkle-community 23277fc39f chore: remove tweets from community section 2025-12-09 19:19:06 +08:00
tinkle-community 8b1cf2e6fe fix: respect transport_encryption setting in API config functions
When TRANSPORT_ENCRYPTION=false, updateModelConfigs and
updateExchangeConfigsEncrypted now send plain JSON instead of
attempting encryption which would fail with an empty public key.
2025-12-09 19:08:04 +08:00
tinkle-community c720d663f1 feat: add TRANSPORT_ENCRYPTION toggle for easier deployment
- Add TRANSPORT_ENCRYPTION env config (default: false)
- Allow HTTP/IP access when transport encryption is disabled
- Add /api/crypto/config endpoint to expose encryption status
- Update WebCryptoEnvironmentCheck with 'disabled' status
- Update ExchangeConfigModal and AITradersPage to allow form submission when disabled
- Add i18n translations for disabled status (EN/CN)
- Update README with two deployment modes documentation
2025-12-09 18:04:42 +08:00
tinkle-community 5f3797e255 feat: add one-click install and simplify README
- Add docker-compose.prod.yml with env_file support
- Add install.sh with auto-generated encryption keys
- Remove API endpoints and recommendations from README
- Add multi-language links to README
2025-12-09 17:44:45 +08:00
tinkle-community 63ddeec7ba docs: rewrite README with updated features and deployment guide
- Update project description to reflect current AI trading platform
- Rewrite Core Features with 6 key capabilities
- Add complete deployment guide (Docker + manual installation)
- Update all i18n versions (zh-CN, ja, ko, ru, uk, vi)
- Remove outdated JSON config examples
2025-12-09 17:27:38 +08:00
tinkle-community 9fa2432705 feat: improve strategy studio and fix trader deletion bug
- Add strategy export/import functionality to Strategy Studio
- Fix trader deletion not removing from memory (competition page ghost data)
- Simplify TraderConfigViewModal: remove unused fields, show strategy name
- Improve quant data formatting: OI/Netflow multi-timeframe display
- Add configurable OI/Netflow toggles in indicator settings
- Clean up unused frontend components and dead code
2025-12-09 16:46:58 +08:00
tinkle-community 48792907b3 feat: redesign landing page UI and improve header 2025-12-09 13:59:14 +08:00
tinkle-community 4291b80273 fix: filter Area entries from chart legend to show only trader names
Use custom Legend content to filter out entries with raw dataKey (_pnl_pct)
and only display Line entries with proper trader names.
2025-12-08 19:38:36 +08:00
tinkle-community 1e7c756dd7 docs: add new screenshots and update README
- Add dashboard-market-chart.png (market chart view)
- Add dashboard-positions.png (positions view)
- Add dashboard-page.png (full dashboard overview)
- Add strategy-indicators.png (technical indicators config)
- Update competition-page.png with latest UI
- Update README Screenshots section with all 7 images
2025-12-08 18:23:02 +08:00
tinkle-community 30f7113a81 fix: calculate pnl_pct in frontend when backend doesn't return it
Frontend now calculates total_pnl_pct from equity values if the backend
doesn't return this field. This ensures the performance chart displays
correctly regardless of backend version.
2025-12-08 18:08:01 +08:00
tinkle-community 9d6b631cd9 feat: add Web3 punk avatars and official social links
- Add PunkAvatar component for Web3-style trader avatars
- Integrate punk avatars into trader cards and dashboard header
- Add official Twitter/Telegram links to footer with anti-fork protection
- Create branding.ts with Base64 encoded official links
2025-12-08 17:52:11 +08:00
tinkle-community e55a6a6ff4 feat: fix competition chart with accurate PnL calculation and improved UI
Backend:
- Add GetByID method to TraderStore for fetching trader without userID
- Calculate total_pnl_pct in equity history API using initial_balance
- Falls back to first snapshot equity if initial_balance not set

Frontend (ComparisonChart):
- Redesign with modern UI: gradient fills, glow effects, rounded corners
- Add mini stats bar showing all traders with current PnL
- Improved tooltip with date, time, and trend icons
- Better Y-axis domain calculation ensuring zero is visible
- Bottom stats grid: Leader, Lead PnL, Gap, Data Points
- Use ComposedChart with Area + Line for visual depth
- Animated loading state with spinning indicator
2025-12-08 13:36:52 +08:00
tinkle-community c6f6d3ba9f feat: auto-restart traders that were running before shutdown
When the program restarts, traders that had is_running=true in the
database will now automatically start. If a trader fails to run,
its status will be updated to false in the database.
2025-12-08 13:19:41 +08:00
tinkle-community 9c53a266c0 feat: redesign indicator editor with required raw klines and improved UX
Backend:
- Add enable_raw_klines field to IndicatorConfig (always true, required)
- Change defaults: disable EMA/MACD/RSI/ATR, keep volume/OI/funding enabled

Frontend:
- Completely redesign IndicatorEditor with 4 clear sections:
  1. Market Data: Raw OHLCV (required, locked) + timeframe selection
  2. Technical Indicators: EMA/MACD/RSI/ATR (optional, AI can calculate)
  3. Market Sentiment: Volume/OI/Funding Rate
  4. Quant Data: External API integration
- Add helpful tips and descriptions in both Chinese and English
- Improve visual hierarchy with section headers and color coding
- Auto-ensure enable_raw_klines is always true
2025-12-08 13:02:51 +08:00
tinkle-community 7a6e6f2d92 fix: preserve AI model API key when updating and add default URLs
Backend:
- Fix AIModelStore.Update to preserve existing API key when new key is empty
  (prevents clearing API key when adding a new model)
- Add default OI Top API URL to strategy config

Frontend:
- Add "Fill Default" buttons for Coin Pool, OI Top, and Quant Data URLs
- Pre-configured default URLs for all data sources
- Users can click to auto-fill with working defaults
2025-12-08 12:58:13 +08:00
tinkle-community 9c1a322901 fix: OI Top API response parsing and quant data URL validation
- Fix OITopAPIResponse struct to use Code int (0=success) instead of Success bool
- Add all response fields from actual API (time_range_param, rank_type, limit)
- Add {symbol} placeholder validation warning in FetchQuantData
- Add API-level validation in strategy create/update to warn about missing {symbol}
2025-12-08 12:49:49 +08:00
tinkle-community ce3f62cb50 docs: add quant data plugin API documentation 2025-12-08 12:42:26 +08:00
tinkle-community 24717d8589 feat: use OHLCV table format for kline data in AI prompts
- Add KlineBar struct with full OHLCV data and timestamp
- Store complete kline data in TimeframeSeriesData.Klines
- Format klines as readable table with Time, Open, High, Low, Close, Volume
- Mark current (latest) bar for clarity
- Use kline count from strategy config instead of hardcoded 10
- Keep MidPrices/Volume for backward compatibility
- Update both market/data.go and decision/strategy_engine.go formatters
2025-12-08 12:27:27 +08:00
tinkle-community 8a5744e0a0 fix: use actual fill price from exchange API for position records
- Remove trader_orders table and OrderSyncManager (never worked correctly)
- Poll GetOrderStatus to get actual avgPrice, executedQty, and commission
- Get entry price from exchange GetPositions API when closing positions
- Pass fee to trader_positions table on close
- Move TraderStats type to position.go
2025-12-08 12:15:41 +08:00
tinkle-community f39fc8af23 fix: save raw AI response for debugging and require calculated numbers
- Add RawResponse field to FullDecision and DecisionRecord
- Save raw AI response to database for debugging parse failures
- Add IMPORTANT note in prompt: all numeric values must be calculated numbers, not formulas
2025-12-08 11:29:31 +08:00
tinkle-community 10047577e1 fix: improve UI state updates after form submissions
- StrategyStudioPage: auto-select new strategy after creation, clear selection after deletion
- ModelConfigModal: add loading state and async onSave handling
- ExchangeConfigModal: add loading state to prevent duplicate submissions
2025-12-08 11:21:09 +08:00
tinkle-community 4a0f56f1ee refactor: remove database pre-population and add i18n strategy templates
- Remove initDefaultData() for exchanges, ai_models, strategies tables
- Change supported exchanges/models API to return static lists
- Add GetDefaultStrategyConfig(lang) with Chinese/English prompt templates
- Frontend passes language parameter when creating new strategy
2025-12-08 02:37:29 +08:00
tinkle-community d780c2a988 refactor: simplify log format 2025-12-08 02:13:58 +08:00
tinkle-community a12c0ae8c9 refactor: standardize code comments 2025-12-08 01:43:22 +08:00
tinkle-community 0636ced476 feat: improve trading UI with interactive position table and chart tabs
- Add clickable position rows that scroll to chart and update symbol
- Add framer-motion animations to chart tab transitions
- Sync exchange selection between positions and TradingView chart
- Optimize position table layout with compact styling
- Update CSS with glass effects and premium button styles
2025-12-08 00:34:49 +08:00
tinkle-community 2334d78e4a refactor: simplify config and remove unused database tables
- Remove system_config, beta_codes, signal_source tables and related code
- Simplify config.go to only read from .env (APIServerPort, JWTSecret, RegistrationEnabled)
- Remove GetCustomCoins, use all USDT perpetual contracts for WSMonitor
- Add trader_equity_snapshots table for equity tracking
- Remove signal source modal from frontend AITradersPage
- Fix WSMonitor nil panic by restoring initialization in main.go
2025-12-07 20:17:03 +08:00
tinkle-community 07ac8e4ecd fix: use http.DefaultClient for OKX trader
- Use http.DefaultClient instead of custom client, consistent with Binance/Bybit SDKs
- Remove unnecessary noProxyFunc and net/url import
- All exchanges now use the same HTTP client behavior
2025-12-07 18:52:42 +08:00
tinkle-community bee4e5dd41 fix: add OKX support to order/position sync and fix WebSocket concurrent write
- Add OKX trader support in order_sync.go and position_sync.go
- Change exchange.Type to exchange.ID for correct exchange identification
- Add writeMu mutex to prevent concurrent WebSocket writes in combined_streams.go and websocket_client.go
2025-12-07 17:13:17 +08:00
tinkle-community a1211153ee fix: Bybit order quantity precision and position fields
- Get qtyStep from Bybit API for each symbol and cache it
- Format quantity based on actual qtyStep (e.g., BEATUSDT requires integers)
- Add missing fields to GetPositions: markPrice, unRealizedProfit, liquidationPrice
- Fix panic in buildTradingContext due to nil interface conversion
2025-12-07 15:17:46 +08:00
tinkle-community 7bd5ca0a55 fix: improve frontend UX and fix OKX close position
Frontend improvements:
- Replace window.location.reload() with SWR mutate() for data refresh
- Replace native alert/confirm with toast notifications (confirmToast, notify)
- Add loading skeletons to AITradersPage and EquityChart
- Fix flash of empty state during initial load
OKX fixes:
- Fix proxy issue in Docker by using explicit no-proxy function
- Fix CloseShort sz parameter error - ensure quantity is always positive
- Fix GetPositions to return absolute value for positionAmt
2025-12-06 19:57:13 +08:00
tinkle-community a77c54dbef feat: add one-click close position for all exchanges
- Add handleClosePosition API endpoint in server.go
- Add closePosition API function in frontend
- Add close position button to positions table in App.tsx and TraderDashboard.tsx
- Fix GetFullConfig to include passphrase field for OKX
- Fix OKX CloseLong/CloseShort to use position quantity directly (already in contracts)
2025-12-06 19:16:37 +08:00
tinkle-community 5e5be347ad feat: auto-restart traders on system startup
- Add AutoStartRunningTraders method to TraderManager
- Automatically restore traders marked as running in database
- Call auto-start after loading traders from store on startup
2025-12-06 18:21:12 +08:00
tinkle-community 1e5ece947c Feature/okx trading (#1177)
* feat: add OKX exchange trading support
- Add OKX trader client with full trading API integration
- Support API Key, Secret Key, and Passphrase authentication
- Add OKX icon and frontend configuration modal
- Update exchange store and types for OKX fields
* fix: add passphrase column migration and fix exchange type mapping
* fix: show OKX input fields in exchange config modal
* fix: ensure all supported exchanges exist for user when listing
* fix: simplify exchange type check condition for OKX
* debug: add visible debug info for exchange id
* fix: remove debug info from exchange config modal
* fix: add OKX to exchange type condition in AITradersPage
* feat: complete OKX trading support and fix exchange config issues
- Add LIGHTER exchange UI support in AITradersPage
- Add passphrase field to UpdateExchangeConfigRequest type
- Fix OKX HTTP client to bypass proxy (disable system proxy)
- Auto-fetch initial balance from exchange when not set
- Support multiple balance field names for different exchanges
- Add detailed error messages when trader fails to load
- Add lighter_api_key_private_key field to exchange store
2025-12-06 18:04:59 +08:00
tinkle-community 5d1d0b6842 Feature/custom strategy (#1173)
* feat: add Strategy Studio with multi-timeframe support
- Add Strategy Studio page with three-column layout for strategy management
- Support multi-timeframe K-line data selection (5m, 15m, 1h, 4h, etc.)
- Add GetWithTimeframes() function in market package for fetching multiple timeframes
- Add TimeframeSeriesData struct for storing per-timeframe technical indicators
- Update formatMarketData() to display all selected timeframes in AI prompt
- Add strategy API endpoints for CRUD operations and test run
- Integrate real AI test runs with configured AI models
- Support custom AI500 and OI Top API URLs from strategy config
* docs: add Strategy Studio screenshot to README files
* feat: add quant data integration and fix position click navigation
- Integrate quant data API (netflow, OI, price changes) into Strategy Studio
- Add enable_quant_data toggle in indicator editor
- Fix position symbol click to navigate to chart (sync defaultSymbol prop)
- Fix TradingView chart fullscreen flickering
2025-12-06 07:47:03 +08:00
tinkle-community 5cff32e4f2 Feature/custom strategy (#1172)
* feat: add Strategy Studio with multi-timeframe support
- Add Strategy Studio page with three-column layout for strategy management
- Support multi-timeframe K-line data selection (5m, 15m, 1h, 4h, etc.)
- Add GetWithTimeframes() function in market package for fetching multiple timeframes
- Add TimeframeSeriesData struct for storing per-timeframe technical indicators
- Update formatMarketData() to display all selected timeframes in AI prompt
- Add strategy API endpoints for CRUD operations and test run
- Integrate real AI test runs with configured AI models
- Support custom AI500 and OI Top API URLs from strategy config
* docs: add Strategy Studio screenshot to README files
* fix: correct strategy-studio.png filename case in README
* refactor: remove legacy signal source config and simplify trader creation
- Remove signal source configuration from traders page (now handled by strategy)
- Remove advanced options (legacy config) from TraderConfigModal
- Rename default strategy to "默认山寨策略" with AI500 coin pool URL
- Delete SignalSourceModal and SignalSourceWarning components
- Clean up related stores, hooks, and page components
2025-12-06 07:20:11 +08:00
tinkle-community afb2d158ac feat: add exchange_id field to trader_positions table
- Add exchange_id column to track which exchange the position is from
- Update all SELECT/INSERT queries to include exchange_id
- Set exchange_id when creating position record in AutoTrader
- Add migration to add column to existing tables
2025-12-06 01:35:26 +08:00
tinkle-community f116d80cda fix: use exchange.ID instead of exchange.Type in PositionSyncManager
exchange.Type is cex/dex category, exchange.ID is the actual exchange name (binance/bybit/etc)
2025-12-06 01:28:43 +08:00
tinkle-community 09fab18494 update 2025-12-06 01:06:49 +08:00
tinkle-community f4ece051e7 Refactor/trading actions (#1169)
* refactor: 简化交易动作,移除 update_stop_loss/update_take_profit/partial_close
- 移除 Decision 结构体中的 NewStopLoss, NewTakeProfit, ClosePercentage 字段
- 删除 executeUpdateStopLossWithRecord, executeUpdateTakeProfitWithRecord, executePartialCloseWithRecord 函数
- 简化 logger 中的 partial_close 聚合逻辑
- 更新 AI prompt 和验证逻辑,只保留 6 个核心动作
- 清理相关测试代码
保留的交易动作: open_long, open_short, close_long, close_short, hold, wait
* refactor: 移除 AI学习与反思 模块
- 删除前端 AILearning.tsx 组件和相关引用
- 删除后端 /performance API 接口
- 删除 logger 中 AnalyzePerformance、calculateSharpeRatio 等函数
- 删除 PerformanceAnalysis、TradeOutcome、SymbolPerformance 等结构体
- 删除 Context 中的 Performance 字段
- 移除 AI prompt 中夏普比率自我进化相关内容
- 清理 i18n 翻译文件中的相关条目
该模块基于磁盘存储计算,经常出错,做减法移除
* refactor: 将数据库操作统一迁移到 store 包
- 新增 store/ 包,统一管理所有数据库操作
  - store.go: 主 Store 结构,懒加载各子模块
  - user.go, ai_model.go, exchange.go, trader.go 等子模块
  - 支持加密/解密函数注入 (SetCryptoFuncs)
- 更新 main.go 使用 store.New() 替代 config.NewDatabase()
- 更新 api/server.go 使用 *store.Store 替代 *config.Database
- 更新 manager/trader_manager.go:
  - 新增 LoadTradersFromStore, LoadUserTradersFromStore 方法
  - 删除旧版 LoadUserTraders, LoadTraderByID, loadSingleTrader 等方法
  - 移除 nofx/config 依赖
- 删除 config/database.go 和 config/database_test.go
- 更新 api/server_test.go 使用 store.Trader 类型
- 清理 logger/ 包中未使用的 telegram 相关代码
* refactor: unify encryption key management via .env
- Remove redundant EncryptionManager and SecureStorage
- Simplify CryptoService to load keys from environment variables only
  - RSA_PRIVATE_KEY: RSA private key for client-server encryption
  - DATA_ENCRYPTION_KEY: AES-256 key for database encryption
  - JWT_SECRET: JWT signing key for authentication
- Update start.sh to auto-generate missing keys on first run
- Remove secrets/ directory and file-based key storage
- Delete obsolete encryption setup scripts
- Update .env.example with all required keys
* refactor: unify logger usage across mcp package
- Add MCPLogger adapter in logger package to implement mcp.Logger interface
- Update mcp/config.go to use global logger by default
- Remove redundant defaultLogger from mcp/logger.go
- Keep noopLogger for testing purposes
* chore: remove leftover test RSA key file
* chore: remove unused bootstrap package
* refactor: unify logging to use logger package instead of fmt/log
- Replace all fmt.Print/log.Print calls with logger package
- Add auto-initialization in logger package init() for test compatibility
- Update main.go to initialize logger at startup
- Migrate all packages: api, backtest, config, decision, manager, market, store, trader
* refactor: rename database file from config.db to data.db
- Update main.go, start.sh, docker-compose.yml
- Update migration script and documentation
- Update .gitignore and translations
* fix: add RSA_PRIVATE_KEY to docker-compose environment
* fix: add registration_enabled to /api/config response
* fix: Fix navigation between login and register pages
Use window.location.href instead of react-router's navigate() to fix
the issue where URL changes but the page doesn't reload due to App.tsx
using custom route state management.
* fix: Switch SQLite from WAL to DELETE mode for Docker compatibility
WAL mode causes data sync issues with Docker bind mounts on macOS due
to incompatible file locking mechanisms between the container and host.
DELETE mode (traditional journaling) ensures data is written directly
to the main database file.
* refactor: Remove default user from database initialization
The default user was a legacy placeholder that is no longer needed now
that proper user registration is in place.
* feat: Add order tracking system with centralized status sync
- Add trader_orders table for tracking all order lifecycle
- Implement GetOrderStatus interface for all exchanges (Binance, Bybit, Hyperliquid, Aster, Lighter)
- Create OrderSyncManager for centralized order status polling
- Add trading statistics (Sharpe ratio, win rate, profit factor) to AI context
- Include recent completed orders in AI decision input
- Remove per-order goroutine polling in favor of global sync manager
* feat: Add TradingView K-line chart to dashboard
- Create TradingViewChart component with exchange/symbol selectors
- Support Binance, Bybit, OKX, Coinbase, Kraken, KuCoin exchanges
- Add popular symbols quick selection
- Support multiple timeframes (1m to 1W)
- Add fullscreen mode
- Integrate with Dashboard page below equity chart
- Add i18n translations for zh/en
* refactor: Replace separate charts with tabbed ChartTabs component
- Create ChartTabs component with tab switching between equity curve and K-line
- Add embedded mode support for EquityChart and TradingViewChart
- User can now switch between account equity and market chart in same area
* fix: Use ChartTabs in App.tsx and fix embedded mode in EquityChart
- Replace EquityChart with ChartTabs in App.tsx (the actual dashboard renderer)
- Fix EquityChart embedded mode for error and empty data states
- Rename interval state to timeInterval to avoid shadowing window.setInterval
- Add debug logging to ChartTabs component
* feat: Add position tracking system for accurate trade history
- Add trader_positions table to track complete open/close trades
- Add PositionSyncManager to detect manual closes via polling
- Record position on open, update on close with PnL calculation
- Use positions table for trading stats and recent trades (replacing orders table)
- Fix TradingView chart symbol format (add .P suffix for futures)
- Fix DecisionCard wait/hold action color (gray instead of red)
- Auto-append USDT suffix for custom symbol input
* update
---------
2025-12-06 01:04:26 +08:00
SkywalkerJi 010676c591 fix: Fix Deepseek compatibility issues on the official website. (#1166)
* fix: Compatible with the HTTP2 stream transmission bug on DeepSeek's official website endpoint.
* fix: Remove reasoning from JSON
2025-12-04 19:19:48 +08:00
tinkle-community 1dab5ef2ee Revert "feat: 添加 OKX 交易所支持 (#1150)"
This reverts commit 174f59b90721572dcdd03a9527fa86a48395018c.
2025-12-03 11:31:50 +08:00