Merge branch 'master' of https://github.com/vnpy/vnpy
Conflicts: .gitignore
This commit is contained in:
commit
29e518d07e
6
.gitignore
vendored
6
.gitignore
vendored
@ -38,5 +38,11 @@ Release/
|
||||
*.dump
|
||||
*.vssettings
|
||||
|
||||
<<<<<<< HEAD
|
||||
# 不想同步的
|
||||
*.local
|
||||
=======
|
||||
vn.ctp/build/*
|
||||
vn.lts/build/*
|
||||
.idea
|
||||
>>>>>>> 65aac25731772259bf2d4049e7adbe92750ea01d
|
||||
|
74
vn.ctp/CMakeLists.txt
Normal file
74
vn.ctp/CMakeLists.txt
Normal file
@ -0,0 +1,74 @@
|
||||
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}/bin)
|
||||
|
||||
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()
|
||||
|
||||
set(CTPAPI_PATH ctpapi)
|
||||
include_directories(${CTPAPI_PATH})
|
||||
set(CTPAPI_LIBRARY )
|
||||
find_library(CTPAPI_MD_LIBRARY
|
||||
NAMES thostmduserapi
|
||||
PATHS ${CTPAPI_PATH})
|
||||
find_library(CTPAPI_TD_LIBRARY
|
||||
NAMES thosttraderapi
|
||||
PATHS ${CTPAPI_PATH})
|
||||
|
||||
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_MD)
|
||||
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()
|
||||
|
||||
|
||||
set(PYTHON_INCLUDE_PATH C:/Python27/include)
|
||||
set(PYTHON_LIBRARY )
|
||||
find_library(PYTHON_LIBRARY
|
||||
NAMES python27
|
||||
PATHS C:/Python27/libs)
|
||||
include_directories(${PYTHON_INCLUDE_PATH})
|
||||
|
||||
# 链接boost库,anaconda
|
||||
set(Boost_USE_STATIC_LIBS ON) #链接boost静态库
|
||||
set(Boost_USE_MULTITHREADED ON)
|
||||
find_package(Boost 1.57.0 COMPONENTS python thread date_time system chrono REQUIRED) # 如果boost库没有完全编译,需要将编译的库明确地指出,否者message(${Boost_LIBRARIES})会出错
|
||||
if(Boost_FOUND)
|
||||
include_directories(${Boost_INCLUDE_DIRS})
|
||||
endif()
|
||||
|
||||
target_link_libraries(vnctpmd ${Boost_LIBRARIES} ${PYTHON_LIBRARY} ${CTPAPI_MD_LIBRARY})
|
||||
set(MD_DLL "${LIBRARY_OUTPUT_PATH}/Release/vnctpmd.dll")
|
||||
if (EXISTS ${MD_DLL})
|
||||
file(RENAME ${MD_DLL} ${LIBRARY_OUTPUT_PATH}/Release/vnctpmd.pyd)
|
||||
endif()
|
||||
target_link_libraries(vnctptd ${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()
|
30
vn.ctp/readme.md
Normal file
30
vn.ctp/readme.md
Normal file
@ -0,0 +1,30 @@
|
||||
# 本目录的作用是编译CTP库
|
||||
---------------------
|
||||
|
||||
# 目录说明
|
||||
------------
|
||||
## vnctpmd: 编译行情API
|
||||
|
||||
# 环境配置
|
||||
----------
|
||||
|
||||
* 建议安装的软件在位数上保持一致,比如全都安装32位,同时编译32位库
|
||||
* cmake:安装最新版本的cmake,用于配置编译环境
|
||||
* [Boost1.57.0](http://sourceforge.net/projects/boost/files/boost/1.57.0/)库:编译的方法可以参考[Boost Getting Started](http://www.boost.org/doc/libs/1_58_0/more/getting_started/)右下角的链接
|
||||
** 设置环境变量:eg: BOOST_ROOT = C:\boost_1_57_0
|
||||
** 编译32位库还是64位库任意选择
|
||||
** 需要编译boost python, thread, system, chrono, date_time共5个库:若编译全部库则会浪费大量时间和硬盘空间。
|
||||
** boost python的动态库64bits可能编译不成功,需加选项address-model=64。或者编译静态库
|
||||
|
||||
* [Anaconda1.9.2](http://repo.continuum.io/archive/index.html): 量化相关包的Python发行版
|
||||
* 编译工具:windows下选择visual studio 2013;linux下使用g++。
|
||||
|
||||
# 编译过程
|
||||
-------------
|
||||
|
||||
* 在vn.ctp目录下新建文件夹,并命名为build, 保存编译的临时文件及库文件
|
||||
* 打开命令行工具输入:cmake-gui .. 则打开cmake配置界面
|
||||
* 点击configure。
|
||||
* 点击generate。如果没有错误则配置成功
|
||||
* 进入build目录,双击vn_ctp_api.sln打开解决方案
|
||||
* 点击编译按钮,建议编译release库
|
Loading…
Reference in New Issue
Block a user