-
Notifications
You must be signed in to change notification settings - Fork 36
/
qot_requestrehab.go
43 lines (37 loc) · 1.03 KB
/
qot_requestrehab.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package futuapi
import (
"context"
"github.com/hurisheng/go-futu-api/pb/qotcommon"
"github.com/hurisheng/go-futu-api/pb/qotrequestrehab"
"github.com/hurisheng/go-futu-api/protocol"
)
const ProtoIDQotRequestRehab = 3105 //Qot_RequestRehab 在线获取单只股票复权信息
func init() {
workers[ProtoIDQotRequestRehab] = protocol.NewGetter()
}
// 获取复权因子
func (api *FutuAPI) GetRehab(ctx context.Context, security *qotcommon.Security) ([]*qotcommon.Rehab, error) {
if security == nil {
return nil, ErrParameters
}
// 请求参数
req := &qotrequestrehab.Request{
C2S: &qotrequestrehab.C2S{
Security: security,
},
}
// 发送请求,同步返回结果
ch := make(chan *qotrequestrehab.Response)
if err := api.proto.RegisterGet(ProtoIDQotRequestRehab, req, protocol.NewProtobufChan(ch)); err != nil {
return nil, err
}
select {
case <-ctx.Done():
return nil, ErrInterrupted
case resp, ok := <-ch:
if !ok {
return nil, ErrChannelClosed
}
return resp.GetS2C().GetRehabList(), protocol.Error(resp)
}
}