forked from hurisheng/go-futu-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrd_getmaxtrdqtys.go
47 lines (43 loc) · 1.27 KB
/
trd_getmaxtrdqtys.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
44
45
46
47
package futuapi
import (
"context"
"github.com/headshot289/go-futu-api/pb/trdcommon"
"github.com/headshot289/go-futu-api/pb/trdgetmaxtrdqtys"
"github.com/headshot289/go-futu-api/protocol"
)
const (
ProtoIDTrdGetMaxTrdQtys = 2111 //Trd_GetMaxTrdQtys 获取最大交易数量
)
// 查询最大可买可卖
func (api *FutuAPI) GetMaxTrdQtys(ctx context.Context, header *TrdHeader, orderType trdcommon.OrderType, code string, price float64,
orderID uint64, adjust bool, sideAndLimit float64, secMarket trdcommon.TrdSecMarket) (*MaxTrdQtys, error) {
req := trdgetmaxtrdqtys.Request{
C2S: &trdgetmaxtrdqtys.C2S{
Header: header.pb(),
OrderType: (*int32)(&orderType),
Code: &code,
Price: &price,
AdjustPrice: &adjust,
AdjustSideAndLimit: &sideAndLimit,
},
}
if orderID != 0 {
req.C2S.OrderID = &orderID
}
if secMarket != 0 {
req.C2S.SecMarket = (*int32)(&secMarket)
}
ch := make(trdgetmaxtrdqtys.ResponseChan)
if err := api.get(ProtoIDTrdGetMaxTrdQtys, &req, ch); err != nil {
return nil, err
}
select {
case <-ctx.Done():
return nil, ErrInterrupted
case resp, ok := <-ch:
if !ok {
return nil, ErrChannelClosed
}
return maxTrdQtysFromPB(resp.GetS2C().GetMaxTrdQtys()), protocol.Error(resp)
}
}