1 Star 0 Fork 39

QinLikang / hf_go_ctp

forked from zhuzhenping / hf_goctp 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
README.md 1.75 KB
一键复制 编辑 原始数据 按行查看 历史

goctp

介绍

CTP封装之golang版,支持Windows Linux x64. 采用二次封装,将C++封装成C,并export所用函数.

软件架构

代码与C#/PYTHON版本逻辑相同

使用说明

源码测试

需卸载已安装 `go clean -i github.com/haifengat/goctp'

安装

go get github.com/haifengat/goctp

示例

https://github.com/haifengat/goctp/raw/master/demo/main.go

编译

linux

复制所有 so文件到系统 lib下,或把当前路径加入 LD_LIBRARY_PATH 中.

windows

编译后复制 dll到应用程序目录下即可

QA

linux中quote与trade不能同时载入的问题

经测试,在trade创建子目录test_quote并载入quote测试代码可行。(test_quote下放quote代码,test_trade下放trade代码,亦报错)

解决

从python项目中复制quote.h quote.cpp过来,修改所有函数和回调函数,增加前缀q. 重新编译ctp_quote.so

cd lnx && g++ -shared -fPIC -Wl,-rpath . -o ./libctp_quote.so ../generate/quote.cpp  thostmduserapi_se.so && cd ..
cd lnx && g++ -shared -fPIC -Wl,-rpath . -o ./libctp_trade.so ../generate/trade.cpp  thosttraderapi_se.so && cd ..

VSCode launch.json 配置

{
    // 使用 IntelliSense 了解相关属性。 
    // 悬停以查看现有属性的描述。
    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch",
            "type": "go",
            "request": "launch",
            "mode": "auto",
            "program": "${workspaceFolder}/demo/",
            "cwd": "${workspaceFolder}",
            "env": {"LD_LIBRARY_PATH":"${workspaceFolder}/go_ctp/lib64/"},
            "args": []
        }
    ]
}
Go
1
https://gitee.com/qinlk/hf_go_ctp.git
git@gitee.com:qinlk/hf_go_ctp.git
qinlk
hf_go_ctp
hf_go_ctp
master

搜索帮助