-
Notifications
You must be signed in to change notification settings - Fork 2
/
gen_md_api.go
178 lines (138 loc) · 4.12 KB
/
gen_md_api.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
// This file was automatically generated by ctpgen
package ctp
//#include "gen_md_api.h"
import "C"
import "unsafe"
func CThostFtdcMdSpiCValue(ptr CThostFtdcMdSpi) C.mdSpi {
v := storeGoPtr(ptr)
p := C.md_new_spi(C.uint64_t(v))
return p
}
type CThostFtdcMdApi struct {
p C.mdApi
spi C.mdSpi
}
func MdCreateFtdcMdApi(pszFlowPath string, bIsUsingUdp bool, bIsMulticast bool) *CThostFtdcMdApi {
cpszFlowPath := go2cStrPtr(pszFlowPath)
cbIsUsingUdp := go2cBool(bIsUsingUdp)
cbIsMulticast := go2cBool(bIsMulticast)
cRet := C.md_create_ftdc_md_api(cpszFlowPath, cbIsUsingUdp, cbIsMulticast)
ret := new(CThostFtdcMdApi)
ret.p = cRet
return ret
}
func MdGetApiVersion() string {
cRet := C.md_get_api_version()
ret := cPtr2GoStr(cRet)
return ret
}
func (a *CThostFtdcMdApi) Release() {
C.md_release(a.p)
if a.spi != nil {
C.md_spi_free(a.spi)
a.spi = nil
}
}
func (a *CThostFtdcMdApi) Init() {
C.md_init(a.p)
}
func (a *CThostFtdcMdApi) Join() int {
ret := C.md_join(a.p)
return int(ret)
}
func (a *CThostFtdcMdApi) GetTradingDay() string {
ret := C.md_get_trading_day(a.p)
return cPtr2GoStr(ret)
}
func (a *CThostFtdcMdApi) RegisterFront(pszFrontAddress string) {
cpszFrontAddress := go2cStrPtr(pszFrontAddress)
defer func() {
freeCStr(cpszFrontAddress)
}()
C.md_register_front(a.p, cpszFrontAddress)
}
func (a *CThostFtdcMdApi) RegisterNameServer(pszNsAddress string) {
cpszNsAddress := go2cStrPtr(pszNsAddress)
defer func() {
freeCStr(cpszNsAddress)
}()
C.md_register_name_server(a.p, cpszNsAddress)
}
func (a *CThostFtdcMdApi) RegisterFensUserInfo(pFensUserInfo *CThostFtdcFensUserInfoField) {
cpFensUserInfo := CThostFtdcFensUserInfoFieldCValue(pFensUserInfo)
defer func() {
C.free(unsafe.Pointer(cpFensUserInfo))
}()
C.md_register_fens_user_info(a.p, cpFensUserInfo)
}
func (a *CThostFtdcMdApi) RegisterSpi(pSpi CThostFtdcMdSpi) {
cpSpi := CThostFtdcMdSpiCValue(pSpi)
C.md_register_spi(a.p, cpSpi)
if a.spi != nil {
C.md_spi_free(a.spi)
}
a.spi = cpSpi
}
func (a *CThostFtdcMdApi) SubscribeMarketData(strs []string) int {
cStr := go2cStrArray(strs)
nCount := C.int(len(strs))
defer func() {
freeCStrArray(cStr, len(strs))
}()
ret := C.md_subscribe_market_data(a.p, cStr, nCount)
return int(ret)
}
func (a *CThostFtdcMdApi) UnSubscribeMarketData(strs []string) int {
cStr := go2cStrArray(strs)
nCount := C.int(len(strs))
defer func() {
freeCStrArray(cStr, len(strs))
}()
ret := C.md_un_subscribe_market_data(a.p, cStr, nCount)
return int(ret)
}
func (a *CThostFtdcMdApi) SubscribeForQuoteRsp(strs []string) int {
cStr := go2cStrArray(strs)
nCount := C.int(len(strs))
defer func() {
freeCStrArray(cStr, len(strs))
}()
ret := C.md_subscribe_for_quote_rsp(a.p, cStr, nCount)
return int(ret)
}
func (a *CThostFtdcMdApi) UnSubscribeForQuoteRsp(strs []string) int {
cStr := go2cStrArray(strs)
nCount := C.int(len(strs))
defer func() {
freeCStrArray(cStr, len(strs))
}()
ret := C.md_un_subscribe_for_quote_rsp(a.p, cStr, nCount)
return int(ret)
}
func (a *CThostFtdcMdApi) ReqUserLogin(pReqUserLoginField *CThostFtdcReqUserLoginField, nRequestID int) int {
cpReqUserLoginField := CThostFtdcReqUserLoginFieldCValue(pReqUserLoginField)
defer func() {
C.free(unsafe.Pointer(cpReqUserLoginField))
}()
cnRequestID := C.int(nRequestID)
ret := C.md_req_user_login(a.p, cpReqUserLoginField, cnRequestID)
return int(ret)
}
func (a *CThostFtdcMdApi) ReqUserLogout(pUserLogout *CThostFtdcUserLogoutField, nRequestID int) int {
cpUserLogout := CThostFtdcUserLogoutFieldCValue(pUserLogout)
defer func() {
C.free(unsafe.Pointer(cpUserLogout))
}()
cnRequestID := C.int(nRequestID)
ret := C.md_req_user_logout(a.p, cpUserLogout, cnRequestID)
return int(ret)
}
func (a *CThostFtdcMdApi) ReqQryMulticastInstrument(pQryMulticastInstrument *CThostFtdcQryMulticastInstrumentField, nRequestID int) int {
cpQryMulticastInstrument := CThostFtdcQryMulticastInstrumentFieldCValue(pQryMulticastInstrument)
defer func() {
C.free(unsafe.Pointer(cpQryMulticastInstrument))
}()
cnRequestID := C.int(nRequestID)
ret := C.md_req_qry_multicast_instrument(a.p, cpQryMulticastInstrument, cnRequestID)
return int(ret)
}