- Notifications
You must be signed in to change notification settings - Fork18
ktrader-tech/jctp
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
基于SWIG 实现的对上期技术 CTP 的封装。支持 64 位的 Windows 及 Linux 操作系统,动态链接库已被包含至 jar 包内,并在类加载时自动 loadLibrary,只需添加 jar 包即可直接使用。
如果你试图直接基于 CTP 开发交易策略程序,那么相比于繁琐、异步且充满各种坑的 CTP 原生接口,经过良好封装的KTrader-Broker-CTP 会是一个更好的选择
6.7.8-1.0.56.7.8_CP-1.0.56.7.2-1.0.56.7.2_CP-1.0.56.6.9-1.0.56.6.9_CP-1.0.56.6.1_P1-1.0.56.6.1_P1_CP-1.0.56.3.19_P1-1.0.56.3.19_T1-1.0.5
API 及使用方法同上期技术官方提供的 C++ 版 CTP SDK,另外使用前可以通过以下方法判断动态链接库是否已被成功加载:
importorg.rationalityfrontline.jctp.*funmain() {if (jctpJNI.libraryLoaded()) {// do something with CTP, here we print its sdk versionprintln(CThostFtdcTraderApi.GetApiVersion())// release native gc root in jni, jctp will be unavailable after doing this jctpJNI.release() }else {System.err.println("Library load failed!") }}
如果在 Linux 环境下使用,则需要确保已安装 zh_CN.GB18030 字符集:
sudo locale-gen zh_CN.GB18030
否则会报以下异常:
locale::facet::_S_create_c_locale name not valid
Gradle Kotlin DSL:
repositories { mavenCentral()}dependencies { implementation("org.rationalityfrontline:jctp:6.7.8-1.0.5")}
Maven:
<dependency> <groupId>org.rationalityfrontline</groupId> <artifactId>jctp</artifactId> <version>6.7.8-1.0.5</version></dependency>
Jar:
使用 Jar 包前请先添加native-lib-loader 依赖:
dependencies { implementation("org.scijava:native-lib-loader:2.5.0")}
前提要求(版本信息仅供参考,非必要):
- 安装SWIG 4.0.2 并将其添加至环境变量中
- 安装CMake > 3.16 并将其添加至环境变量中
- 安装 C++ 编译器( Windows 下是msvc,Linux 下是gcc/g++)
- 安装 JDK 11 或以上的版本,并将其添加至环境变量中
Windows
build.cmd
Linux
./build.sh
以上为单平台版本编译,如需编译跨平台版本,则需要在两个平台下各编译一次(顺序随意)。
build 完毕后,生成的 jar 包在 java/build/libs 目录下。
https://blog.csdn.net/pjjing/article/details/53186394
http://www.swig.org/Doc4.0/Contents.html#Contents
https://github.com/scijava/native-lib-loader
JCTP is released under theApache 2.0 license.
Copyright 2020-2024 RationalityFrontlineLicensed under the Apache License, Version 2.0 (the "License");you may not use this file except in compliance with the License.You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License.
About
CTP 的 Java 封装
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.