├── .github └── workflows │ └── build_wheels.yml ├── .gitignore ├── LICENSE ├── README.md ├── api ├── 6.3.13 │ └── linux │ │ ├── ThostFtdcMdApi.h │ │ ├── ThostFtdcTraderApi.h │ │ ├── ThostFtdcUserApiDataType.h │ │ ├── ThostFtdcUserApiStruct.h │ │ ├── error.dtd │ │ ├── error.xml │ │ ├── libthostmduserapi_se.so │ │ └── libthosttraderapi_se.so ├── 6.3.15 │ └── linux │ │ ├── ThostFtdcMdApi.h │ │ ├── ThostFtdcTraderApi.h │ │ ├── ThostFtdcUserApiDataType.h │ │ ├── ThostFtdcUserApiStruct.h │ │ ├── error.dtd │ │ ├── error.xml │ │ ├── libthostmduserapi_se.so │ │ └── libthosttraderapi_se.so ├── 6.5.1.c │ └── linux │ │ ├── ThostFtdcMdApi.h │ │ ├── ThostFtdcTraderApi.h │ │ ├── ThostFtdcUserApiDataType.h │ │ ├── ThostFtdcUserApiStruct.h │ │ ├── error.dtd │ │ ├── error.xml │ │ ├── libthostmduserapi_se.so │ │ └── libthosttraderapi_se.so ├── 6.5.1 │ └── linux │ │ ├── ThostFtdcMdApi.h │ │ ├── ThostFtdcTraderApi.h │ │ ├── ThostFtdcUserApiDataType.h │ │ ├── ThostFtdcUserApiStruct.h │ │ ├── error.dtd │ │ ├── error.xml │ │ ├── libthostmduserapi_se.so │ │ └── libthosttraderapi_se.so ├── 6.6.1.c │ └── linux │ │ ├── ThostFtdcMdApi.h │ │ ├── ThostFtdcTraderApi.h │ │ ├── ThostFtdcUserApiDataType.h │ │ ├── ThostFtdcUserApiStruct.h │ │ ├── error.dtd │ │ ├── error.xml │ │ ├── libthostmduserapi_se.so │ │ └── libthosttraderapi_se.so ├── 6.6.1 │ └── linux │ │ ├── ThostFtdcMdApi.h │ │ ├── ThostFtdcTraderApi.h │ │ ├── ThostFtdcUserApiDataType.h │ │ ├── ThostFtdcUserApiStruct.h │ │ ├── error.dtd │ │ ├── error.xml │ │ ├── libthostmduserapi_se.so │ │ └── libthosttraderapi_se.so ├── 6.6.9.c │ ├── darwin │ │ ├── ThostFtdcMdApi.h │ │ ├── ThostFtdcTraderApi.h │ │ ├── ThostFtdcUserApiDataType.h │ │ ├── ThostFtdcUserApiStruct.h │ │ ├── libcomunicationkeylib.a │ │ ├── libcrypto.a │ │ ├── libssl.a │ │ ├── libthostmduserapi_se.a │ │ └── libthosttraderapi_se.a │ ├── linux │ │ ├── ThostFtdcMdApi.h │ │ ├── ThostFtdcTraderApi.h │ │ ├── ThostFtdcUserApiDataType.h │ │ ├── ThostFtdcUserApiStruct.h │ │ ├── error.dtd │ │ ├── error.xml │ │ ├── libthostmduserapi_se.so │ │ └── libthosttraderapi_se.so │ └── windows │ │ ├── ThostFtdcMdApi.h │ │ ├── ThostFtdcTraderApi.h │ │ ├── ThostFtdcUserApiDataType.h │ │ ├── ThostFtdcUserApiStruct.h │ │ ├── error.dtd │ │ ├── error.xml │ │ ├── thostmduserapi_se.dll │ │ ├── thostmduserapi_se.lib │ │ ├── thosttraderapi_se.dll │ │ └── thosttraderapi_se.lib ├── 6.6.9 │ ├── darwin │ │ ├── ThostFtdcMdApi.h │ │ ├── ThostFtdcTraderApi.h │ │ ├── ThostFtdcUserApiDataType.h │ │ ├── ThostFtdcUserApiStruct.h │ │ ├── libcomunicationkeylib.a │ │ ├── libcrypto.a │ │ ├── libssl.a │ │ ├── libthostmduserapi_se.a │ │ └── libthosttraderapi_se.a │ ├── linux │ │ ├── ThostFtdcMdApi.h │ │ ├── ThostFtdcTraderApi.h │ │ ├── ThostFtdcUserApiDataType.h │ │ ├── ThostFtdcUserApiStruct.h │ │ ├── error.dtd │ │ ├── error.xml │ │ ├── libthostmduserapi_se.so │ │ └── libthosttraderapi_se.so │ └── windows │ │ ├── ThostFtdcMdApi.h │ │ ├── ThostFtdcTraderApi.h │ │ ├── ThostFtdcUserApiDataType.h │ │ ├── ThostFtdcUserApiStruct.h │ │ ├── error.dtd │ │ ├── error.xml │ │ ├── thostmduserapi_se.dll │ │ ├── thostmduserapi_se.lib │ │ ├── thosttraderapi_se.dll │ │ └── thosttraderapi_se.lib └── 6.7.7 │ ├── darwin │ ├── thostmduserapi_se.framework │ │ ├── Headers │ │ ├── Resources │ │ ├── Versions │ │ │ ├── A │ │ │ │ ├── Headers │ │ │ │ │ ├── ThostFtdcMdApi.h │ │ │ │ │ ├── ThostFtdcUserApiDataType.h │ │ │ │ │ └── ThostFtdcUserApiStruct.h │ │ │ │ ├── Resources │ │ │ │ │ └── Info.plist │ │ │ │ ├── _CodeSignature │ │ │ │ │ └── CodeResources │ │ │ │ └── thostmduserapi_se │ │ │ └── Current │ │ └── thostmduserapi_se │ └── thosttraderapi_se.framework │ │ ├── Headers │ │ ├── Resources │ │ ├── Versions │ │ ├── A │ │ │ ├── Headers │ │ │ │ ├── ThostFtdcTraderApi.h │ │ │ │ ├── ThostFtdcUserApiDataType.h │ │ │ │ └── ThostFtdcUserApiStruct.h │ │ │ ├── Resources │ │ │ │ └── Info.plist │ │ │ ├── _CodeSignature │ │ │ │ └── CodeResources │ │ │ └── thosttraderapi_se │ │ └── Current │ │ └── thosttraderapi_se │ ├── linux │ ├── ThostFtdcMdApi.h │ ├── ThostFtdcTraderApi.h │ ├── ThostFtdcUserApiDataType.h │ ├── ThostFtdcUserApiStruct.h │ ├── error.dtd │ ├── error.xml │ ├── libthostmduserapi_se.so │ └── libthosttraderapi_se.so │ └── windows │ ├── ThostFtdcMdApi.h │ ├── ThostFtdcTraderApi.h │ ├── ThostFtdcUserApiDataType.h │ ├── ThostFtdcUserApiStruct.h │ ├── error.dtd │ ├── error.xml │ ├── thostmduserapi_se.dll │ ├── thostmduserapi_se.lib │ ├── thosttraderapi_se.dll │ └── thosttraderapi_se.lib ├── ctp.i ├── ctp └── __init__.py ├── setup.py └── tests ├── conftest.py ├── test_md.py └── test_trader.py /.github/workflows/build_wheels.yml: -------------------------------------------------------------------------------- 1 | on: 2 | workflow_dispatch: 3 | 4 | jobs: 5 | build_unix: 6 | runs-on: ${{ matrix.os }} 7 | strategy: 8 | matrix: 9 | os: [ubuntu-latest, macos-latest] 10 | version: ["cp37", "cp38", "cp39", "cp310", "cp311", "cp312", "cp313"] 11 | steps: 12 | - uses: actions/checkout@v4 13 | 14 | - uses: actions/setup-python@v4 15 | with: 16 | python-version: "3.11" 17 | 18 | - name: Setup swig for macos 19 | if: matrix.os == 'macos-latest' 20 | run: | 21 | brew install swig 22 | env: 23 | HOMEBREW_NO_AUTO_UPDATE: 1 24 | 25 | - name: Setup pip 26 | run: | 27 | python -m pip install --upgrade pip cibuildwheel 28 | 29 | - name: Build wheel 30 | run: python -m cibuildwheel --output-dir dist 31 | env: 32 | CIBW_BUILD: ${{ matrix.version }}-* 33 | CIBW_SKIP: "cp36-* *-win* *_i686 *-musllinux*" 34 | CIBW_ARCHS_MACOS: "x86_64 arm64" 35 | # Skip delocate for macOS builds 36 | CIBW_REPAIR_WHEEL_COMMAND_MACOS: "" 37 | 38 | - uses: actions/upload-artifact@v3 39 | with: 40 | name: ctp-python 41 | path: ./dist/*.whl 42 | 43 | build_win: 44 | runs-on: ${{ matrix.os }} 45 | strategy: 46 | matrix: 47 | os: [windows-latest] 48 | python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] 49 | steps: 50 | - uses: actions/checkout@v4 51 | 52 | - uses: conda-incubator/setup-miniconda@v3 53 | with: 54 | auto-update-conda: true 55 | python-version: ${{ matrix.python-version }} 56 | 57 | - name: Prepare Windows 58 | if: matrix.os == 'windows-latest' 59 | run: | 60 | conda init 61 | conda install -c conda-forge libiconv 62 | 63 | - name: Setup pip for Windows 64 | run: | 65 | python -m pip install --upgrade pip wheel build 66 | 67 | - name: Build wheel for Windows 68 | run: python -m build -w -n 69 | 70 | - uses: actions/upload-artifact@v3 71 | with: 72 | name: ctp-python 73 | path: ./dist/*.whl 74 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ctp.py 2 | ctp_wrap.cpp 3 | ctp_wrap.h 4 | build/ 5 | dist/ 6 | artifact/ 7 | *.egg-info/ 8 | *.pyc 9 | .DS_Store 10 | *.bak 11 | *.orig 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 2-Clause License 2 | 3 | Copyright (c) 2019, Keli 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Python版CTP期货接口 2 | 3 | 这套接口使用swig为官方C++版CTP接口提供Python版API,同时支持Linux/Mac/Windows。 4 | 5 | ## 注意事项 6 | 7 | - **本项目出于个人兴趣及分享目的,与上期所CTP官方无任何关系。本人不对使用这套库的任何后果负责。** 8 | - 本人生产环境使用Linux,其他平台仅编译测试通过 9 | - 已通过github workflow编译好发布至pypi 10 | - Linux已测试环境:Debian stable amd64 11 | - Mac已测试环境:Mac OS 15.x(M1 Mac Mini,API版本6.6.9以上,Intel Mac未测试) 12 | - Windows已测试环境:Windows 11 64位(API版本6.6.9以上)+ MiniConda3 13 | - api目录中结尾带`.c`的版本号为测评版 14 | - CTP返回的GBK编码字符串已经全部自动转换为UTF-8 15 | - 市场数据中的极大值代表无数据,为可读性起见打印整个结构体时会显示为None 16 | 17 | ## 快速安装 18 | 19 | * 如果在Windows下推荐使用miniconda3环境 20 | ``` 21 | winget install miniconda3 22 | ``` 23 | 24 | * Windows下使用ctp前还需要安装libiconv 25 | ``` 26 | conda install -c conda-forge libiconv 27 | ``` 28 | 29 | * 直接使用pip安装 30 | ``` 31 | pip install ctp-python 32 | ``` 33 | 34 | - 只支持6.6.9以上的CTP版本,如需使用评测版本请自行编译 35 | - 已编译的二进制版本支持Python3.7 - 3.13 36 | - 已编译的二进制版本支持平台:Windows amd64,Linux amd64,MacOS arm64 和 amd64 37 | - 其他版本请自行尝试编译(前提是有对应的CTP C++链接库),具体方法见下 38 | 39 | ## 测试 40 | 41 | > 打开python shell,检查是否能正常import ctp 42 | 43 | ``` 44 | $ python 45 | Python 3.11.3 46 | Type "help", "copyright", "credits" or "license" for more information. 47 | >>> import ctp 48 | >>> 49 | ``` 50 | 51 | > 跑一下测试(以simnow服务器为例,需要在simnow网站注册用户) 52 | ``` 53 | pytest -s tests/test_trader.py --front=tcp://180.168.146.187:10130 --broker=9999 --user= --password= --app=simnow_client_test --auth=0000000000000000 54 | ``` 55 | 56 | ## 自行编译 (可选) 57 | 58 | ### 编译环境准备 59 | 60 | #### Windows 11 61 | 62 | 1. 安装编译环境 63 | ``` 64 | winget install Microsoft.VisualStudio.2022.BuildTools 65 | ``` 66 | > 然后菜单栏搜索并打开Visual Studio Installer,修改Build Tools的配置,将使用C++的桌面开发勾选上并安装 67 | 68 | 2. 安装Python(以miniconda为例) 69 | ``` 70 | winget install miniconda3 71 | conda init 72 | ``` 73 | 74 | 3. 安装swig命令,以及iconv库 75 | ``` 76 | conda install -c conda-forge swig libiconv 77 | ``` 78 | > 可能需要关闭并重新打开命令行 79 | 80 | #### Mac OS 81 | 82 | 1. 安装Xcode和命令行工具 83 | ``` 84 | xcode-select --install 85 | ``` 86 | > 在弹出的窗口确认 87 | 88 | 2. 安装Python(推荐使用pyenv) 89 | 90 | 3. 安装swig命令(以homebrew为例) 91 | ``` 92 | brew install swig 93 | ``` 94 | 95 | #### Linux 96 | 97 | - 使用系统自带包管理器安装swig和gcc/g++编译器 98 | - 推荐使用pyenv安装管理python版本 99 | 100 | ### 编译方法 101 | 102 | 1. 克隆代码到本地 103 | ``` 104 | git clone git@github.com:keli/ctp-python.git 105 | cd ctp-python 106 | ``` 107 | 108 | 2. 编译安装 109 | ``` 110 | python setup.py install 111 | ``` 112 | 或 113 | ``` 114 | pip install . 115 | ``` 116 | 117 | 3. 版本选择(可选) 118 | 119 | 目前默认使用的是6.7.7 版本。如果需要链接和使用其他版本,只需要在编译安装前,设置API_VER环境变量为相应版本即可。 120 | 121 | 以6.6.9.c版为例: 122 | 123 | Linux/Mac(bash/zsh): 124 | ``` 125 | export API_VER=6.6.9.c 126 | ``` 127 | 128 | Windows: 129 | ``` 130 | set API_VER=6.6.9.c 131 | ``` 132 | 133 | ## Linux下穿透式监管信息采集常见问题 134 | 135 | - 到底需要不需要LinuxDataCollect.so? 136 | 137 | 自写CTP程序直连是不需要的,如果你不确定,那就是不需要 138 | 139 | - 报错Decrypt handshake data failed 140 | 141 | CTP版本与服务器端不一致,首次跟期货公司采集的时候可能需要使用"评测版本"如6.6.9.c,后续生产环境请用"生产版本"如6.6.9 142 | 143 | - 报错 dmidecode not found 144 | 145 | 通常默认都有装,加一下dmidecode命令的相关路径到PATH,一般是/usr/sbin 146 | 147 | - 报一堆 permission denied 148 | 149 | 给dmidecode加下权限`sudo chmod a+s /usr/sbin/dmidecode` 150 | 151 | - 拿不到硬盘序列号 152 | 153 | Debian系可以`sudo adduser username disk`把自己加到disk组(加完需要重新登录,输入`groups`确认自己已经在disk组里),或者直接给磁盘设备文件加读权限`sudo chmod a+r /dev/sda` 154 | 155 | - 不知道什么情况,xx数据拿不到 156 | 157 | 用以下python脚本自己慢慢试吧,当打印出来是第一行结果是0则成功了,否则是-1。第二行是取到的信息,格式为```(操作系统类型)@(信息采集时间)@(内网IP1)@(内网IP2)@(网卡MAC1)@(网卡MAC2)@(设备名)@(操作系统版本)@(Disk_ID)@(CPU_ID)@(BIOS_ID)``` 158 | 159 | ```python 160 | import ctypes 161 | dll = ctypes.cdll.LoadLibrary('./thosttraderapi_se.so') 162 | info = (ctypes.c_char * 344)() 163 | length = ctypes.c_int() 164 | print(dll._Z21CTP_GetRealSystemInfoPcRi(info, ctypes.byref(length))) 165 | print(info.value) 166 | ``` 167 | 168 | ## 其他常见问题 169 | 170 | - 回调函数中传入的数据结构为何不能缓存? 171 | 172 | 回调函数传入的数据结构是由ctp库负责内存管理的,调用结束后会释放掉。这个最理想的处理是通过脚本把相应的结构体全部批量生成swig定义来自动把结构体内容复制到python,但目前还没有做这件事。我自己的用户代码中需要缓存起来的ctp结构只有很少的几处,直接在用户代码中手动拷贝到自己定义的python数据类型就可以了。 173 | -------------------------------------------------------------------------------- /api/6.3.13/linux/ThostFtdcMdApi.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////// 2 | ///@system 新一代交易所系统 3 | ///@company 上海期货信息技术有限公司 4 | ///@file ThostFtdcMdApi.h 5 | ///@brief 定义了客户端接口 6 | ///@history 7 | ///20060106 赵鸿昊 创建该文件 8 | ///////////////////////////////////////////////////////////////////////// 9 | 10 | #if !defined(THOST_FTDCMDAPI_H) 11 | #define THOST_FTDCMDAPI_H 12 | 13 | #if _MSC_VER > 1000 14 | #pragma once 15 | #endif // _MSC_VER > 1000 16 | 17 | #include "ThostFtdcUserApiStruct.h" 18 | 19 | #if defined(ISLIB) && defined(WIN32) 20 | #ifdef LIB_MD_API_EXPORT 21 | #define MD_API_EXPORT __declspec(dllexport) 22 | #else 23 | #define MD_API_EXPORT __declspec(dllimport) 24 | #endif 25 | #else 26 | #define MD_API_EXPORT 27 | #endif 28 | 29 | class CThostFtdcMdSpi 30 | { 31 | public: 32 | ///当客户端与交易后台建立起通信连接时(还未登录前),该方法被调用。 33 | virtual void OnFrontConnected(){}; 34 | 35 | ///当客户端与交易后台通信连接断开时,该方法被调用。当发生这个情况后,API会自动重新连接,客户端可不做处理。 36 | ///@param nReason 错误原因 37 | /// 0x1001 网络读失败 38 | /// 0x1002 网络写失败 39 | /// 0x2001 接收心跳超时 40 | /// 0x2002 发送心跳失败 41 | /// 0x2003 收到错误报文 42 | virtual void OnFrontDisconnected(int nReason){}; 43 | 44 | ///心跳超时警告。当长时间未收到报文时,该方法被调用。 45 | ///@param nTimeLapse 距离上次接收报文的时间 46 | virtual void OnHeartBeatWarning(int nTimeLapse){}; 47 | 48 | 49 | ///登录请求响应 50 | virtual void OnRspUserLogin(CThostFtdcRspUserLoginField *pRspUserLogin, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 51 | 52 | ///登出请求响应 53 | virtual void OnRspUserLogout(CThostFtdcUserLogoutField *pUserLogout, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 54 | 55 | ///错误应答 56 | virtual void OnRspError(CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 57 | 58 | ///订阅行情应答 59 | virtual void OnRspSubMarketData(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 60 | 61 | ///取消订阅行情应答 62 | virtual void OnRspUnSubMarketData(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 63 | 64 | ///订阅询价应答 65 | virtual void OnRspSubForQuoteRsp(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 66 | 67 | ///取消订阅询价应答 68 | virtual void OnRspUnSubForQuoteRsp(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 69 | 70 | ///深度行情通知 71 | virtual void OnRtnDepthMarketData(CThostFtdcDepthMarketDataField *pDepthMarketData) {}; 72 | 73 | ///询价通知 74 | virtual void OnRtnForQuoteRsp(CThostFtdcForQuoteRspField *pForQuoteRsp) {}; 75 | }; 76 | 77 | class MD_API_EXPORT CThostFtdcMdApi 78 | { 79 | public: 80 | ///创建MdApi 81 | ///@param pszFlowPath 存贮订阅信息文件的目录,默认为当前目录 82 | ///@return 创建出的UserApi 83 | ///modify for udp marketdata 84 | static CThostFtdcMdApi *CreateFtdcMdApi(const char *pszFlowPath = "", const bool bIsUsingUdp=false, const bool bIsMulticast=false); 85 | 86 | ///获取API的版本信息 87 | ///@retrun 获取到的版本号 88 | static const char *GetApiVersion(); 89 | 90 | ///删除接口对象本身 91 | ///@remark 不再使用本接口对象时,调用该函数删除接口对象 92 | virtual void Release() = 0; 93 | 94 | ///初始化 95 | ///@remark 初始化运行环境,只有调用后,接口才开始工作 96 | virtual void Init() = 0; 97 | 98 | ///等待接口线程结束运行 99 | ///@return 线程退出代码 100 | virtual int Join() = 0; 101 | 102 | ///获取当前交易日 103 | ///@retrun 获取到的交易日 104 | ///@remark 只有登录成功后,才能得到正确的交易日 105 | virtual const char *GetTradingDay() = 0; 106 | 107 | ///注册前置机网络地址 108 | ///@param pszFrontAddress:前置机网络地址。 109 | ///@remark 网络地址的格式为:“protocol://ipaddress:port”,如:”tcp://127.0.0.1:17001”。 110 | ///@remark “tcp”代表传输协议,“127.0.0.1”代表服务器地址。”17001”代表服务器端口号。 111 | virtual void RegisterFront(char *pszFrontAddress) = 0; 112 | 113 | ///注册名字服务器网络地址 114 | ///@param pszNsAddress:名字服务器网络地址。 115 | ///@remark 网络地址的格式为:“protocol://ipaddress:port”,如:”tcp://127.0.0.1:12001”。 116 | ///@remark “tcp”代表传输协议,“127.0.0.1”代表服务器地址。”12001”代表服务器端口号。 117 | ///@remark RegisterNameServer优先于RegisterFront 118 | virtual void RegisterNameServer(char *pszNsAddress) = 0; 119 | 120 | ///注册名字服务器用户信息 121 | ///@param pFensUserInfo:用户信息。 122 | virtual void RegisterFensUserInfo(CThostFtdcFensUserInfoField * pFensUserInfo) = 0; 123 | 124 | ///注册回调接口 125 | ///@param pSpi 派生自回调接口类的实例 126 | virtual void RegisterSpi(CThostFtdcMdSpi *pSpi) = 0; 127 | 128 | ///订阅行情。 129 | ///@param ppInstrumentID 合约ID 130 | ///@param nCount 要订阅/退订行情的合约个数 131 | ///@remark 132 | virtual int SubscribeMarketData(char *ppInstrumentID[], int nCount) = 0; 133 | 134 | ///退订行情。 135 | ///@param ppInstrumentID 合约ID 136 | ///@param nCount 要订阅/退订行情的合约个数 137 | ///@remark 138 | virtual int UnSubscribeMarketData(char *ppInstrumentID[], int nCount) = 0; 139 | 140 | ///订阅询价。 141 | ///@param ppInstrumentID 合约ID 142 | ///@param nCount 要订阅/退订行情的合约个数 143 | ///@remark 144 | virtual int SubscribeForQuoteRsp(char *ppInstrumentID[], int nCount) = 0; 145 | 146 | ///退订询价。 147 | ///@param ppInstrumentID 合约ID 148 | ///@param nCount 要订阅/退订行情的合约个数 149 | ///@remark 150 | virtual int UnSubscribeForQuoteRsp(char *ppInstrumentID[], int nCount) = 0; 151 | 152 | ///用户登录请求 153 | virtual int ReqUserLogin(CThostFtdcReqUserLoginField *pReqUserLoginField, int nRequestID) = 0; 154 | 155 | 156 | ///登出请求 157 | virtual int ReqUserLogout(CThostFtdcUserLogoutField *pUserLogout, int nRequestID) = 0; 158 | protected: 159 | ~CThostFtdcMdApi(){}; 160 | }; 161 | 162 | #endif 163 | -------------------------------------------------------------------------------- /api/6.3.13/linux/error.dtd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | -------------------------------------------------------------------------------- /api/6.3.13/linux/error.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | -------------------------------------------------------------------------------- /api/6.3.13/linux/libthostmduserapi_se.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keli/ctp-python/31295a4044c00f34b326b2c4d675568b4e7b78c3/api/6.3.13/linux/libthostmduserapi_se.so -------------------------------------------------------------------------------- /api/6.3.13/linux/libthosttraderapi_se.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keli/ctp-python/31295a4044c00f34b326b2c4d675568b4e7b78c3/api/6.3.13/linux/libthosttraderapi_se.so -------------------------------------------------------------------------------- /api/6.3.15/linux/ThostFtdcMdApi.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////// 2 | ///@system 新一代交易所系统 3 | ///@company 上海期货信息技术有限公司 4 | ///@file ThostFtdcMdApi.h 5 | ///@brief 定义了客户端接口 6 | ///@history 7 | ///20060106 赵鸿昊 创建该文件 8 | ///////////////////////////////////////////////////////////////////////// 9 | 10 | #if !defined(THOST_FTDCMDAPI_H) 11 | #define THOST_FTDCMDAPI_H 12 | 13 | #if _MSC_VER > 1000 14 | #pragma once 15 | #endif // _MSC_VER > 1000 16 | 17 | #include "ThostFtdcUserApiStruct.h" 18 | 19 | #if defined(ISLIB) && defined(WIN32) 20 | #ifdef LIB_MD_API_EXPORT 21 | #define MD_API_EXPORT __declspec(dllexport) 22 | #else 23 | #define MD_API_EXPORT __declspec(dllimport) 24 | #endif 25 | #else 26 | #define MD_API_EXPORT 27 | #endif 28 | 29 | class CThostFtdcMdSpi 30 | { 31 | public: 32 | ///当客户端与交易后台建立起通信连接时(还未登录前),该方法被调用。 33 | virtual void OnFrontConnected(){}; 34 | 35 | ///当客户端与交易后台通信连接断开时,该方法被调用。当发生这个情况后,API会自动重新连接,客户端可不做处理。 36 | ///@param nReason 错误原因 37 | /// 0x1001 网络读失败 38 | /// 0x1002 网络写失败 39 | /// 0x2001 接收心跳超时 40 | /// 0x2002 发送心跳失败 41 | /// 0x2003 收到错误报文 42 | virtual void OnFrontDisconnected(int nReason){}; 43 | 44 | ///心跳超时警告。当长时间未收到报文时,该方法被调用。 45 | ///@param nTimeLapse 距离上次接收报文的时间 46 | virtual void OnHeartBeatWarning(int nTimeLapse){}; 47 | 48 | 49 | ///登录请求响应 50 | virtual void OnRspUserLogin(CThostFtdcRspUserLoginField *pRspUserLogin, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 51 | 52 | ///登出请求响应 53 | virtual void OnRspUserLogout(CThostFtdcUserLogoutField *pUserLogout, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 54 | 55 | ///错误应答 56 | virtual void OnRspError(CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 57 | 58 | ///订阅行情应答 59 | virtual void OnRspSubMarketData(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 60 | 61 | ///取消订阅行情应答 62 | virtual void OnRspUnSubMarketData(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 63 | 64 | ///订阅询价应答 65 | virtual void OnRspSubForQuoteRsp(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 66 | 67 | ///取消订阅询价应答 68 | virtual void OnRspUnSubForQuoteRsp(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 69 | 70 | ///深度行情通知 71 | virtual void OnRtnDepthMarketData(CThostFtdcDepthMarketDataField *pDepthMarketData) {}; 72 | 73 | ///询价通知 74 | virtual void OnRtnForQuoteRsp(CThostFtdcForQuoteRspField *pForQuoteRsp) {}; 75 | }; 76 | 77 | class MD_API_EXPORT CThostFtdcMdApi 78 | { 79 | public: 80 | ///创建MdApi 81 | ///@param pszFlowPath 存贮订阅信息文件的目录,默认为当前目录 82 | ///@return 创建出的UserApi 83 | ///modify for udp marketdata 84 | static CThostFtdcMdApi *CreateFtdcMdApi(const char *pszFlowPath = "", const bool bIsUsingUdp=false, const bool bIsMulticast=false); 85 | 86 | ///获取API的版本信息 87 | ///@retrun 获取到的版本号 88 | static const char *GetApiVersion(); 89 | 90 | ///删除接口对象本身 91 | ///@remark 不再使用本接口对象时,调用该函数删除接口对象 92 | virtual void Release() = 0; 93 | 94 | ///初始化 95 | ///@remark 初始化运行环境,只有调用后,接口才开始工作 96 | virtual void Init() = 0; 97 | 98 | ///等待接口线程结束运行 99 | ///@return 线程退出代码 100 | virtual int Join() = 0; 101 | 102 | ///获取当前交易日 103 | ///@retrun 获取到的交易日 104 | ///@remark 只有登录成功后,才能得到正确的交易日 105 | virtual const char *GetTradingDay() = 0; 106 | 107 | ///注册前置机网络地址 108 | ///@param pszFrontAddress:前置机网络地址。 109 | ///@remark 网络地址的格式为:“protocol://ipaddress:port”,如:”tcp://127.0.0.1:17001”。 110 | ///@remark “tcp”代表传输协议,“127.0.0.1”代表服务器地址。”17001”代表服务器端口号。 111 | virtual void RegisterFront(char *pszFrontAddress) = 0; 112 | 113 | ///注册名字服务器网络地址 114 | ///@param pszNsAddress:名字服务器网络地址。 115 | ///@remark 网络地址的格式为:“protocol://ipaddress:port”,如:”tcp://127.0.0.1:12001”。 116 | ///@remark “tcp”代表传输协议,“127.0.0.1”代表服务器地址。”12001”代表服务器端口号。 117 | ///@remark RegisterNameServer优先于RegisterFront 118 | virtual void RegisterNameServer(char *pszNsAddress) = 0; 119 | 120 | ///注册名字服务器用户信息 121 | ///@param pFensUserInfo:用户信息。 122 | virtual void RegisterFensUserInfo(CThostFtdcFensUserInfoField * pFensUserInfo) = 0; 123 | 124 | ///注册回调接口 125 | ///@param pSpi 派生自回调接口类的实例 126 | virtual void RegisterSpi(CThostFtdcMdSpi *pSpi) = 0; 127 | 128 | ///订阅行情。 129 | ///@param ppInstrumentID 合约ID 130 | ///@param nCount 要订阅/退订行情的合约个数 131 | ///@remark 132 | virtual int SubscribeMarketData(char *ppInstrumentID[], int nCount) = 0; 133 | 134 | ///退订行情。 135 | ///@param ppInstrumentID 合约ID 136 | ///@param nCount 要订阅/退订行情的合约个数 137 | ///@remark 138 | virtual int UnSubscribeMarketData(char *ppInstrumentID[], int nCount) = 0; 139 | 140 | ///订阅询价。 141 | ///@param ppInstrumentID 合约ID 142 | ///@param nCount 要订阅/退订行情的合约个数 143 | ///@remark 144 | virtual int SubscribeForQuoteRsp(char *ppInstrumentID[], int nCount) = 0; 145 | 146 | ///退订询价。 147 | ///@param ppInstrumentID 合约ID 148 | ///@param nCount 要订阅/退订行情的合约个数 149 | ///@remark 150 | virtual int UnSubscribeForQuoteRsp(char *ppInstrumentID[], int nCount) = 0; 151 | 152 | ///用户登录请求 153 | virtual int ReqUserLogin(CThostFtdcReqUserLoginField *pReqUserLoginField, int nRequestID) = 0; 154 | 155 | 156 | ///登出请求 157 | virtual int ReqUserLogout(CThostFtdcUserLogoutField *pUserLogout, int nRequestID) = 0; 158 | protected: 159 | ~CThostFtdcMdApi(){}; 160 | }; 161 | 162 | #endif 163 | -------------------------------------------------------------------------------- /api/6.3.15/linux/error.dtd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | -------------------------------------------------------------------------------- /api/6.3.15/linux/error.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | -------------------------------------------------------------------------------- /api/6.3.15/linux/libthostmduserapi_se.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keli/ctp-python/31295a4044c00f34b326b2c4d675568b4e7b78c3/api/6.3.15/linux/libthostmduserapi_se.so -------------------------------------------------------------------------------- /api/6.3.15/linux/libthosttraderapi_se.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keli/ctp-python/31295a4044c00f34b326b2c4d675568b4e7b78c3/api/6.3.15/linux/libthosttraderapi_se.so -------------------------------------------------------------------------------- /api/6.5.1.c/linux/ThostFtdcMdApi.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////// 2 | ///@system 新一代交易所系统 3 | ///@company 上海期货信息技术有限公司 4 | ///@file ThostFtdcMdApi.h 5 | ///@brief 定义了客户端接口 6 | ///@history 7 | ///20060106 赵鸿昊 创建该文件 8 | ///////////////////////////////////////////////////////////////////////// 9 | 10 | #if !defined(THOST_FTDCMDAPI_H) 11 | #define THOST_FTDCMDAPI_H 12 | 13 | #if _MSC_VER > 1000 14 | #pragma once 15 | #endif // _MSC_VER > 1000 16 | 17 | #include "ThostFtdcUserApiStruct.h" 18 | 19 | #if defined(ISLIB) && defined(WIN32) 20 | #ifdef LIB_MD_API_EXPORT 21 | #define MD_API_EXPORT __declspec(dllexport) 22 | #else 23 | #define MD_API_EXPORT __declspec(dllimport) 24 | #endif 25 | #else 26 | #define MD_API_EXPORT 27 | #endif 28 | 29 | class CThostFtdcMdSpi 30 | { 31 | public: 32 | ///当客户端与交易后台建立起通信连接时(还未登录前),该方法被调用。 33 | virtual void OnFrontConnected(){}; 34 | 35 | ///当客户端与交易后台通信连接断开时,该方法被调用。当发生这个情况后,API会自动重新连接,客户端可不做处理。 36 | ///@param nReason 错误原因 37 | /// 0x1001 网络读失败 38 | /// 0x1002 网络写失败 39 | /// 0x2001 接收心跳超时 40 | /// 0x2002 发送心跳失败 41 | /// 0x2003 收到错误报文 42 | virtual void OnFrontDisconnected(int nReason){}; 43 | 44 | ///心跳超时警告。当长时间未收到报文时,该方法被调用。 45 | ///@param nTimeLapse 距离上次接收报文的时间 46 | virtual void OnHeartBeatWarning(int nTimeLapse){}; 47 | 48 | 49 | ///登录请求响应 50 | virtual void OnRspUserLogin(CThostFtdcRspUserLoginField *pRspUserLogin, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 51 | 52 | ///登出请求响应 53 | virtual void OnRspUserLogout(CThostFtdcUserLogoutField *pUserLogout, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 54 | 55 | ///请求查询组播合约响应 56 | virtual void OnRspQryMulticastInstrument(CThostFtdcMulticastInstrumentField *pMulticastInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 57 | 58 | ///错误应答 59 | virtual void OnRspError(CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 60 | 61 | ///订阅行情应答 62 | virtual void OnRspSubMarketData(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 63 | 64 | ///取消订阅行情应答 65 | virtual void OnRspUnSubMarketData(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 66 | 67 | ///订阅询价应答 68 | virtual void OnRspSubForQuoteRsp(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 69 | 70 | ///取消订阅询价应答 71 | virtual void OnRspUnSubForQuoteRsp(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 72 | 73 | ///深度行情通知 74 | virtual void OnRtnDepthMarketData(CThostFtdcDepthMarketDataField *pDepthMarketData) {}; 75 | 76 | ///询价通知 77 | virtual void OnRtnForQuoteRsp(CThostFtdcForQuoteRspField *pForQuoteRsp) {}; 78 | }; 79 | 80 | class MD_API_EXPORT CThostFtdcMdApi 81 | { 82 | public: 83 | ///创建MdApi 84 | ///@param pszFlowPath 存贮订阅信息文件的目录,默认为当前目录 85 | ///@return 创建出的UserApi 86 | ///modify for udp marketdata 87 | static CThostFtdcMdApi *CreateFtdcMdApi(const char *pszFlowPath = "", const bool bIsUsingUdp=false, const bool bIsMulticast=false); 88 | 89 | ///获取API的版本信息 90 | ///@retrun 获取到的版本号 91 | static const char *GetApiVersion(); 92 | 93 | ///删除接口对象本身 94 | ///@remark 不再使用本接口对象时,调用该函数删除接口对象 95 | virtual void Release() = 0; 96 | 97 | ///初始化 98 | ///@remark 初始化运行环境,只有调用后,接口才开始工作 99 | virtual void Init() = 0; 100 | 101 | ///等待接口线程结束运行 102 | ///@return 线程退出代码 103 | virtual int Join() = 0; 104 | 105 | ///获取当前交易日 106 | ///@retrun 获取到的交易日 107 | ///@remark 只有登录成功后,才能得到正确的交易日 108 | virtual const char *GetTradingDay() = 0; 109 | 110 | ///注册前置机网络地址 111 | ///@param pszFrontAddress:前置机网络地址。 112 | ///@remark 网络地址的格式为:“protocol://ipaddress:port”,如:”tcp://127.0.0.1:17001”。 113 | ///@remark “tcp”代表传输协议,“127.0.0.1”代表服务器地址。”17001”代表服务器端口号。 114 | virtual void RegisterFront(char *pszFrontAddress) = 0; 115 | 116 | ///注册名字服务器网络地址 117 | ///@param pszNsAddress:名字服务器网络地址。 118 | ///@remark 网络地址的格式为:“protocol://ipaddress:port”,如:”tcp://127.0.0.1:12001”。 119 | ///@remark “tcp”代表传输协议,“127.0.0.1”代表服务器地址。”12001”代表服务器端口号。 120 | ///@remark RegisterNameServer优先于RegisterFront 121 | virtual void RegisterNameServer(char *pszNsAddress) = 0; 122 | 123 | ///注册名字服务器用户信息 124 | ///@param pFensUserInfo:用户信息。 125 | virtual void RegisterFensUserInfo(CThostFtdcFensUserInfoField * pFensUserInfo) = 0; 126 | 127 | ///注册回调接口 128 | ///@param pSpi 派生自回调接口类的实例 129 | virtual void RegisterSpi(CThostFtdcMdSpi *pSpi) = 0; 130 | 131 | ///订阅行情。 132 | ///@param ppInstrumentID 合约ID 133 | ///@param nCount 要订阅/退订行情的合约个数 134 | ///@remark 135 | virtual int SubscribeMarketData(char *ppInstrumentID[], int nCount) = 0; 136 | 137 | ///退订行情。 138 | ///@param ppInstrumentID 合约ID 139 | ///@param nCount 要订阅/退订行情的合约个数 140 | ///@remark 141 | virtual int UnSubscribeMarketData(char *ppInstrumentID[], int nCount) = 0; 142 | 143 | ///订阅询价。 144 | ///@param ppInstrumentID 合约ID 145 | ///@param nCount 要订阅/退订行情的合约个数 146 | ///@remark 147 | virtual int SubscribeForQuoteRsp(char *ppInstrumentID[], int nCount) = 0; 148 | 149 | ///退订询价。 150 | ///@param ppInstrumentID 合约ID 151 | ///@param nCount 要订阅/退订行情的合约个数 152 | ///@remark 153 | virtual int UnSubscribeForQuoteRsp(char *ppInstrumentID[], int nCount) = 0; 154 | 155 | ///用户登录请求 156 | virtual int ReqUserLogin(CThostFtdcReqUserLoginField *pReqUserLoginField, int nRequestID) = 0; 157 | 158 | 159 | ///登出请求 160 | virtual int ReqUserLogout(CThostFtdcUserLogoutField *pUserLogout, int nRequestID) = 0; 161 | 162 | ///请求查询组播合约 163 | virtual int ReqQryMulticastInstrument(CThostFtdcQryMulticastInstrumentField *pQryMulticastInstrument, int nRequestID) = 0; 164 | protected: 165 | ~CThostFtdcMdApi(){}; 166 | }; 167 | 168 | #endif 169 | -------------------------------------------------------------------------------- /api/6.5.1.c/linux/error.dtd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | -------------------------------------------------------------------------------- /api/6.5.1.c/linux/error.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | ~ 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | -------------------------------------------------------------------------------- /api/6.5.1.c/linux/libthostmduserapi_se.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keli/ctp-python/31295a4044c00f34b326b2c4d675568b4e7b78c3/api/6.5.1.c/linux/libthostmduserapi_se.so -------------------------------------------------------------------------------- /api/6.5.1.c/linux/libthosttraderapi_se.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keli/ctp-python/31295a4044c00f34b326b2c4d675568b4e7b78c3/api/6.5.1.c/linux/libthosttraderapi_se.so -------------------------------------------------------------------------------- /api/6.5.1/linux/ThostFtdcMdApi.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////// 2 | ///@system 新一代交易所系统 3 | ///@company 上海期货信息技术有限公司 4 | ///@file ThostFtdcMdApi.h 5 | ///@brief 定义了客户端接口 6 | ///@history 7 | ///20060106 赵鸿昊 创建该文件 8 | ///////////////////////////////////////////////////////////////////////// 9 | 10 | #if !defined(THOST_FTDCMDAPI_H) 11 | #define THOST_FTDCMDAPI_H 12 | 13 | #if _MSC_VER > 1000 14 | #pragma once 15 | #endif // _MSC_VER > 1000 16 | 17 | #include "ThostFtdcUserApiStruct.h" 18 | 19 | #if defined(ISLIB) && defined(WIN32) 20 | #ifdef LIB_MD_API_EXPORT 21 | #define MD_API_EXPORT __declspec(dllexport) 22 | #else 23 | #define MD_API_EXPORT __declspec(dllimport) 24 | #endif 25 | #else 26 | #define MD_API_EXPORT 27 | #endif 28 | 29 | class CThostFtdcMdSpi 30 | { 31 | public: 32 | ///当客户端与交易后台建立起通信连接时(还未登录前),该方法被调用。 33 | virtual void OnFrontConnected(){}; 34 | 35 | ///当客户端与交易后台通信连接断开时,该方法被调用。当发生这个情况后,API会自动重新连接,客户端可不做处理。 36 | ///@param nReason 错误原因 37 | /// 0x1001 网络读失败 38 | /// 0x1002 网络写失败 39 | /// 0x2001 接收心跳超时 40 | /// 0x2002 发送心跳失败 41 | /// 0x2003 收到错误报文 42 | virtual void OnFrontDisconnected(int nReason){}; 43 | 44 | ///心跳超时警告。当长时间未收到报文时,该方法被调用。 45 | ///@param nTimeLapse 距离上次接收报文的时间 46 | virtual void OnHeartBeatWarning(int nTimeLapse){}; 47 | 48 | 49 | ///登录请求响应 50 | virtual void OnRspUserLogin(CThostFtdcRspUserLoginField *pRspUserLogin, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 51 | 52 | ///登出请求响应 53 | virtual void OnRspUserLogout(CThostFtdcUserLogoutField *pUserLogout, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 54 | 55 | ///请求查询组播合约响应 56 | virtual void OnRspQryMulticastInstrument(CThostFtdcMulticastInstrumentField *pMulticastInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 57 | 58 | ///错误应答 59 | virtual void OnRspError(CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 60 | 61 | ///订阅行情应答 62 | virtual void OnRspSubMarketData(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 63 | 64 | ///取消订阅行情应答 65 | virtual void OnRspUnSubMarketData(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 66 | 67 | ///订阅询价应答 68 | virtual void OnRspSubForQuoteRsp(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 69 | 70 | ///取消订阅询价应答 71 | virtual void OnRspUnSubForQuoteRsp(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 72 | 73 | ///深度行情通知 74 | virtual void OnRtnDepthMarketData(CThostFtdcDepthMarketDataField *pDepthMarketData) {}; 75 | 76 | ///询价通知 77 | virtual void OnRtnForQuoteRsp(CThostFtdcForQuoteRspField *pForQuoteRsp) {}; 78 | }; 79 | 80 | class MD_API_EXPORT CThostFtdcMdApi 81 | { 82 | public: 83 | ///创建MdApi 84 | ///@param pszFlowPath 存贮订阅信息文件的目录,默认为当前目录 85 | ///@return 创建出的UserApi 86 | ///modify for udp marketdata 87 | static CThostFtdcMdApi *CreateFtdcMdApi(const char *pszFlowPath = "", const bool bIsUsingUdp=false, const bool bIsMulticast=false); 88 | 89 | ///获取API的版本信息 90 | ///@retrun 获取到的版本号 91 | static const char *GetApiVersion(); 92 | 93 | ///删除接口对象本身 94 | ///@remark 不再使用本接口对象时,调用该函数删除接口对象 95 | virtual void Release() = 0; 96 | 97 | ///初始化 98 | ///@remark 初始化运行环境,只有调用后,接口才开始工作 99 | virtual void Init() = 0; 100 | 101 | ///等待接口线程结束运行 102 | ///@return 线程退出代码 103 | virtual int Join() = 0; 104 | 105 | ///获取当前交易日 106 | ///@retrun 获取到的交易日 107 | ///@remark 只有登录成功后,才能得到正确的交易日 108 | virtual const char *GetTradingDay() = 0; 109 | 110 | ///注册前置机网络地址 111 | ///@param pszFrontAddress:前置机网络地址。 112 | ///@remark 网络地址的格式为:“protocol://ipaddress:port”,如:”tcp://127.0.0.1:17001”。 113 | ///@remark “tcp”代表传输协议,“127.0.0.1”代表服务器地址。”17001”代表服务器端口号。 114 | virtual void RegisterFront(char *pszFrontAddress) = 0; 115 | 116 | ///注册名字服务器网络地址 117 | ///@param pszNsAddress:名字服务器网络地址。 118 | ///@remark 网络地址的格式为:“protocol://ipaddress:port”,如:”tcp://127.0.0.1:12001”。 119 | ///@remark “tcp”代表传输协议,“127.0.0.1”代表服务器地址。”12001”代表服务器端口号。 120 | ///@remark RegisterNameServer优先于RegisterFront 121 | virtual void RegisterNameServer(char *pszNsAddress) = 0; 122 | 123 | ///注册名字服务器用户信息 124 | ///@param pFensUserInfo:用户信息。 125 | virtual void RegisterFensUserInfo(CThostFtdcFensUserInfoField * pFensUserInfo) = 0; 126 | 127 | ///注册回调接口 128 | ///@param pSpi 派生自回调接口类的实例 129 | virtual void RegisterSpi(CThostFtdcMdSpi *pSpi) = 0; 130 | 131 | ///订阅行情。 132 | ///@param ppInstrumentID 合约ID 133 | ///@param nCount 要订阅/退订行情的合约个数 134 | ///@remark 135 | virtual int SubscribeMarketData(char *ppInstrumentID[], int nCount) = 0; 136 | 137 | ///退订行情。 138 | ///@param ppInstrumentID 合约ID 139 | ///@param nCount 要订阅/退订行情的合约个数 140 | ///@remark 141 | virtual int UnSubscribeMarketData(char *ppInstrumentID[], int nCount) = 0; 142 | 143 | ///订阅询价。 144 | ///@param ppInstrumentID 合约ID 145 | ///@param nCount 要订阅/退订行情的合约个数 146 | ///@remark 147 | virtual int SubscribeForQuoteRsp(char *ppInstrumentID[], int nCount) = 0; 148 | 149 | ///退订询价。 150 | ///@param ppInstrumentID 合约ID 151 | ///@param nCount 要订阅/退订行情的合约个数 152 | ///@remark 153 | virtual int UnSubscribeForQuoteRsp(char *ppInstrumentID[], int nCount) = 0; 154 | 155 | ///用户登录请求 156 | virtual int ReqUserLogin(CThostFtdcReqUserLoginField *pReqUserLoginField, int nRequestID) = 0; 157 | 158 | 159 | ///登出请求 160 | virtual int ReqUserLogout(CThostFtdcUserLogoutField *pUserLogout, int nRequestID) = 0; 161 | 162 | ///请求查询组播合约 163 | virtual int ReqQryMulticastInstrument(CThostFtdcQryMulticastInstrumentField *pQryMulticastInstrument, int nRequestID) = 0; 164 | protected: 165 | ~CThostFtdcMdApi(){}; 166 | }; 167 | 168 | #endif 169 | -------------------------------------------------------------------------------- /api/6.5.1/linux/error.dtd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | -------------------------------------------------------------------------------- /api/6.5.1/linux/error.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | ~ 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | -------------------------------------------------------------------------------- /api/6.5.1/linux/libthostmduserapi_se.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keli/ctp-python/31295a4044c00f34b326b2c4d675568b4e7b78c3/api/6.5.1/linux/libthostmduserapi_se.so -------------------------------------------------------------------------------- /api/6.5.1/linux/libthosttraderapi_se.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keli/ctp-python/31295a4044c00f34b326b2c4d675568b4e7b78c3/api/6.5.1/linux/libthosttraderapi_se.so -------------------------------------------------------------------------------- /api/6.6.1.c/linux/ThostFtdcMdApi.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////// 2 | ///@system 新一代交易所系统 3 | ///@company 上海期货信息技术有限公司 4 | ///@file ThostFtdcMdApi.h 5 | ///@brief 定义了客户端接口 6 | ///@history 7 | ///20060106 赵鸿昊 创建该文件 8 | ///////////////////////////////////////////////////////////////////////// 9 | 10 | #if !defined(THOST_FTDCMDAPI_H) 11 | #define THOST_FTDCMDAPI_H 12 | 13 | #if _MSC_VER > 1000 14 | #pragma once 15 | #endif // _MSC_VER > 1000 16 | 17 | #include "ThostFtdcUserApiStruct.h" 18 | 19 | #if defined(ISLIB) && defined(WIN32) 20 | #ifdef LIB_MD_API_EXPORT 21 | #define MD_API_EXPORT __declspec(dllexport) 22 | #else 23 | #define MD_API_EXPORT __declspec(dllimport) 24 | #endif 25 | #else 26 | #define MD_API_EXPORT 27 | #endif 28 | 29 | class CThostFtdcMdSpi 30 | { 31 | public: 32 | ///当客户端与交易后台建立起通信连接时(还未登录前),该方法被调用。 33 | virtual void OnFrontConnected(){}; 34 | 35 | ///当客户端与交易后台通信连接断开时,该方法被调用。当发生这个情况后,API会自动重新连接,客户端可不做处理。 36 | ///@param nReason 错误原因 37 | /// 0x1001 网络读失败 38 | /// 0x1002 网络写失败 39 | /// 0x2001 接收心跳超时 40 | /// 0x2002 发送心跳失败 41 | /// 0x2003 收到错误报文 42 | virtual void OnFrontDisconnected(int nReason){}; 43 | 44 | ///心跳超时警告。当长时间未收到报文时,该方法被调用。 45 | ///@param nTimeLapse 距离上次接收报文的时间 46 | virtual void OnHeartBeatWarning(int nTimeLapse){}; 47 | 48 | 49 | ///登录请求响应 50 | virtual void OnRspUserLogin(CThostFtdcRspUserLoginField *pRspUserLogin, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 51 | 52 | ///登出请求响应 53 | virtual void OnRspUserLogout(CThostFtdcUserLogoutField *pUserLogout, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 54 | 55 | ///请求查询组播合约响应 56 | virtual void OnRspQryMulticastInstrument(CThostFtdcMulticastInstrumentField *pMulticastInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 57 | 58 | ///错误应答 59 | virtual void OnRspError(CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 60 | 61 | ///订阅行情应答 62 | virtual void OnRspSubMarketData(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 63 | 64 | ///取消订阅行情应答 65 | virtual void OnRspUnSubMarketData(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 66 | 67 | ///订阅询价应答 68 | virtual void OnRspSubForQuoteRsp(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 69 | 70 | ///取消订阅询价应答 71 | virtual void OnRspUnSubForQuoteRsp(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 72 | 73 | ///深度行情通知 74 | virtual void OnRtnDepthMarketData(CThostFtdcDepthMarketDataField *pDepthMarketData) {}; 75 | 76 | ///询价通知 77 | virtual void OnRtnForQuoteRsp(CThostFtdcForQuoteRspField *pForQuoteRsp) {}; 78 | }; 79 | 80 | class MD_API_EXPORT CThostFtdcMdApi 81 | { 82 | public: 83 | ///创建MdApi 84 | ///@param pszFlowPath 存贮订阅信息文件的目录,默认为当前目录 85 | ///@return 创建出的UserApi 86 | ///modify for udp marketdata 87 | static CThostFtdcMdApi *CreateFtdcMdApi(const char *pszFlowPath = "", const bool bIsUsingUdp=false, const bool bIsMulticast=false); 88 | 89 | ///获取API的版本信息 90 | ///@retrun 获取到的版本号 91 | static const char *GetApiVersion(); 92 | 93 | ///删除接口对象本身 94 | ///@remark 不再使用本接口对象时,调用该函数删除接口对象 95 | virtual void Release() = 0; 96 | 97 | ///初始化 98 | ///@remark 初始化运行环境,只有调用后,接口才开始工作 99 | virtual void Init() = 0; 100 | 101 | ///等待接口线程结束运行 102 | ///@return 线程退出代码 103 | virtual int Join() = 0; 104 | 105 | ///获取当前交易日 106 | ///@retrun 获取到的交易日 107 | ///@remark 只有登录成功后,才能得到正确的交易日 108 | virtual const char *GetTradingDay() = 0; 109 | 110 | ///注册前置机网络地址 111 | ///@param pszFrontAddress:前置机网络地址。 112 | ///@remark 网络地址的格式为:“protocol://ipaddress:port”,如:”tcp://127.0.0.1:17001”。 113 | ///@remark “tcp”代表传输协议,“127.0.0.1”代表服务器地址。”17001”代表服务器端口号。 114 | virtual void RegisterFront(char *pszFrontAddress) = 0; 115 | 116 | ///注册名字服务器网络地址 117 | ///@param pszNsAddress:名字服务器网络地址。 118 | ///@remark 网络地址的格式为:“protocol://ipaddress:port”,如:”tcp://127.0.0.1:12001”。 119 | ///@remark “tcp”代表传输协议,“127.0.0.1”代表服务器地址。”12001”代表服务器端口号。 120 | ///@remark RegisterNameServer优先于RegisterFront 121 | virtual void RegisterNameServer(char *pszNsAddress) = 0; 122 | 123 | ///注册名字服务器用户信息 124 | ///@param pFensUserInfo:用户信息。 125 | virtual void RegisterFensUserInfo(CThostFtdcFensUserInfoField * pFensUserInfo) = 0; 126 | 127 | ///注册回调接口 128 | ///@param pSpi 派生自回调接口类的实例 129 | virtual void RegisterSpi(CThostFtdcMdSpi *pSpi) = 0; 130 | 131 | ///订阅行情。 132 | ///@param ppInstrumentID 合约ID 133 | ///@param nCount 要订阅/退订行情的合约个数 134 | ///@remark 135 | virtual int SubscribeMarketData(char *ppInstrumentID[], int nCount) = 0; 136 | 137 | ///退订行情。 138 | ///@param ppInstrumentID 合约ID 139 | ///@param nCount 要订阅/退订行情的合约个数 140 | ///@remark 141 | virtual int UnSubscribeMarketData(char *ppInstrumentID[], int nCount) = 0; 142 | 143 | ///订阅询价。 144 | ///@param ppInstrumentID 合约ID 145 | ///@param nCount 要订阅/退订行情的合约个数 146 | ///@remark 147 | virtual int SubscribeForQuoteRsp(char *ppInstrumentID[], int nCount) = 0; 148 | 149 | ///退订询价。 150 | ///@param ppInstrumentID 合约ID 151 | ///@param nCount 要订阅/退订行情的合约个数 152 | ///@remark 153 | virtual int UnSubscribeForQuoteRsp(char *ppInstrumentID[], int nCount) = 0; 154 | 155 | ///用户登录请求 156 | virtual int ReqUserLogin(CThostFtdcReqUserLoginField *pReqUserLoginField, int nRequestID) = 0; 157 | 158 | 159 | ///登出请求 160 | virtual int ReqUserLogout(CThostFtdcUserLogoutField *pUserLogout, int nRequestID) = 0; 161 | 162 | ///请求查询组播合约 163 | virtual int ReqQryMulticastInstrument(CThostFtdcQryMulticastInstrumentField *pQryMulticastInstrument, int nRequestID) = 0; 164 | protected: 165 | ~CThostFtdcMdApi(){}; 166 | }; 167 | 168 | #endif 169 | -------------------------------------------------------------------------------- /api/6.6.1.c/linux/error.dtd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | -------------------------------------------------------------------------------- /api/6.6.1.c/linux/libthostmduserapi_se.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keli/ctp-python/31295a4044c00f34b326b2c4d675568b4e7b78c3/api/6.6.1.c/linux/libthostmduserapi_se.so -------------------------------------------------------------------------------- /api/6.6.1.c/linux/libthosttraderapi_se.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keli/ctp-python/31295a4044c00f34b326b2c4d675568b4e7b78c3/api/6.6.1.c/linux/libthosttraderapi_se.so -------------------------------------------------------------------------------- /api/6.6.1/linux/ThostFtdcMdApi.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////// 2 | ///@system 新一代交易所系统 3 | ///@company 上海期货信息技术有限公司 4 | ///@file ThostFtdcMdApi.h 5 | ///@brief 定义了客户端接口 6 | ///@history 7 | ///20060106 赵鸿昊 创建该文件 8 | ///////////////////////////////////////////////////////////////////////// 9 | 10 | #if !defined(THOST_FTDCMDAPI_H) 11 | #define THOST_FTDCMDAPI_H 12 | 13 | #if _MSC_VER > 1000 14 | #pragma once 15 | #endif // _MSC_VER > 1000 16 | 17 | #include "ThostFtdcUserApiStruct.h" 18 | 19 | #if defined(ISLIB) && defined(WIN32) 20 | #ifdef LIB_MD_API_EXPORT 21 | #define MD_API_EXPORT __declspec(dllexport) 22 | #else 23 | #define MD_API_EXPORT __declspec(dllimport) 24 | #endif 25 | #else 26 | #define MD_API_EXPORT 27 | #endif 28 | 29 | class CThostFtdcMdSpi 30 | { 31 | public: 32 | ///当客户端与交易后台建立起通信连接时(还未登录前),该方法被调用。 33 | virtual void OnFrontConnected(){}; 34 | 35 | ///当客户端与交易后台通信连接断开时,该方法被调用。当发生这个情况后,API会自动重新连接,客户端可不做处理。 36 | ///@param nReason 错误原因 37 | /// 0x1001 网络读失败 38 | /// 0x1002 网络写失败 39 | /// 0x2001 接收心跳超时 40 | /// 0x2002 发送心跳失败 41 | /// 0x2003 收到错误报文 42 | virtual void OnFrontDisconnected(int nReason){}; 43 | 44 | ///心跳超时警告。当长时间未收到报文时,该方法被调用。 45 | ///@param nTimeLapse 距离上次接收报文的时间 46 | virtual void OnHeartBeatWarning(int nTimeLapse){}; 47 | 48 | 49 | ///登录请求响应 50 | virtual void OnRspUserLogin(CThostFtdcRspUserLoginField *pRspUserLogin, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 51 | 52 | ///登出请求响应 53 | virtual void OnRspUserLogout(CThostFtdcUserLogoutField *pUserLogout, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 54 | 55 | ///请求查询组播合约响应 56 | virtual void OnRspQryMulticastInstrument(CThostFtdcMulticastInstrumentField *pMulticastInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 57 | 58 | ///错误应答 59 | virtual void OnRspError(CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 60 | 61 | ///订阅行情应答 62 | virtual void OnRspSubMarketData(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 63 | 64 | ///取消订阅行情应答 65 | virtual void OnRspUnSubMarketData(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 66 | 67 | ///订阅询价应答 68 | virtual void OnRspSubForQuoteRsp(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 69 | 70 | ///取消订阅询价应答 71 | virtual void OnRspUnSubForQuoteRsp(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 72 | 73 | ///深度行情通知 74 | virtual void OnRtnDepthMarketData(CThostFtdcDepthMarketDataField *pDepthMarketData) {}; 75 | 76 | ///询价通知 77 | virtual void OnRtnForQuoteRsp(CThostFtdcForQuoteRspField *pForQuoteRsp) {}; 78 | }; 79 | 80 | class MD_API_EXPORT CThostFtdcMdApi 81 | { 82 | public: 83 | ///创建MdApi 84 | ///@param pszFlowPath 存贮订阅信息文件的目录,默认为当前目录 85 | ///@return 创建出的UserApi 86 | ///modify for udp marketdata 87 | static CThostFtdcMdApi *CreateFtdcMdApi(const char *pszFlowPath = "", const bool bIsUsingUdp=false, const bool bIsMulticast=false); 88 | 89 | ///获取API的版本信息 90 | ///@retrun 获取到的版本号 91 | static const char *GetApiVersion(); 92 | 93 | ///删除接口对象本身 94 | ///@remark 不再使用本接口对象时,调用该函数删除接口对象 95 | virtual void Release() = 0; 96 | 97 | ///初始化 98 | ///@remark 初始化运行环境,只有调用后,接口才开始工作 99 | virtual void Init() = 0; 100 | 101 | ///等待接口线程结束运行 102 | ///@return 线程退出代码 103 | virtual int Join() = 0; 104 | 105 | ///获取当前交易日 106 | ///@retrun 获取到的交易日 107 | ///@remark 只有登录成功后,才能得到正确的交易日 108 | virtual const char *GetTradingDay() = 0; 109 | 110 | ///注册前置机网络地址 111 | ///@param pszFrontAddress:前置机网络地址。 112 | ///@remark 网络地址的格式为:“protocol://ipaddress:port”,如:”tcp://127.0.0.1:17001”。 113 | ///@remark “tcp”代表传输协议,“127.0.0.1”代表服务器地址。”17001”代表服务器端口号。 114 | virtual void RegisterFront(char *pszFrontAddress) = 0; 115 | 116 | ///注册名字服务器网络地址 117 | ///@param pszNsAddress:名字服务器网络地址。 118 | ///@remark 网络地址的格式为:“protocol://ipaddress:port”,如:”tcp://127.0.0.1:12001”。 119 | ///@remark “tcp”代表传输协议,“127.0.0.1”代表服务器地址。”12001”代表服务器端口号。 120 | ///@remark RegisterNameServer优先于RegisterFront 121 | virtual void RegisterNameServer(char *pszNsAddress) = 0; 122 | 123 | ///注册名字服务器用户信息 124 | ///@param pFensUserInfo:用户信息。 125 | virtual void RegisterFensUserInfo(CThostFtdcFensUserInfoField * pFensUserInfo) = 0; 126 | 127 | ///注册回调接口 128 | ///@param pSpi 派生自回调接口类的实例 129 | virtual void RegisterSpi(CThostFtdcMdSpi *pSpi) = 0; 130 | 131 | ///订阅行情。 132 | ///@param ppInstrumentID 合约ID 133 | ///@param nCount 要订阅/退订行情的合约个数 134 | ///@remark 135 | virtual int SubscribeMarketData(char *ppInstrumentID[], int nCount) = 0; 136 | 137 | ///退订行情。 138 | ///@param ppInstrumentID 合约ID 139 | ///@param nCount 要订阅/退订行情的合约个数 140 | ///@remark 141 | virtual int UnSubscribeMarketData(char *ppInstrumentID[], int nCount) = 0; 142 | 143 | ///订阅询价。 144 | ///@param ppInstrumentID 合约ID 145 | ///@param nCount 要订阅/退订行情的合约个数 146 | ///@remark 147 | virtual int SubscribeForQuoteRsp(char *ppInstrumentID[], int nCount) = 0; 148 | 149 | ///退订询价。 150 | ///@param ppInstrumentID 合约ID 151 | ///@param nCount 要订阅/退订行情的合约个数 152 | ///@remark 153 | virtual int UnSubscribeForQuoteRsp(char *ppInstrumentID[], int nCount) = 0; 154 | 155 | ///用户登录请求 156 | virtual int ReqUserLogin(CThostFtdcReqUserLoginField *pReqUserLoginField, int nRequestID) = 0; 157 | 158 | 159 | ///登出请求 160 | virtual int ReqUserLogout(CThostFtdcUserLogoutField *pUserLogout, int nRequestID) = 0; 161 | 162 | ///请求查询组播合约 163 | virtual int ReqQryMulticastInstrument(CThostFtdcQryMulticastInstrumentField *pQryMulticastInstrument, int nRequestID) = 0; 164 | protected: 165 | ~CThostFtdcMdApi(){}; 166 | }; 167 | 168 | #endif 169 | -------------------------------------------------------------------------------- /api/6.6.1/linux/error.dtd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | -------------------------------------------------------------------------------- /api/6.6.1/linux/libthostmduserapi_se.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keli/ctp-python/31295a4044c00f34b326b2c4d675568b4e7b78c3/api/6.6.1/linux/libthostmduserapi_se.so -------------------------------------------------------------------------------- /api/6.6.1/linux/libthosttraderapi_se.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keli/ctp-python/31295a4044c00f34b326b2c4d675568b4e7b78c3/api/6.6.1/linux/libthosttraderapi_se.so -------------------------------------------------------------------------------- /api/6.6.9.c/darwin/ThostFtdcMdApi.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////// 2 | ///@system 新一代交易所系统 3 | ///@company 上海期货信息技术有限公司 4 | ///@file ThostFtdcMdApi.h 5 | ///@brief 定义了客户端接口 6 | ///@history 7 | ///20060106 赵鸿昊 创建该文件 8 | ///////////////////////////////////////////////////////////////////////// 9 | 10 | #if !defined(THOST_FTDCMDAPI_H) 11 | #define THOST_FTDCMDAPI_H 12 | 13 | #if _MSC_VER > 1000 14 | #pragma once 15 | #endif // _MSC_VER > 1000 16 | 17 | #include "ThostFtdcUserApiStruct.h" 18 | 19 | #if defined(ISLIB) && defined(WIN32) 20 | #ifdef LIB_MD_API_EXPORT 21 | #define MD_API_EXPORT __declspec(dllexport) 22 | #else 23 | #define MD_API_EXPORT __declspec(dllimport) 24 | #endif 25 | #else 26 | #define MD_API_EXPORT 27 | #endif 28 | 29 | class CThostFtdcMdSpi 30 | { 31 | public: 32 | ///当客户端与交易后台建立起通信连接时(还未登录前),该方法被调用。 33 | virtual void OnFrontConnected(){}; 34 | 35 | ///当客户端与交易后台通信连接断开时,该方法被调用。当发生这个情况后,API会自动重新连接,客户端可不做处理。 36 | ///@param nReason 错误原因 37 | /// 0x1001 网络读失败 38 | /// 0x1002 网络写失败 39 | /// 0x2001 接收心跳超时 40 | /// 0x2002 发送心跳失败 41 | /// 0x2003 收到错误报文 42 | virtual void OnFrontDisconnected(int nReason){}; 43 | 44 | ///心跳超时警告。当长时间未收到报文时,该方法被调用。 45 | ///@param nTimeLapse 距离上次接收报文的时间 46 | virtual void OnHeartBeatWarning(int nTimeLapse){}; 47 | 48 | 49 | ///登录请求响应 50 | virtual void OnRspUserLogin(CThostFtdcRspUserLoginField *pRspUserLogin, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 51 | 52 | ///登出请求响应 53 | virtual void OnRspUserLogout(CThostFtdcUserLogoutField *pUserLogout, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 54 | 55 | ///请求查询组播合约响应 56 | virtual void OnRspQryMulticastInstrument(CThostFtdcMulticastInstrumentField *pMulticastInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 57 | 58 | ///错误应答 59 | virtual void OnRspError(CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 60 | 61 | ///订阅行情应答 62 | virtual void OnRspSubMarketData(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 63 | 64 | ///取消订阅行情应答 65 | virtual void OnRspUnSubMarketData(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 66 | 67 | ///订阅询价应答 68 | virtual void OnRspSubForQuoteRsp(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 69 | 70 | ///取消订阅询价应答 71 | virtual void OnRspUnSubForQuoteRsp(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 72 | 73 | ///深度行情通知 74 | virtual void OnRtnDepthMarketData(CThostFtdcDepthMarketDataField *pDepthMarketData) {}; 75 | 76 | ///询价通知 77 | virtual void OnRtnForQuoteRsp(CThostFtdcForQuoteRspField *pForQuoteRsp) {}; 78 | }; 79 | 80 | class MD_API_EXPORT CThostFtdcMdApi 81 | { 82 | public: 83 | ///创建MdApi 84 | ///@param pszFlowPath 存贮订阅信息文件的目录,默认为当前目录 85 | ///@return 创建出的UserApi 86 | ///modify for udp marketdata 87 | static CThostFtdcMdApi *CreateFtdcMdApi(const char *pszFlowPath = "", const bool bIsUsingUdp=false, const bool bIsMulticast=false); 88 | 89 | ///获取API的版本信息 90 | ///@retrun 获取到的版本号 91 | static const char *GetApiVersion(); 92 | 93 | ///删除接口对象本身 94 | ///@remark 不再使用本接口对象时,调用该函数删除接口对象 95 | virtual void Release() = 0; 96 | 97 | ///初始化 98 | ///@remark 初始化运行环境,只有调用后,接口才开始工作 99 | virtual void Init() = 0; 100 | 101 | ///等待接口线程结束运行 102 | ///@return 线程退出代码 103 | virtual int Join() = 0; 104 | 105 | ///获取当前交易日 106 | ///@retrun 获取到的交易日 107 | ///@remark 只有登录成功后,才能得到正确的交易日 108 | virtual const char *GetTradingDay() = 0; 109 | 110 | ///注册前置机网络地址 111 | ///@param pszFrontAddress 前置机网络地址。 112 | ///@remark 网络地址的格式为:“protocol://ipaddress:port”,如:”tcp://127.0.0.1:17001”。 113 | ///@remark “tcp”代表传输协议,“127.0.0.1”代表服务器地址。”17001”代表服务器端口号。 114 | virtual void RegisterFront(char *pszFrontAddress) = 0; 115 | 116 | ///注册名字服务器网络地址 117 | ///@param pszNsAddress 名字服务器网络地址。 118 | ///@remark 网络地址的格式为:“protocol://ipaddress:port”,如:”tcp://127.0.0.1:12001”。 119 | ///@remark “tcp”代表传输协议,“127.0.0.1”代表服务器地址。”12001”代表服务器端口号。 120 | ///@remark RegisterNameServer优先于RegisterFront 121 | virtual void RegisterNameServer(char *pszNsAddress) = 0; 122 | 123 | ///注册名字服务器用户信息 124 | ///@param pFensUserInfo 用户信息。 125 | virtual void RegisterFensUserInfo(CThostFtdcFensUserInfoField * pFensUserInfo) = 0; 126 | 127 | ///注册回调接口 128 | ///@param pSpi 派生自回调接口类的实例 129 | virtual void RegisterSpi(CThostFtdcMdSpi *pSpi) = 0; 130 | 131 | ///订阅行情。 132 | ///@param ppInstrumentID 合约ID 133 | ///@param nCount 要订阅/退订行情的合约个数 134 | virtual int SubscribeMarketData(char *ppInstrumentID[], int nCount) = 0; 135 | 136 | ///退订行情。 137 | ///@param ppInstrumentID 合约ID 138 | ///@param nCount 要订阅/退订行情的合约个数 139 | virtual int UnSubscribeMarketData(char *ppInstrumentID[], int nCount) = 0; 140 | 141 | ///订阅询价。 142 | ///@param ppInstrumentID 合约ID 143 | ///@param nCount 要订阅/退订行情的合约个数 144 | virtual int SubscribeForQuoteRsp(char *ppInstrumentID[], int nCount) = 0; 145 | 146 | ///退订询价。 147 | ///@param ppInstrumentID 合约ID 148 | ///@param nCount 要订阅/退订行情的合约个数 149 | virtual int UnSubscribeForQuoteRsp(char *ppInstrumentID[], int nCount) = 0; 150 | 151 | ///用户登录请求 152 | virtual int ReqUserLogin(CThostFtdcReqUserLoginField *pReqUserLoginField, int nRequestID) = 0; 153 | 154 | 155 | ///登出请求 156 | virtual int ReqUserLogout(CThostFtdcUserLogoutField *pUserLogout, int nRequestID) = 0; 157 | 158 | ///请求查询组播合约 159 | virtual int ReqQryMulticastInstrument(CThostFtdcQryMulticastInstrumentField *pQryMulticastInstrument, int nRequestID) = 0; 160 | protected: 161 | ~CThostFtdcMdApi(){}; 162 | }; 163 | 164 | #endif 165 | -------------------------------------------------------------------------------- /api/6.6.9.c/darwin/libcomunicationkeylib.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keli/ctp-python/31295a4044c00f34b326b2c4d675568b4e7b78c3/api/6.6.9.c/darwin/libcomunicationkeylib.a -------------------------------------------------------------------------------- /api/6.6.9.c/darwin/libcrypto.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keli/ctp-python/31295a4044c00f34b326b2c4d675568b4e7b78c3/api/6.6.9.c/darwin/libcrypto.a -------------------------------------------------------------------------------- /api/6.6.9.c/darwin/libssl.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keli/ctp-python/31295a4044c00f34b326b2c4d675568b4e7b78c3/api/6.6.9.c/darwin/libssl.a -------------------------------------------------------------------------------- /api/6.6.9.c/darwin/libthostmduserapi_se.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keli/ctp-python/31295a4044c00f34b326b2c4d675568b4e7b78c3/api/6.6.9.c/darwin/libthostmduserapi_se.a -------------------------------------------------------------------------------- /api/6.6.9.c/darwin/libthosttraderapi_se.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keli/ctp-python/31295a4044c00f34b326b2c4d675568b4e7b78c3/api/6.6.9.c/darwin/libthosttraderapi_se.a -------------------------------------------------------------------------------- /api/6.6.9.c/linux/ThostFtdcMdApi.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////// 2 | ///@system 新一代交易所系统 3 | ///@company 上海期货信息技术有限公司 4 | ///@file ThostFtdcMdApi.h 5 | ///@brief 定义了客户端接口 6 | ///@history 7 | ///20060106 赵鸿昊 创建该文件 8 | ///////////////////////////////////////////////////////////////////////// 9 | 10 | #if !defined(THOST_FTDCMDAPI_H) 11 | #define THOST_FTDCMDAPI_H 12 | 13 | #if _MSC_VER > 1000 14 | #pragma once 15 | #endif // _MSC_VER > 1000 16 | 17 | #include "ThostFtdcUserApiStruct.h" 18 | 19 | #if defined(ISLIB) && defined(WIN32) 20 | #ifdef LIB_MD_API_EXPORT 21 | #define MD_API_EXPORT __declspec(dllexport) 22 | #else 23 | #define MD_API_EXPORT __declspec(dllimport) 24 | #endif 25 | #else 26 | #define MD_API_EXPORT 27 | #endif 28 | 29 | class CThostFtdcMdSpi 30 | { 31 | public: 32 | ///当客户端与交易后台建立起通信连接时(还未登录前),该方法被调用。 33 | virtual void OnFrontConnected(){}; 34 | 35 | ///当客户端与交易后台通信连接断开时,该方法被调用。当发生这个情况后,API会自动重新连接,客户端可不做处理。 36 | ///@param nReason 错误原因 37 | /// 0x1001 网络读失败 38 | /// 0x1002 网络写失败 39 | /// 0x2001 接收心跳超时 40 | /// 0x2002 发送心跳失败 41 | /// 0x2003 收到错误报文 42 | virtual void OnFrontDisconnected(int nReason){}; 43 | 44 | ///心跳超时警告。当长时间未收到报文时,该方法被调用。 45 | ///@param nTimeLapse 距离上次接收报文的时间 46 | virtual void OnHeartBeatWarning(int nTimeLapse){}; 47 | 48 | 49 | ///登录请求响应 50 | virtual void OnRspUserLogin(CThostFtdcRspUserLoginField *pRspUserLogin, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 51 | 52 | ///登出请求响应 53 | virtual void OnRspUserLogout(CThostFtdcUserLogoutField *pUserLogout, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 54 | 55 | ///请求查询组播合约响应 56 | virtual void OnRspQryMulticastInstrument(CThostFtdcMulticastInstrumentField *pMulticastInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 57 | 58 | ///错误应答 59 | virtual void OnRspError(CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 60 | 61 | ///订阅行情应答 62 | virtual void OnRspSubMarketData(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 63 | 64 | ///取消订阅行情应答 65 | virtual void OnRspUnSubMarketData(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 66 | 67 | ///订阅询价应答 68 | virtual void OnRspSubForQuoteRsp(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 69 | 70 | ///取消订阅询价应答 71 | virtual void OnRspUnSubForQuoteRsp(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 72 | 73 | ///深度行情通知 74 | virtual void OnRtnDepthMarketData(CThostFtdcDepthMarketDataField *pDepthMarketData) {}; 75 | 76 | ///询价通知 77 | virtual void OnRtnForQuoteRsp(CThostFtdcForQuoteRspField *pForQuoteRsp) {}; 78 | }; 79 | 80 | class MD_API_EXPORT CThostFtdcMdApi 81 | { 82 | public: 83 | ///创建MdApi 84 | ///@param pszFlowPath 存贮订阅信息文件的目录,默认为当前目录 85 | ///@return 创建出的UserApi 86 | ///modify for udp marketdata 87 | static CThostFtdcMdApi *CreateFtdcMdApi(const char *pszFlowPath = "", const bool bIsUsingUdp=false, const bool bIsMulticast=false); 88 | 89 | ///获取API的版本信息 90 | ///@retrun 获取到的版本号 91 | static const char *GetApiVersion(); 92 | 93 | ///删除接口对象本身 94 | ///@remark 不再使用本接口对象时,调用该函数删除接口对象 95 | virtual void Release() = 0; 96 | 97 | ///初始化 98 | ///@remark 初始化运行环境,只有调用后,接口才开始工作 99 | virtual void Init() = 0; 100 | 101 | ///等待接口线程结束运行 102 | ///@return 线程退出代码 103 | virtual int Join() = 0; 104 | 105 | ///获取当前交易日 106 | ///@retrun 获取到的交易日 107 | ///@remark 只有登录成功后,才能得到正确的交易日 108 | virtual const char *GetTradingDay() = 0; 109 | 110 | ///注册前置机网络地址 111 | ///@param pszFrontAddress:前置机网络地址。 112 | ///@remark 网络地址的格式为:“protocol://ipaddress:port”,如:”tcp://127.0.0.1:17001”。 113 | ///@remark “tcp”代表传输协议,“127.0.0.1”代表服务器地址。”17001”代表服务器端口号。 114 | virtual void RegisterFront(char *pszFrontAddress) = 0; 115 | 116 | ///注册名字服务器网络地址 117 | ///@param pszNsAddress:名字服务器网络地址。 118 | ///@remark 网络地址的格式为:“protocol://ipaddress:port”,如:”tcp://127.0.0.1:12001”。 119 | ///@remark “tcp”代表传输协议,“127.0.0.1”代表服务器地址。”12001”代表服务器端口号。 120 | ///@remark RegisterNameServer优先于RegisterFront 121 | virtual void RegisterNameServer(char *pszNsAddress) = 0; 122 | 123 | ///注册名字服务器用户信息 124 | ///@param pFensUserInfo:用户信息。 125 | virtual void RegisterFensUserInfo(CThostFtdcFensUserInfoField * pFensUserInfo) = 0; 126 | 127 | ///注册回调接口 128 | ///@param pSpi 派生自回调接口类的实例 129 | virtual void RegisterSpi(CThostFtdcMdSpi *pSpi) = 0; 130 | 131 | ///订阅行情。 132 | ///@param ppInstrumentID 合约ID 133 | ///@param nCount 要订阅/退订行情的合约个数 134 | ///@remark 135 | virtual int SubscribeMarketData(char *ppInstrumentID[], int nCount) = 0; 136 | 137 | ///退订行情。 138 | ///@param ppInstrumentID 合约ID 139 | ///@param nCount 要订阅/退订行情的合约个数 140 | ///@remark 141 | virtual int UnSubscribeMarketData(char *ppInstrumentID[], int nCount) = 0; 142 | 143 | ///订阅询价。 144 | ///@param ppInstrumentID 合约ID 145 | ///@param nCount 要订阅/退订行情的合约个数 146 | ///@remark 147 | virtual int SubscribeForQuoteRsp(char *ppInstrumentID[], int nCount) = 0; 148 | 149 | ///退订询价。 150 | ///@param ppInstrumentID 合约ID 151 | ///@param nCount 要订阅/退订行情的合约个数 152 | ///@remark 153 | virtual int UnSubscribeForQuoteRsp(char *ppInstrumentID[], int nCount) = 0; 154 | 155 | ///用户登录请求 156 | virtual int ReqUserLogin(CThostFtdcReqUserLoginField *pReqUserLoginField, int nRequestID) = 0; 157 | 158 | 159 | ///登出请求 160 | virtual int ReqUserLogout(CThostFtdcUserLogoutField *pUserLogout, int nRequestID) = 0; 161 | 162 | ///请求查询组播合约 163 | virtual int ReqQryMulticastInstrument(CThostFtdcQryMulticastInstrumentField *pQryMulticastInstrument, int nRequestID) = 0; 164 | protected: 165 | ~CThostFtdcMdApi(){}; 166 | }; 167 | 168 | #endif 169 | -------------------------------------------------------------------------------- /api/6.6.9.c/linux/error.dtd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | -------------------------------------------------------------------------------- /api/6.6.9.c/linux/libthostmduserapi_se.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keli/ctp-python/31295a4044c00f34b326b2c4d675568b4e7b78c3/api/6.6.9.c/linux/libthostmduserapi_se.so -------------------------------------------------------------------------------- /api/6.6.9.c/linux/libthosttraderapi_se.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keli/ctp-python/31295a4044c00f34b326b2c4d675568b4e7b78c3/api/6.6.9.c/linux/libthosttraderapi_se.so -------------------------------------------------------------------------------- /api/6.6.9.c/windows/ThostFtdcMdApi.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////// 2 | ///@system 新一代交易所系统 3 | ///@company 上海期货信息技术有限公司 4 | ///@file ThostFtdcMdApi.h 5 | ///@brief 定义了客户端接口 6 | ///@history 7 | ///20060106 赵鸿昊 创建该文件 8 | ///////////////////////////////////////////////////////////////////////// 9 | 10 | #if !defined(THOST_FTDCMDAPI_H) 11 | #define THOST_FTDCMDAPI_H 12 | 13 | #if _MSC_VER > 1000 14 | #pragma once 15 | #endif // _MSC_VER > 1000 16 | 17 | #include "ThostFtdcUserApiStruct.h" 18 | 19 | #if defined(ISLIB) && defined(WIN32) 20 | #ifdef LIB_MD_API_EXPORT 21 | #define MD_API_EXPORT __declspec(dllexport) 22 | #else 23 | #define MD_API_EXPORT __declspec(dllimport) 24 | #endif 25 | #else 26 | #define MD_API_EXPORT 27 | #endif 28 | 29 | class CThostFtdcMdSpi 30 | { 31 | public: 32 | ///当客户端与交易后台建立起通信连接时(还未登录前),该方法被调用。 33 | virtual void OnFrontConnected(){}; 34 | 35 | ///当客户端与交易后台通信连接断开时,该方法被调用。当发生这个情况后,API会自动重新连接,客户端可不做处理。 36 | ///@param nReason 错误原因 37 | /// 0x1001 网络读失败 38 | /// 0x1002 网络写失败 39 | /// 0x2001 接收心跳超时 40 | /// 0x2002 发送心跳失败 41 | /// 0x2003 收到错误报文 42 | virtual void OnFrontDisconnected(int nReason){}; 43 | 44 | ///心跳超时警告。当长时间未收到报文时,该方法被调用。 45 | ///@param nTimeLapse 距离上次接收报文的时间 46 | virtual void OnHeartBeatWarning(int nTimeLapse){}; 47 | 48 | 49 | ///登录请求响应 50 | virtual void OnRspUserLogin(CThostFtdcRspUserLoginField *pRspUserLogin, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 51 | 52 | ///登出请求响应 53 | virtual void OnRspUserLogout(CThostFtdcUserLogoutField *pUserLogout, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 54 | 55 | ///请求查询组播合约响应 56 | virtual void OnRspQryMulticastInstrument(CThostFtdcMulticastInstrumentField *pMulticastInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 57 | 58 | ///错误应答 59 | virtual void OnRspError(CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 60 | 61 | ///订阅行情应答 62 | virtual void OnRspSubMarketData(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 63 | 64 | ///取消订阅行情应答 65 | virtual void OnRspUnSubMarketData(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 66 | 67 | ///订阅询价应答 68 | virtual void OnRspSubForQuoteRsp(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 69 | 70 | ///取消订阅询价应答 71 | virtual void OnRspUnSubForQuoteRsp(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 72 | 73 | ///深度行情通知 74 | virtual void OnRtnDepthMarketData(CThostFtdcDepthMarketDataField *pDepthMarketData) {}; 75 | 76 | ///询价通知 77 | virtual void OnRtnForQuoteRsp(CThostFtdcForQuoteRspField *pForQuoteRsp) {}; 78 | }; 79 | 80 | class MD_API_EXPORT CThostFtdcMdApi 81 | { 82 | public: 83 | ///创建MdApi 84 | ///@param pszFlowPath 存贮订阅信息文件的目录,默认为当前目录 85 | ///@return 创建出的UserApi 86 | ///modify for udp marketdata 87 | static CThostFtdcMdApi *CreateFtdcMdApi(const char *pszFlowPath = "", const bool bIsUsingUdp=false, const bool bIsMulticast=false); 88 | 89 | ///获取API的版本信息 90 | ///@retrun 获取到的版本号 91 | static const char *GetApiVersion(); 92 | 93 | ///删除接口对象本身 94 | ///@remark 不再使用本接口对象时,调用该函数删除接口对象 95 | virtual void Release() = 0; 96 | 97 | ///初始化 98 | ///@remark 初始化运行环境,只有调用后,接口才开始工作 99 | virtual void Init() = 0; 100 | 101 | ///等待接口线程结束运行 102 | ///@return 线程退出代码 103 | virtual int Join() = 0; 104 | 105 | ///获取当前交易日 106 | ///@retrun 获取到的交易日 107 | ///@remark 只有登录成功后,才能得到正确的交易日 108 | virtual const char *GetTradingDay() = 0; 109 | 110 | ///注册前置机网络地址 111 | ///@param pszFrontAddress:前置机网络地址。 112 | ///@remark 网络地址的格式为:“protocol://ipaddress:port”,如:”tcp://127.0.0.1:17001”。 113 | ///@remark “tcp”代表传输协议,“127.0.0.1”代表服务器地址。”17001”代表服务器端口号。 114 | virtual void RegisterFront(char *pszFrontAddress) = 0; 115 | 116 | ///注册名字服务器网络地址 117 | ///@param pszNsAddress:名字服务器网络地址。 118 | ///@remark 网络地址的格式为:“protocol://ipaddress:port”,如:”tcp://127.0.0.1:12001”。 119 | ///@remark “tcp”代表传输协议,“127.0.0.1”代表服务器地址。”12001”代表服务器端口号。 120 | ///@remark RegisterNameServer优先于RegisterFront 121 | virtual void RegisterNameServer(char *pszNsAddress) = 0; 122 | 123 | ///注册名字服务器用户信息 124 | ///@param pFensUserInfo:用户信息。 125 | virtual void RegisterFensUserInfo(CThostFtdcFensUserInfoField * pFensUserInfo) = 0; 126 | 127 | ///注册回调接口 128 | ///@param pSpi 派生自回调接口类的实例 129 | virtual void RegisterSpi(CThostFtdcMdSpi *pSpi) = 0; 130 | 131 | ///订阅行情。 132 | ///@param ppInstrumentID 合约ID 133 | ///@param nCount 要订阅/退订行情的合约个数 134 | ///@remark 135 | virtual int SubscribeMarketData(char *ppInstrumentID[], int nCount) = 0; 136 | 137 | ///退订行情。 138 | ///@param ppInstrumentID 合约ID 139 | ///@param nCount 要订阅/退订行情的合约个数 140 | ///@remark 141 | virtual int UnSubscribeMarketData(char *ppInstrumentID[], int nCount) = 0; 142 | 143 | ///订阅询价。 144 | ///@param ppInstrumentID 合约ID 145 | ///@param nCount 要订阅/退订行情的合约个数 146 | ///@remark 147 | virtual int SubscribeForQuoteRsp(char *ppInstrumentID[], int nCount) = 0; 148 | 149 | ///退订询价。 150 | ///@param ppInstrumentID 合约ID 151 | ///@param nCount 要订阅/退订行情的合约个数 152 | ///@remark 153 | virtual int UnSubscribeForQuoteRsp(char *ppInstrumentID[], int nCount) = 0; 154 | 155 | ///用户登录请求 156 | virtual int ReqUserLogin(CThostFtdcReqUserLoginField *pReqUserLoginField, int nRequestID) = 0; 157 | 158 | 159 | ///登出请求 160 | virtual int ReqUserLogout(CThostFtdcUserLogoutField *pUserLogout, int nRequestID) = 0; 161 | 162 | ///请求查询组播合约 163 | virtual int ReqQryMulticastInstrument(CThostFtdcQryMulticastInstrumentField *pQryMulticastInstrument, int nRequestID) = 0; 164 | protected: 165 | ~CThostFtdcMdApi(){}; 166 | }; 167 | 168 | #endif 169 | -------------------------------------------------------------------------------- /api/6.6.9.c/windows/error.dtd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | -------------------------------------------------------------------------------- /api/6.6.9.c/windows/thostmduserapi_se.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keli/ctp-python/31295a4044c00f34b326b2c4d675568b4e7b78c3/api/6.6.9.c/windows/thostmduserapi_se.dll -------------------------------------------------------------------------------- /api/6.6.9.c/windows/thostmduserapi_se.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keli/ctp-python/31295a4044c00f34b326b2c4d675568b4e7b78c3/api/6.6.9.c/windows/thostmduserapi_se.lib -------------------------------------------------------------------------------- /api/6.6.9.c/windows/thosttraderapi_se.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keli/ctp-python/31295a4044c00f34b326b2c4d675568b4e7b78c3/api/6.6.9.c/windows/thosttraderapi_se.dll -------------------------------------------------------------------------------- /api/6.6.9.c/windows/thosttraderapi_se.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keli/ctp-python/31295a4044c00f34b326b2c4d675568b4e7b78c3/api/6.6.9.c/windows/thosttraderapi_se.lib -------------------------------------------------------------------------------- /api/6.6.9/darwin/ThostFtdcMdApi.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////// 2 | ///@system 新一代交易所系统 3 | ///@company 上海期货信息技术有限公司 4 | ///@file ThostFtdcMdApi.h 5 | ///@brief 定义了客户端接口 6 | ///@history 7 | ///20060106 赵鸿昊 创建该文件 8 | ///////////////////////////////////////////////////////////////////////// 9 | 10 | #if !defined(THOST_FTDCMDAPI_H) 11 | #define THOST_FTDCMDAPI_H 12 | 13 | #if _MSC_VER > 1000 14 | #pragma once 15 | #endif // _MSC_VER > 1000 16 | 17 | #include "ThostFtdcUserApiStruct.h" 18 | 19 | #if defined(ISLIB) && defined(WIN32) 20 | #ifdef LIB_MD_API_EXPORT 21 | #define MD_API_EXPORT __declspec(dllexport) 22 | #else 23 | #define MD_API_EXPORT __declspec(dllimport) 24 | #endif 25 | #else 26 | #define MD_API_EXPORT 27 | #endif 28 | 29 | class CThostFtdcMdSpi 30 | { 31 | public: 32 | ///当客户端与交易后台建立起通信连接时(还未登录前),该方法被调用。 33 | virtual void OnFrontConnected(){}; 34 | 35 | ///当客户端与交易后台通信连接断开时,该方法被调用。当发生这个情况后,API会自动重新连接,客户端可不做处理。 36 | ///@param nReason 错误原因 37 | /// 0x1001 网络读失败 38 | /// 0x1002 网络写失败 39 | /// 0x2001 接收心跳超时 40 | /// 0x2002 发送心跳失败 41 | /// 0x2003 收到错误报文 42 | virtual void OnFrontDisconnected(int nReason){}; 43 | 44 | ///心跳超时警告。当长时间未收到报文时,该方法被调用。 45 | ///@param nTimeLapse 距离上次接收报文的时间 46 | virtual void OnHeartBeatWarning(int nTimeLapse){}; 47 | 48 | 49 | ///登录请求响应 50 | virtual void OnRspUserLogin(CThostFtdcRspUserLoginField *pRspUserLogin, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 51 | 52 | ///登出请求响应 53 | virtual void OnRspUserLogout(CThostFtdcUserLogoutField *pUserLogout, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 54 | 55 | ///请求查询组播合约响应 56 | virtual void OnRspQryMulticastInstrument(CThostFtdcMulticastInstrumentField *pMulticastInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 57 | 58 | ///错误应答 59 | virtual void OnRspError(CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 60 | 61 | ///订阅行情应答 62 | virtual void OnRspSubMarketData(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 63 | 64 | ///取消订阅行情应答 65 | virtual void OnRspUnSubMarketData(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 66 | 67 | ///订阅询价应答 68 | virtual void OnRspSubForQuoteRsp(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 69 | 70 | ///取消订阅询价应答 71 | virtual void OnRspUnSubForQuoteRsp(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 72 | 73 | ///深度行情通知 74 | virtual void OnRtnDepthMarketData(CThostFtdcDepthMarketDataField *pDepthMarketData) {}; 75 | 76 | ///询价通知 77 | virtual void OnRtnForQuoteRsp(CThostFtdcForQuoteRspField *pForQuoteRsp) {}; 78 | }; 79 | 80 | class MD_API_EXPORT CThostFtdcMdApi 81 | { 82 | public: 83 | ///创建MdApi 84 | ///@param pszFlowPath 存贮订阅信息文件的目录,默认为当前目录 85 | ///@return 创建出的UserApi 86 | ///modify for udp marketdata 87 | static CThostFtdcMdApi *CreateFtdcMdApi(const char *pszFlowPath = "", const bool bIsUsingUdp=false, const bool bIsMulticast=false); 88 | 89 | ///获取API的版本信息 90 | ///@retrun 获取到的版本号 91 | static const char *GetApiVersion(); 92 | 93 | ///删除接口对象本身 94 | ///@remark 不再使用本接口对象时,调用该函数删除接口对象 95 | virtual void Release() = 0; 96 | 97 | ///初始化 98 | ///@remark 初始化运行环境,只有调用后,接口才开始工作 99 | virtual void Init() = 0; 100 | 101 | ///等待接口线程结束运行 102 | ///@return 线程退出代码 103 | virtual int Join() = 0; 104 | 105 | ///获取当前交易日 106 | ///@retrun 获取到的交易日 107 | ///@remark 只有登录成功后,才能得到正确的交易日 108 | virtual const char *GetTradingDay() = 0; 109 | 110 | ///注册前置机网络地址 111 | ///@param pszFrontAddress 前置机网络地址。 112 | ///@remark 网络地址的格式为:“protocol://ipaddress:port”,如:”tcp://127.0.0.1:17001”。 113 | ///@remark “tcp”代表传输协议,“127.0.0.1”代表服务器地址。”17001”代表服务器端口号。 114 | virtual void RegisterFront(char *pszFrontAddress) = 0; 115 | 116 | ///注册名字服务器网络地址 117 | ///@param pszNsAddress 名字服务器网络地址。 118 | ///@remark 网络地址的格式为:“protocol://ipaddress:port”,如:”tcp://127.0.0.1:12001”。 119 | ///@remark “tcp”代表传输协议,“127.0.0.1”代表服务器地址。”12001”代表服务器端口号。 120 | ///@remark RegisterNameServer优先于RegisterFront 121 | virtual void RegisterNameServer(char *pszNsAddress) = 0; 122 | 123 | ///注册名字服务器用户信息 124 | ///@param pFensUserInfo 用户信息。 125 | virtual void RegisterFensUserInfo(CThostFtdcFensUserInfoField * pFensUserInfo) = 0; 126 | 127 | ///注册回调接口 128 | ///@param pSpi 派生自回调接口类的实例 129 | virtual void RegisterSpi(CThostFtdcMdSpi *pSpi) = 0; 130 | 131 | ///订阅行情。 132 | ///@param ppInstrumentID 合约ID 133 | ///@param nCount 要订阅/退订行情的合约个数 134 | virtual int SubscribeMarketData(char *ppInstrumentID[], int nCount) = 0; 135 | 136 | ///退订行情。 137 | ///@param ppInstrumentID 合约ID 138 | ///@param nCount 要订阅/退订行情的合约个数 139 | virtual int UnSubscribeMarketData(char *ppInstrumentID[], int nCount) = 0; 140 | 141 | ///订阅询价。 142 | ///@param ppInstrumentID 合约ID 143 | ///@param nCount 要订阅/退订行情的合约个数 144 | virtual int SubscribeForQuoteRsp(char *ppInstrumentID[], int nCount) = 0; 145 | 146 | ///退订询价。 147 | ///@param ppInstrumentID 合约ID 148 | ///@param nCount 要订阅/退订行情的合约个数 149 | virtual int UnSubscribeForQuoteRsp(char *ppInstrumentID[], int nCount) = 0; 150 | 151 | ///用户登录请求 152 | virtual int ReqUserLogin(CThostFtdcReqUserLoginField *pReqUserLoginField, int nRequestID) = 0; 153 | 154 | 155 | ///登出请求 156 | virtual int ReqUserLogout(CThostFtdcUserLogoutField *pUserLogout, int nRequestID) = 0; 157 | 158 | ///请求查询组播合约 159 | virtual int ReqQryMulticastInstrument(CThostFtdcQryMulticastInstrumentField *pQryMulticastInstrument, int nRequestID) = 0; 160 | protected: 161 | ~CThostFtdcMdApi(){}; 162 | }; 163 | 164 | #endif 165 | -------------------------------------------------------------------------------- /api/6.6.9/darwin/libcomunicationkeylib.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keli/ctp-python/31295a4044c00f34b326b2c4d675568b4e7b78c3/api/6.6.9/darwin/libcomunicationkeylib.a -------------------------------------------------------------------------------- /api/6.6.9/darwin/libcrypto.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keli/ctp-python/31295a4044c00f34b326b2c4d675568b4e7b78c3/api/6.6.9/darwin/libcrypto.a -------------------------------------------------------------------------------- /api/6.6.9/darwin/libssl.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keli/ctp-python/31295a4044c00f34b326b2c4d675568b4e7b78c3/api/6.6.9/darwin/libssl.a -------------------------------------------------------------------------------- /api/6.6.9/darwin/libthostmduserapi_se.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keli/ctp-python/31295a4044c00f34b326b2c4d675568b4e7b78c3/api/6.6.9/darwin/libthostmduserapi_se.a -------------------------------------------------------------------------------- /api/6.6.9/darwin/libthosttraderapi_se.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keli/ctp-python/31295a4044c00f34b326b2c4d675568b4e7b78c3/api/6.6.9/darwin/libthosttraderapi_se.a -------------------------------------------------------------------------------- /api/6.6.9/linux/ThostFtdcMdApi.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////// 2 | ///@system 新一代交易所系统 3 | ///@company 上海期货信息技术有限公司 4 | ///@file ThostFtdcMdApi.h 5 | ///@brief 定义了客户端接口 6 | ///@history 7 | ///20060106 赵鸿昊 创建该文件 8 | ///////////////////////////////////////////////////////////////////////// 9 | 10 | #if !defined(THOST_FTDCMDAPI_H) 11 | #define THOST_FTDCMDAPI_H 12 | 13 | #if _MSC_VER > 1000 14 | #pragma once 15 | #endif // _MSC_VER > 1000 16 | 17 | #include "ThostFtdcUserApiStruct.h" 18 | 19 | #if defined(ISLIB) && defined(WIN32) 20 | #ifdef LIB_MD_API_EXPORT 21 | #define MD_API_EXPORT __declspec(dllexport) 22 | #else 23 | #define MD_API_EXPORT __declspec(dllimport) 24 | #endif 25 | #else 26 | #define MD_API_EXPORT 27 | #endif 28 | 29 | class CThostFtdcMdSpi 30 | { 31 | public: 32 | ///当客户端与交易后台建立起通信连接时(还未登录前),该方法被调用。 33 | virtual void OnFrontConnected(){}; 34 | 35 | ///当客户端与交易后台通信连接断开时,该方法被调用。当发生这个情况后,API会自动重新连接,客户端可不做处理。 36 | ///@param nReason 错误原因 37 | /// 0x1001 网络读失败 38 | /// 0x1002 网络写失败 39 | /// 0x2001 接收心跳超时 40 | /// 0x2002 发送心跳失败 41 | /// 0x2003 收到错误报文 42 | virtual void OnFrontDisconnected(int nReason){}; 43 | 44 | ///心跳超时警告。当长时间未收到报文时,该方法被调用。 45 | ///@param nTimeLapse 距离上次接收报文的时间 46 | virtual void OnHeartBeatWarning(int nTimeLapse){}; 47 | 48 | 49 | ///登录请求响应 50 | virtual void OnRspUserLogin(CThostFtdcRspUserLoginField *pRspUserLogin, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 51 | 52 | ///登出请求响应 53 | virtual void OnRspUserLogout(CThostFtdcUserLogoutField *pUserLogout, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 54 | 55 | ///请求查询组播合约响应 56 | virtual void OnRspQryMulticastInstrument(CThostFtdcMulticastInstrumentField *pMulticastInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 57 | 58 | ///错误应答 59 | virtual void OnRspError(CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 60 | 61 | ///订阅行情应答 62 | virtual void OnRspSubMarketData(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 63 | 64 | ///取消订阅行情应答 65 | virtual void OnRspUnSubMarketData(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 66 | 67 | ///订阅询价应答 68 | virtual void OnRspSubForQuoteRsp(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 69 | 70 | ///取消订阅询价应答 71 | virtual void OnRspUnSubForQuoteRsp(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 72 | 73 | ///深度行情通知 74 | virtual void OnRtnDepthMarketData(CThostFtdcDepthMarketDataField *pDepthMarketData) {}; 75 | 76 | ///询价通知 77 | virtual void OnRtnForQuoteRsp(CThostFtdcForQuoteRspField *pForQuoteRsp) {}; 78 | }; 79 | 80 | class MD_API_EXPORT CThostFtdcMdApi 81 | { 82 | public: 83 | ///创建MdApi 84 | ///@param pszFlowPath 存贮订阅信息文件的目录,默认为当前目录 85 | ///@return 创建出的UserApi 86 | ///modify for udp marketdata 87 | static CThostFtdcMdApi *CreateFtdcMdApi(const char *pszFlowPath = "", const bool bIsUsingUdp=false, const bool bIsMulticast=false); 88 | 89 | ///获取API的版本信息 90 | ///@retrun 获取到的版本号 91 | static const char *GetApiVersion(); 92 | 93 | ///删除接口对象本身 94 | ///@remark 不再使用本接口对象时,调用该函数删除接口对象 95 | virtual void Release() = 0; 96 | 97 | ///初始化 98 | ///@remark 初始化运行环境,只有调用后,接口才开始工作 99 | virtual void Init() = 0; 100 | 101 | ///等待接口线程结束运行 102 | ///@return 线程退出代码 103 | virtual int Join() = 0; 104 | 105 | ///获取当前交易日 106 | ///@retrun 获取到的交易日 107 | ///@remark 只有登录成功后,才能得到正确的交易日 108 | virtual const char *GetTradingDay() = 0; 109 | 110 | ///注册前置机网络地址 111 | ///@param pszFrontAddress:前置机网络地址。 112 | ///@remark 网络地址的格式为:“protocol://ipaddress:port”,如:”tcp://127.0.0.1:17001”。 113 | ///@remark “tcp”代表传输协议,“127.0.0.1”代表服务器地址。”17001”代表服务器端口号。 114 | virtual void RegisterFront(char *pszFrontAddress) = 0; 115 | 116 | ///注册名字服务器网络地址 117 | ///@param pszNsAddress:名字服务器网络地址。 118 | ///@remark 网络地址的格式为:“protocol://ipaddress:port”,如:”tcp://127.0.0.1:12001”。 119 | ///@remark “tcp”代表传输协议,“127.0.0.1”代表服务器地址。”12001”代表服务器端口号。 120 | ///@remark RegisterNameServer优先于RegisterFront 121 | virtual void RegisterNameServer(char *pszNsAddress) = 0; 122 | 123 | ///注册名字服务器用户信息 124 | ///@param pFensUserInfo:用户信息。 125 | virtual void RegisterFensUserInfo(CThostFtdcFensUserInfoField * pFensUserInfo) = 0; 126 | 127 | ///注册回调接口 128 | ///@param pSpi 派生自回调接口类的实例 129 | virtual void RegisterSpi(CThostFtdcMdSpi *pSpi) = 0; 130 | 131 | ///订阅行情。 132 | ///@param ppInstrumentID 合约ID 133 | ///@param nCount 要订阅/退订行情的合约个数 134 | ///@remark 135 | virtual int SubscribeMarketData(char *ppInstrumentID[], int nCount) = 0; 136 | 137 | ///退订行情。 138 | ///@param ppInstrumentID 合约ID 139 | ///@param nCount 要订阅/退订行情的合约个数 140 | ///@remark 141 | virtual int UnSubscribeMarketData(char *ppInstrumentID[], int nCount) = 0; 142 | 143 | ///订阅询价。 144 | ///@param ppInstrumentID 合约ID 145 | ///@param nCount 要订阅/退订行情的合约个数 146 | ///@remark 147 | virtual int SubscribeForQuoteRsp(char *ppInstrumentID[], int nCount) = 0; 148 | 149 | ///退订询价。 150 | ///@param ppInstrumentID 合约ID 151 | ///@param nCount 要订阅/退订行情的合约个数 152 | ///@remark 153 | virtual int UnSubscribeForQuoteRsp(char *ppInstrumentID[], int nCount) = 0; 154 | 155 | ///用户登录请求 156 | virtual int ReqUserLogin(CThostFtdcReqUserLoginField *pReqUserLoginField, int nRequestID) = 0; 157 | 158 | 159 | ///登出请求 160 | virtual int ReqUserLogout(CThostFtdcUserLogoutField *pUserLogout, int nRequestID) = 0; 161 | 162 | ///请求查询组播合约 163 | virtual int ReqQryMulticastInstrument(CThostFtdcQryMulticastInstrumentField *pQryMulticastInstrument, int nRequestID) = 0; 164 | protected: 165 | ~CThostFtdcMdApi(){}; 166 | }; 167 | 168 | #endif 169 | -------------------------------------------------------------------------------- /api/6.6.9/linux/error.dtd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | -------------------------------------------------------------------------------- /api/6.6.9/linux/libthostmduserapi_se.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keli/ctp-python/31295a4044c00f34b326b2c4d675568b4e7b78c3/api/6.6.9/linux/libthostmduserapi_se.so -------------------------------------------------------------------------------- /api/6.6.9/linux/libthosttraderapi_se.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keli/ctp-python/31295a4044c00f34b326b2c4d675568b4e7b78c3/api/6.6.9/linux/libthosttraderapi_se.so -------------------------------------------------------------------------------- /api/6.6.9/windows/ThostFtdcMdApi.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////// 2 | ///@system 新一代交易所系统 3 | ///@company 上海期货信息技术有限公司 4 | ///@file ThostFtdcMdApi.h 5 | ///@brief 定义了客户端接口 6 | ///@history 7 | ///20060106 赵鸿昊 创建该文件 8 | ///////////////////////////////////////////////////////////////////////// 9 | 10 | #if !defined(THOST_FTDCMDAPI_H) 11 | #define THOST_FTDCMDAPI_H 12 | 13 | #if _MSC_VER > 1000 14 | #pragma once 15 | #endif // _MSC_VER > 1000 16 | 17 | #include "ThostFtdcUserApiStruct.h" 18 | 19 | #if defined(ISLIB) && defined(WIN32) 20 | #ifdef LIB_MD_API_EXPORT 21 | #define MD_API_EXPORT __declspec(dllexport) 22 | #else 23 | #define MD_API_EXPORT __declspec(dllimport) 24 | #endif 25 | #else 26 | #define MD_API_EXPORT 27 | #endif 28 | 29 | class CThostFtdcMdSpi 30 | { 31 | public: 32 | ///当客户端与交易后台建立起通信连接时(还未登录前),该方法被调用。 33 | virtual void OnFrontConnected(){}; 34 | 35 | ///当客户端与交易后台通信连接断开时,该方法被调用。当发生这个情况后,API会自动重新连接,客户端可不做处理。 36 | ///@param nReason 错误原因 37 | /// 0x1001 网络读失败 38 | /// 0x1002 网络写失败 39 | /// 0x2001 接收心跳超时 40 | /// 0x2002 发送心跳失败 41 | /// 0x2003 收到错误报文 42 | virtual void OnFrontDisconnected(int nReason){}; 43 | 44 | ///心跳超时警告。当长时间未收到报文时,该方法被调用。 45 | ///@param nTimeLapse 距离上次接收报文的时间 46 | virtual void OnHeartBeatWarning(int nTimeLapse){}; 47 | 48 | 49 | ///登录请求响应 50 | virtual void OnRspUserLogin(CThostFtdcRspUserLoginField *pRspUserLogin, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 51 | 52 | ///登出请求响应 53 | virtual void OnRspUserLogout(CThostFtdcUserLogoutField *pUserLogout, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 54 | 55 | ///请求查询组播合约响应 56 | virtual void OnRspQryMulticastInstrument(CThostFtdcMulticastInstrumentField *pMulticastInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 57 | 58 | ///错误应答 59 | virtual void OnRspError(CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 60 | 61 | ///订阅行情应答 62 | virtual void OnRspSubMarketData(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 63 | 64 | ///取消订阅行情应答 65 | virtual void OnRspUnSubMarketData(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 66 | 67 | ///订阅询价应答 68 | virtual void OnRspSubForQuoteRsp(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 69 | 70 | ///取消订阅询价应答 71 | virtual void OnRspUnSubForQuoteRsp(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 72 | 73 | ///深度行情通知 74 | virtual void OnRtnDepthMarketData(CThostFtdcDepthMarketDataField *pDepthMarketData) {}; 75 | 76 | ///询价通知 77 | virtual void OnRtnForQuoteRsp(CThostFtdcForQuoteRspField *pForQuoteRsp) {}; 78 | }; 79 | 80 | class MD_API_EXPORT CThostFtdcMdApi 81 | { 82 | public: 83 | ///创建MdApi 84 | ///@param pszFlowPath 存贮订阅信息文件的目录,默认为当前目录 85 | ///@return 创建出的UserApi 86 | ///modify for udp marketdata 87 | static CThostFtdcMdApi *CreateFtdcMdApi(const char *pszFlowPath = "", const bool bIsUsingUdp=false, const bool bIsMulticast=false); 88 | 89 | ///获取API的版本信息 90 | ///@retrun 获取到的版本号 91 | static const char *GetApiVersion(); 92 | 93 | ///删除接口对象本身 94 | ///@remark 不再使用本接口对象时,调用该函数删除接口对象 95 | virtual void Release() = 0; 96 | 97 | ///初始化 98 | ///@remark 初始化运行环境,只有调用后,接口才开始工作 99 | virtual void Init() = 0; 100 | 101 | ///等待接口线程结束运行 102 | ///@return 线程退出代码 103 | virtual int Join() = 0; 104 | 105 | ///获取当前交易日 106 | ///@retrun 获取到的交易日 107 | ///@remark 只有登录成功后,才能得到正确的交易日 108 | virtual const char *GetTradingDay() = 0; 109 | 110 | ///注册前置机网络地址 111 | ///@param pszFrontAddress:前置机网络地址。 112 | ///@remark 网络地址的格式为:“protocol://ipaddress:port”,如:”tcp://127.0.0.1:17001”。 113 | ///@remark “tcp”代表传输协议,“127.0.0.1”代表服务器地址。”17001”代表服务器端口号。 114 | virtual void RegisterFront(char *pszFrontAddress) = 0; 115 | 116 | ///注册名字服务器网络地址 117 | ///@param pszNsAddress:名字服务器网络地址。 118 | ///@remark 网络地址的格式为:“protocol://ipaddress:port”,如:”tcp://127.0.0.1:12001”。 119 | ///@remark “tcp”代表传输协议,“127.0.0.1”代表服务器地址。”12001”代表服务器端口号。 120 | ///@remark RegisterNameServer优先于RegisterFront 121 | virtual void RegisterNameServer(char *pszNsAddress) = 0; 122 | 123 | ///注册名字服务器用户信息 124 | ///@param pFensUserInfo:用户信息。 125 | virtual void RegisterFensUserInfo(CThostFtdcFensUserInfoField * pFensUserInfo) = 0; 126 | 127 | ///注册回调接口 128 | ///@param pSpi 派生自回调接口类的实例 129 | virtual void RegisterSpi(CThostFtdcMdSpi *pSpi) = 0; 130 | 131 | ///订阅行情。 132 | ///@param ppInstrumentID 合约ID 133 | ///@param nCount 要订阅/退订行情的合约个数 134 | ///@remark 135 | virtual int SubscribeMarketData(char *ppInstrumentID[], int nCount) = 0; 136 | 137 | ///退订行情。 138 | ///@param ppInstrumentID 合约ID 139 | ///@param nCount 要订阅/退订行情的合约个数 140 | ///@remark 141 | virtual int UnSubscribeMarketData(char *ppInstrumentID[], int nCount) = 0; 142 | 143 | ///订阅询价。 144 | ///@param ppInstrumentID 合约ID 145 | ///@param nCount 要订阅/退订行情的合约个数 146 | ///@remark 147 | virtual int SubscribeForQuoteRsp(char *ppInstrumentID[], int nCount) = 0; 148 | 149 | ///退订询价。 150 | ///@param ppInstrumentID 合约ID 151 | ///@param nCount 要订阅/退订行情的合约个数 152 | ///@remark 153 | virtual int UnSubscribeForQuoteRsp(char *ppInstrumentID[], int nCount) = 0; 154 | 155 | ///用户登录请求 156 | virtual int ReqUserLogin(CThostFtdcReqUserLoginField *pReqUserLoginField, int nRequestID) = 0; 157 | 158 | 159 | ///登出请求 160 | virtual int ReqUserLogout(CThostFtdcUserLogoutField *pUserLogout, int nRequestID) = 0; 161 | 162 | ///请求查询组播合约 163 | virtual int ReqQryMulticastInstrument(CThostFtdcQryMulticastInstrumentField *pQryMulticastInstrument, int nRequestID) = 0; 164 | protected: 165 | ~CThostFtdcMdApi(){}; 166 | }; 167 | 168 | #endif 169 | -------------------------------------------------------------------------------- /api/6.6.9/windows/error.dtd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | -------------------------------------------------------------------------------- /api/6.6.9/windows/thostmduserapi_se.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keli/ctp-python/31295a4044c00f34b326b2c4d675568b4e7b78c3/api/6.6.9/windows/thostmduserapi_se.dll -------------------------------------------------------------------------------- /api/6.6.9/windows/thostmduserapi_se.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keli/ctp-python/31295a4044c00f34b326b2c4d675568b4e7b78c3/api/6.6.9/windows/thostmduserapi_se.lib -------------------------------------------------------------------------------- /api/6.6.9/windows/thosttraderapi_se.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keli/ctp-python/31295a4044c00f34b326b2c4d675568b4e7b78c3/api/6.6.9/windows/thosttraderapi_se.dll -------------------------------------------------------------------------------- /api/6.6.9/windows/thosttraderapi_se.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keli/ctp-python/31295a4044c00f34b326b2c4d675568b4e7b78c3/api/6.6.9/windows/thosttraderapi_se.lib -------------------------------------------------------------------------------- /api/6.7.7/darwin/thostmduserapi_se.framework/Headers: -------------------------------------------------------------------------------- 1 | Versions/Current/Headers -------------------------------------------------------------------------------- /api/6.7.7/darwin/thostmduserapi_se.framework/Resources: -------------------------------------------------------------------------------- 1 | Versions/Current/Resources -------------------------------------------------------------------------------- /api/6.7.7/darwin/thostmduserapi_se.framework/Versions/A/Headers/ThostFtdcMdApi.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////// 2 | ///@system 新一代交易所系统 3 | ///@company 上海期货信息技术有限公司 4 | ///@file ThostFtdcMdApi.h 5 | ///@brief 定义了客户端接口 6 | ///@history 7 | ///20060106 赵鸿昊 创建该文件 8 | ///////////////////////////////////////////////////////////////////////// 9 | 10 | #if !defined(THOST_FTDCMDAPI_H) 11 | #define THOST_FTDCMDAPI_H 12 | 13 | #if _MSC_VER > 1000 14 | #pragma once 15 | #endif // _MSC_VER > 1000 16 | 17 | #include "ThostFtdcUserApiStruct.h" 18 | 19 | #if defined(ISLIB) && defined(WIN32) 20 | #ifdef LIB_MD_API_EXPORT 21 | #define MD_API_EXPORT __declspec(dllexport) 22 | #else 23 | #define MD_API_EXPORT __declspec(dllimport) 24 | #endif 25 | #else 26 | #define MD_API_EXPORT 27 | #endif 28 | 29 | class CThostFtdcMdSpi 30 | { 31 | public: 32 | ///当客户端与交易后台建立起通信连接时(还未登录前),该方法被调用。 33 | virtual void OnFrontConnected(){}; 34 | 35 | ///当客户端与交易后台通信连接断开时,该方法被调用。当发生这个情况后,API会自动重新连接,客户端可不做处理。 36 | ///@param nReason 错误原因 37 | /// 0x1001 网络读失败 38 | /// 0x1002 网络写失败 39 | /// 0x2001 接收心跳超时 40 | /// 0x2002 发送心跳失败 41 | /// 0x2003 收到错误报文 42 | virtual void OnFrontDisconnected(int nReason){}; 43 | 44 | ///心跳超时警告。当长时间未收到报文时,该方法被调用。 45 | ///@param nTimeLapse 距离上次接收报文的时间 46 | virtual void OnHeartBeatWarning(int nTimeLapse){}; 47 | 48 | 49 | ///登录请求响应 50 | virtual void OnRspUserLogin(CThostFtdcRspUserLoginField *pRspUserLogin, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 51 | 52 | ///登出请求响应 53 | virtual void OnRspUserLogout(CThostFtdcUserLogoutField *pUserLogout, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 54 | 55 | ///请求查询组播合约响应 56 | virtual void OnRspQryMulticastInstrument(CThostFtdcMulticastInstrumentField *pMulticastInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 57 | 58 | ///错误应答 59 | virtual void OnRspError(CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 60 | 61 | ///订阅行情应答 62 | virtual void OnRspSubMarketData(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 63 | 64 | ///取消订阅行情应答 65 | virtual void OnRspUnSubMarketData(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 66 | 67 | ///订阅询价应答 68 | virtual void OnRspSubForQuoteRsp(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 69 | 70 | ///取消订阅询价应答 71 | virtual void OnRspUnSubForQuoteRsp(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 72 | 73 | ///深度行情通知 74 | virtual void OnRtnDepthMarketData(CThostFtdcDepthMarketDataField *pDepthMarketData) {}; 75 | 76 | ///询价通知 77 | virtual void OnRtnForQuoteRsp(CThostFtdcForQuoteRspField *pForQuoteRsp) {}; 78 | }; 79 | 80 | class MD_API_EXPORT CThostFtdcMdApi 81 | { 82 | public: 83 | ///创建MdApi 84 | ///@param pszFlowPath 存贮订阅信息文件的目录,默认为当前目录 85 | ///@return 创建出的UserApi 86 | ///modify for udp marketdata 87 | static CThostFtdcMdApi *CreateFtdcMdApi(const char *pszFlowPath = "", const bool bIsUsingUdp=false, const bool bIsMulticast=false); 88 | 89 | ///获取API的版本信息 90 | ///@retrun 获取到的版本号 91 | static const char *GetApiVersion(); 92 | 93 | ///删除接口对象本身 94 | ///@remark 不再使用本接口对象时,调用该函数删除接口对象 95 | virtual void Release() = 0; 96 | 97 | ///初始化 98 | ///@remark 初始化运行环境,只有调用后,接口才开始工作 99 | virtual void Init() = 0; 100 | 101 | ///等待接口线程结束运行 102 | ///@return 线程退出代码 103 | virtual int Join() = 0; 104 | 105 | ///获取当前交易日 106 | ///@retrun 获取到的交易日 107 | ///@remark 只有登录成功后,才能得到正确的交易日 108 | virtual const char *GetTradingDay() = 0; 109 | 110 | ///注册前置机网络地址 111 | ///@param pszFrontAddress:前置机网络地址。 112 | ///@remark 网络地址的格式为:“protocol://ipaddress:port”,如:”tcp://127.0.0.1:17001”。 113 | ///@remark “tcp”代表传输协议,“127.0.0.1”代表服务器地址。”17001”代表服务器端口号。 114 | virtual void RegisterFront(char *pszFrontAddress) = 0; 115 | 116 | ///注册名字服务器网络地址 117 | ///@param pszNsAddress:名字服务器网络地址。 118 | ///@remark 网络地址的格式为:“protocol://ipaddress:port”,如:”tcp://127.0.0.1:12001”。 119 | ///@remark “tcp”代表传输协议,“127.0.0.1”代表服务器地址。”12001”代表服务器端口号。 120 | ///@remark RegisterNameServer优先于RegisterFront 121 | virtual void RegisterNameServer(char *pszNsAddress) = 0; 122 | 123 | ///注册名字服务器用户信息 124 | ///@param pFensUserInfo:用户信息。 125 | virtual void RegisterFensUserInfo(CThostFtdcFensUserInfoField * pFensUserInfo) = 0; 126 | 127 | ///注册回调接口 128 | ///@param pSpi 派生自回调接口类的实例 129 | virtual void RegisterSpi(CThostFtdcMdSpi *pSpi) = 0; 130 | 131 | ///订阅行情。 132 | ///@param ppInstrumentID 合约ID 133 | ///@param nCount 要订阅/退订行情的合约个数 134 | ///@remark 135 | virtual int SubscribeMarketData(char *ppInstrumentID[], int nCount) = 0; 136 | 137 | ///退订行情。 138 | ///@param ppInstrumentID 合约ID 139 | ///@param nCount 要订阅/退订行情的合约个数 140 | ///@remark 141 | virtual int UnSubscribeMarketData(char *ppInstrumentID[], int nCount) = 0; 142 | 143 | ///订阅询价。 144 | ///@param ppInstrumentID 合约ID 145 | ///@param nCount 要订阅/退订行情的合约个数 146 | ///@remark 147 | virtual int SubscribeForQuoteRsp(char *ppInstrumentID[], int nCount) = 0; 148 | 149 | ///退订询价。 150 | ///@param ppInstrumentID 合约ID 151 | ///@param nCount 要订阅/退订行情的合约个数 152 | ///@remark 153 | virtual int UnSubscribeForQuoteRsp(char *ppInstrumentID[], int nCount) = 0; 154 | 155 | ///用户登录请求 156 | virtual int ReqUserLogin(CThostFtdcReqUserLoginField *pReqUserLoginField, int nRequestID) = 0; 157 | 158 | 159 | ///登出请求 160 | virtual int ReqUserLogout(CThostFtdcUserLogoutField *pUserLogout, int nRequestID) = 0; 161 | 162 | ///请求查询组播合约 163 | virtual int ReqQryMulticastInstrument(CThostFtdcQryMulticastInstrumentField *pQryMulticastInstrument, int nRequestID) = 0; 164 | protected: 165 | ~CThostFtdcMdApi(){}; 166 | }; 167 | 168 | #endif 169 | -------------------------------------------------------------------------------- /api/6.7.7/darwin/thostmduserapi_se.framework/Versions/A/Resources/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | BuildMachineOSBuild 6 | 23F79 7 | CFBundleDevelopmentRegion 8 | en 9 | CFBundleExecutable 10 | thostmduserapi_se 11 | CFBundleIdentifier 12 | com.sfit.thostmduserapi-se 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | thostmduserapi_se 17 | CFBundlePackageType 18 | FMWK 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSupportedPlatforms 22 | 23 | MacOSX 24 | 25 | CFBundleVersion 26 | 1 27 | DTCompiler 28 | com.apple.compilers.llvm.clang.1_0 29 | DTPlatformBuild 30 | 31 | DTPlatformName 32 | macosx 33 | DTPlatformVersion 34 | 14.2 35 | DTSDKBuild 36 | 23C53 37 | DTSDKName 38 | macosx14.2 39 | DTXcode 40 | 1510 41 | DTXcodeBuild 42 | 15C65 43 | LSMinimumSystemVersion 44 | 10.15 45 | 46 | 47 | -------------------------------------------------------------------------------- /api/6.7.7/darwin/thostmduserapi_se.framework/Versions/A/_CodeSignature/CodeResources: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | files 6 | 7 | Resources/Info.plist 8 | 9 | TOE+h5cJeWlDwmJo/Xo5uQQLWvU= 10 | 11 | 12 | files2 13 | 14 | Headers/ThostFtdcMdApi.h 15 | 16 | hash2 17 | 18 | dEtokAKLUmXyqR3WtDgh7HH7BRJ3Cm9ej7AQVvby1Og= 19 | 20 | 21 | Headers/ThostFtdcUserApiDataType.h 22 | 23 | hash2 24 | 25 | jeG/TAar2HshrQ9+4jkob94MKMFWLoH4Xl/HcKjIgww= 26 | 27 | 28 | Headers/ThostFtdcUserApiStruct.h 29 | 30 | hash2 31 | 32 | E0WAQNGnhA4Om36nesySUQiOWRpOfovob8bEQ0DXibU= 33 | 34 | 35 | Resources/Info.plist 36 | 37 | hash2 38 | 39 | W+Y03he/s8YHwth//OW4ntlb03j3ayTRQRuR+s23cWk= 40 | 41 | 42 | 43 | rules 44 | 45 | ^Resources/ 46 | 47 | ^Resources/.*\.lproj/ 48 | 49 | optional 50 | 51 | weight 52 | 1000 53 | 54 | ^Resources/.*\.lproj/locversion.plist$ 55 | 56 | omit 57 | 58 | weight 59 | 1100 60 | 61 | ^Resources/Base\.lproj/ 62 | 63 | weight 64 | 1010 65 | 66 | ^version.plist$ 67 | 68 | 69 | rules2 70 | 71 | .*\.dSYM($|/) 72 | 73 | weight 74 | 11 75 | 76 | ^(.*/)?\.DS_Store$ 77 | 78 | omit 79 | 80 | weight 81 | 2000 82 | 83 | ^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/ 84 | 85 | nested 86 | 87 | weight 88 | 10 89 | 90 | ^.* 91 | 92 | ^Info\.plist$ 93 | 94 | omit 95 | 96 | weight 97 | 20 98 | 99 | ^PkgInfo$ 100 | 101 | omit 102 | 103 | weight 104 | 20 105 | 106 | ^Resources/ 107 | 108 | weight 109 | 20 110 | 111 | ^Resources/.*\.lproj/ 112 | 113 | optional 114 | 115 | weight 116 | 1000 117 | 118 | ^Resources/.*\.lproj/locversion.plist$ 119 | 120 | omit 121 | 122 | weight 123 | 1100 124 | 125 | ^Resources/Base\.lproj/ 126 | 127 | weight 128 | 1010 129 | 130 | ^[^/]+$ 131 | 132 | nested 133 | 134 | weight 135 | 10 136 | 137 | ^embedded\.provisionprofile$ 138 | 139 | weight 140 | 20 141 | 142 | ^version\.plist$ 143 | 144 | weight 145 | 20 146 | 147 | 148 | 149 | 150 | -------------------------------------------------------------------------------- /api/6.7.7/darwin/thostmduserapi_se.framework/Versions/A/thostmduserapi_se: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keli/ctp-python/31295a4044c00f34b326b2c4d675568b4e7b78c3/api/6.7.7/darwin/thostmduserapi_se.framework/Versions/A/thostmduserapi_se -------------------------------------------------------------------------------- /api/6.7.7/darwin/thostmduserapi_se.framework/Versions/Current: -------------------------------------------------------------------------------- 1 | A -------------------------------------------------------------------------------- /api/6.7.7/darwin/thostmduserapi_se.framework/thostmduserapi_se: -------------------------------------------------------------------------------- 1 | Versions/Current/thostmduserapi_se -------------------------------------------------------------------------------- /api/6.7.7/darwin/thosttraderapi_se.framework/Headers: -------------------------------------------------------------------------------- 1 | Versions/Current/Headers -------------------------------------------------------------------------------- /api/6.7.7/darwin/thosttraderapi_se.framework/Resources: -------------------------------------------------------------------------------- 1 | Versions/Current/Resources -------------------------------------------------------------------------------- /api/6.7.7/darwin/thosttraderapi_se.framework/Versions/A/Resources/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | BuildMachineOSBuild 6 | 23F79 7 | CFBundleDevelopmentRegion 8 | en 9 | CFBundleExecutable 10 | thosttraderapi_se 11 | CFBundleIdentifier 12 | com.sfit.thosttraderapi-se 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | thosttraderapi_se 17 | CFBundlePackageType 18 | FMWK 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSupportedPlatforms 22 | 23 | MacOSX 24 | 25 | CFBundleVersion 26 | 1 27 | DTCompiler 28 | com.apple.compilers.llvm.clang.1_0 29 | DTPlatformBuild 30 | 31 | DTPlatformName 32 | macosx 33 | DTPlatformVersion 34 | 14.2 35 | DTSDKBuild 36 | 23C53 37 | DTSDKName 38 | macosx14.2 39 | DTXcode 40 | 1510 41 | DTXcodeBuild 42 | 15C65 43 | LSMinimumSystemVersion 44 | 10.15 45 | 46 | 47 | -------------------------------------------------------------------------------- /api/6.7.7/darwin/thosttraderapi_se.framework/Versions/A/_CodeSignature/CodeResources: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | files 6 | 7 | Resources/Info.plist 8 | 9 | VUxdF9Vsqsjm2nN6RDpWJxe/ttg= 10 | 11 | 12 | files2 13 | 14 | Headers/ThostFtdcTraderApi.h 15 | 16 | hash2 17 | 18 | XOwoHYsnMXiRjCVhgOIQgb+mqapnf7LP1GV5fMix3Yo= 19 | 20 | 21 | Headers/ThostFtdcUserApiDataType.h 22 | 23 | hash2 24 | 25 | jeG/TAar2HshrQ9+4jkob94MKMFWLoH4Xl/HcKjIgww= 26 | 27 | 28 | Headers/ThostFtdcUserApiStruct.h 29 | 30 | hash2 31 | 32 | E0WAQNGnhA4Om36nesySUQiOWRpOfovob8bEQ0DXibU= 33 | 34 | 35 | Resources/Info.plist 36 | 37 | hash2 38 | 39 | WyUVnuil9tugvcHJcCw76ljlp1tONfIfxoKvod2ek+k= 40 | 41 | 42 | 43 | rules 44 | 45 | ^Resources/ 46 | 47 | ^Resources/.*\.lproj/ 48 | 49 | optional 50 | 51 | weight 52 | 1000 53 | 54 | ^Resources/.*\.lproj/locversion.plist$ 55 | 56 | omit 57 | 58 | weight 59 | 1100 60 | 61 | ^Resources/Base\.lproj/ 62 | 63 | weight 64 | 1010 65 | 66 | ^version.plist$ 67 | 68 | 69 | rules2 70 | 71 | .*\.dSYM($|/) 72 | 73 | weight 74 | 11 75 | 76 | ^(.*/)?\.DS_Store$ 77 | 78 | omit 79 | 80 | weight 81 | 2000 82 | 83 | ^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/ 84 | 85 | nested 86 | 87 | weight 88 | 10 89 | 90 | ^.* 91 | 92 | ^Info\.plist$ 93 | 94 | omit 95 | 96 | weight 97 | 20 98 | 99 | ^PkgInfo$ 100 | 101 | omit 102 | 103 | weight 104 | 20 105 | 106 | ^Resources/ 107 | 108 | weight 109 | 20 110 | 111 | ^Resources/.*\.lproj/ 112 | 113 | optional 114 | 115 | weight 116 | 1000 117 | 118 | ^Resources/.*\.lproj/locversion.plist$ 119 | 120 | omit 121 | 122 | weight 123 | 1100 124 | 125 | ^Resources/Base\.lproj/ 126 | 127 | weight 128 | 1010 129 | 130 | ^[^/]+$ 131 | 132 | nested 133 | 134 | weight 135 | 10 136 | 137 | ^embedded\.provisionprofile$ 138 | 139 | weight 140 | 20 141 | 142 | ^version\.plist$ 143 | 144 | weight 145 | 20 146 | 147 | 148 | 149 | 150 | -------------------------------------------------------------------------------- /api/6.7.7/darwin/thosttraderapi_se.framework/Versions/A/thosttraderapi_se: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keli/ctp-python/31295a4044c00f34b326b2c4d675568b4e7b78c3/api/6.7.7/darwin/thosttraderapi_se.framework/Versions/A/thosttraderapi_se -------------------------------------------------------------------------------- /api/6.7.7/darwin/thosttraderapi_se.framework/Versions/Current: -------------------------------------------------------------------------------- 1 | A -------------------------------------------------------------------------------- /api/6.7.7/darwin/thosttraderapi_se.framework/thosttraderapi_se: -------------------------------------------------------------------------------- 1 | Versions/Current/thosttraderapi_se -------------------------------------------------------------------------------- /api/6.7.7/linux/ThostFtdcMdApi.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////// 2 | ///@system 新一代交易所系统 3 | ///@company 上海期货信息技术有限公司 4 | ///@file ThostFtdcMdApi.h 5 | ///@brief 定义了客户端接口 6 | ///@history 7 | ///20060106 赵鸿昊 创建该文件 8 | ///////////////////////////////////////////////////////////////////////// 9 | 10 | #if !defined(THOST_FTDCMDAPI_H) 11 | #define THOST_FTDCMDAPI_H 12 | 13 | #if _MSC_VER > 1000 14 | #pragma once 15 | #endif // _MSC_VER > 1000 16 | 17 | #include "ThostFtdcUserApiStruct.h" 18 | 19 | #if defined(ISLIB) && defined(WIN32) 20 | #ifdef LIB_MD_API_EXPORT 21 | #define MD_API_EXPORT __declspec(dllexport) 22 | #else 23 | #define MD_API_EXPORT __declspec(dllimport) 24 | #endif 25 | #else 26 | #define MD_API_EXPORT 27 | #endif 28 | 29 | class CThostFtdcMdSpi 30 | { 31 | public: 32 | ///当客户端与交易后台建立起通信连接时(还未登录前),该方法被调用。 33 | virtual void OnFrontConnected(){}; 34 | 35 | ///当客户端与交易后台通信连接断开时,该方法被调用。当发生这个情况后,API会自动重新连接,客户端可不做处理。 36 | ///@param nReason 错误原因 37 | /// 0x1001 网络读失败 38 | /// 0x1002 网络写失败 39 | /// 0x2001 接收心跳超时 40 | /// 0x2002 发送心跳失败 41 | /// 0x2003 收到错误报文 42 | virtual void OnFrontDisconnected(int nReason){}; 43 | 44 | ///心跳超时警告。当长时间未收到报文时,该方法被调用。 45 | ///@param nTimeLapse 距离上次接收报文的时间 46 | virtual void OnHeartBeatWarning(int nTimeLapse){}; 47 | 48 | 49 | ///登录请求响应 50 | virtual void OnRspUserLogin(CThostFtdcRspUserLoginField *pRspUserLogin, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 51 | 52 | ///登出请求响应 53 | virtual void OnRspUserLogout(CThostFtdcUserLogoutField *pUserLogout, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 54 | 55 | ///请求查询组播合约响应 56 | virtual void OnRspQryMulticastInstrument(CThostFtdcMulticastInstrumentField *pMulticastInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 57 | 58 | ///错误应答 59 | virtual void OnRspError(CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 60 | 61 | ///订阅行情应答 62 | virtual void OnRspSubMarketData(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 63 | 64 | ///取消订阅行情应答 65 | virtual void OnRspUnSubMarketData(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 66 | 67 | ///订阅询价应答 68 | virtual void OnRspSubForQuoteRsp(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 69 | 70 | ///取消订阅询价应答 71 | virtual void OnRspUnSubForQuoteRsp(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 72 | 73 | ///深度行情通知 74 | virtual void OnRtnDepthMarketData(CThostFtdcDepthMarketDataField *pDepthMarketData) {}; 75 | 76 | ///询价通知 77 | virtual void OnRtnForQuoteRsp(CThostFtdcForQuoteRspField *pForQuoteRsp) {}; 78 | }; 79 | 80 | class MD_API_EXPORT CThostFtdcMdApi 81 | { 82 | public: 83 | ///创建MdApi 84 | ///@param pszFlowPath 存贮订阅信息文件的目录,默认为当前目录 85 | ///@return 创建出的UserApi 86 | ///modify for udp marketdata 87 | static CThostFtdcMdApi *CreateFtdcMdApi(const char *pszFlowPath = "", const bool bIsUsingUdp=false, const bool bIsMulticast=false); 88 | 89 | ///获取API的版本信息 90 | ///@retrun 获取到的版本号 91 | static const char *GetApiVersion(); 92 | 93 | ///删除接口对象本身 94 | ///@remark 不再使用本接口对象时,调用该函数删除接口对象 95 | virtual void Release() = 0; 96 | 97 | ///初始化 98 | ///@remark 初始化运行环境,只有调用后,接口才开始工作 99 | virtual void Init() = 0; 100 | 101 | ///等待接口线程结束运行 102 | ///@return 线程退出代码 103 | virtual int Join() = 0; 104 | 105 | ///获取当前交易日 106 | ///@retrun 获取到的交易日 107 | ///@remark 只有登录成功后,才能得到正确的交易日 108 | virtual const char *GetTradingDay() = 0; 109 | 110 | ///注册前置机网络地址 111 | ///@param pszFrontAddress:前置机网络地址。 112 | ///@remark 网络地址的格式为:“protocol://ipaddress:port”,如:”tcp://127.0.0.1:17001”。 113 | ///@remark “tcp”代表传输协议,“127.0.0.1”代表服务器地址。”17001”代表服务器端口号。 114 | virtual void RegisterFront(char *pszFrontAddress) = 0; 115 | 116 | ///注册名字服务器网络地址 117 | ///@param pszNsAddress:名字服务器网络地址。 118 | ///@remark 网络地址的格式为:“protocol://ipaddress:port”,如:”tcp://127.0.0.1:12001”。 119 | ///@remark “tcp”代表传输协议,“127.0.0.1”代表服务器地址。”12001”代表服务器端口号。 120 | ///@remark RegisterNameServer优先于RegisterFront 121 | virtual void RegisterNameServer(char *pszNsAddress) = 0; 122 | 123 | ///注册名字服务器用户信息 124 | ///@param pFensUserInfo:用户信息。 125 | virtual void RegisterFensUserInfo(CThostFtdcFensUserInfoField * pFensUserInfo) = 0; 126 | 127 | ///注册回调接口 128 | ///@param pSpi 派生自回调接口类的实例 129 | virtual void RegisterSpi(CThostFtdcMdSpi *pSpi) = 0; 130 | 131 | ///订阅行情。 132 | ///@param ppInstrumentID 合约ID 133 | ///@param nCount 要订阅/退订行情的合约个数 134 | ///@remark 135 | virtual int SubscribeMarketData(char *ppInstrumentID[], int nCount) = 0; 136 | 137 | ///退订行情。 138 | ///@param ppInstrumentID 合约ID 139 | ///@param nCount 要订阅/退订行情的合约个数 140 | ///@remark 141 | virtual int UnSubscribeMarketData(char *ppInstrumentID[], int nCount) = 0; 142 | 143 | ///订阅询价。 144 | ///@param ppInstrumentID 合约ID 145 | ///@param nCount 要订阅/退订行情的合约个数 146 | ///@remark 147 | virtual int SubscribeForQuoteRsp(char *ppInstrumentID[], int nCount) = 0; 148 | 149 | ///退订询价。 150 | ///@param ppInstrumentID 合约ID 151 | ///@param nCount 要订阅/退订行情的合约个数 152 | ///@remark 153 | virtual int UnSubscribeForQuoteRsp(char *ppInstrumentID[], int nCount) = 0; 154 | 155 | ///用户登录请求 156 | virtual int ReqUserLogin(CThostFtdcReqUserLoginField *pReqUserLoginField, int nRequestID) = 0; 157 | 158 | 159 | ///登出请求 160 | virtual int ReqUserLogout(CThostFtdcUserLogoutField *pUserLogout, int nRequestID) = 0; 161 | 162 | ///请求查询组播合约 163 | virtual int ReqQryMulticastInstrument(CThostFtdcQryMulticastInstrumentField *pQryMulticastInstrument, int nRequestID) = 0; 164 | protected: 165 | ~CThostFtdcMdApi(){}; 166 | }; 167 | 168 | #endif 169 | -------------------------------------------------------------------------------- /api/6.7.7/linux/error.dtd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | -------------------------------------------------------------------------------- /api/6.7.7/linux/libthostmduserapi_se.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keli/ctp-python/31295a4044c00f34b326b2c4d675568b4e7b78c3/api/6.7.7/linux/libthostmduserapi_se.so -------------------------------------------------------------------------------- /api/6.7.7/linux/libthosttraderapi_se.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keli/ctp-python/31295a4044c00f34b326b2c4d675568b4e7b78c3/api/6.7.7/linux/libthosttraderapi_se.so -------------------------------------------------------------------------------- /api/6.7.7/windows/ThostFtdcMdApi.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////// 2 | ///@system 新一代交易所系统 3 | ///@company 上海期货信息技术有限公司 4 | ///@file ThostFtdcMdApi.h 5 | ///@brief 定义了客户端接口 6 | ///@history 7 | ///20060106 赵鸿昊 创建该文件 8 | ///////////////////////////////////////////////////////////////////////// 9 | 10 | #if !defined(THOST_FTDCMDAPI_H) 11 | #define THOST_FTDCMDAPI_H 12 | 13 | #if _MSC_VER > 1000 14 | #pragma once 15 | #endif // _MSC_VER > 1000 16 | 17 | #include "ThostFtdcUserApiStruct.h" 18 | 19 | #if defined(ISLIB) && defined(WIN32) 20 | #ifdef LIB_MD_API_EXPORT 21 | #define MD_API_EXPORT __declspec(dllexport) 22 | #else 23 | #define MD_API_EXPORT __declspec(dllimport) 24 | #endif 25 | #else 26 | #define MD_API_EXPORT 27 | #endif 28 | 29 | class CThostFtdcMdSpi 30 | { 31 | public: 32 | ///当客户端与交易后台建立起通信连接时(还未登录前),该方法被调用。 33 | virtual void OnFrontConnected(){}; 34 | 35 | ///当客户端与交易后台通信连接断开时,该方法被调用。当发生这个情况后,API会自动重新连接,客户端可不做处理。 36 | ///@param nReason 错误原因 37 | /// 0x1001 网络读失败 38 | /// 0x1002 网络写失败 39 | /// 0x2001 接收心跳超时 40 | /// 0x2002 发送心跳失败 41 | /// 0x2003 收到错误报文 42 | virtual void OnFrontDisconnected(int nReason){}; 43 | 44 | ///心跳超时警告。当长时间未收到报文时,该方法被调用。 45 | ///@param nTimeLapse 距离上次接收报文的时间 46 | virtual void OnHeartBeatWarning(int nTimeLapse){}; 47 | 48 | 49 | ///登录请求响应 50 | virtual void OnRspUserLogin(CThostFtdcRspUserLoginField *pRspUserLogin, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 51 | 52 | ///登出请求响应 53 | virtual void OnRspUserLogout(CThostFtdcUserLogoutField *pUserLogout, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 54 | 55 | ///请求查询组播合约响应 56 | virtual void OnRspQryMulticastInstrument(CThostFtdcMulticastInstrumentField *pMulticastInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 57 | 58 | ///错误应答 59 | virtual void OnRspError(CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 60 | 61 | ///订阅行情应答 62 | virtual void OnRspSubMarketData(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 63 | 64 | ///取消订阅行情应答 65 | virtual void OnRspUnSubMarketData(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 66 | 67 | ///订阅询价应答 68 | virtual void OnRspSubForQuoteRsp(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 69 | 70 | ///取消订阅询价应答 71 | virtual void OnRspUnSubForQuoteRsp(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 72 | 73 | ///深度行情通知 74 | virtual void OnRtnDepthMarketData(CThostFtdcDepthMarketDataField *pDepthMarketData) {}; 75 | 76 | ///询价通知 77 | virtual void OnRtnForQuoteRsp(CThostFtdcForQuoteRspField *pForQuoteRsp) {}; 78 | }; 79 | 80 | class MD_API_EXPORT CThostFtdcMdApi 81 | { 82 | public: 83 | ///创建MdApi 84 | ///@param pszFlowPath 存贮订阅信息文件的目录,默认为当前目录 85 | ///@return 创建出的UserApi 86 | ///modify for udp marketdata 87 | static CThostFtdcMdApi *CreateFtdcMdApi(const char *pszFlowPath = "", const bool bIsUsingUdp=false, const bool bIsMulticast=false); 88 | 89 | ///获取API的版本信息 90 | ///@retrun 获取到的版本号 91 | static const char *GetApiVersion(); 92 | 93 | ///删除接口对象本身 94 | ///@remark 不再使用本接口对象时,调用该函数删除接口对象 95 | virtual void Release() = 0; 96 | 97 | ///初始化 98 | ///@remark 初始化运行环境,只有调用后,接口才开始工作 99 | virtual void Init() = 0; 100 | 101 | ///等待接口线程结束运行 102 | ///@return 线程退出代码 103 | virtual int Join() = 0; 104 | 105 | ///获取当前交易日 106 | ///@retrun 获取到的交易日 107 | ///@remark 只有登录成功后,才能得到正确的交易日 108 | virtual const char *GetTradingDay() = 0; 109 | 110 | ///注册前置机网络地址 111 | ///@param pszFrontAddress:前置机网络地址。 112 | ///@remark 网络地址的格式为:“protocol://ipaddress:port”,如:”tcp://127.0.0.1:17001”。 113 | ///@remark “tcp”代表传输协议,“127.0.0.1”代表服务器地址。”17001”代表服务器端口号。 114 | virtual void RegisterFront(char *pszFrontAddress) = 0; 115 | 116 | ///注册名字服务器网络地址 117 | ///@param pszNsAddress:名字服务器网络地址。 118 | ///@remark 网络地址的格式为:“protocol://ipaddress:port”,如:”tcp://127.0.0.1:12001”。 119 | ///@remark “tcp”代表传输协议,“127.0.0.1”代表服务器地址。”12001”代表服务器端口号。 120 | ///@remark RegisterNameServer优先于RegisterFront 121 | virtual void RegisterNameServer(char *pszNsAddress) = 0; 122 | 123 | ///注册名字服务器用户信息 124 | ///@param pFensUserInfo:用户信息。 125 | virtual void RegisterFensUserInfo(CThostFtdcFensUserInfoField * pFensUserInfo) = 0; 126 | 127 | ///注册回调接口 128 | ///@param pSpi 派生自回调接口类的实例 129 | virtual void RegisterSpi(CThostFtdcMdSpi *pSpi) = 0; 130 | 131 | ///订阅行情。 132 | ///@param ppInstrumentID 合约ID 133 | ///@param nCount 要订阅/退订行情的合约个数 134 | ///@remark 135 | virtual int SubscribeMarketData(char *ppInstrumentID[], int nCount) = 0; 136 | 137 | ///退订行情。 138 | ///@param ppInstrumentID 合约ID 139 | ///@param nCount 要订阅/退订行情的合约个数 140 | ///@remark 141 | virtual int UnSubscribeMarketData(char *ppInstrumentID[], int nCount) = 0; 142 | 143 | ///订阅询价。 144 | ///@param ppInstrumentID 合约ID 145 | ///@param nCount 要订阅/退订行情的合约个数 146 | ///@remark 147 | virtual int SubscribeForQuoteRsp(char *ppInstrumentID[], int nCount) = 0; 148 | 149 | ///退订询价。 150 | ///@param ppInstrumentID 合约ID 151 | ///@param nCount 要订阅/退订行情的合约个数 152 | ///@remark 153 | virtual int UnSubscribeForQuoteRsp(char *ppInstrumentID[], int nCount) = 0; 154 | 155 | ///用户登录请求 156 | virtual int ReqUserLogin(CThostFtdcReqUserLoginField *pReqUserLoginField, int nRequestID) = 0; 157 | 158 | 159 | ///登出请求 160 | virtual int ReqUserLogout(CThostFtdcUserLogoutField *pUserLogout, int nRequestID) = 0; 161 | 162 | ///请求查询组播合约 163 | virtual int ReqQryMulticastInstrument(CThostFtdcQryMulticastInstrumentField *pQryMulticastInstrument, int nRequestID) = 0; 164 | protected: 165 | ~CThostFtdcMdApi(){}; 166 | }; 167 | 168 | #endif 169 | -------------------------------------------------------------------------------- /api/6.7.7/windows/error.dtd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | -------------------------------------------------------------------------------- /api/6.7.7/windows/thostmduserapi_se.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keli/ctp-python/31295a4044c00f34b326b2c4d675568b4e7b78c3/api/6.7.7/windows/thostmduserapi_se.dll -------------------------------------------------------------------------------- /api/6.7.7/windows/thostmduserapi_se.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keli/ctp-python/31295a4044c00f34b326b2c4d675568b4e7b78c3/api/6.7.7/windows/thostmduserapi_se.lib -------------------------------------------------------------------------------- /api/6.7.7/windows/thosttraderapi_se.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keli/ctp-python/31295a4044c00f34b326b2c4d675568b4e7b78c3/api/6.7.7/windows/thosttraderapi_se.dll -------------------------------------------------------------------------------- /api/6.7.7/windows/thosttraderapi_se.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keli/ctp-python/31295a4044c00f34b326b2c4d675568b4e7b78c3/api/6.7.7/windows/thosttraderapi_se.lib -------------------------------------------------------------------------------- /ctp.i: -------------------------------------------------------------------------------- 1 | %module(directors="1") ctp 2 | 3 | %include "typemaps.i" 4 | 5 | //%begin %{ 6 | //#define SWIG_PYTHON_STRICT_BYTE_CHAR 7 | //%} 8 | 9 | // #define %ctp_new_instance(TYPE...) %reinterpret_cast(calloc(1, sizeof(TYPE)), TYPE*) 10 | // #define %ctp_new_copy(VAL, TYPE...) %reinterpret_cast(memcpy(%ctp_new_instance(TYPE), &(VAL), sizeof(TYPE)), TYPE*) 11 | 12 | // %extend TAGNAME { 13 | // struct TAGNAME *__copy__() { 14 | // return %ctp_new_copy(*$self, struct TAGNAME); 15 | // } 16 | // } 17 | 18 | %pythonbegin %{ 19 | from sys import stderr, float_info 20 | from traceback import print_exc, print_exception 21 | %} 22 | 23 | %pythoncode %{ 24 | def _swig_repr(self): 25 | values = [] 26 | for k in vars(self.__class__): 27 | if not k.startswith('_'): 28 | v = getattr(self, k) 29 | if isinstance(v, float): 30 | if v == float_info.max: 31 | values.append("%s: None" % k) 32 | else: 33 | values.append("%s: %.2f" % (k, v)) 34 | elif isinstance(v, int): 35 | values.append("%s: %i" % (k, v)) 36 | else: 37 | values.append('%s: "%s"' % (k, v)) 38 | 39 | return "<%s.%s; %s>" % (self.__class__.__module__, self.__class__.__name__, ', '.join(values)) 40 | %} 41 | 42 | %{ 43 | #define SWIG_FILE_WITH_INIT 44 | #include "ThostFtdcUserApiDataType.h" 45 | #include "ThostFtdcUserApiStruct.h" 46 | #include "ThostFtdcMdApi.h" 47 | #include "ThostFtdcTraderApi.h" 48 | #include "iconv.h" 49 | %} 50 | 51 | %feature("director:except") { 52 | if ($error != NULL) { 53 | 54 | if ( !( PyErr_ExceptionMatches(PyExc_SystemExit) || 55 | PyErr_ExceptionMatches(PyExc_SystemError) || 56 | PyErr_ExceptionMatches(PyExc_KeyboardInterrupt) ) ) 57 | { 58 | PyObject *value = 0; 59 | PyObject *traceback = 0; 60 | 61 | PyErr_Fetch(&$error, &value, &traceback); 62 | PyErr_NormalizeException(&$error, &value, &traceback); 63 | 64 | { 65 | if (value == NULL) { 66 | value = Py_None; 67 | } 68 | if (traceback == NULL) { 69 | traceback = Py_None; 70 | } 71 | swig::SwigVar_PyObject swig_method_name = SWIG_Python_str_FromChar((char *) "pyError"); 72 | swig::SwigVar_PyObject result = PyObject_CallMethodObjArgs(swig_get_self(), (PyObject *) swig_method_name, $error, value, traceback, NULL); 73 | } 74 | 75 | Py_XDECREF($error); 76 | Py_XDECREF(value); 77 | Py_XDECREF(traceback); 78 | 79 | $error = PyErr_Occurred(); 80 | if ($error != NULL) { 81 | PyErr_Print(); 82 | throw Swig::DirectorMethodException(); 83 | } 84 | } 85 | else 86 | { 87 | throw Swig::DirectorMethodException(); 88 | } 89 | } 90 | } 91 | 92 | %extend CThostFtdcMdSpi { 93 | %pythoncode { 94 | def pyError(self, type, value, traceback): 95 | '''Handles an error thrown during invocation of an method. 96 | 97 | Arguments are those provided by sys.exc_info() 98 | ''' 99 | stderr.write("Exception thrown during method dispatch:\n") 100 | print_exception(type, value, traceback) 101 | } 102 | } 103 | 104 | %extend CThostFtdcTraderSpi { 105 | %pythoncode { 106 | def pyError(self, type, value, traceback): 107 | '''Handles an error thrown during invocation of an method. 108 | 109 | Arguments are those provided by sys.exc_info() 110 | ''' 111 | stderr.write("Exception thrown during method dispatch:\n") 112 | print_exception(type, value, traceback) 113 | } 114 | } 115 | 116 | /* Exception handling */ 117 | %include exception.i 118 | %exception { 119 | try { 120 | $action 121 | } catch(Swig::DirectorPureVirtualException &e) { 122 | /* Call to pure virtual method, raise not implemented error */ 123 | PyErr_SetString(PyExc_NotImplementedError, "$decl not implemented"); 124 | SWIG_fail; 125 | } catch(Swig::DirectorException &e) { 126 | /* Fail if there is a problem in the director proxy transport */ 127 | SWIG_fail; 128 | } catch(std::exception& e) { 129 | /* Convert standard error to Exception */ 130 | PyErr_SetString(PyExc_Exception, const_cast(e.what())); 131 | SWIG_fail; 132 | } catch(...) { 133 | /* Final catch all, results in runtime error */ 134 | PyErr_SetString(PyExc_RuntimeError, "Unknown error caught in CTP SWIG wrapper..."); 135 | SWIG_fail; 136 | } 137 | } 138 | 139 | %typemap(out) char[ANY], char[] { 140 | if ($1) { 141 | size_t inlen = strlen($1); 142 | if (inlen == 0) { 143 | $result = SWIG_FromCharPtr(""); 144 | } else { 145 | iconv_t conv = iconv_open("UTF-8", "GBK"); 146 | if (conv == (iconv_t)-1) { 147 | $result = SWIG_FromCharPtr($1); 148 | if (PyErr_WarnEx(PyExc_UnicodeWarning, "Failed to initialize iconv.", 1) < 0) { 149 | return NULL; 150 | } 151 | } else { 152 | size_t outlen = 4096; 153 | char buf[4096]; 154 | char **in = &$1; 155 | char *out = buf; 156 | 157 | if (iconv(conv, in, &inlen, &out, &outlen) != (size_t)-1) { 158 | iconv_close(conv); 159 | $result = SWIG_FromCharPtrAndSize(buf, sizeof buf - outlen); 160 | } else { 161 | iconv_close(conv); 162 | $result = SWIG_FromCharPtr($1); 163 | if (PyErr_WarnEx(PyExc_UnicodeWarning, "Failed to convert '$1_name' from GBK to UTF-8.", 1) < 0) { 164 | return NULL; 165 | } 166 | } 167 | } 168 | } 169 | } 170 | } 171 | 172 | %typemap(in) (char **ARRAY, int SIZE) { 173 | /* Check if is a list */ 174 | if (PyList_Check($input)) { 175 | int size = PyList_Size($input); 176 | int i = 0; 177 | $1 = (char **) malloc((size+1)*sizeof(char *)); 178 | $2 = size; 179 | 180 | for (i = 0; i < size; i++) { 181 | PyObject *o = PyList_GetItem($input, i); 182 | if (PyUnicode_Check(o)) { 183 | $1[i] = (char *)PyUnicode_AsUTF8(PyList_GetItem($input, i)); 184 | if ($1[i] == NULL) { 185 | PyErr_SetString(PyExc_TypeError, "failed to convert UTF-8"); 186 | SWIG_fail; 187 | } 188 | } else { 189 | free($1); 190 | PyErr_SetString(PyExc_TypeError, "list must contain strings"); 191 | SWIG_fail; 192 | } 193 | } 194 | $1[i] = 0; 195 | } else { 196 | PyErr_SetString(PyExc_TypeError, "not a list"); 197 | SWIG_fail; 198 | } 199 | } 200 | 201 | %typemap(freearg) (char **ARRAY, int SIZE) { 202 | free((char *)$1); 203 | } 204 | 205 | %apply (char **ARRAY, int SIZE) { (char *ppInstrumentID[], int nCount) }; 206 | 207 | %feature("director") CThostFtdcMdSpi; 208 | %feature("director") CThostFtdcTraderSpi; 209 | 210 | // Ignore problematic character constants that cause compilation issues on Windows 211 | %ignore THOST_FTDC_FTC_BankLaunchBankToBroker; 212 | %ignore THOST_FTDC_FTC_BrokerLaunchBankToBroker; 213 | %ignore THOST_FTDC_FTC_BankLaunchBrokerToBank; 214 | %ignore THOST_FTDC_FTC_BrokerLaunchBrokerToBank; 215 | 216 | // Additional constants to ignore 217 | %ignore THOST_FTDC_VTC_BankBankToFuture; 218 | %ignore THOST_FTDC_VTC_BankFutureToBank; 219 | %ignore THOST_FTDC_VTC_FutureBankToFuture; 220 | %ignore THOST_FTDC_VTC_FutureFutureToBank; 221 | 222 | %include "ThostFtdcUserApiDataType.h" 223 | %include "ThostFtdcUserApiStruct.h" 224 | %include "ThostFtdcMdApi.h" 225 | %include "ThostFtdcTraderApi.h" 226 | -------------------------------------------------------------------------------- /ctp/__init__.py: -------------------------------------------------------------------------------- 1 | from ._ctp import * 2 | from .ctp import * 3 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | import distutils.command.install as dist_install 2 | import glob 3 | import os 4 | import pathlib 5 | import shutil 6 | import sys 7 | import sysconfig 8 | from distutils import dist 9 | 10 | from setuptools import Extension, find_packages, setup 11 | from setuptools.command.build_py import build_py 12 | 13 | API_VER = os.environ.get("API_VER", "6.7.7") 14 | REVISION = "" 15 | BUILD_VER = API_VER + "." + REVISION if REVISION else API_VER 16 | 17 | # Get the long description from relevant files 18 | with open("README.md", encoding="utf-8") as f: 19 | readme = f.read() 20 | 21 | if sys.platform.startswith("darwin"): 22 | if API_VER < "6.6.9": 23 | print( 24 | "Error: Platform", sys.platform, "API Version <", API_VER, "not supported" 25 | ) 26 | sys.exit(-1) 27 | API_DIR = os.path.join("api", API_VER, "darwin") 28 | if API_VER >= "6.7.7": 29 | # Handle macOS frameworks 30 | INC_DIRS = [ 31 | os.path.join(API_DIR, "thostmduserapi_se.framework/Versions/A/Headers"), 32 | os.path.join(API_DIR, "thosttraderapi_se.framework/Versions/A/Headers"), 33 | ] 34 | LIB_DIRS = [API_DIR] 35 | LIB_NAMES = [] 36 | # Get direct paths to the framework libraries 37 | MD_LIB = os.path.join( 38 | API_DIR, "thostmduserapi_se.framework/Versions/A/thostmduserapi_se" 39 | ) 40 | TRADER_LIB = os.path.join( 41 | API_DIR, "thosttraderapi_se.framework/Versions/A/thosttraderapi_se" 42 | ) 43 | API_LIBS = [MD_LIB, TRADER_LIB] 44 | LINK_ARGS = [ 45 | "-Wl,-rpath,@loader_path", 46 | MD_LIB, 47 | TRADER_LIB, 48 | ] 49 | COMPILE_ARGS = [] 50 | # Define framework files for package_data 51 | FRAMEWORK_FILES = ["*.framework", "*.framework/**/*"] 52 | else: 53 | # Handle older versions with static libraries 54 | API_LIBS = glob.glob(API_DIR + "/*.a") 55 | INC_DIRS = [API_DIR] 56 | LIB_DIRS = [API_DIR] 57 | LIB_NAMES = [] 58 | LINK_ARGS = ["-Wl,-rpath,$ORIGIN"] 59 | LINK_ARGS.extend(API_LIBS) 60 | COMPILE_ARGS = [] 61 | elif sys.platform.startswith("linux"): 62 | API_DIR = os.path.join("api", API_VER, "linux") 63 | API_LIBS = glob.glob(API_DIR + "/*.so") 64 | LIB_NAMES = [pathlib.Path(path).stem[3:] for path in API_LIBS] 65 | INC_DIRS = [API_DIR] 66 | LIB_DIRS = [API_DIR] 67 | LINK_ARGS = ["-Wl,-rpath,$ORIGIN"] 68 | COMPILE_ARGS = [] 69 | elif sys.platform.startswith("win"): 70 | if API_VER < "6.6.9": 71 | print( 72 | "Error: Platform", sys.platform, "API Version <", API_VER, "not supported" 73 | ) 74 | sys.exit(-1) 75 | API_DIR = os.path.join("api", API_VER, "windows") 76 | API_LIBS = glob.glob(API_DIR + "/*.dll") 77 | LIB_NAMES = [pathlib.Path(path).stem for path in API_LIBS] + ["iconv"] 78 | INC_DIRS = [ 79 | API_DIR, 80 | os.path.join(sysconfig.get_config_var("base"), "Library", "include"), 81 | ] 82 | LIB_DIRS = [ 83 | API_DIR, 84 | os.path.join(sysconfig.get_config_var("base"), "Library", "lib"), 85 | ] 86 | LINK_ARGS = [] 87 | COMPILE_ARGS = ["/utf-8", "/wd4101"] 88 | else: 89 | print("Error: Platform", sys.platform, "not supported") 90 | sys.exit(-1) 91 | 92 | 93 | def get_install_data_dir(): 94 | d = dist.Distribution() 95 | install_cmd = dist_install.install(d) 96 | install_cmd.finalize_options() 97 | return install_cmd.install_data 98 | 99 | 100 | package_data = [] 101 | if not sys.platform.startswith("darwin"): 102 | package_data = [os.path.basename(lib) for lib in API_LIBS] 103 | else: 104 | if API_VER >= "6.7.7": 105 | package_data = FRAMEWORK_FILES 106 | else: 107 | package_data = [] 108 | 109 | 110 | class BuildPy(build_py): 111 | def run(self): 112 | self.run_command("build_ext") 113 | result = super().run() 114 | 115 | # Get the build directory 116 | build_lib = self.get_finalized_command("build").build_lib 117 | build_ctp_dir = os.path.join(build_lib, "ctp") 118 | 119 | # Move SWIG-generated ctp.py from current directory to the package directory 120 | if os.path.exists("ctp.py"): 121 | shutil.move("ctp.py", os.path.join(build_ctp_dir, "ctp.py")) 122 | 123 | # Copy API libraries 124 | if package_data: 125 | for lib in API_LIBS: 126 | lib_name = os.path.basename(lib) 127 | dst = os.path.join(build_ctp_dir, lib_name) 128 | if not sys.platform.startswith("darwin"): 129 | shutil.copy2(lib, dst) 130 | else: 131 | # Copy the framework to the package directory 132 | framework_name = f"{lib_name}.framework" 133 | framework_path = os.path.join(API_DIR, framework_name) 134 | dst_framework = os.path.join(build_ctp_dir, framework_name) 135 | if os.path.exists(dst_framework): 136 | shutil.rmtree(dst_framework) 137 | 138 | def ignore_dsstore(dir, files): 139 | return [f for f in files if f == ".DS_Store"] 140 | 141 | shutil.copytree( 142 | framework_path, 143 | dst_framework, 144 | symlinks=True, 145 | ignore=ignore_dsstore, 146 | ) 147 | return result 148 | 149 | 150 | CTP_EXT = Extension( 151 | "ctp._ctp", 152 | ["ctp.i"], 153 | # ['ctp_wrap.cpp'], 154 | include_dirs=INC_DIRS, 155 | library_dirs=LIB_DIRS, 156 | extra_link_args=LINK_ARGS, 157 | extra_compile_args=COMPILE_ARGS, 158 | libraries=LIB_NAMES, 159 | language="c++", 160 | swig_opts=["-py3", "-c++", "-threads"] + ["-I" + inc for inc in INC_DIRS], 161 | ) 162 | 163 | try: 164 | setup( 165 | name="ctp-python", 166 | version=BUILD_VER, 167 | author="Keli Hu", 168 | author_email="dev@keli.hu", 169 | description="""CTP for python""", 170 | long_description=readme, 171 | long_description_content_type="text/markdown", 172 | url="https://github.com/keli/ctp-python", 173 | ext_modules=[CTP_EXT], 174 | packages=["ctp"], # Define ctp as a package 175 | package_data={"ctp": package_data}, 176 | classifiers=[ 177 | "License :: OSI Approved :: BSD License", 178 | "Programming Language :: Python", 179 | "Programming Language :: Python :: 3", 180 | "Programming Language :: Python :: 3.7", 181 | "Programming Language :: Python :: 3.8", 182 | "Programming Language :: Python :: 3.9", 183 | "Programming Language :: Python :: 3.10", 184 | "Programming Language :: Python :: 3.11", 185 | "Programming Language :: Python :: 3.12", 186 | "Programming Language :: Python :: 3.13", 187 | "Programming Language :: Python :: Implementation :: CPython", 188 | ], 189 | cmdclass={ 190 | "build_py": BuildPy, 191 | }, 192 | ) 193 | finally: 194 | pass 195 | -------------------------------------------------------------------------------- /tests/conftest.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | def pytest_addoption(parser): 4 | parser.addoption( 5 | "--front", action="store", default="", help="front uri" 6 | ) 7 | parser.addoption( 8 | "--broker", action="store", default="9999", help="broker ID" 9 | ) 10 | parser.addoption( 11 | "--user", action="store", default="", help="user ID" 12 | ) 13 | parser.addoption( 14 | "--password", action="store", default="", help="password" 15 | ) 16 | parser.addoption( 17 | "--app", action="store", default="", help="app ID" 18 | ) 19 | parser.addoption( 20 | "--auth", action="store", default="0000000000000000", help="app ID" 21 | ) 22 | parser.addoption( 23 | "--instrument", action="store", default="IF1907", help="instrument ID" 24 | ) 25 | parser.addoption( 26 | "--exchange", action="store", default="CFE", help="exchange ID" 27 | ) 28 | 29 | @pytest.fixture(scope="module") 30 | def front(request): 31 | return request.config.getoption("--front") 32 | 33 | @pytest.fixture(scope="module") 34 | def broker(request): 35 | return request.config.getoption("--broker") 36 | 37 | @pytest.fixture(scope="module") 38 | def user(request): 39 | return request.config.getoption("--user") 40 | 41 | @pytest.fixture(scope="module") 42 | def password(request): 43 | return request.config.getoption("--password") 44 | 45 | @pytest.fixture(scope="module") 46 | def app(request): 47 | return request.config.getoption("--app") 48 | 49 | @pytest.fixture(scope="module") 50 | def auth(request): 51 | return request.config.getoption("--auth") 52 | 53 | @pytest.fixture(scope="module") 54 | def instrument(request): 55 | return request.config.getoption("--instrument") 56 | 57 | @pytest.fixture(scope="module") 58 | def exchange(request): 59 | return request.config.getoption("--exchange") 60 | -------------------------------------------------------------------------------- /tests/test_md.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import ctp 3 | import pytest 4 | import sys 5 | import time 6 | import hashlib 7 | import tempfile 8 | import os, os.path 9 | import threading 10 | 11 | 12 | @pytest.fixture(scope="module") 13 | def spi(front, broker, user, password): 14 | assert front and broker and user and password, "missing arguments" 15 | _spi = MdSpi(front, broker, user, password) 16 | th = threading.Thread(target=_spi.run) 17 | th.daemon = True 18 | th.start() 19 | secs = 5 20 | while secs: 21 | if not (_spi.connected and _spi.loggedin): 22 | secs -= 1 23 | time.sleep(1) 24 | else: 25 | break 26 | return _spi 27 | 28 | 29 | class MdSpi(ctp.CThostFtdcMdSpi): 30 | def __init__(self, front, broker_id, user_id, password): 31 | ctp.CThostFtdcMdSpi.__init__(self) 32 | 33 | self.front = front 34 | self.broker_id = broker_id 35 | self.user_id = user_id 36 | self.password = password 37 | 38 | self.request_id = 0 39 | self.connected = False 40 | self.loggedin = False 41 | self.subscribed = False 42 | self.data = None 43 | 44 | self.api = self.create() 45 | 46 | def create(self): 47 | dir = ''.join(('ctp', self.broker_id, self.user_id)).encode('UTF-8') 48 | dir = hashlib.md5(dir).hexdigest() 49 | dir = os.path.join(tempfile.gettempdir(), dir, 'Md') + os.sep 50 | if not os.path.isdir(dir): os.makedirs(dir) 51 | return ctp.CThostFtdcMdApi.CreateFtdcMdApi(dir) 52 | 53 | def run(self): 54 | self.api.RegisterSpi(self) 55 | self.api.RegisterFront(self.front) 56 | self.api.Init() 57 | self.api.Join() 58 | 59 | def login(self): 60 | field = ctp.CThostFtdcReqUserLoginField() 61 | field.BrokerID = self.broker_id 62 | field.UserID = self.user_id 63 | field.Password = self.password 64 | self.request_id += 1 65 | self.api.ReqUserLogin(field, self.request_id) 66 | 67 | def OnFrontConnected(self): 68 | print("OnFrontConnected") 69 | self.connected = True 70 | self.login() 71 | 72 | def OnRspUserLogin(self, pRspUserLogin:'CThostFtdcRspUserLoginField', pRspInfo:'CThostFtdcRspInfoField', nRequestID:'int', bIsLast:'bool'): 73 | print("OnRspUserLogin", pRspInfo.ErrorID, pRspInfo.ErrorMsg) 74 | if pRspInfo.ErrorID == 0: 75 | self.loggedin = True 76 | 77 | def OnRspError(self, pRspInfo:'CThostFtdcRspInfoField', nRequestID:'int', bIsLast:'bool'): 78 | print("OnRspError:", pRspInfo.ErrorID, pRspInfo.ErrorMsg) 79 | 80 | def OnRspSubMarketData(self, pSpecificInstrument: 'CThostFtdcSpecificInstrumentField', pRspInfo: 'CThostFtdcRspInfoField', nRequestID: 'int', bIsLast: 'bool'): 81 | print("OnRspSubMarketData:", pRspInfo.ErrorID, pRspInfo.ErrorMsg) 82 | if pRspInfo.ErrorID == 0: 83 | self.subscribed = True 84 | 85 | def OnRtnDepthMarketData(self, pDepthMarketData: 'CThostFtdcDepthMarketDataField'): 86 | print("OnRtnDepthMarketData:", pDepthMarketData) 87 | self.data = pDepthMarketData 88 | 89 | def __del__(self): 90 | self.api.RegisterSpi(None) 91 | self.api.Release() 92 | 93 | 94 | def test_init(spi): 95 | assert spi.connected and spi.loggedin 96 | 97 | 98 | def test_subscribe(spi, instrument, exchange): 99 | spi.api.SubscribeMarketData([instrument]) 100 | secs = 5 101 | while secs: 102 | if not (spi.subscribed and spi.data): 103 | secs -= 1 104 | time.sleep(1) 105 | else: 106 | break 107 | assert spi.subscribed and spi.data 108 | -------------------------------------------------------------------------------- /tests/test_trader.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import ctp 3 | import pytest 4 | import sys 5 | import time 6 | import hashlib 7 | import tempfile 8 | import os, os.path 9 | import threading 10 | 11 | 12 | @pytest.fixture(scope="module") 13 | def spi(front, broker, user, password, app, auth): 14 | assert front and broker and user and password and app and auth, "missing arguments" 15 | _spi = TraderSpi(front, broker, user, password, app, auth) 16 | th = threading.Thread(target=_spi.run) 17 | th.daemon = True 18 | th.start() 19 | secs = 5 20 | while secs: 21 | if not (_spi.connected and _spi.authed and _spi.loggedin): 22 | secs -= 1 23 | time.sleep(1) 24 | else: 25 | break 26 | return _spi 27 | 28 | 29 | class TraderSpi(ctp.CThostFtdcTraderSpi): 30 | def __init__(self, front, broker_id, user_id, password, app_id, auth_code): 31 | ctp.CThostFtdcTraderSpi.__init__(self) 32 | 33 | self.front = front 34 | self.broker_id = broker_id 35 | self.user_id = user_id 36 | self.password = password 37 | self.app_id = app_id 38 | self.auth_code = auth_code 39 | 40 | self.request_id = 0 41 | self.connected = False 42 | self.authed = False 43 | self.loggedin = False 44 | 45 | self.api = self.create() 46 | 47 | def create(self): 48 | dir = ''.join(('ctp', self.broker_id, self.user_id)).encode('UTF-8') 49 | dir = hashlib.md5(dir).hexdigest() 50 | dir = os.path.join(tempfile.gettempdir(), dir, 'Trader') + os.sep 51 | if not os.path.isdir(dir): os.makedirs(dir) 52 | return ctp.CThostFtdcTraderApi.CreateFtdcTraderApi(dir) 53 | 54 | def run(self): 55 | self.api.RegisterSpi(self) 56 | self.api.RegisterFront(self.front) 57 | self.api.Init() 58 | self.api.Join() 59 | 60 | def auth(self): 61 | field = ctp.CThostFtdcReqAuthenticateField() 62 | field.BrokerID = self.broker_id 63 | field.UserID = self.user_id 64 | field.AppID = self.app_id 65 | field.AuthCode = self.auth_code 66 | self.request_id += 1 67 | self.api.ReqAuthenticate(field, self.request_id) 68 | 69 | def login(self): 70 | field = ctp.CThostFtdcReqUserLoginField() 71 | field.BrokerID = self.broker_id 72 | field.UserID = self.user_id 73 | field.Password = self.password 74 | self.request_id += 1 75 | self.api.ReqUserLogin(field, self.request_id) 76 | 77 | def OnFrontConnected(self): 78 | print("OnFrontConnected") 79 | self.connected = True 80 | self.auth() 81 | 82 | def OnRspAuthenticate(self, pRspAuthenticateField:'CThostFtdcRspAuthenticateField', pRspInfo:'CThostFtdcRspInfoField', nRequestID:'int', bIsLast:'bool'): 83 | print("OnRspAuthenticate:", pRspInfo.ErrorID, pRspInfo.ErrorMsg) 84 | if pRspInfo.ErrorID == 0: 85 | self.authed = True 86 | self.login() 87 | 88 | def OnRspUserLogin(self, pRspUserLogin:'CThostFtdcRspUserLoginField', pRspInfo:'CThostFtdcRspInfoField', nRequestID:'int', bIsLast:'bool'): 89 | print("OnRspUserLogin", pRspInfo.ErrorID, pRspInfo.ErrorMsg) 90 | if pRspInfo.ErrorID == 0: 91 | self.loggedin = True 92 | 93 | def OnRspError(self, pRspInfo:'CThostFtdcRspInfoField', nRequestID:'int', bIsLast:'bool'): 94 | print("OnRspError:", pRspInfo.ErrorID, pRspInfo.ErrorMsg) 95 | 96 | def __del__(self): 97 | self.api.RegisterSpi(None) 98 | self.api.Release() 99 | 100 | 101 | def test_init(spi): 102 | assert spi.connected and spi.authed and spi.loggedin 103 | --------------------------------------------------------------------------------