jackyu66git and Claude Opus 4.6
559d7bb870
feat: 趋势过滤信号记录系统 + 实时涨跌方向判断
...
- 新增 TrendFilter 信号记录(enter/exit),按完整信号和高分信号两档分类
- 信号持久化到 data/trend_signals_cache.json,开机自动恢复
- 新增 /api/trend-signals API + SSE trend_signal 实时广播
- 前端新增完整信号卡片和高分信号卡片,移除旧趋势检测卡片
- 评分加入 1h 涨跌方向和实时 drift 惩罚,下跌币不触发信号
- OKX 交易所支持(累积变动、动量、趋势检测)
- 修复 trend_filter.go 编译错误
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com >
2026-05-06 22:24:59 +08:00
jackyu66git and Claude Opus 4.6
73dac50a36
chore: 清理git跟踪的node_modules + 添加node_modules/.DS_Store到gitignore
...
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com >
2026-05-06 13:29:36 +08:00
jackyu66git and Claude Opus 4.6
b7767c95ae
feat: 添加OKX行情接入+趋势检测+累积变动系统+界面重构
...
- 新增OKX WebSocket行情连接器,扩展4交易所价格监控
- 新增z-score趋势检测引擎(TrendDetector),识别价格异动/趋势启动
- 新增累积变动跟踪(CumulativeTracker),基于1min/5min多交易所共识
- 趋势事件和累积变动事件持久化到SQLite
- 新增Binance/OKX动量检测字段,扩展前端动量卡片至15列
- 迁移至macOS(darwin-arm64),更新前端依赖
- Dashboard网格重构:非交易卡片置顶,交易卡片置底
- TrackedCoin添加OK字段,添加ExBinance/ExOKX常量
- 前端新增趋势检测卡片、趋势历史卡片、累积变动卡片
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com >
2026-05-06 13:26:05 +08:00
jackyu66git and Claude Opus 4.7
047571921e
fix: 重启时查交易所验证持仓是否存在,幽灵仓位自动标记 closed
...
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com >
2026-05-05 03:23:44 +08:00
jackyu66git and Claude 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
jackyu66git and Claude 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
c0cafb0400
fix: BG 22002视为已平仓不重试 + 删除STBL
...
- closeLeg: 22002(暂无仓位可平)→ 标记已平仓,不报错不重试
- closeLeg: 新增holdSide参数传给BG API
- scanner.go: 删除STBL币对
2026-05-05 01:09:52 +08:00
jackyu66git
d7405a5f33
fix: 删除STBL, 撤回22002错误修正(22002是Passphrase认证问题)
...
- 删除 scanner.go 中的 STBL
- 撤回 22002 的'已平仓'处理(该码是API认证错误)
- 保持 closeLeg 报错原样输出
2026-05-05 01:03:17 +08:00
jackyu66git
fd777e6fe0
fix: Bitget 平仓必须传 holdSide 参数
...
- PlaceMarketOrder 新增 holdSide 参数
- 平仓时(closeLeg)根据 leg.Side 传 holdSide="long"/"short"
- 开仓传空字符串,不受影响
- 修复 BG 持续 'No position to close' (22002) 问题
2026-05-05 00:46:49 +08:00
jackyu66git
d01a261828
fix: 删除零成交误判逻辑 + 各种稳定性修复
...
- 删除: Bitget GetTradeFee 零成交检查(PlaceMarketOrder 成功即成交)
- 修复: GetTradeFee 加 1s 延迟 + 查不到返回 0(用配置估算费兜底)
- 修复: HL InitExchange 在 NewTrader 中提前调用,避免 szDecimals 延迟
- 修复: close_failed 30 次重试上限,超限标记 failed 并清理
- 修复: DB 恢复时校验 Legs 完整性,跳过非法记录
- 修复: checkScaleIn/checkExit nil guard 防 panic
- 修复: config.go 参数调整(手续费、阈值等)
- 移除: scanner.go 中 MEW/USTC 等低流动性币对
- 添加: 更详细的下单日志(szStr、amountUSD、price)
- 添加: bin/ 到 .gitignore
2026-05-05 00:41:39 +08:00
jackyu66git
866f9906b7
fix: HL market order double slippage causing 'Order has invalid size'
...
Root cause: PlaceMarketOrder manually calculated limitPx=mid*0.5 (sell)
then passed &limitPx to SDK's MarketOpen. SDK treated this as reference
price and applied slippage AGAIN (0.95x), resulting in limitPx=mid*0.475.
Notional value fell below HL's 0 minimum → error.
Fix: pass nil instead of &limitPx, letting SDK get mid price and
apply standard 5% slippage itself.
2026-05-04 23:35:44 +08:00
jackyu66git
ce204abc81
fix: remove HL-delisted coins from scanner (BNT/CATI/CYBER/ILV/LISTA/OGN/STG) + PIXEL
...
Root cause: HL WS uses allMids (all coins), BG WS subscribes per-coin.
Delisted coins had stale HL prices showing huge fake spreads (~200%).
Monitor tried entry → BG buy succeeds, HL sell fails (Trading is halted)
→ orphan position on BG accumulated across restarts.
Fix:
- Set HL="" for BNT, CATI, CYBER, ILV, LISTA, OGN, STG, PIXEL
- Add guard in ScanBGHL to skip coins where BG or HL is empty
- Same guard in SpreadWindowTracker.Tick
2026-05-04 23:12:41 +08:00
jackyu66git
c04d8ca0da
fix: 修正注释位置 && 清理废弃的 GetHLSize
2026-05-04 22:52:45 +08:00
jackyu66git
9d942e9dee
fix: HL size 动态格式化(从 Meta 取 szDecimals)
...
- 新增 HyperLiquidTrade.GetSize(),从 HL Meta.Universe 获取
每个币的 SzDecimals 运行时格式化订单数量
- 替代硬编码的 exchange.GetHLSize() switch case
- trader.go 中 placeOrder/placeOrderAt 两处调用切换为新方法
- 新增 TryEntry 价格<=0 检查,过滤异常数据
2026-05-04 22:50:24 +08:00
jackyu66git
292669fb0d
fix: 手动平仓持久化PnL到DB
...
ClosePosition/CloseAllPositions 之前只调 closeBothLegs 关交易所仓位
后直接 delete(t.positions),没有写DB/记PnL/入 closedTrades,
重启后交易数据丢失。
- 新增 finalizeClosedPosition() 共享方法:
统一处理 PnL计算、exchangeFunds更新、DB持久化(exit orders +
UpdateTradeStatus)、closedTrades追加、SSE推事件
- ClosePosition/CloseAllPositions 改用该方法
- 手动平仓用入场均价的出场价格,PnL=0,
原因标记为'手动平仓'/'全部平仓'
- 同时增加 closeBothLegs 失败的处理(之前直接忽略)
2026-05-04 22:32:42 +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
4b009124d1
fix: revert dashboard bind to :8888 (external access), keep CLI IPC for control
2026-05-04 20:36:44 +08:00
jackyu66git
8ccb439f7a
refactor: replace REST API with Unix socket IPC + CLI subcommands
...
- Remove insecure HTTP API endpoints (positions, close, close-all, pnl)
- Add Unix socket IPC at /tmp/exchange-monitor.sock
- Add CLI subcommands: status, close-all, close <COIN>, stop, start
- Bind dashboard HTTP to 127.0.0.1:8888 (localhost only)
2026-05-04 20:34:00 +08:00
jackyu66git
88462f9829
feat: add API endpoints for positions, close, close-all, pnl, plus DB persistence before goroutine
2026-05-04 20:28:52 +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
411365b66e
fix: correct HL fee parsing (OrderStatus not statuses[]) and add productType to BG fills query
2026-05-04 20:06:27 +08:00
jackyu66git
6e9b982c66
config: lower threshold 0.10->0.05, arb 0.03->0.02, amount 0->0
2026-05-04 19:31:08 +08:00
jackyu66git
19443c132a
cleanup: remove 6 coins unsupported on Bitget testnet (OP, WIF, PYTH, SAND, IOTA, MOVE)
...
These coins return 40034 error on Bitget testnet (Parameter does not exist).
Keeping only 14 confirmed-working coins. Update memory with correct list.
2026-05-04 19:18:58 +08:00
jackyu66git
6baae85eaa
feat: actual exchange fees for entry orders
...
- BitgetTrade: added GetTradeFee() queries /mix/order/fills
- HyperLiquidTrade: added GetTradeFee() parses MarketOpen response
- trader.placeOrder() now returns (errMsg, actualFeeUSD)
- executeEntry uses actual fee from exchange, falls back to estimate
2026-05-04 18:35:33 +08:00
jackyu66git
0b2bfd0b02
chore: remove re-tracked gitignored files
2026-05-04 18:27:44 +08:00
jackyu66git
0aa9923067
fix: full arb table + net profit columns in price view
...
- ArbTable: removed slice(0,10) cap, shows all 42 opps (21x2)
- PriceTable: added net_bg_to_hl and net_hl_to_bg columns
- Backend SSE: sends net profit for both directions per coin
2026-05-04 18:26:49 +08:00
jackyu66git
9628100681
chore: remove tracked files that should be gitignored
2026-05-04 18:06:03 +08:00
jackyu66git
5f6578c179
feat: add 17 new cross-exchange pairs (BG↔HL)
...
Added: ALGO, PYTH, SAND, ADA, HBAR, IOTA, MINA, FET, WLD,
SUI, APT, NEAR, FIL, DYDX, JUP, TIA, MOVE
Removed: pixel and VET (fake 195% spreads on testnet)
Also updated GetHLSize() to handle szDecimals for all new coins.
2026-05-04 18:05:53 +08:00
jackyu66git
dd26152c2b
chore: clean tracked ignores (logs, binary, .env, data)
2026-05-04 17:50:46 +08:00
jackyu66git
49da6fd35b
fix: HL balance now reads spot USDC via SpotUserState
...
HL testnet USDC lives in the spot account, not the perp clearinghouse.
GetBalance() was calling UserState() (perp clearinghouseState), which
returned /usr/bin/bash. Switched to SpotUserState() and parse USDC.total - USDC.hold.
Also cleaned up .gitignore to exclude .env, binary, logs, data/.
2026-05-04 17:48:14 +08:00
jackyu66git
156ce22474
feat: HL EVM signing via sonirico/go-hyperliquid SDK - testnet orders work
2026-05-04 16:21:57 +08:00
jackyu66git
24727e4ec4
refactor: HL EVM signing via sonirico/go-hyperliquid SDK
2026-05-04 16:16:21 +08:00
jackyu66git
8b8d4140f9
refactor: HL EVM signing via sonirico/go-hyperliquid SDK
2026-05-04 16:15:51 +08:00
jackyu66git
c5c4c7394f
fix: HL testnet - add API wallet address to signed orders, 3-param constructor
2026-05-04 15:39:31 +08:00
jackyu66git
30436bbe75
fix: BG paper trading API - tradeSide param, correct host, marginMode
2026-05-04 15:28:08 +08:00
jackyu66git
e5ea78ffd2
feat: real trading mode, auto-stop after 5 trades, HL testnet support
...
- config.json: test_mode=false, ready for sim/testnet trading
- trader.go: auto-stop after 5 real trades, exchange response logging,
Stop()/Start() API, shuttingDown flag for graceful stop
- dashboard.go: POST /api/stop + POST /api/start endpoints,
trading status in SSE stats
- exchange/hyperliquid.go: switch HL WS to testnet endpoint
- exchange/hyperliquid_trade.go: switch REST to testnet endpoint,
support base64 + 32-byte EVM private keys
- main.go: listen on trader.StopCh (graceful, no process exit)
- scanner.go: trim TrackedCoins to only 6 core coins (DOGE/LINK/ONDO/OP/WIF/ARB)
- .gitignore: ignore main binary
2026-05-04 14:31:52 +08:00
jackyu66git
5fa3e1bac8
docs: update README for v1.3 — fund management, position click detail, slippage
2026-05-04 13:59:21 +08:00
jackyu66git
f29e78a435
fix: db migration tab char corrupted, restore historical trades
2026-05-04 13:50:49 +08:00
jackyu66git
e74fd084ce
config: raise trade_threshold to 0.20%, mock_slippage to 0.05%
2026-05-04 13:10:22 +08:00
jackyu66git
9eaa4597db
chore: 删除未使用的 SpreadReverseExitPct 配置字段
2026-05-04 06:41:49 +08:00
jackyu66git
ccfa27b1a6
fix: scanner netProfit 漏算exit fees + 孤儿仓位标记failed
...
- scanner.go: netProfit 扣费改为 2*(buyFee+sellFee) 匹配 calcArbPnL
- trader.go: 第二腿失败时设 pos.Status=failed,避免语义混淆
2026-05-04 06:39:24 +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
2f4d03f9b1
优化: 共用一次 store.GetAll() 快照,消除每 tick 两次 map 分配
2026-05-04 06:10:37 +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
7b8ad6abc8
feat: 交易详情净收益总计加美元金额
2026-05-04 05:43:11 +08:00
jackyu66git
af44e14f39
feat: 交易详情订单按交易所+时间排序, 加仓位列, 多空Pnl显示USD金额
2026-05-04 05:38:08 +08:00
jackyu66git
a9a21de5a2
refactor: 逐批次实时写入DB,删除persistTrade
2026-05-04 05:29:04 +08:00
jackyu66git
ec725ed11a
fix: PnL计算改为美元归一化,加仓不再虚增手续费 (calcArbPnL)
2026-05-04 05:03:16 +08:00
jackyu66git
c44d763ab0
fix: 持仓面板 pnl_est 显示改为美元符号(后台已改为USD)
2026-05-04 04:38:52 +08:00
jackyu66git
0288dc8284
feat: 手续费改为逐笔USD累算 + Vite React前端 + system_orders表 + README
2026-05-04 04:34:27 +08:00