We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
swig 版本必须 >= 3.0以上,最新的4.1; yum install gcc-c++ 安装C++; Go 低版本的 比如: 1.8.7 编译时报错 -std 的问题; 升级 Go版本, 1.10以上未出现问题,1.9不清楚;
# 注释掉如下代码 => 在 example/goctp_md_example.go 中,修改如下: func (p *GoCThostFtdcMdSpi) SubscribeMarketData(symbols []string) { args := make([]*C.char, 0) for _, v := range symbols { symbol := C.CString(v) defer C.free(unsafe.Pointer(symbol)) args = append(args, symbol) } iResult := p.Client.MdApi.SubscribeMarketData((*string)(unsafe.Pointer(&args[0])), len(symbols)) if iResult != 0 { log.Println("发送行情订阅请求: 失败.") } else { log.Println("发送行情订阅请求: 成功.") } } func (p *GoCThostFtdcMdSpi) SubscribeForQuoteRsp(symbols []string) { args := make([]*C.char, 0) for _, v := range symbols { symbol := C.CString(v) defer C.free(unsafe.Pointer(symbol)) args = append(args, symbol) } iResult := p.Client.MdApi.SubscribeForQuoteRsp((*string)(unsafe.Pointer(&args[0])), len(symbols)) if iResult != 0 { log.Println("发送询价订阅请求: 失败.") } else { log.Println("发送询价订阅请求: 成功.") } } //%typemap(gotype) (char **ppInstrumentID, int nCount) "[]string" // //%typemap(in) (char *ppInstrumentID, int nCount) //%{ // { // int i; // _gostring_* a; // // $2 = $input.len; // a = (_gostring_*) $input.array; // $1 = (char **) malloc (($2 + 1) * sizeof (char *)); // for (i = 0; i < $2; i++) { // // /* Not work */ // //_gostring_ *ps = &a[i]; // //$1[i] = (char *) ps->p; // //$1[i][ps->n] = '\0'; // // /*Work well*/ // _gostring_ *ps = &a[i]; // $1[i] = (char*) malloc(ps->n + 1); // memcpy($1[i], ps->p, ps->n); // $1[i][ps->n] = '\0'; // // } // $1[i] = NULL; // } //%} // //%typemap(argout) (char *ppInstrumentID, int nCount) "" /* override char *[] default */ // //%typemap(freearg) (char **ppInstrumentID, int nCount) //%{ // { // int i; // for (i = 0; i < $2; i++) // { // free ($1[i]); // } // free($1); // } //%}
# v6.3.15_20190220_api_tradeapi_se_linux64 版本的该头文件 将字符串以 ''括起来,导致 SWIG翻译时报错; 将类似 '102001' 的都转为 ""; 否则编译成.go之后 出现 const THOST_FTDC_VTC_BankBankToFuture byte '102001' 编译器退出报错; 实际上应该是: const THOST_FTDC_VTC_BankBankToFuture string "102001" #define THOST_FTDC_VTC_BankBankToFuture "102001" #define THOST_FTDC_VTC_BankFutureToBank "102002" #define THOST_FTDC_VTC_FutureBankToFuture "202001" #define THOST_FTDC_VTC_FutureFutureToBank "202002" #define THOST_FTDC_FTC_BankLaunchBankToBroker "102001" #define THOST_FTDC_FTC_BrokerLaunchBankToBroker "202001" #define THOST_FTDC_FTC_BankLaunchBrokerToBank "102002" #define THOST_FTDC_FTC_BrokerLaunchBrokerToBank "202002"
# 默认的动态加载库在 /usr/lib 目录下,而非 /usr/local/lib (建立软连接即可) sudo ln -s /usr/local/lib/libthostmduserapi.so /usr/lib/libthostmduserapi.so sudo ln -s /usr/local/lib/libthosttraderapi.so /usr/lib/libthosttraderapi.so
./goctp_md_example CTP: 2019/07/10 13:49:33.854960 usage: ./goctp_md_example -BrokerID 9999 -InvestorID 000000 -Password 000000 -MarketFront tcp://180.168.146.187:10010 -TradeFront tcp://180.168.146.187:10000
The text was updated successfully, but these errors were encountered:
非常不错的总结。
Sorry, something went wrong.
可以参考 https://github.com/mayiweb/goctp
No branches or pull requests
swig && c++ 安装
goctp/goctp.swigcxx 修改
ThostFtdcUserApiDataType.h 问题
编译后 libthostmduserapi.so => not found 的问题
# 默认的动态加载库在 /usr/lib 目录下,而非 /usr/local/lib (建立软连接即可) sudo ln -s /usr/local/lib/libthostmduserapi.so /usr/lib/libthostmduserapi.so sudo ln -s /usr/local/lib/libthosttraderapi.so /usr/lib/libthosttraderapi.so
最后执行例子
The text was updated successfully, but these errors were encountered: