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>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
c0cafb0400
commit
f97ac16b1c
@@ -111,6 +111,13 @@ func (d *DB) SetTradeStatus(id int64, status string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// UpdateTradeEntry updates entry-related fields on an existing trade (prices, exchanges, spread).
|
||||
func (d *DB) UpdateTradeEntry(id int64, t *TradeRecord) error {
|
||||
_, err := d.Exec(`UPDATE trades SET long_entry=?, short_entry=?, long_exchange=?, short_exchange=?, entry_spread=? WHERE id=?`,
|
||||
t.LongEntry, t.ShortEntry, t.LongExchange, t.ShortExchange, t.EntrySpread, id)
|
||||
return err
|
||||
}
|
||||
|
||||
// GetOpenTrades returns all non-closed trades (status='open' or status='entering').
|
||||
func (d *DB) GetOpenTrades() ([]TradeRecord, error) {
|
||||
rows, err := d.Query(`SELECT id, coin, direction, status, entry_spread, exit_spread,
|
||||
|
||||
Reference in New Issue
Block a user