1、波段触发修改

This commit is contained in:
2025-04-21 17:32:57 +08:00
parent 79af1ab2c1
commit 44ba8bfbf1
11 changed files with 314 additions and 71 deletions

View File

@ -66,9 +66,11 @@ func GetConfigCacheByKey(db *gorm.DB, key string) models.SysConfig {
// 获取缓存交易对
// symbolType 0-现货 1-合约
func GetTradeSet(exchangeType string, symbol string, symbolType int) (models2.TradeSet, error) {
// 定义返回结果和val变量
result := models2.TradeSet{}
val := ""
// 根据交易对类型选择不同的key
switch symbolType {
case 0:
key := fmt.Sprintf(global.TICKER_SPOT, exchangeType, symbol)
@ -78,14 +80,17 @@ func GetTradeSet(exchangeType string, symbol string, symbolType int) (models2.Tr
val, _ = helper.DefaultRedis.GetString(key)
}
// 如果val不为空则解析val为TradeSet结构体
if val != "" {
if err := sonic.Unmarshal([]byte(val), &result); err != nil {
return result, err
}
} else {
// 如果val为空则返回错误信息
return result, errors.New("未找到交易对信息")
}
// 返回结果
return result, nil
}