1、重写
This commit is contained in:
@ -218,26 +218,16 @@ func handleTickerMessage(msg []byte) {
|
||||
tradeSet.LowPrice = utility.StringFloat64Cut(dataMap["l"].(string), int32(tradeSet.PriceDigit))
|
||||
tradeSet.Volume = utility.StringFloat64Cut(dataMap["v"].(string), int32(tradeSet.AmountDigit))
|
||||
tradeSet.QuoteVolume = utility.StringFloat64Cut(dataMap["q"].(string), 5)
|
||||
hasData := false
|
||||
|
||||
for index := range pairs {
|
||||
if symbol, ok := pairs[index]["symbol"].(string); ok {
|
||||
if symbol == symbolName {
|
||||
hasData = true
|
||||
pairs[index]["price"] = tradeSet.LastPrice
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !hasData {
|
||||
pairs = append(pairs, map[string]interface{}{
|
||||
"symbol": symbolName,
|
||||
"price": tradeSet.LastPrice,
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
trades = append(trades, tradeSet)
|
||||
tcVal, _ = sonic.MarshalString(&tradeSet)
|
||||
|
||||
@ -251,35 +241,11 @@ func handleTickerMessage(msg []byte) {
|
||||
//判断触发现货下单
|
||||
if len(trades) > 0 {
|
||||
for index := range trades {
|
||||
if wsBin.WorkType == "normal" {
|
||||
// 主单触发
|
||||
utility.SafeGoParam(binanceservice.JudgeSpotPrice, trades[index])
|
||||
// 主单触发
|
||||
utility.SafeGoParam(binanceservice.JudgeSpotPrice, trades[index])
|
||||
|
||||
// 止损单
|
||||
utility.SafeGoParam(binanceservice.JudgeSpotStopLoss, trades[index])
|
||||
|
||||
// 触发加仓
|
||||
utility.SafeGoParam(binanceservice.JudgeSpotAddPosition, trades[index])
|
||||
|
||||
// 对冲平仓
|
||||
utility.SafeGoParam(binanceservice.JudgeSpotHedgeClosePosition, trades[index])
|
||||
// 保险对冲
|
||||
utility.SafeGoParam(binanceservice.JudgeSpotProtectHedge, trades[index])
|
||||
} else {
|
||||
//todo
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if wsBin.WorkType == "normal" {
|
||||
if len(pairs) > 0 {
|
||||
pairsVal, _ = sonic.MarshalString(&pairs)
|
||||
|
||||
if pairsVal != "" {
|
||||
if err := helper.DefaultRedis.SetString(rediskey.SpotSymbolTicker, pairsVal); err != nil {
|
||||
log.Error("redis保存", rediskey.SpotSymbolTicker, "失败,", pairs)
|
||||
}
|
||||
}
|
||||
// 止损单
|
||||
// utility.SafeGoParam(binanceservice.JudgeSpotStopLoss, trades[index])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user