基于 SWIG 实现的对中泰证券 XTP 的封装。当前封装版本为 2.2.27.4,支持 64 位的 Windows | Linux | Mac 操作系统,动态链接库已被包含至 jar 包内,并在类加载时自动 loadLibrary,只需添加 jar 包即可直接使用。
API 及使用方法同中泰证券官方提供的 C++ 版 XTP SDK,另外使用前可以通过以下方法判断动态链接库是否已被成功加载:
import org.rationalityfrontline.jxtp.*
fun main() {
if (jxtpJNI.libraryLoaded()) {
// do something with XTP, here we print its sdk version
val traderApi = TraderApi.CreateTraderApi(1, "./log", XTP_LOG_LEVEL.XTP_LOG_LEVEL_INFO)
println(traderApi.GetApiVersion())
traderApi.Release()
// release native gc root in jni, jxtp will be unavailable after doing this
jxtpJNI.release()
} else {
System.err.println("Library load failed!")
}
}
Gradle Kotlin DSL:
repositories {
mavenCentral()
}
dependencies {
implementation("org.rationalityfrontline:jxtp:2.2.27.4-1.1.0")
}
Maven:
<dependency>
<groupId>org.rationalityfrontline</groupId>
<artifactId>jxtp</artifactId>
<version>2.2.27.4-1.1.0</version>
</dependency>
Jar:
使用 Jar 包前请先添加 native-lib-loader 依赖:
dependencies {
implementation("org.scijava:native-lib-loader:2.3.5")
}
前提要求(版本信息仅供参考,非必要):
Windows
build.cmd
Linux | Mac
./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
JXTP is released under the Apache 2.0 license.
Copyright 2020-2021 RationalityFrontline
Licensed 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.0
Unless required by applicable law or agreed to in writing, software
distributed 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 and
limitations under the License.