-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathqot_getipolist.go
42 lines (36 loc) · 1.02 KB
/
qot_getipolist.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
package futuapi
import (
"context"
"github.com/hurisheng/go-futu-api/pb/qotcommon"
"github.com/hurisheng/go-futu-api/pb/qotgetipolist"
"github.com/hurisheng/go-futu-api/protocol"
"google.golang.org/protobuf/proto"
)
const ProtoIDQotGetIpoList = 3217 //Qot_GetIpoList 获取新股
func init() {
workers[ProtoIDQotGetIpoList] = protocol.NewGetter()
}
// 获取 IPO 信息
func (api *FutuAPI) GetIPOList(ctx context.Context, market qotcommon.QotMarket) ([]*qotgetipolist.IpoData, error) {
if market == qotcommon.QotMarket_QotMarket_Unknown {
return nil, ErrParameters
}
req := &qotgetipolist.Request{
C2S: &qotgetipolist.C2S{
Market: proto.Int32(int32(market)),
},
}
ch := make(chan *qotgetipolist.Response)
if err := api.proto.RegisterGet(ProtoIDQotGetIpoList, 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().GetIpoList(), protocol.Error(resp)
}
}