1、反向下单初始化

This commit is contained in:
2025-06-17 14:09:37 +08:00
parent e943a47121
commit 3013486dd4
14 changed files with 1042 additions and 0 deletions

View File

@ -0,0 +1,15 @@
package binanceservice
import "github.com/go-admin-team/go-admin-core/sdk/service"
type BinanceReverseFuturesService struct {
service.Service
}
//
func (e *BinanceReverseFuturesService) DoReverse() error {
apiInfo, ok := ShouldReverse(apiKey)
//TODO: 实现反向开仓逻辑
return nil
}

View File

@ -0,0 +1,12 @@
package binanceservice
import "github.com/go-admin-team/go-admin-core/sdk/service"
type BinanceReverseSpotService struct {
service.Service
}
// JudgeApiUser 判断是否需要
func (e *BinanceReverseSpotService) JudgeApiUser() bool {
return false
}

View File

@ -0,0 +1,16 @@
package binanceservice
import DbModels "go-admin/app/admin/models"
// ShouldReverse 判断是否需要反单
// return apiInfo, bool
func ShouldReverse(apiKey string) (DbModels.LineApiUser, bool) {
// TODO: 实现判断是否需要反单的逻辑
apiInfo := GetApiInfoByKey(apiKey)
if apiInfo.ReverseStatus == 1 && apiInfo.ReverseApiId > 0 {
return apiInfo, true
}
return DbModels.LineApiUser{}, false
}

View File

@ -467,6 +467,21 @@ func GetApiInfo(apiId int) (DbModels.LineApiUser, error) {
return api, nil
}
// GetReverseApiInfo 根据apiKey获取api用户信息
func GetApiInfoByKey(apiKey string) DbModels.LineApiUser {
result := DbModels.LineApiUser{}
keys, _ := helper.DefaultRedis.GetAllKeysAndValues(fmt.Sprintf(rediskey.API_USER, "*"))
for _, key := range keys {
if strings.Contains(key, apiKey) {
sonic.UnmarshalString(key, &result)
break
}
}
return result
}
/*
根据A账户获取B账号信息
*/