This commit is contained in:
msincenselee 2019-06-27 15:32:52 +08:00
parent 145bfa55c3
commit bd78353ee5
11 changed files with 0 additions and 6902 deletions

View File

@ -1,117 +0,0 @@
cmake_minimum_required(VERSION 2.8)
project(vn_ctp_api)
# 使
set(CMAKE_BUILD_TYPE "Release")
if (CMAKE_COMPILER_IS_GNUC OR CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -std=c++11")
endif ()
#
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
# 使64
option(USE_64BITS "comiple 64bits" ON)
if (USE_64BITS)
add_definitions(-DUSE_64BITS)
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
endif()
# C++ API
if (WIN32)
set(CTPAPI_PATH ctpapi)
elseif (UNIX)
message("Under unix: " ${CMAKE_SIZEOF_VOID_P})
if (CMAKE_SIZEOF_VOID_P MATCHES "8")
set(CTPAPI_PATH ctpapi/x64_linux)
endif()
endif()
include_directories(${CTPAPI_PATH})
set(CTPAPI_LIBRARY )
find_library(CTPAPI_MD_LIBRARY
NAMES thostmduserapi_se
PATHS ${CTPAPI_PATH})
find_library(CTPAPI_TD_LIBRARY
NAMES thosttraderapi_se
PATHS ${CTPAPI_PATH})
message("CTPAPI_MD_LIBRARY:" ${CTPAPI_MD_LIBRARY})
message("CTPAPI_TD_LIBRARY:" ${CTPAPI_TD_LIBRARY})
#
set (vnctpmd )
set (vnctptd )
option(BUILD_CTP_MD "build ctp md" ON)
if (BUILD_CTP_MD)
add_definitions(-DBUILD_CTP_MD)
set(CTP_MD_PATH vnctpmd/vnctpmd)
include_directories(${CTP_MD_PATH})
set(VN_CTP_MD_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/vnctpmd/vnctpmd/vnctpmd.cpp)
add_library(vnctpmd SHARED ${VN_CTP_MD_SOURCE})
endif()
option(BUILD_CTP_TD "build ctp td" ON)
if (BUILD_CTP_TD)
add_definitions(-DBUILD_CTP_TD)
set(CTP_TD_PATH vnctptd/vnctptd)
include_directories(${CTP_TD_PATH})
set(VN_CTP_TD_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/vnctptd/vnctptd/vnctptd.cpp)
add_library(vnctptd SHARED ${VN_CTP_TD_SOURCE})
endif()
# Python
set(PYTHON_LIBRARY )
if (WIN32)
set(PYTHON_INCLUDE_PATH C:/Python27/include)
find_library(PYTHON_LIBRARY
NAMES python27
PATHS C:/Python27/libs)
include_directories(${PYTHON_INCLUDE_PATH})
else()
set(PYTHON_INCLUDE_PATH /home/trade/anaconda3/envs/py35/include/python3.5m)
find_library(PYTHON_LIBRARY
NAMES python3.5
PATHS /home/trade/anaconda3/envs/py35/lib/)
include_directories(${PYTHON_INCLUDE_PATH})
endif()
# hard code virtual environment
set (PYTHON_LIBRARY /home/trade/anaconda3/envs/py35/lib/libpython3.so)
# boostanaconda
if (WIN32)
set(Boost_USE_STATIC_LIBS ON) #boost
endif()
set(Boost_USE_MULTITHREADED ON)
find_package(Boost 1.66.0 COMPONENTS locale thread date_time system chrono python3 REQUIRED) # boost否者message(${Boost_LIBRARIES})
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
endif()
# hard code boost include folder
set(MY_BOOST_INCLUDE /usr/local/include/boost)
include_directories(${MY_BOOST_INCLUDE})
# solib
set_target_properties(vnctpmd PROPERTIES PREFIX "")
set(MY_BOOST /usr/local/lib)
# .so
target_link_libraries(vnctpmd ${MY_BOOST} ${Boost_LIBRARIES} ${PYTHON_LIBRARY} ${CTPAPI_MD_LIBRARY})
# dllpydwindows
set(MD_DLL "${LIBRARY_OUTPUT_PATH}/Release/vnctpmd.dll")
if (EXISTS ${MD_DLL})
file(RENAME ${MD_DLL} ${LIBRARY_OUTPUT_PATH}/Release/vnctpmd.pyd)
endif()
# MD
set_target_properties(vnctptd PROPERTIES PREFIX "")
target_link_libraries(vnctptd ${MY_BOOST} ${Boost_LIBRARIES} ${PYTHON_LIBRARY} ${CTPAPI_TD_LIBRARY})
set(TD_DLL ${LIBRARY_OUTPUT_PATH}/Release/vnctptd.dll)
if (EXISTS ${TD_DLL})
file(RENAME ${TD_DLL} ${LIBRARY_OUTPUT_PATH}/Release/vnctptd.pyd)
endif()

View File

@ -1,5 +0,0 @@
# encoding: UTF-8
from vnpy.api.ctp_se.vnctpmd import MdApi
from vnpy.api.ctp_se.vnctptd import TdApi
from vnpy.api.ctp_se.ctp_data_type import defineDict

View File

@ -1,17 +0,0 @@
#!/bin/bash
# Written by Suzhengchun on 20160213
# updated by Incenselee on 20180226, support PY3 in Linux
set -e
BUILDDIR=build
rm -rf $BUILDDIR
if [ ! -f $BUILDDIR ]; then
mkdir -p $BUILDDIR
fi
pushd $BUILDDIR
cmake ..
make VERBOSE=1 -j 1
ln -fs `pwd`/lib/vnctpmd.so ../vnctpmd.so
ln -fs `pwd`/lib/vnctptd.so ../vnctptd.so
cp ../vnctpmd.* ../../../trader/gateway/ctpseGateway/
cp ../vnctptd.* ../../../trader/gateway/ctpseGateway/
popd

File diff suppressed because it is too large Load Diff

View File

@ -1,70 +0,0 @@
# vn.ctp
### 简介
CTP柜台API接口的Python封装基于pyscript目录下的脚本自动分析头文件生成封装代码模块提供原生C++ API中的全部功能。
### 目录说明
* py3: Windows下编译
* vnctpmd: 行情API(py3)
* vnctptd: 交易API(py3)
* pyscript: 自动封装脚本
* ctpapiC++ API文件
### 使用CMake编译
**Windows 7/10**
环境配置:
* Anaconda使用64bitpython 3 如 python 3.5 3.6
* Boost 使用 1.57 以上
boost 安装后有一个stage的版本对应include & lib的路径。
* cmake:安装最新版本的cmake,用于配置编译环境
* 设置环境变量BOOST_ROOT = C:\boost_1_57_0
* 编译工具Visual Studio 2017
编译过程:
* 使用 Visual Studio 2017, 打开 py3/vnctpmd下解决方案vnctpmd.sln
* 检查“项目”配置中对应的include和ib目录均要包含python 3.x 和boost的include & lib路径
* 点击编译按钮,建议编译release库
* vnctptd的编译同上。
**Linux (Debian jessie, Ubuntu 16.04)**
环境配置:
* 参考[这里](http://www.continuum.io/downloads)的教程下载并安装Anaconda的Linux 64位版本
* 使用apt-get安装编译相关的工具注意某些老的Ubuntu必须指定使用boost 1.58.0版本:
- apt-get install build-essential
- apt-get install libboost-all-dev
- apt-get install python-dev
- apt-get install cmake
* 如果从官网下载新的ctp api tar包比如v6.3.5_20150803_tradeapi_linux64.tar需要重命名ctp api so文件名否则可以忽略该步骤
- thostmduserapi.so --> libthostmduserapi.so
- thosttraderapi.so --> libthosttraderapi.so
编译过程:
* 当前目录运行build.sh完成编译

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.