feat(hook): Add hook module to help decouple some specific logic (#784)

This commit is contained in:
Shui
2025-11-08 20:02:30 -05:00
committed by GitHub
parent 52b0bfe1d2
commit 631fb62d21
12 changed files with 466 additions and 35 deletions

View File

@@ -6,6 +6,7 @@ import (
"encoding/hex"
"fmt"
"log"
"nofx/hook"
"strconv"
"strings"
"sync"
@@ -61,8 +62,14 @@ type FuturesTrader struct {
}
// NewFuturesTrader 创建合约交易器
func NewFuturesTrader(apiKey, secretKey string) *FuturesTrader {
func NewFuturesTrader(apiKey, secretKey string, userId string) *FuturesTrader {
client := futures.NewClient(apiKey, secretKey)
hookRes := hook.HookExec[hook.NewBinanceTraderResult](hook.NEW_BINANCE_TRADER, userId, client)
if hookRes != nil && hookRes.GetResult() != nil {
client = hookRes.GetResult()
}
// 同步时间,避免 Timestamp ahead 错误
syncBinanceServerTime(client)
trader := &FuturesTrader{