Get chagnes to GetCandles

This commit is contained in:
zhangkun9038@dingtalk.com 2025-03-05 22:21:00 +08:00
parent bd0154310b
commit bd2354b81e

View File

@ -44,18 +44,51 @@ type RESTAPIResult struct {
TotalUsedTime time.Duration `json:"totalUsedTime"`
}
// ResponseData 定义统一的响应数据接口
type ResponseData interface {
GetCode() string
GetMsg() string
GetData() interface{}
}
type Okexv5APIResponse struct {
Code string `json:"code"`
Msg string `json:"msg"`
Data interface{} `json:"data"`
}
type CandleData struct {
// 实现 ResponseData 接口
func (r Okexv5APIResponse) GetCode() string {
return r.Code
}
func (r Okexv5APIResponse) GetMsg() string {
return r.Msg
}
func (r Okexv5APIResponse) GetData() interface{} {
return r.Data
}
type CandleDataResponse struct {
Code string `json:"code"`
Msg string `json:"msg"`
Data [][]interface{} `json:"data"` // 用二维数组来接收 candles 数据
}
// 实现 ResponseData 接口
func (r CandleDataResponse) GetCode() string {
return r.Code
}
func (r CandleDataResponse) GetMsg() string {
return r.Msg
}
func (r CandleDataResponse) GetData() interface{} {
return r.Data
}
/*
endPoint:请求地址
apiKey
@ -153,11 +186,16 @@ func (this *RESTAPI) Post(ctx context.Context, uri string, param *map[string]int
return this.Run(ctx)
}
func (this *RESTAPI) Run(ctx context.Context) (res *RESTAPIResult, err error) {
func (this *RESTAPI) Run(ctx context.Context) (ResponseData, error) {
var res *RESTAPIResult
var err error
if this.ApiKeyInfo == nil {
err = errors.New("APIKey不可为空")
return
if err != nil {
return nil, err
}
return res.V5Response, nil
}
procStart := time.Now()