Skip to content

kozyan/ctp-rust

Repository files navigation

ctp-rs

CTP sdk version: v6.6.1_P1_20210406

windows 环境下: 编译时需要安装

  1. LLVM-14.0.6-win64.exe
  2. visual studio 2022 c++

运行 examples 里的 mdapi 或 tdapi 命令如下:

cargo run --example mdapicargo run --example tdapi

注意:由于 rust-bindgen 当前版本(0.60.1)有 bug,如果要重新生成 src/generated/mod.rs 文件,则产生的释构函数的 link 名称,需要用以下的来替换

??1Rust_CThostFtdcMdApi@@QEAA@XZ (public: __cdecl Rust_CThostFtdcMdApi::~Rust_CThostFtdcMdApi(void)):
??1Rust_CThostFtdcMdSpi@@QEAA@XZ (public: __cdecl Rust_CThostFtdcMdSpi::~Rust_CThostFtdcMdSpi(void)):
??1Rust_CThostFtdcTraderApi@@QEAA@XZ (public: __cdecl Rust_CThostFtdcTraderApi::~Rust_CThostFtdcTraderApi(void)):
??1Rust_CThostFtdcTraderSpi@@QEAA@XZ (public: __cdecl Rust_CThostFtdcTraderSpi::~Rust_CThostFtdcTraderSpi(void)):

linux 环境下: 编译时需要安装 llvm 和 clang:

sudo apt install llvm-dev libclang-dev clang

sudo apt-get install clang

特别说明:代码源自 https://github.com/SheldonNico/ctp-rs 的一个分支,但是我在 windows 环境下一直没有跑成功,所以另建一个名字来学习 ctp 及 rust。

*.hpp and *.cpp are generated by autobind.py, then processed by rut_bindgen. Look at xtp-rs for detail.

Use at your own risk. The crate is unsafe, look at examples/tdapi.rs and examples/mdapi.rs for how to use it.

where to put my .so files

so files is not included, please put it like this:

$ tree shared

shared
├── data_collect
│   ├── unix.x86_64
│   │   ├── libLinuxDataCollect.so -> LinuxDataCollect.so
│   │   └── LinuxDataCollect.so
│   ├── windows.x86
│   │   ├── WinDataCollect.dll
│   │   └── WinDataCollect.lib
│   └── windows.x86_x64
│       ├── WinDataCollect.dll
│       └── WinDataCollect.lib
├── include
│   ├── DataCollect.h
│   ├── ThostFtdcMdApi.h
│   ├── ThostFtdcTraderApi.h
│   ├── ThostFtdcUserApiDataType.h
│   └── ThostFtdcUserApiStruct.h
├── md
│   ├── unix.x86_64
│   │   ├── libthostmduserapi_se.so -> thostmduserapi_se.so
│   │   └── thostmduserapi_se.so
│   ├── windows.x86
│   │   ├── thostmduserapi_se.dll
│   │   └── thostmduserapi_se.lib
│   └── windows.x86_x64
│       ├── thostmduserapi_se.dll
│       └── thostmduserapi_se.lib
└── td
    ├── unix.x86_64
    │   ├── libthosttraderapi_se.so -> thosttraderapi_se.so
    │   └── thosttraderapi_se.so
    ├── windows.x86
    │   ├── thosttraderapi_se.dll
    │   └── thosttraderapi_se.lib
    └── windows.x86_x64
        ├── thosttraderapi_se.dll
        └── thosttraderapi_se.lib

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published