Commit Graph
11 Commits
Author SHA1 Message Date
jackyu66gitandClaude Opus 4.7 2f4d7869a9 fix: 重启后加仓数据恢复 + scale_count/amount_usd 实时持久化
- restoreOpenPositions 从 orders 表 count 加仓次数,正确设置 ScaleLevels 和 AmountUSD
- 加仓时立即持久化 amount_usd 和 scale_count 到 trades 表(不等到平仓)
- PnL 图表支持单笔交易显示(原点+累计PnL连线)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-05 03:19:26 +08:00
jackyu66gitandClaude Opus 4.7 f97ac16b1c feat: 实际成交价追踪 + reduceOnly保护 + 数据库增强
- Bitget GetTradeFee 返回实际成交均价(weighted avg fill price)及手续费, 支持最多5次重试
- HyperLiquid ParseFillFromResponse 提取订单成交均价, 新增 GetSize/GetBalance 方法
- 开仓/加仓/平仓均从交易所获取实际成交价替代WS估算价
- HL 平仓使用 reduceOnly 防止反向开仓
- 所有 OrderID 保存到数据库 orders 表
- 加仓零成交检测及实际手续费获取
- PnL 计算修正为按USD计算手续费
- 新增 GetAllClosedTrades / GetClosedStats 数据库查询
- 服务器重启 restore 未完成交易修复(DBTradeID 缺失)
- 黑名单强平添加 USD PnL/手续费预计算

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-05 02:59:18 +08:00
jackyu66git 9163d7fd30 切换到实盘环境
- HL: WS/REST 从 testnet 切换到 mainnet
- BG: 删除 paptrading header(实盘 key 不以 bg_ 前缀区分)
- config: 调整交易参数
- scanner: 更新跟踪币种列表
2026-05-04 22:24:30 +08:00
jackyu66git 06a7e37836 fix: persist positions to DB before goroutine so restarts don't lose open trades 2026-05-04 20:16:44 +08:00
jackyu66git f29e78a435 fix: db migration tab char corrupted, restore historical trades 2026-05-04 13:50:49 +08:00
jackyu66git ddaa5badd2 fix: 重启后总PnL回到0的问题 + 前端PnL图表公式统一
- trader.go: NewTrader 启动时从DB GetAllClosedTrades() 加载所有已平仓交易到 closedTrades
- trader.go: 新增 safeFloat/safeStr 辅助函数处理DB空指针
- db/trade_repo.go: 新增 GetAllClosedTrades() 方法
- frontend: PnL图表标题和曲线改用 2*AmountUSD*NetPnl/100 公式,与后端Stats一致
2026-05-04 06:23:35 +08:00
jackyu66git 5aedcb6566 修复 scale-in 后 leg.EntryPrice 不更新 + 重启恢复时加载 scale prices
- trader.go: scale-in 后用 weightedAvgPrice 更新 LongLeg/ShortLeg.EntryPrice
- trader.go: restoreOpenPositions 从 orders 表加载 scale prices 重建完整价格切片
- db/trade_repo.go: 新增 GetScalePrices(tradeID) 方法
- README: v1.2.1 版本记录
2026-05-04 06:06:37 +08:00
jackyu66git a9a21de5a2 refactor: 逐批次实时写入DB,删除persistTrade 2026-05-04 05:29:04 +08:00
jackyu66git 0288dc8284 feat: 手续费改为逐笔USD累算 + Vite React前端 + system_orders表 + README 2026-05-04 04:34:27 +08:00
jackyu66git 505137bcb0 feat(web): trade detail modal with prices, fees, timestamps
- Click any trade row in history table to open detail modal
- Modal shows 6 sections: 概览, 时间, 价差, 手续费, 多仓, 空仓
- Entries and exits displayed with 6 decimal precision
- Fee entry/exit and total fee displayed
- Open/close timestamps with full date-time format
- Duration, scale count, total amount, exit reason
- Orders sub-table if available
- Escape key and overlay click to close
2026-05-03 18:59:28 +08:00
jackyu66git b09314f317 Phase 1: SQLite persistence layer
- Add modernc.org/sqlite (pure Go, no CGO)
- db/ package: trades, orders, config_log tables + CRUD
- Trade persistence: every closed trade saved to SQLite
- Restart recovery: open positions restored from DB
- Automatic migration on startup
2026-05-03 17:28:08 +08:00