GithubHelp home page GithubHelp logo

xpineal / jctp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ktrader-tech/jctp

0.0 0.0 0.0 14.16 MB

CTP 的 Java 封装

License: Apache License 2.0

CMake 0.10% Batchfile 0.07% Shell 0.06% C++ 26.10% C 72.46% Kotlin 0.52% Java 0.02% SWIG 0.66%

jctp's Introduction

JCTP

maven central jdk platform Apache License 2.0

基于 SWIG 实现的对上期技术 CTP 的封装。支持 64 位的 Windows 及 Linux 操作系统,动态链接库已被包含至 jar 包内,并在类加载时自动 loadLibrary,只需添加 jar 包即可直接使用。

如果你试图直接基于 CTP 开发交易策略程序,那么相比于繁琐、异步且充满各种坑的 CTP 原生接口,经过良好封装的 KTrader-Broker-CTP 会是一个更好的选择

当前已封装的 CTP 版本

6.6.1_P1-1.0.3
6.6.1_P1_CP-1.0.3
6.3.19_P1-1.0.3
6.3.19_T1-1.0.3

Usage

API 及使用方法同上期技术官方提供的 C++ 版 CTP SDK,另外使用前可以通过以下方法判断动态链接库是否已被成功加载:

import org.rationalityfrontline.jctp.*

fun main() {
    if (jctpJNI.libraryLoaded()) {
        // do something with CTP, here we print its sdk version
        println(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
sudo dpkg-reconfigure locales

Download

Gradle Kotlin DSL:

repositories {
    mavenCentral()
}

dependencies {
    implementation("org.rationalityfrontline:jctp:6.6.1_P1-1.0.3")
}

Maven:

<dependency>
    <groupId>org.rationalityfrontline</groupId>
    <artifactId>jctp</artifactId>
    <version>6.6.1_P1-1.0.3</version>
</dependency>

Jar:

Maven Repository

使用 Jar 包前请先添加 native-lib-loader 依赖:

dependencies {
    implementation("org.scijava:native-lib-loader:2.4.0")
}

Build

前提要求(版本信息仅供参考,非必要):

  1. 安装 SWIG 4.0.2 并将其添加至环境变量中
  2. 安装 CMake > 3.16 并将其添加至环境变量中
  3. 安装 C++ 编译器( Windows 下是 msvc,Linux 下是 gcc/g++
  4. 安装 JDK 11 或以上的版本,并将其添加至环境变量中

Windows

build.cmd

Linux

./build.sh

以上为单平台版本编译,如需编译跨平台版本,则需要在两个平台下各编译一次(顺序随意)。

build 完毕后,生成的 jar 包在 java/build/libs 目录下。

Reference

https://blog.csdn.net/pjjing/article/details/53186394

http://www.swig.org/Doc4.0/Contents.html#Contents

https://github.com/scijava/native-lib-loader

License

JCTP 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.

jctp's People

Contributors

rationalityfrontline avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.