├── .gitignore ├── PyCTP_API ├── .idea │ ├── PyCtp.iml │ ├── encodings.xml │ ├── misc.xml │ ├── modules.xml │ ├── vcs.xml │ └── workspace.xml ├── CTP_API_File │ ├── ThostFtdcMdApi.h │ ├── ThostFtdcTraderApi.h │ ├── ThostFtdcUserApiDataType.h │ ├── ThostFtdcUserApiStruct.h │ ├── error.dtd │ ├── error.xml │ ├── thostmduserapi.dll │ ├── thostmduserapi.lib │ ├── thosttraderapi.dll │ └── thosttraderapi.lib ├── CTP_Run.py ├── FunctionLog.py ├── Market.py ├── Strategy.py ├── Trade.py ├── Utils.py ├── __pycache__ │ ├── FunctionLog.cpython-34.pyc │ ├── Market.cpython-34.pyc │ ├── Trade.cpython-34.pyc │ └── Utils.cpython-34.pyc ├── command.txt └── tmp │ ├── _tmp_m_DialogRsp.con │ ├── _tmp_m_QueryRsp.con │ ├── _tmp_m_TradingDay.con │ ├── _tmp_t_DialogRsp.con │ ├── _tmp_t_Private.con │ ├── _tmp_t_Public.con │ ├── _tmp_t_QueryRsp.con │ └── _tmp_t_TradingDay.con ├── PyCTP_Client ├── .gitignore ├── PyCTP_ClientCore │ ├── .gitignore │ ├── A性能分析.bat │ ├── CTPManager.py │ ├── CTP_API_File │ │ ├── .gitignore │ │ ├── ThostFtdcMdApi.h │ │ ├── ThostFtdcTraderApi.h │ │ ├── ThostFtdcUserApiDataType.h │ │ ├── ThostFtdcUserApiStruct.h │ │ ├── error.dtd │ │ ├── error.xml │ │ ├── thostmduserapi.dll │ │ ├── thostmduserapi.lib │ │ ├── thosttraderapi.dll │ │ └── thosttraderapi.lib │ ├── ClientMain.py │ ├── ClientMain.spec │ ├── DBManager.py │ ├── MarketManager.py │ ├── MessageBox.py │ ├── OrderAlgorithm.py │ ├── PyCTP.pyd │ ├── PyCTP_Market.py │ ├── PyCTP_Trade.py │ ├── QAccountWidget.py │ ├── QAlertBox.py │ ├── QCTP.py │ ├── QLogin.py │ ├── QMessageCenter.py │ ├── QNewStrategy.py │ ├── README.md │ ├── SocketManager.py │ ├── Strategy.py │ ├── StrategyDataModel.py │ ├── StructMap │ │ ├── PyCTP_ClientCore.asta │ │ ├── PyCTP_ClientCore.asta.bak │ │ └── PyCTP_ClientCore.asta.lock │ ├── TimerThread.py │ ├── Trader.py │ ├── Ui_QAccountWidget.py │ ├── Ui_QAlertBox.py │ ├── Ui_QCTP.py │ ├── Ui_QLogin.py │ ├── Ui_QMessageCenter.py │ ├── Ui_QOrderWidget.py │ ├── Ui_QStrategySetting.py │ ├── User.py │ ├── Utils.py │ ├── XML_Manager.py │ ├── command.txt │ ├── config │ │ ├── bee_config.xml │ │ ├── bee_config_end.xml │ │ ├── bee_config_start.xml │ │ └── trade_server_ip.xml │ ├── data │ │ ├── .gitignore │ │ ├── order_063802_01.csv │ │ ├── order_063802_02.csv │ │ ├── order_063802_03.csv │ │ ├── order_083849_01.csv │ │ ├── order_083849_02.csv │ │ ├── order_083849_03.csv │ │ ├── order_083849_04.csv │ │ ├── order_083849_05.csv │ │ ├── order_083849_06.csv │ │ ├── order_083849_07.csv │ │ ├── order_083849_08.csv │ │ ├── trade_063802_01.csv │ │ ├── trade_063802_02.csv │ │ ├── trade_063802_03.csv │ │ ├── trade_083849_01.csv │ │ ├── trade_083849_02.csv │ │ ├── trade_083849_03.csv │ │ ├── trade_083849_04.csv │ │ ├── trade_083849_05.csv │ │ ├── trade_083849_06.csv │ │ ├── trade_083849_07.csv │ │ └── trade_083849_08.csv │ ├── image.qrc │ ├── image │ │ ├── active.ico │ │ ├── add_strategy.ico │ │ ├── delete_strategy.ico │ │ ├── disactive.ico │ │ ├── login_bee.png │ │ ├── trayicon_exit.ico │ │ ├── trayicon_hide.ico │ │ └── trayicon_show.ico │ ├── img │ │ ├── add-line_horizontal.png │ │ ├── add-line_vertical.png │ │ ├── array_down.png │ │ ├── array_up.png │ │ ├── bee_24px_521056_easyicon.net.ico │ │ ├── checkbox_checked.png │ │ ├── checkbox_unchecked.png │ │ ├── info.png │ │ ├── login_bee.png │ │ ├── radio_normal.png │ │ ├── radio_selected.png │ │ ├── read.png │ │ ├── rocket.ico │ │ ├── silvery.css │ │ ├── sub-line_horizontal.png │ │ ├── sub-line_vertical.png │ │ └── unread.png │ ├── img_rc.py │ ├── login_bee.png │ ├── test.py │ ├── thostmduserapi.dll │ ├── thosttraderapi.dll │ └── 打包_spec.bat ├── PyCTP_ClientUI │ ├── QAccountWidget.py │ ├── QAccountWidget.ui │ ├── QAlertBox.py │ ├── QAlertBox.ui │ ├── QCTP.e4p │ ├── QCTP.py │ ├── QCTP.ui │ ├── QLogin.py │ ├── QLogin.ui │ ├── QMessageCenter.py │ ├── QMessageCenter.ui │ ├── QMessageTable.ui │ ├── QOrderWidget.ui │ ├── QStrategySetting.py │ ├── QStrategySetting.ui │ ├── Ui_QAccountWidget.py │ ├── Ui_QAlertBox.py │ ├── Ui_QCTP.py │ ├── Ui_QLogin.py │ ├── Ui_QMessageCenter.py │ ├── Ui_QMessageTable.py │ ├── Ui_QOrderWidget.py │ ├── Ui_QStrategySetting.py │ ├── __pycache__ │ │ ├── Ui_QAccountWidget.cpython-34.pyc │ │ └── Ui_QLogin.cpython-34.pyc │ ├── _eric6project │ │ ├── QCTP.e4q │ │ └── QCTP.e6t │ ├── image │ │ ├── 20161209085323652_easyicon_net_48.icns │ │ ├── 20161209085326120_easyicon_net_32.icns │ │ ├── 20161209085329196_easyicon_net_16.icns │ │ ├── bee.ico │ │ ├── bee_16px_521056_easyicon.net.ico │ │ ├── bee_16px_521056_easyicon.net.png │ │ ├── bee_24px_521056_easyicon.net.ico │ │ ├── bee_24px_521056_easyicon.net.png │ │ ├── bee_32px_521056_easyicon.net.ico │ │ ├── bee_32px_521056_easyicon.net.png │ │ ├── bee_48px_521056_easyicon.net.ico │ │ ├── bee_64px_521056_easyicon.net.ico │ │ ├── bee_64px_521056_easyicon.net.png │ │ ├── bee_72px_521056_easyicon.net.ico │ │ ├── bee_72px_521056_easyicon.net.png │ │ ├── login_bee.png │ │ └── rocket.ico │ ├── img.qrc │ ├── img_rc.py │ ├── login_bee.png │ ├── profile analysis │ │ ├── diagram-2017年3月23日.svg │ │ ├── diagram-2017年3月23日2.svg │ │ └── diagram-2017年3月24日.svg │ ├── 效果图 │ │ ├── QCTP效果图1.png │ │ ├── QCTP效果图2.png │ │ ├── QCTP效果图3.png │ │ ├── QCTP效果图4.png │ │ ├── QCTP效果图5.png │ │ ├── QCTP效果图6.png │ │ ├── QCTP效果图定稿.png │ │ └── eric6.png │ └── 结构导图 │ │ ├── QCTP.mmap │ │ ├── QTCP_Ui_QCTP.mmap │ │ └── ~$QCTP.mmap.~$lock ├── PyQt_Demo │ ├── 360界面.zip │ ├── GAS_V20160904.zip │ └── QSS.zip └── README.md ├── PyCTP_Integration ├── CTP_API_File │ ├── ThostFtdcMdApi.h │ ├── ThostFtdcTraderApi.h │ ├── ThostFtdcUserApiDataType.h │ ├── ThostFtdcUserApiStruct.h │ ├── error.dtd │ ├── error.xml │ ├── thostmduserapi.dll │ ├── thostmduserapi.lib │ ├── thosttraderapi.dll │ └── thosttraderapi.lib ├── DBManager.py ├── FunctionLog.py ├── MarketManager.py ├── MultiUserTradeSys.py ├── OrderAlgorithm.py ├── PyCTP_Market.py ├── PyCTP_Trade.py ├── README.md ├── Strategy.py ├── Trader.py ├── User.py ├── Utils.py ├── __pycache__ │ ├── DBManager.cpython-34.pyc │ ├── FunctionLog.cpython-34.pyc │ ├── MarketManager.cpython-34.pyc │ ├── MultiUserTradeSys.cpython-34.pyc │ ├── OrderAlgorithm.cpython-34.pyc │ ├── PyCTP_Market.cpython-34.pyc │ ├── PyCTP_Trade.cpython-34.pyc │ ├── Strategy.cpython-34.pyc │ ├── Trader.cpython-34.pyc │ ├── User.cpython-34.pyc │ └── Utils.cpython-34.pyc ├── command.txt ├── conn │ ├── md │ │ ├── 180.168.146.187_10010 │ │ │ ├── DialogRsp.con │ │ │ ├── QueryRsp.con │ │ │ └── TradingDay.con │ │ ├── 180.168.146.187_10030 │ │ │ ├── DialogRsp.con │ │ │ ├── QueryRsp.con │ │ │ └── TradingDay.con │ │ └── 180.168.146.187_10031 │ │ │ ├── DialogRsp.con │ │ │ ├── QueryRsp.con │ │ │ └── TradingDay.con │ └── td │ │ ├── 058176 │ │ ├── DialogRsp.con │ │ ├── Private.con │ │ ├── Public.con │ │ ├── QueryRsp.con │ │ └── TradingDay.con │ │ └── 063802 │ │ ├── DialogRsp.con │ │ ├── Private.con │ │ ├── Public.con │ │ ├── QueryRsp.con │ │ └── TradingDay.con ├── data │ ├── df_qry_data.csv │ └── df_tick_data.csv ├── test.py └── test2.py ├── PyCTP_SOCKT └── README.md ├── README.md ├── push.bat └── 小蜜蜂套利系统测试文档.xls /.gitignore: -------------------------------------------------------------------------------- 1 | PyCTP_Client/PyCTP_ClientCore/build 2 | PyCTP_Client/PyCTP_ClientCore/dist 3 | PyCTP_Integration/.idea/* 4 | PyCTP_Client/PyCTP_ClientCore/conn 5 | PyCTP_Client/PyCTP_ClientCore/.idea/ -------------------------------------------------------------------------------- /PyCTP_API/.idea/PyCtp.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 11 | -------------------------------------------------------------------------------- /PyCTP_API/.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /PyCTP_API/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /PyCTP_API/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /PyCTP_API/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /PyCTP_API/CTP_API_File/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 | -------------------------------------------------------------------------------- /PyCTP_API/CTP_API_File/error.dtd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | -------------------------------------------------------------------------------- /PyCTP_API/CTP_API_File/thostmduserapi.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_API/CTP_API_File/thostmduserapi.dll -------------------------------------------------------------------------------- /PyCTP_API/CTP_API_File/thostmduserapi.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_API/CTP_API_File/thostmduserapi.lib -------------------------------------------------------------------------------- /PyCTP_API/CTP_API_File/thosttraderapi.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_API/CTP_API_File/thosttraderapi.dll -------------------------------------------------------------------------------- /PyCTP_API/CTP_API_File/thosttraderapi.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_API/CTP_API_File/thosttraderapi.lib -------------------------------------------------------------------------------- /PyCTP_API/FunctionLog.py: -------------------------------------------------------------------------------- 1 | def fun_log(fn): 2 | def wrapper(*args, **kwargs): 3 | print("Before Calling %s" %fn.__name__) 4 | retval = fn(*args, **kwargs) 5 | # print("After Calling %s" %fn.__name__) 6 | return retval 7 | return wrapper 8 | 9 | def fun_log_message(msg): 10 | print(msg) 11 | def wrapper(fn): 12 | def new_wrapper(*args, **kwargs): 13 | print ("Before Calling %s" %fn.__name__) 14 | retval = fn(*args, **kwargs) 15 | # print ("After Calling %s" %fn.__name__) 16 | return retval 17 | return new_wrapper 18 | return wrapper 19 | -------------------------------------------------------------------------------- /PyCTP_API/Strategy.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Wed Jul 20 08:46:13 2016 4 | 5 | @author: YuWanying 6 | """ 7 | 8 | 9 | from Trade import PyCTP_Trader, PyCTP_Trader_API 10 | from Market import PyCTP_Market, PyCTP_Market_API 11 | 12 | 13 | class Strategy: 14 | def __init__(self): 15 | print('新建Strategy类的实例') 16 | 17 | @staticmethod 18 | def strategy_1(len_ma1=10, len_ma2=20): 19 | print('strategy_1被调用,参数:', len_ma1, len_ma2) 20 | 21 | def strategy_2(self, len_ma1=10, len_ma2=20): 22 | print('strategy_2被调用,参数:', len_ma1, len_ma2) -------------------------------------------------------------------------------- /PyCTP_API/Utils.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Wed Jul 20 08:46:13 2016 4 | 5 | @author: YuWanying 6 | """ 7 | 8 | 9 | # 对CTP_API返回的dict结构内部的元素编码从bytes转换为utf-8,该方法也适用于单个变量的格式转换 10 | def code_transform(data): 11 | # 传入参数为list 12 | if isinstance(data, list): 13 | list_output = [] 14 | for i_dict in data: 15 | if isinstance(i_dict, dict): # k是个dict 16 | data_output = {} 17 | for j_key in i_dict: # j是dict内部单个元素的key 18 | data_output[j_key] = code_transform(i_dict[j_key]) 19 | list_output.append(data_output) 20 | return list_output 21 | # 传入参数为dict 22 | elif isinstance(data, dict): 23 | data_output = {} 24 | for i in data: 25 | data_output[i] = code_transform(data[i]) 26 | return data_output 27 | # 传入参数为单个变量 28 | elif isinstance(data, bytes): 29 | return data.decode('gbk') 30 | else: 31 | return data 32 | 33 | 34 | # 打印主菜单 35 | def print_menu(): 36 | print('===========================') 37 | print('|请输入您的操作编号:') 38 | print('|【1】查询交易所') 39 | print('|【2】查询合约') 40 | print('|【3】查询合约状态') 41 | print('|【4】查询账户信息') 42 | print('|【5】查询账户资金') 43 | print('|【6】查询账户持仓汇总') 44 | print('|【7】查询账户持仓明细') 45 | print('|【8】查询委托记录') 46 | print('|【9】查询交易记录') 47 | print('|【10】报单') 48 | print('|【11】撤单') 49 | print('|【s】保存文件本地') 50 | print('|【q】退出') 51 | print('===========================') 52 | 53 | -------------------------------------------------------------------------------- /PyCTP_API/__pycache__/FunctionLog.cpython-34.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_API/__pycache__/FunctionLog.cpython-34.pyc -------------------------------------------------------------------------------- /PyCTP_API/__pycache__/Market.cpython-34.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_API/__pycache__/Market.cpython-34.pyc -------------------------------------------------------------------------------- /PyCTP_API/__pycache__/Trade.cpython-34.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_API/__pycache__/Trade.cpython-34.pyc -------------------------------------------------------------------------------- /PyCTP_API/__pycache__/Utils.cpython-34.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_API/__pycache__/Utils.cpython-34.pyc -------------------------------------------------------------------------------- /PyCTP_API/command.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_API/command.txt -------------------------------------------------------------------------------- /PyCTP_API/tmp/_tmp_m_DialogRsp.con: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /PyCTP_API/tmp/_tmp_m_QueryRsp.con: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /PyCTP_API/tmp/_tmp_m_TradingDay.con: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_API/tmp/_tmp_m_TradingDay.con -------------------------------------------------------------------------------- /PyCTP_API/tmp/_tmp_t_DialogRsp.con: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /PyCTP_API/tmp/_tmp_t_Private.con: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_API/tmp/_tmp_t_Private.con -------------------------------------------------------------------------------- /PyCTP_API/tmp/_tmp_t_Public.con: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_API/tmp/_tmp_t_Public.con -------------------------------------------------------------------------------- /PyCTP_API/tmp/_tmp_t_QueryRsp.con: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /PyCTP_API/tmp/_tmp_t_TradingDay.con: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_API/tmp/_tmp_t_TradingDay.con -------------------------------------------------------------------------------- /PyCTP_Client/.gitignore: -------------------------------------------------------------------------------- 1 | ./PyCTP_ClientCore/build 2 | ./PyCTP_ClientCore/dist 3 | ./.idea/* 4 | ./PyCTP_ClientCore/conn 5 | ./PyCTP_ClientCore/data/* 6 | ./PyCTP_ClientCore/CTP_API_File/* 7 | ./PyCTP_ClientCore/.idea/ -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/.gitignore: -------------------------------------------------------------------------------- 1 | .idea/* 2 | ./build/* 3 | ./__pycache__/* 4 | ./dist/* 5 | ./conn/* 6 | ./CTP_API_File/* 7 | ./data/* 8 | 9 | -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/A性能分析.bat: -------------------------------------------------------------------------------- 1 | python -m cProfile ClientMain.py -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/CTP_API_File/.gitignore: -------------------------------------------------------------------------------- 1 | ./* 2 | -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/CTP_API_File/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 | -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/CTP_API_File/error.dtd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/CTP_API_File/thostmduserapi.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientCore/CTP_API_File/thostmduserapi.dll -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/CTP_API_File/thostmduserapi.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientCore/CTP_API_File/thostmduserapi.lib -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/CTP_API_File/thosttraderapi.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientCore/CTP_API_File/thosttraderapi.dll -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/CTP_API_File/thosttraderapi.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientCore/CTP_API_File/thosttraderapi.lib -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/ClientMain.spec: -------------------------------------------------------------------------------- 1 | # -*- mode: python -*- 2 | 3 | block_cipher = None 4 | 5 | def get_pandas_path(): 6 | import pandas 7 | pandas_path = pandas.__path__[0] 8 | return pandas_path 9 | 10 | added_files = [('D:\\Python34\\DLLs\\python3.dll', '.'),('*.dll', '.'),('img', 'img'),('image', 'image'),('config', 'config'),('log', 'log')] 11 | 12 | a = Analysis(['ClientMain.py'], 13 | pathex=['.', 'D:\\CTP\\PyCTP\\PyCTP_Client\\PyCTP_ClientCore'], 14 | binaries=[('PyCTP.pyd',''), 15 | ('thostmduserapi.dll',''), 16 | ('thosttraderapi.dll','')], 17 | datas=added_files, 18 | hiddenimports=[], 19 | hookspath=[], 20 | runtime_hooks=[], 21 | excludes=[], 22 | win_no_prefer_redirects=False, 23 | win_private_assemblies=False, 24 | cipher=block_cipher) 25 | 26 | dict_tree = Tree(get_pandas_path(), prefix='pandas', excludes=["*.pyc"]) 27 | a.datas += dict_tree 28 | a.binaries = filter(lambda x: 'pandas' not in x[0], a.binaries) 29 | 30 | pyz = PYZ(a.pure, a.zipped_data, 31 | cipher=block_cipher) 32 | exe = EXE(pyz, 33 | a.scripts, 34 | exclude_binaries=True, 35 | name='ClientMain', 36 | debug=False, 37 | strip=False, 38 | upx=False, 39 | console=True , icon='img\\rocket.ico') 40 | coll = COLLECT(exe, 41 | a.binaries, 42 | a.zipfiles, 43 | a.datas, 44 | strip=False, 45 | upx=False, 46 | name='bee') 47 | -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/MessageBox.py: -------------------------------------------------------------------------------- 1 | from PyQt4 import QtGui 2 | import sys 3 | 4 | 5 | class MessageBox(QtGui.QWidget): 6 | def __init__(self): 7 | super(MessageBox, self).__init__() 8 | self.msg_box = QtGui.QMessageBox(self) 9 | 10 | def showMessage(self, info_type, info_content): 11 | self.msg_box.about(self, info_type, info_content) 12 | # self.msg_box.show() 13 | 14 | def showMessage_list(self, list_input): 15 | self.msg_box.about(self, list_input[0], list_input[1]) 16 | # self.msg_box.show() 17 | 18 | 19 | if __name__ == '__main__': 20 | app = QtGui.QApplication(sys.argv) 21 | MessageBox().showMessage("leixing", "hah") 22 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/OrderAlgorithm.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Wed Jul 20 08:46:13 2016 4 | 5 | @author: YuWanying 6 | """ 7 | 8 | import os 9 | import time 10 | import DBManager 11 | 12 | 13 | class OrderAlgorithm: 14 | # 下单算法类 15 | def __init__(self, dict_arguments, user): 16 | self.__list_order_ref = None 17 | self.__execute_flag = dict_arguments['order_algorithm'] 18 | self.__user = user 19 | pass 20 | 21 | def set_execute_flag(self, execute_flag): 22 | self.__execute_flag = execute_flag 23 | 24 | def execute(self): 25 | if self.__execute_flag == '1': 26 | self.order_algorithm_one() 27 | elif self.__execute_flag == '2': 28 | self.order_algorithm_two() 29 | 30 | def order_algorithm_one(self): 31 | pass 32 | 33 | def order_algorithm_two(self): 34 | pass 35 | -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/PyCTP.pyd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientCore/PyCTP.pyd -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/QAlertBox.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """ 4 | Module implementing QAlertBox.py. 5 | """ 6 | 7 | from PyQt4.QtCore import pyqtSlot 8 | from PyQt4.QtGui import QWidget 9 | from PyQt4 import QtGui, QtCore 10 | 11 | from Ui_QAlertBox import Ui_Form 12 | 13 | 14 | class QAlertBox(QWidget, Ui_Form): 15 | """ 16 | Class documentation goes here. 17 | """ 18 | def __init__(self, parent=None): 19 | """ 20 | Constructor 21 | 22 | @param parent reference to the parent widget 23 | @type QWidget 24 | """ 25 | super(QAlertBox, self).__init__(parent) 26 | self.setupUi(self) 27 | 28 | @pyqtSlot() 29 | def on_pushButton_clicked(self): 30 | """ 31 | Slot documentation goes here. 32 | """ 33 | # TODO: not implemented yet 34 | pass 35 | self.hide() 36 | 37 | # 形参:{窗口标题, 消息主体} 38 | def slot_show_alert(self, dict_input): 39 | self.setWindowTitle(dict_input['title']) 40 | self.label.setText(dict_input['main']) 41 | self.show() 42 | self.setWindowState(self.windowState() & ~QtCore.Qt.WindowMinimized | QtCore.Qt.WindowActive) 43 | # this will activate the window 44 | self.activateWindow() 45 | 46 | if __name__ == '__main__': 47 | import sys 48 | app = QtGui.QApplication(sys.argv) 49 | abox = QAlertBox() 50 | abox.label.setText("haha") # 消息主体 51 | abox.setWindowTitle("提示") # 窗口标题 52 | abox.show() 53 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/QCTP.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """ 4 | Module implementing QCTP. 5 | """ 6 | 7 | from PyQt4.QtCore import pyqtSlot 8 | from PyQt4.QtGui import QMainWindow 9 | from PyQt4.QtGui import QStatusBar 10 | from PyQt4.QtGui import QCloseEvent 11 | from PyQt4 import QtCore 12 | from QMessageCenter import MessageCenter 13 | 14 | 15 | from Ui_QCTP import Ui_MainWindow 16 | 17 | from PyQt4 import QtCore, QtGui 18 | 19 | try: 20 | _fromUtf8 = QtCore.QString.fromUtf8 21 | except AttributeError: 22 | def _fromUtf8(s): 23 | return s 24 | 25 | try: 26 | _encoding = QtGui.QApplication.UnicodeUTF8 27 | def _translate(context, text, disambig): 28 | return QtGui.QApplication.translate(context, text, disambig, _encoding) 29 | except AttributeError: 30 | def _translate(context, text, disambig): 31 | return QtGui.QApplication.translate(context, text, disambig) 32 | 33 | 34 | class QCTP(QMainWindow, Ui_MainWindow): 35 | """ 36 | Class documentation goes here. 37 | """ 38 | # 定义信号:TabWidget的tab页被鼠标点击(切换tab页),形参为tab_name 39 | signal_on_tab_accounts_currentChanged = QtCore.pyqtSignal(str) 40 | 41 | def __init__(self, parent=None): 42 | """ 43 | Constructor 44 | 45 | @param parent reference to the parent widget 46 | @type QWidget 47 | """ 48 | super(QCTP, self).__init__(parent) 49 | self.setupUi(self) 50 | 51 | # 托盘 52 | self.hideAction = QtGui.QAction("&隐藏", self, triggered=self.hide) 53 | self.hideAction.setIcon(QtGui.QIcon("image/trayicon_hide.ico")) 54 | self.showAction = QtGui.QAction("&显示", self, triggered=self.showNormal) 55 | self.showAction.setIcon(QtGui.QIcon("image/trayicon_show.ico")) 56 | self.quitAction = QtGui.QAction("&退出", self, triggered=self.quitWindow) 57 | self.quitAction.setIcon(QtGui.QIcon("image/trayicon_exit.ico")) 58 | # self.quitAction = QtGui.QAction("&退出", self, triggered=QtGui.qApp.quit) 59 | self.trayIconMenu = QtGui.QMenu(self) 60 | self.trayIconMenu.addAction(self.hideAction) 61 | self.trayIconMenu.addAction(self.showAction) 62 | self.trayIconMenu.addSeparator() 63 | self.trayIconMenu.addAction(self.quitAction) 64 | self.icon = QtGui.QIcon('img/rocket.ico') 65 | self.trayIcon = QtGui.QSystemTrayIcon() 66 | self.trayIcon.setToolTip("小蜜蜂套利系统") 67 | self.trayIcon.setIcon(self.icon) 68 | self.setWindowIcon(self.icon) 69 | self.trayIcon.activated.connect(self.iconActivated) 70 | self.trayIcon.setContextMenu(self.trayIconMenu) 71 | self.trayIcon.show() 72 | 73 | self.message_center = MessageCenter(self) 74 | 75 | status_bar = QtGui.QStatusBar() # 创建状态栏 76 | status_bar.addWidget(self.message_center, stretch=1) # 设置状态栏格式 77 | self.setStatusBar(status_bar) 78 | self.__init_finished = False # QCTP界面初始化完成标志位,初始值为False 79 | 80 | # 托盘图标被点击,槽函数 81 | def iconActivated(self, reason): 82 | if reason in (QtGui.QSystemTrayIcon.Trigger, QtGui.QSystemTrayIcon.DoubleClick): 83 | self.show() 84 | self.setWindowState(self.windowState() & ~QtCore.Qt.WindowMinimized | QtCore.Qt.WindowActive) 85 | # this will activate the window 86 | self.activateWindow() 87 | 88 | # 托盘菜单:退出 89 | @pyqtSlot() 90 | def quitWindow(self): 91 | print(">>> QCTP.quitWindow() ") 92 | self.widget_QAccountWidget.get_SocketManager().set_recive_msg_flag(False) 93 | QtCore.QCoreApplication.instance().quit() 94 | 95 | def set_ClientMain(self, obj_ClientMain): 96 | self.__client_main = obj_ClientMain 97 | 98 | def get_ClientMain(self): 99 | return self.__client_main 100 | 101 | def set_CTPManager(self, obj_CTPManager): 102 | self.__ctp_manager = obj_CTPManager 103 | 104 | def get_CTPManager(self): 105 | return self.__ctp_manager 106 | 107 | def set_QLogin(self, obj_QLogin): 108 | self.__q_login = obj_QLogin 109 | 110 | def get_QLogin(self): 111 | return self.__q_login 112 | 113 | def set_SocketManager(self, obj_SocketManager): 114 | self.__socket_manager = obj_SocketManager 115 | 116 | def get_SocketManager(self): 117 | return self.__socket_manager 118 | 119 | # 隐藏登录框且显示自己 120 | def show_me(self): 121 | self.__q_login.hide() 122 | self.show() 123 | 124 | # @pyqtSlot(int) 125 | # def on_tab_accounts_currentChanged(self, index): 126 | # """ 127 | # Slot documentation goes here. 128 | # 129 | # @param index DESCRIPTION 130 | # @type int 131 | # """ 132 | # # TODO: not implemented yet 133 | # # raise NotImplementedError 134 | # pass 135 | # tab_name = self.tab_accounts.tabText(index) 136 | # self.signal_on_tab_accounts_currentChanged.emit(tab_name) 137 | 138 | @pyqtSlot(int) 139 | def on_tab_records_currentChanged(self, index): 140 | """ 141 | Slot documentation goes here. 142 | 143 | @param index DESCRIPTION 144 | @type int 145 | """ 146 | # TODO: not implemented yet 147 | # raise NotImplementedError 148 | pass 149 | 150 | def closeEvent(self, QCloseEvent): 151 | print(">>> QCTP.closeEvent() ") 152 | # self.trayIcon.showMessage("小蜜蜂套利系统", "隐藏在右下角") 153 | self.trayIcon.showMessage("小蜜蜂套利系统", "隐藏在右下角", QtGui.QSystemTrayIcon.NoIcon, 2 * 1000) 154 | # self.widget_QAccountWidget.get_SocketManager().set_recive_msg_flag(False) 155 | # QtCore.QCoreApplication.instance().quit() 156 | -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/QLogin.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """ 4 | Module implementing QLoginForm. 5 | """ 6 | import time 7 | import Utils 8 | from PyQt4.QtCore import pyqtSlot 9 | from PyQt4.QtGui import QWidget 10 | from PyQt4 import QtGui, QtCore 11 | import PyQt4 12 | from SocketManager import SocketManager 13 | import socket 14 | import json 15 | import QCTP 16 | import ClientMain 17 | import threading 18 | 19 | from Ui_QLogin import Ui_LoginForm 20 | 21 | 22 | class QLoginForm(QWidget, Ui_LoginForm): 23 | """ 24 | Class documentation goes here. 25 | """ 26 | 27 | signal_send_msg = QtCore.pyqtSignal(dict) # 信号:绑定到SocketManager的send_msg函数 28 | 29 | def __init__(self, parent=None): 30 | """ 31 | Constructor 32 | @param parent reference to the parent widget 33 | @type QWidget 34 | """ 35 | super(QLoginForm, self).__init__(parent) 36 | self.setupUi(self) 37 | 38 | self.__sockfd = None # socket_file_description 39 | self.__socket_manager = None # SocketManager对象 40 | 41 | self.lineEdit_trader_password.setEchoMode(QtGui.QLineEdit.Password) # 密码框暗文 42 | 43 | def set_sockfd(self, socket_file_description): 44 | self.__sockfd = socket_file_description 45 | 46 | def set_SocketManager(self, obj_sm): 47 | self.__socket_manager = obj_sm 48 | 49 | def get_SocketManager(self): 50 | return self.__socket_manager 51 | 52 | def set_QCTP(self, obj_QCTP): 53 | self.__q_ctp = obj_QCTP 54 | 55 | def get_QCTP(self): 56 | return self.__q_ctp 57 | 58 | def set_CTPManager(self, obj_CTPManager): 59 | self.__ctp_manager = obj_CTPManager 60 | 61 | def get_CTPManager(self): 62 | return self.__ctp_manager 63 | 64 | def set_QAccountWidget(self, obj_QAccountWidget): 65 | self.__QAccountWidget = obj_QAccountWidget 66 | 67 | def set_dict_QAccountWidget(self, dict_QAccountWidget): 68 | self.dict_QAccountWidget = dict_QAccountWidget 69 | 70 | def set_QOrderWidget(self, obj_QOrderWidget): 71 | self.__QOrderWidget = obj_QOrderWidget 72 | 73 | def set_ClientMain(self, obj_ClientMain): 74 | self.__client_main = obj_ClientMain 75 | 76 | def get_ClientMain(self): 77 | return self.__client_main 78 | 79 | def closeEvent(self, QCloseEvent): 80 | print(">>> QLogin.closeEvent() ") 81 | # self.widget_QAccountWidget.get_SocketManager().set_recive_msg_flag(False) 82 | QtCore.QCoreApplication.instance().quit() 83 | 84 | # 自定义槽 85 | @pyqtSlot(str) 86 | def slot_SendMsg(self, msg): 87 | # print("QLogin.slot_SendMsg()", msg) 88 | # send json to server 89 | self.__socket_manager.send_msg(msg) 90 | 91 | @pyqtSlot() 92 | def on_pushButton_login_clicked(self): 93 | thread = threading.current_thread() 94 | print("QLogin.on_pushButton_login_clicked() thread.getName()=", thread.getName()) 95 | """ 96 | Slot documentation goes here. 97 | """ 98 | # TODO: not implemented yet 99 | self.pushButton_login.setEnabled(False) # 点击后按钮灰显不可用,收到登录失败重新激活 100 | self.__dict_login = {'MsgRef': self.__socket_manager.msg_ref_add(), 101 | 'MsgSendFlag': 0, # 发送标志,客户端发出0,服务端发出1 102 | 'MsgSrc': 0, # 消息源,客户端0,服务端1 103 | 'MsgType': 1, # 消息类型为trader登录验证 104 | 'TraderID': self.lineEdit_trader_id.text(), 105 | 'Password': self.lineEdit_trader_password.text() 106 | } 107 | # json_login = json.dumps(self.__dict_login) 108 | self.signal_send_msg.emit(self.__dict_login) 109 | 110 | # 获得交易员登录信息 111 | def get_dict_login(self): 112 | return self.__dict_login 113 | 114 | @pyqtSlot() 115 | def on_pushButton_cancel_clicked(self): 116 | """ 117 | Slot documentation goes here. 118 | """ 119 | # TODO: not implemented yet 120 | # raise NotImplementedError 121 | self.close() 122 | 123 | 124 | @pyqtSlot(bool) 125 | def on_checkBox_isoffline_clicked(self, checked): 126 | """ 127 | Slot documentation goes here. 128 | 129 | @param checked DESCRIPTION 130 | @type bool 131 | """ 132 | # TODO: not implemented yet 133 | # raise NotImplementedError 134 | print("on_checkBox_isoffline_clicked()", checked) 135 | 136 | @pyqtSlot(int) 137 | def on_checkBox_isoffline_stateChanged(self, p0): 138 | """ 139 | Slot documentation goes here. 140 | 141 | @param p0 DESCRIPTION 142 | @type int 143 | """ 144 | # TODO: not implemented yet 145 | # raise NotImplementedError 146 | 147 | 148 | if __name__ == "__main__": 149 | import sys 150 | 151 | app = QtGui.QApplication(sys.argv) 152 | Form = QLoginForm() 153 | Form.show() 154 | 155 | sys.exit(app.exec_()) 156 | 157 | -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/QMessageCenter.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """ 4 | Module implementing MessageCenter. 5 | """ 6 | 7 | from PyQt4.QtCore import pyqtSlot 8 | from PyQt4.QtGui import QWidget 9 | from PyQt4 import QtGui 10 | import sys 11 | 12 | from Ui_QMessageCenter import Ui_MessageForm 13 | 14 | 15 | class MessageCenter(QWidget, Ui_MessageForm): 16 | """ 17 | Class documentation goes here. 18 | """ 19 | def __init__(self, parent=None): 20 | """ 21 | Constructor 22 | 23 | @param parent reference to the parent widget 24 | @type QWidget 25 | """ 26 | super(MessageCenter, self).__init__(parent) 27 | self.setupUi(self) 28 | 29 | 30 | if __name__ == '__main__': 31 | app = QtGui.QApplication(sys.argv) 32 | ex = MessageCenter() 33 | ex.show() 34 | sys.exit(app.exec_()) 35 | pass 36 | -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/README.md: -------------------------------------------------------------------------------- 1 | PyCTP 2 | ========= 3 | 上期信息技术CTP开发(Python实现) 4 | 5 | 开发环境 6 | -------- 7 | 8 | windows10 64, lang:Python3.4.3 9 | 开发顺序 10 | -------- 11 | 12 | PyCTP_API -> PyCTP_QT -> PyCPT_SOCKT 13 | 14 | ## 各个目录说明 15 | * PyCTP_API 16 | * 针对CTP的API库进行的API测试,分为Market(市场行情),Trader(交易) 17 | * PyCTP_Integration 18 | * 将CTP的Market、Trader集成到一起的版本,并实现多账户管理 19 | * PyCTP_QT 20 | * 在PyCTP_Integration基础上实现界面操作 21 | * PyCTP_SOCKET 22 | * 实现PyCTP与Server之间的socket通信版本 23 | 24 | ### 更新时间:2016.07.21 25 | -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/StructMap/PyCTP_ClientCore.asta: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientCore/StructMap/PyCTP_ClientCore.asta -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/StructMap/PyCTP_ClientCore.asta.bak: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientCore/StructMap/PyCTP_ClientCore.asta.bak -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/StructMap/PyCTP_ClientCore.asta.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientCore/StructMap/PyCTP_ClientCore.asta.lock -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/TimerThread.py: -------------------------------------------------------------------------------- 1 | import time 2 | from PyQt4 import QtCore, QtGui 3 | 4 | 5 | class TimerThread(QtCore.QThread): 6 | 7 | timeout_signal = QtCore.pyqtSignal() 8 | 9 | def __init__(self): 10 | QtCore.QThread.__init__(self) 11 | 12 | #重写run方法 13 | def run(self): 14 | self.timeout_signal.emit() 15 | while True: 16 | time.sleep(0.5) 17 | #发送timeout信号 18 | self.timeout_signal.emit() 19 | -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/Trader.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on 2016年8月12日21:49:19 4 | 5 | @author: YuWanying 6 | """ 7 | 8 | 9 | from PyCTP_Trade import PyCTP_Trader_API 10 | import Utils 11 | 12 | 13 | # 交易员类 14 | class Trader: 15 | def __init__(self, dict_argument): # trader_id, trader_name, password, is_active): 16 | self.__trader_id = dict_argument['trader_id'] 17 | self.__trader_name = dict_argument['trader_name'] 18 | # self.__password = dict_argument['password'] 19 | # self.__is_active = dict_argument['is_active'] 20 | # self.__list_user = list() # 保存交易员名下的期货账户列表 21 | 22 | def set_list_user(self, list_obj_user): 23 | self.__list_user = list_obj_user 24 | 25 | def get_list_user(self): 26 | return self.__list_user 27 | 28 | # 获取trader_id 29 | def get_trader_id(self): 30 | return self.__trader_id 31 | 32 | # 设置交易员密码 33 | def set_password(self, password): 34 | self.__password = password 35 | 36 | # 获取交易员密码 37 | def get_password(self): 38 | return self.__password 39 | 40 | # 设置交易员活跃状态 41 | def set_is_active(self, is_active): 42 | self.__is_active = is_active 43 | 44 | # 获取交易员活跃状态 45 | def get_is_active(self): 46 | return self.__is_active 47 | 48 | # 设置交易员名称 49 | def set_trader_name(self, trader_name): 50 | self.__trader_name = trader_name 51 | 52 | # 获取交易员名称 53 | def get_trader_name(self): 54 | return self.__trader_name 55 | 56 | # 设置交易员id 57 | def set_trader_id(self, trader_id): 58 | self.__trader_id = trader_id 59 | 60 | -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/Ui_QAlertBox.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file 'D:\CTP\PyCTP\PyCTP_Client\PyCTP_ClientUI\QAlertBox.ui' 4 | # 5 | # Created by: PyQt4 UI code generator 4.11.4 6 | # 7 | # WARNING! All changes made in this file will be lost! 8 | 9 | from PyQt4 import QtCore, QtGui 10 | 11 | try: 12 | _fromUtf8 = QtCore.QString.fromUtf8 13 | except AttributeError: 14 | def _fromUtf8(s): 15 | return s 16 | 17 | try: 18 | _encoding = QtGui.QApplication.UnicodeUTF8 19 | def _translate(context, text, disambig): 20 | return QtGui.QApplication.translate(context, text, disambig, _encoding) 21 | except AttributeError: 22 | def _translate(context, text, disambig): 23 | return QtGui.QApplication.translate(context, text, disambig) 24 | 25 | class Ui_Form(object): 26 | def setupUi(self, Form): 27 | Form.setObjectName(_fromUtf8("Form")) 28 | Form.resize(405, 177) 29 | icon = QtGui.QIcon() 30 | icon.addPixmap(QtGui.QPixmap(_fromUtf8(":/image/bee.ico")), QtGui.QIcon.Normal, QtGui.QIcon.Off) 31 | Form.setWindowIcon(icon) 32 | Form.setStyleSheet(_fromUtf8("background-color: rgb(255, 255, 245);")) 33 | self.verticalLayout_2 = QtGui.QVBoxLayout(Form) 34 | self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2")) 35 | self.verticalLayout = QtGui.QVBoxLayout() 36 | self.verticalLayout.setSpacing(2) 37 | self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) 38 | self.label = QtGui.QLabel(Form) 39 | self.label.setStyleSheet(_fromUtf8("font: 75 10pt \"微软雅黑\";")) 40 | self.label.setAlignment(QtCore.Qt.AlignCenter) 41 | self.label.setObjectName(_fromUtf8("label")) 42 | self.verticalLayout.addWidget(self.label) 43 | self.horizontalLayout = QtGui.QHBoxLayout() 44 | self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) 45 | spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) 46 | self.horizontalLayout.addItem(spacerItem) 47 | self.pushButton = QtGui.QPushButton(Form) 48 | sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Maximum) 49 | sizePolicy.setHorizontalStretch(0) 50 | sizePolicy.setVerticalStretch(0) 51 | sizePolicy.setHeightForWidth(self.pushButton.sizePolicy().hasHeightForWidth()) 52 | self.pushButton.setSizePolicy(sizePolicy) 53 | self.pushButton.setMinimumSize(QtCore.QSize(100, 30)) 54 | self.pushButton.setStyleSheet(_fromUtf8("QPushButton{\n" 55 | " font: 100 10pt \"微软雅黑\";\n" 56 | " background-color: rgb(255, 255, 255);\n" 57 | " border: 1px solid #6D6D6D;\n" 58 | " color: rgb(0, 0, 0);\n" 59 | "}\n" 60 | "\n" 61 | "QPushButton::pressed{\n" 62 | " background-color: rgb(109, 109, 109);\n" 63 | " color: rgb(255, 255, 255);\n" 64 | "}")) 65 | self.pushButton.setObjectName(_fromUtf8("pushButton")) 66 | self.horizontalLayout.addWidget(self.pushButton) 67 | spacerItem1 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) 68 | self.horizontalLayout.addItem(spacerItem1) 69 | self.verticalLayout.addLayout(self.horizontalLayout) 70 | self.verticalLayout.setStretch(0, 6) 71 | self.verticalLayout.setStretch(1, 2) 72 | self.verticalLayout_2.addLayout(self.verticalLayout) 73 | 74 | self.retranslateUi(Form) 75 | QtCore.QMetaObject.connectSlotsByName(Form) 76 | 77 | def retranslateUi(self, Form): 78 | Form.setWindowTitle(_translate("Form", "信息提示窗口", None)) 79 | self.label.setText(_translate("Form", "34", None)) 80 | self.pushButton.setText(_translate("Form", "确定", None)) 81 | 82 | import img_rc 83 | 84 | if __name__ == "__main__": 85 | import sys 86 | app = QtGui.QApplication(sys.argv) 87 | Form = QtGui.QWidget() 88 | ui = Ui_Form() 89 | ui.setupUi(Form) 90 | Form.show() 91 | sys.exit(app.exec_()) 92 | 93 | -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/Ui_QCTP.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file 'D:\CTP\PyCTP\PyCTP_Client\PyCTP_ClientUI\QCTP.ui' 4 | # 5 | # Created by: PyQt4 UI code generator 4.11.4 6 | # 7 | # WARNING! All changes made in this file will be lost! 8 | 9 | from PyQt4 import QtCore, QtGui 10 | 11 | try: 12 | _fromUtf8 = QtCore.QString.fromUtf8 13 | except AttributeError: 14 | def _fromUtf8(s): 15 | return s 16 | 17 | try: 18 | _encoding = QtGui.QApplication.UnicodeUTF8 19 | def _translate(context, text, disambig): 20 | return QtGui.QApplication.translate(context, text, disambig, _encoding) 21 | except AttributeError: 22 | def _translate(context, text, disambig): 23 | return QtGui.QApplication.translate(context, text, disambig) 24 | 25 | class Ui_MainWindow(object): 26 | def setupUi(self, MainWindow): 27 | MainWindow.setObjectName(_fromUtf8("MainWindow")) 28 | MainWindow.resize(1425, 900) 29 | sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) 30 | sizePolicy.setHorizontalStretch(0) 31 | sizePolicy.setVerticalStretch(0) 32 | sizePolicy.setHeightForWidth(MainWindow.sizePolicy().hasHeightForWidth()) 33 | MainWindow.setSizePolicy(sizePolicy) 34 | MainWindow.setContextMenuPolicy(QtCore.Qt.DefaultContextMenu) 35 | icon = QtGui.QIcon() 36 | icon.addPixmap(QtGui.QPixmap(_fromUtf8(":/image/bee.ico")), QtGui.QIcon.Normal, QtGui.QIcon.Off) 37 | MainWindow.setWindowIcon(icon) 38 | self.centralWidget = QtGui.QWidget(MainWindow) 39 | sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred) 40 | sizePolicy.setHorizontalStretch(0) 41 | sizePolicy.setVerticalStretch(0) 42 | sizePolicy.setHeightForWidth(self.centralWidget.sizePolicy().hasHeightForWidth()) 43 | self.centralWidget.setSizePolicy(sizePolicy) 44 | self.centralWidget.setObjectName(_fromUtf8("centralWidget")) 45 | self.verticalLayout = QtGui.QVBoxLayout(self.centralWidget) 46 | self.verticalLayout.setMargin(5) 47 | self.verticalLayout.setSpacing(5) 48 | self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) 49 | self.splitter_mainwindow = QtGui.QSplitter(self.centralWidget) 50 | sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) 51 | sizePolicy.setHorizontalStretch(0) 52 | sizePolicy.setVerticalStretch(0) 53 | sizePolicy.setHeightForWidth(self.splitter_mainwindow.sizePolicy().hasHeightForWidth()) 54 | self.splitter_mainwindow.setSizePolicy(sizePolicy) 55 | self.splitter_mainwindow.setOrientation(QtCore.Qt.Vertical) 56 | self.splitter_mainwindow.setHandleWidth(2) 57 | self.splitter_mainwindow.setChildrenCollapsible(False) 58 | self.splitter_mainwindow.setObjectName(_fromUtf8("splitter_mainwindow")) 59 | self.widget_QAccountWidget = QAccountWidget(self.splitter_mainwindow) 60 | sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) 61 | sizePolicy.setHorizontalStretch(0) 62 | sizePolicy.setVerticalStretch(0) 63 | sizePolicy.setHeightForWidth(self.widget_QAccountWidget.sizePolicy().hasHeightForWidth()) 64 | self.widget_QAccountWidget.setSizePolicy(sizePolicy) 65 | self.widget_QAccountWidget.setObjectName(_fromUtf8("widget_QAccountWidget")) 66 | self.tab_records = QtGui.QTabWidget(self.splitter_mainwindow) 67 | sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) 68 | sizePolicy.setHorizontalStretch(0) 69 | sizePolicy.setVerticalStretch(0) 70 | sizePolicy.setHeightForWidth(self.tab_records.sizePolicy().hasHeightForWidth()) 71 | self.tab_records.setSizePolicy(sizePolicy) 72 | self.tab_records.setMinimumSize(QtCore.QSize(0, 330)) 73 | self.tab_records.setObjectName(_fromUtf8("tab_records")) 74 | self.verticalLayout.addWidget(self.splitter_mainwindow) 75 | MainWindow.setCentralWidget(self.centralWidget) 76 | self.menuBar = QtGui.QMenuBar(MainWindow) 77 | self.menuBar.setGeometry(QtCore.QRect(0, 0, 1425, 26)) 78 | self.menuBar.setObjectName(_fromUtf8("menuBar")) 79 | self.menu_file = QtGui.QMenu(self.menuBar) 80 | self.menu_file.setObjectName(_fromUtf8("menu_file")) 81 | self.menu_account = QtGui.QMenu(self.menuBar) 82 | self.menu_account.setObjectName(_fromUtf8("menu_account")) 83 | self.menu_market = QtGui.QMenu(self.menuBar) 84 | self.menu_market.setObjectName(_fromUtf8("menu_market")) 85 | self.menu_trademodel = QtGui.QMenu(self.menuBar) 86 | self.menu_trademodel.setObjectName(_fromUtf8("menu_trademodel")) 87 | self.menu_report = QtGui.QMenu(self.menuBar) 88 | self.menu_report.setObjectName(_fromUtf8("menu_report")) 89 | MainWindow.setMenuBar(self.menuBar) 90 | self.statusBar = QtGui.QStatusBar(MainWindow) 91 | self.statusBar.setObjectName(_fromUtf8("statusBar")) 92 | MainWindow.setStatusBar(self.statusBar) 93 | self.toolBar = QtGui.QToolBar(MainWindow) 94 | self.toolBar.setObjectName(_fromUtf8("toolBar")) 95 | MainWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.toolBar) 96 | self.menuBar.addAction(self.menu_file.menuAction()) 97 | self.menuBar.addAction(self.menu_account.menuAction()) 98 | self.menuBar.addAction(self.menu_market.menuAction()) 99 | self.menuBar.addAction(self.menu_trademodel.menuAction()) 100 | self.menuBar.addAction(self.menu_report.menuAction()) 101 | 102 | self.retranslateUi(MainWindow) 103 | self.tab_records.setCurrentIndex(-1) 104 | QtCore.QMetaObject.connectSlotsByName(MainWindow) 105 | 106 | def retranslateUi(self, MainWindow): 107 | MainWindow.setWindowTitle(_translate("MainWindow", "小蜜蜂套利交易系统", None)) 108 | self.menu_file.setTitle(_translate("MainWindow", "文件", None)) 109 | self.menu_account.setTitle(_translate("MainWindow", "账户", None)) 110 | self.menu_market.setTitle(_translate("MainWindow", "行情", None)) 111 | self.menu_trademodel.setTitle(_translate("MainWindow", "交易模型", None)) 112 | self.menu_report.setTitle(_translate("MainWindow", "报告", None)) 113 | self.toolBar.setWindowTitle(_translate("MainWindow", "toolBar", None)) 114 | 115 | from QAccountWidget import QAccountWidget 116 | import img_rc 117 | 118 | if __name__ == "__main__": 119 | import sys 120 | app = QtGui.QApplication(sys.argv) 121 | MainWindow = QtGui.QMainWindow() 122 | ui = Ui_MainWindow() 123 | ui.setupUi(MainWindow) 124 | MainWindow.show() 125 | sys.exit(app.exec_()) 126 | 127 | -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/Ui_QMessageCenter.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file 'D:\CTP\PyCTP\PyCTP_Client\PyCTP_ClientUI\QMessageCenter.ui' 4 | # 5 | # Created by: PyQt4 UI code generator 4.11.4 6 | # 7 | # WARNING! All changes made in this file will be lost! 8 | 9 | from PyQt4 import QtCore, QtGui 10 | 11 | try: 12 | _fromUtf8 = QtCore.QString.fromUtf8 13 | except AttributeError: 14 | def _fromUtf8(s): 15 | return s 16 | 17 | try: 18 | _encoding = QtGui.QApplication.UnicodeUTF8 19 | def _translate(context, text, disambig): 20 | return QtGui.QApplication.translate(context, text, disambig, _encoding) 21 | except AttributeError: 22 | def _translate(context, text, disambig): 23 | return QtGui.QApplication.translate(context, text, disambig) 24 | 25 | class Ui_MessageForm(object): 26 | def setupUi(self, MessageForm): 27 | MessageForm.setObjectName(_fromUtf8("MessageForm")) 28 | MessageForm.resize(1425, 33) 29 | self.horizontalLayout = QtGui.QHBoxLayout(MessageForm) 30 | self.horizontalLayout.setContentsMargins(10, 0, 5, 0) 31 | self.horizontalLayout.setSpacing(0) 32 | self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) 33 | self.label_message = QtGui.QLabel(MessageForm) 34 | self.label_message.setObjectName(_fromUtf8("label_message")) 35 | self.horizontalLayout.addWidget(self.label_message) 36 | self.line = QtGui.QFrame(MessageForm) 37 | self.line.setFrameShape(QtGui.QFrame.VLine) 38 | self.line.setFrameShadow(QtGui.QFrame.Sunken) 39 | self.line.setObjectName(_fromUtf8("line")) 40 | self.horizontalLayout.addWidget(self.line) 41 | self.label_trade_connect_status = QtGui.QLabel(MessageForm) 42 | self.label_trade_connect_status.setObjectName(_fromUtf8("label_trade_connect_status")) 43 | self.horizontalLayout.addWidget(self.label_trade_connect_status) 44 | self.line_2 = QtGui.QFrame(MessageForm) 45 | self.line_2.setFrameShape(QtGui.QFrame.VLine) 46 | self.line_2.setFrameShadow(QtGui.QFrame.Sunken) 47 | self.line_2.setObjectName(_fromUtf8("line_2")) 48 | self.horizontalLayout.addWidget(self.line_2) 49 | self.label_market_connect_status = QtGui.QLabel(MessageForm) 50 | self.label_market_connect_status.setObjectName(_fromUtf8("label_market_connect_status")) 51 | self.horizontalLayout.addWidget(self.label_market_connect_status) 52 | self.line_3 = QtGui.QFrame(MessageForm) 53 | self.line_3.setFrameShape(QtGui.QFrame.VLine) 54 | self.line_3.setFrameShadow(QtGui.QFrame.Sunken) 55 | self.line_3.setObjectName(_fromUtf8("line_3")) 56 | self.horizontalLayout.addWidget(self.line_3) 57 | self.label_CFFEX_time = QtGui.QLabel(MessageForm) 58 | self.label_CFFEX_time.setObjectName(_fromUtf8("label_CFFEX_time")) 59 | self.horizontalLayout.addWidget(self.label_CFFEX_time) 60 | self.line_4 = QtGui.QFrame(MessageForm) 61 | self.line_4.setFrameShape(QtGui.QFrame.VLine) 62 | self.line_4.setFrameShadow(QtGui.QFrame.Sunken) 63 | self.line_4.setObjectName(_fromUtf8("line_4")) 64 | self.horizontalLayout.addWidget(self.line_4) 65 | self.label_SHFE_time = QtGui.QLabel(MessageForm) 66 | self.label_SHFE_time.setObjectName(_fromUtf8("label_SHFE_time")) 67 | self.horizontalLayout.addWidget(self.label_SHFE_time) 68 | self.line_5 = QtGui.QFrame(MessageForm) 69 | self.line_5.setFrameShape(QtGui.QFrame.VLine) 70 | self.line_5.setFrameShadow(QtGui.QFrame.Sunken) 71 | self.line_5.setObjectName(_fromUtf8("line_5")) 72 | self.horizontalLayout.addWidget(self.line_5) 73 | self.label_CZCE_time = QtGui.QLabel(MessageForm) 74 | self.label_CZCE_time.setObjectName(_fromUtf8("label_CZCE_time")) 75 | self.horizontalLayout.addWidget(self.label_CZCE_time) 76 | self.line_6 = QtGui.QFrame(MessageForm) 77 | self.line_6.setFrameShape(QtGui.QFrame.VLine) 78 | self.line_6.setFrameShadow(QtGui.QFrame.Sunken) 79 | self.line_6.setObjectName(_fromUtf8("line_6")) 80 | self.horizontalLayout.addWidget(self.line_6) 81 | self.label_DCE_time = QtGui.QLabel(MessageForm) 82 | self.label_DCE_time.setObjectName(_fromUtf8("label_DCE_time")) 83 | self.horizontalLayout.addWidget(self.label_DCE_time) 84 | self.horizontalLayout.setStretch(0, 14) 85 | self.horizontalLayout.setStretch(1, 1) 86 | self.horizontalLayout.setStretch(2, 1) 87 | self.horizontalLayout.setStretch(3, 1) 88 | self.horizontalLayout.setStretch(4, 1) 89 | self.horizontalLayout.setStretch(5, 1) 90 | self.horizontalLayout.setStretch(6, 1) 91 | self.horizontalLayout.setStretch(7, 1) 92 | self.horizontalLayout.setStretch(8, 1) 93 | self.horizontalLayout.setStretch(9, 1) 94 | self.horizontalLayout.setStretch(10, 1) 95 | self.horizontalLayout.setStretch(11, 1) 96 | self.horizontalLayout.setStretch(12, 1) 97 | 98 | self.retranslateUi(MessageForm) 99 | QtCore.QMetaObject.connectSlotsByName(MessageForm) 100 | 101 | def retranslateUi(self, MessageForm): 102 | MessageForm.setWindowTitle(_translate("MessageForm", "MessageCenter", None)) 103 | self.label_message.setText(_translate("MessageForm", "SHFE:收盘", None)) 104 | self.label_trade_connect_status.setText(_translate("MessageForm", "交易连接", None)) 105 | self.label_market_connect_status.setText(_translate("MessageForm", "行情连接", None)) 106 | self.label_CFFEX_time.setText(_translate("MessageForm", "15:00:10", None)) 107 | self.label_SHFE_time.setText(_translate("MessageForm", "15:00:10", None)) 108 | self.label_CZCE_time.setText(_translate("MessageForm", "15:00:10", None)) 109 | self.label_DCE_time.setText(_translate("MessageForm", "15:00:10", None)) 110 | 111 | 112 | if __name__ == "__main__": 113 | import sys 114 | app = QtGui.QApplication(sys.argv) 115 | MessageForm = QtGui.QWidget() 116 | ui = Ui_MessageForm() 117 | ui.setupUi(MessageForm) 118 | MessageForm.show() 119 | sys.exit(app.exec_()) 120 | 121 | -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/Ui_QStrategySetting.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file 'D:\CTP\PyCTP\PyCTP_Client\PyCTP_ClientUI\QStrategySetting.ui' 4 | # 5 | # Created by: PyQt4 UI code generator 4.11.4 6 | # 7 | # WARNING! All changes made in this file will be lost! 8 | 9 | from PyQt4 import QtCore, QtGui 10 | 11 | try: 12 | _fromUtf8 = QtCore.QString.fromUtf8 13 | except AttributeError: 14 | def _fromUtf8(s): 15 | return s 16 | 17 | try: 18 | _encoding = QtGui.QApplication.UnicodeUTF8 19 | def _translate(context, text, disambig): 20 | return QtGui.QApplication.translate(context, text, disambig, _encoding) 21 | except AttributeError: 22 | def _translate(context, text, disambig): 23 | return QtGui.QApplication.translate(context, text, disambig) 24 | 25 | class Ui_NewStrategy(object): 26 | def setupUi(self, NewStrategy): 27 | NewStrategy.setObjectName(_fromUtf8("NewStrategy")) 28 | NewStrategy.resize(326, 294) 29 | sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) 30 | sizePolicy.setHorizontalStretch(1) 31 | sizePolicy.setVerticalStretch(1) 32 | sizePolicy.setHeightForWidth(NewStrategy.sizePolicy().hasHeightForWidth()) 33 | NewStrategy.setSizePolicy(sizePolicy) 34 | NewStrategy.setMinimumSize(QtCore.QSize(326, 294)) 35 | NewStrategy.setMaximumSize(QtCore.QSize(326, 294)) 36 | NewStrategy.setStyleSheet(_fromUtf8("background-color: rgb(255, 255, 245);")) 37 | self.label_user_id = QtGui.QLabel(NewStrategy) 38 | self.label_user_id.setGeometry(QtCore.QRect(40, 40, 117, 16)) 39 | self.label_user_id.setObjectName(_fromUtf8("label_user_id")) 40 | self.label_strategy_id = QtGui.QLabel(NewStrategy) 41 | self.label_strategy_id.setGeometry(QtCore.QRect(40, 80, 117, 16)) 42 | self.label_strategy_id.setObjectName(_fromUtf8("label_strategy_id")) 43 | self.label_a_instrument = QtGui.QLabel(NewStrategy) 44 | self.label_a_instrument.setGeometry(QtCore.QRect(40, 120, 117, 16)) 45 | self.label_a_instrument.setObjectName(_fromUtf8("label_a_instrument")) 46 | self.label_b_instrument = QtGui.QLabel(NewStrategy) 47 | self.label_b_instrument.setGeometry(QtCore.QRect(40, 160, 117, 16)) 48 | self.label_b_instrument.setObjectName(_fromUtf8("label_b_instrument")) 49 | self.comboBox_user_id = QtGui.QComboBox(NewStrategy) 50 | self.comboBox_user_id.setGeometry(QtCore.QRect(160, 40, 117, 21)) 51 | self.comboBox_user_id.setObjectName(_fromUtf8("comboBox_user_id")) 52 | self.lineEdit_a_instrument = QtGui.QLineEdit(NewStrategy) 53 | self.lineEdit_a_instrument.setGeometry(QtCore.QRect(160, 120, 117, 21)) 54 | self.lineEdit_a_instrument.setObjectName(_fromUtf8("lineEdit_a_instrument")) 55 | self.lineEdit_b_instrument = QtGui.QLineEdit(NewStrategy) 56 | self.lineEdit_b_instrument.setGeometry(QtCore.QRect(160, 160, 117, 21)) 57 | self.lineEdit_b_instrument.setObjectName(_fromUtf8("lineEdit_b_instrument")) 58 | self.pushButton_cancel = QtGui.QPushButton(NewStrategy) 59 | self.pushButton_cancel.setGeometry(QtCore.QRect(167, 240, 110, 28)) 60 | self.pushButton_cancel.setStyleSheet(_fromUtf8("QPushButton{\n" 61 | " font: 100 10pt \"微软雅黑\";\n" 62 | " background-color: rgb(255, 255, 255);\n" 63 | " border: 1px solid #6D6D6D;\n" 64 | " color: rgb(0, 0, 0);\n" 65 | "}\n" 66 | "\n" 67 | "QPushButton::pressed{\n" 68 | " background-color: rgb(109, 109, 109);\n" 69 | " color: rgb(255, 255, 255);\n" 70 | "}")) 71 | self.pushButton_cancel.setObjectName(_fromUtf8("pushButton_cancel")) 72 | self.pushButton_ok = QtGui.QPushButton(NewStrategy) 73 | self.pushButton_ok.setGeometry(QtCore.QRect(40, 240, 110, 28)) 74 | self.pushButton_ok.setStyleSheet(_fromUtf8("QPushButton{\n" 75 | " font: 100 10pt \"微软雅黑\";\n" 76 | " background-color: rgb(255, 255, 255);\n" 77 | " border: 1px solid #6D6D6D;\n" 78 | " color: rgb(0, 0, 0);\n" 79 | "}\n" 80 | "\n" 81 | "QPushButton::pressed{\n" 82 | " background-color: rgb(109, 109, 109);\n" 83 | " color: rgb(255, 255, 255);\n" 84 | "}")) 85 | self.pushButton_ok.setObjectName(_fromUtf8("pushButton_ok")) 86 | self.label_error_msg = QtGui.QLabel(NewStrategy) 87 | self.label_error_msg.setGeometry(QtCore.QRect(42, 192, 237, 37)) 88 | self.label_error_msg.setStyleSheet(_fromUtf8("color: rgb(255, 0, 0);")) 89 | self.label_error_msg.setText(_fromUtf8("")) 90 | self.label_error_msg.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter) 91 | self.label_error_msg.setObjectName(_fromUtf8("label_error_msg")) 92 | self.lineEdit_strategy_id = QtGui.QLineEdit(NewStrategy) 93 | self.lineEdit_strategy_id.setGeometry(QtCore.QRect(160, 80, 117, 21)) 94 | self.lineEdit_strategy_id.setObjectName(_fromUtf8("lineEdit_strategy_id")) 95 | 96 | self.retranslateUi(NewStrategy) 97 | QtCore.QMetaObject.connectSlotsByName(NewStrategy) 98 | NewStrategy.setTabOrder(self.comboBox_user_id, self.lineEdit_strategy_id) 99 | NewStrategy.setTabOrder(self.lineEdit_strategy_id, self.lineEdit_a_instrument) 100 | NewStrategy.setTabOrder(self.lineEdit_a_instrument, self.lineEdit_b_instrument) 101 | NewStrategy.setTabOrder(self.lineEdit_b_instrument, self.pushButton_ok) 102 | NewStrategy.setTabOrder(self.pushButton_ok, self.pushButton_cancel) 103 | 104 | def retranslateUi(self, NewStrategy): 105 | NewStrategy.setWindowTitle(_translate("NewStrategy", "新建策略", None)) 106 | self.label_user_id.setText(_translate("NewStrategy", "期货账号", None)) 107 | self.label_strategy_id.setText(_translate("NewStrategy", "策略编号", None)) 108 | self.label_a_instrument.setText(_translate("NewStrategy", "A合约代码", None)) 109 | self.label_b_instrument.setText(_translate("NewStrategy", "B合约代码", None)) 110 | self.pushButton_cancel.setText(_translate("NewStrategy", "取消", None)) 111 | self.pushButton_ok.setText(_translate("NewStrategy", "确定", None)) 112 | 113 | 114 | if __name__ == "__main__": 115 | import sys 116 | app = QtGui.QApplication(sys.argv) 117 | NewStrategy = QtGui.QWidget() 118 | ui = Ui_NewStrategy() 119 | ui.setupUi(NewStrategy) 120 | NewStrategy.show() 121 | sys.exit(app.exec_()) 122 | 123 | -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/command.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientCore/command.txt -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/config/bee_config_end.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 | -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/config/trade_server_ip.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/data/.gitignore: -------------------------------------------------------------------------------- 1 | ./* 2 | -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/data/order_063802_01.csv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientCore/data/order_063802_01.csv -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/data/order_063802_02.csv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientCore/data/order_063802_02.csv -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/data/order_063802_03.csv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientCore/data/order_063802_03.csv -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/data/order_083849_01.csv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientCore/data/order_083849_01.csv -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/data/order_083849_02.csv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientCore/data/order_083849_02.csv -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/data/order_083849_03.csv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientCore/data/order_083849_03.csv -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/data/order_083849_04.csv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientCore/data/order_083849_04.csv -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/data/order_083849_05.csv: -------------------------------------------------------------------------------- 1 | "" 2 | -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/data/order_083849_06.csv: -------------------------------------------------------------------------------- 1 | "" 2 | -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/data/order_083849_07.csv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientCore/data/order_083849_07.csv -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/data/order_083849_08.csv: -------------------------------------------------------------------------------- 1 | "" 2 | -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/data/trade_063802_01.csv: -------------------------------------------------------------------------------- 1 | ,BrokerID,BrokerOrderSeq,BusinessUnit,ClearingPartID,ClientID,Direction,ExchangeID,ExchangeInstID,HedgeFlag,InstrumentID,InvestorID,OffsetFlag,OperatorID,OrderLocalID,OrderRef,OrderSysID,ParticipantID,Price,PriceSource,ReceiveLocalTime,SequenceNo,SettlementID,StrategyID,TradeDate,TradeID,TradeSource,TradeTime,TradeType,TraderID,TradingDay,TradingRole,UserID,Volume 2 | 0,9999,189418.0,,9999,9999063802,0,SHFE,rb1801,1,rb1801,063802,0,1601, 172676,100000000201, 168194,9999,2780.0,"",2017-04-24 14:14:32 893508,255669.0,1.0,01,20170424, 81494,0,11:06:47,"",9999cac,20170424,"",063802,1.0 3 | 1,9999,189419.0,,9999,9999063802,1,SHFE,rb1710,1,rb1710,063802,0,1601, 172677,100000000301, 168195,9999,2862.0,"",2017-04-24 14:14:32 895517,255671.0,1.0,01,20170424, 81495,0,11:06:47,"",9999cac,20170424,"",063802,1.0 4 | 2,9999,189471.0,,9999,9999063802,1,SHFE,rb1801,1,rb1801,063802,3,1601, 172702,100000000401, 168230,9999,2780.0,"",2017-04-24 14:14:32 897521,255699.0,1.0,01,20170424, 81512,0,11:06:50,"",9999cac,20170424,"",063802,1.0 5 | 3,9999,189473.0,,9999,9999063802,0,SHFE,rb1710,1,rb1710,063802,3,1601, 172703,100000000501, 168231,9999,2864.0,"",2017-04-24 14:14:32 899526,255701.0,1.0,01,20170424, 81513,0,11:06:50,"",9999cac,20170424,"",063802,1.0 6 | 4,9999,189695.0,,9999,9999063802,1,SHFE,rb1801,1,rb1801,063802,0,1601, 172813,100000000601, 168408,9999,2780.0,"",2017-04-24 14:14:32 900528,255854.0,1.0,01,20170424, 81607,0,11:07:06,"",9999cac,20170424,"",063802,1.0 7 | 5,9999,189696.0,,9999,9999063802,0,SHFE,rb1710,1,rb1710,063802,0,1601, 172814,100000000701, 168409,9999,2863.0,"",2017-04-24 14:14:32 901530,255856.0,1.0,01,20170424, 81608,0,11:07:06,"",9999cac,20170424,"",063802,1.0 8 | 6,9999,189769.0,,9999,9999063802,0,SHFE,rb1801,1,rb1801,063802,3,1601, 172849,100000000801, 168463,9999,2780.0,"",2017-04-24 14:14:32 905545,255920.0,1.0,01,20170424, 81652,0,11:07:10,"",9999cac,20170424,"",063802,1.0 9 | 7,9999,189788.0,,9999,9999063802,1,SHFE,rb1710,1,rb1710,063802,3,1601, 172862,100000001001, 168479,9999,2861.0,"",2017-04-24 14:14:32 908553,255950.0,1.0,01,20170424, 81666,0,11:07:11,"",9999cac,20170424,"",063802,1.0 10 | 8,9999,191444.0,,9999,9999063802,1,SHFE,rb1801,1,rb1801,063802,0,1601, 173974,100000003501, 169740,9999,2779.0,"",2017-04-24 14:14:32 968781,257581.0,1.0,01,20170424, 82330,0,11:08:56,"",9999cac,20170424,"",063802,1.0 11 | 9,9999,191446.0,,9999,9999063802,0,SHFE,rb1710,1,rb1710,063802,0,1601, 173980,100000003601, 169742,9999,2863.0,"",2017-04-24 14:14:32 971807,257588.0,1.0,01,20170424, 82331,0,11:08:56,"",9999cac,20170424,"",063802,1.0 12 | 10,9999,191733.0,,9999,9999063802,0,SHFE,rb1801,1,rb1801,063802,3,1601, 174134,100000003701, 169969,9999,2780.0,"",2017-04-24 14:14:32 974188,257805.0,1.0,01,20170424, 82455,0,11:09:12,"",9999cac,20170424,"",063802,1.0 13 | 11,9999,191735.0,,9999,9999063802,1,SHFE,rb1710,1,rb1710,063802,3,1601, 174135,100000003801, 169971,9999,2861.0,"",2017-04-24 14:14:32 976699,257807.0,1.0,01,20170424, 82456,0,11:09:12,"",9999cac,20170424,"",063802,1.0 14 | 12,9999,195374.0,,9999,9999063802,1,SHFE,rb1801,1,rb1801,063802,0,1601, 176076,100000003901, 172743,9999,2777.0,"",2017-04-24 14:14:32 978710,260397.0,1.0,01,20170424, 83894,0,11:13:11,"",9999cac,20170424,"",063802,1.0 15 | 13,9999,195378.0,,9999,9999063802,0,SHFE,rb1710,1,rb1710,063802,0,1601, 176079,100000004001, 172746,9999,2861.0,"",2017-04-24 14:14:32 980716,260401.0,1.0,01,20170424, 83896,0,11:13:11,"",9999cac,20170424,"",063802,1.0 16 | 14,9999,195481.0,,9999,9999063802,0,SHFE,rb1801,1,rb1801,063802,3,1601, 176119,100000004101, 172814,9999,2779.0,"",2017-04-24 14:14:32 982723,260465.0,1.0,01,20170424, 83938,0,11:13:20,"",9999cac,20170424,"",063802,1.0 17 | 15,9999,195483.0,,9999,9999063802,1,SHFE,rb1710,1,rb1710,063802,3,1601, 176120,100000004201, 172815,9999,2861.0,"",2017-04-24 14:14:32 986731,260467.0,1.0,01,20170424, 83939,0,11:13:20,"",9999cac,20170424,"",063802,1.0 18 | -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/data/trade_063802_03.csv: -------------------------------------------------------------------------------- 1 | ,BrokerID,BrokerOrderSeq,BusinessUnit,ClearingPartID,ClientID,Direction,ExchangeID,ExchangeInstID,HedgeFlag,InstrumentID,InvestorID,OffsetFlag,OperatorID,OrderLocalID,OrderRef,OrderSysID,ParticipantID,Price,PriceSource,ReceiveLocalTime,SequenceNo,SettlementID,StrategyID,TradeDate,TradeID,TradeSource,TradeTime,TradeType,TraderID,TradingDay,TradingRole,UserID,Volume 2 | 0,9999,252571.0,,9999,9999063802,1,SHFE,bu1709,1,bu1709,063802,0,1601, 217852,100000010403, 213202,9999,2532.0,"",2017-04-24 14:14:33 055928,313103.0,1.0,03,20170424, 105864,0,14:07:12,"",9999cac,20170424,"",063802,10.0 3 | 1,9999,252573.0,,9999,9999063802,0,SHFE,bu1706,1,bu1706,063802,0,1601, 217853,100000010503, 213204,9999,2456.0,"",2017-04-24 14:14:33 057939,313105.0,1.0,03,20170424, 105866,0,14:07:12,"",9999cac,20170424,"",063802,10.0 4 | 2,9999,253101.0,,9999,9999063802,0,SHFE,bu1709,1,bu1709,063802,3,1601, 218264,100000010603, 213622,9999,2532.0,"",2017-04-24 14:14:33 059945,313692.0,1.0,03,20170424, 106044,0,14:07:46,"",9999cac,20170424,"",063802,10.0 5 | 3,9999,253103.0,,9999,9999063802,1,SHFE,bu1706,1,bu1706,063802,3,1601, 218266,100000010703, 213624,9999,2452.0,"",2017-04-24 14:14:33 060949,313695.0,1.0,03,20170424, 106045,0,14:07:46,"",9999cac,20170424,"",063802,10.0 6 | 4,9999,253107.0,,9999,9999063802,0,SHFE,bu1709,1,bu1709,063802,0,1601, 218268,100000010803, 213627,9999,2532.0,"",2017-04-24 14:14:33 062955,313698.0,1.0,03,20170424, 106047,0,14:07:46,"",9999cac,20170424,"",063802,10.0 7 | 5,9999,253108.0,,9999,9999063802,1,SHFE,bu1706,1,bu1706,063802,0,1601, 218269,100000010903, 213628,9999,2452.0,"",2017-04-24 14:14:33 064956,313700.0,1.0,03,20170424, 106048,0,14:07:46,"",9999cac,20170424,"",063802,10.0 8 | 6,9999,253349.0,,9999,9999063802,1,SHFE,bu1709,1,bu1709,063802,3,1601, 218441,100000011003, 213814,9999,2532.0,"",2017-04-24 14:14:33 066964,313972.0,1.0,03,20170424, 106144,0,14:08:02,"",9999cac,20170424,"",063802,10.0 9 | 7,9999,253350.0,,9999,9999063802,0,SHFE,bu1706,1,bu1706,063802,3,1601, 218442,100000011103, 213815,9999,2454.0,"",2017-04-24 14:14:33 068989,313974.0,1.0,03,20170424, 106145,0,14:08:02,"",9999cac,20170424,"",063802,10.0 10 | 8,9999,253355.0,,9999,9999063802,0,SHFE,bu1709,1,bu1709,063802,0,1601, 218446,100000011203, 213819,9999,2534.0,"",2017-04-24 14:14:33 070973,313979.0,1.0,03,20170424, 106146,0,14:08:02,"",9999cac,20170424,"",063802,10.0 11 | 9,9999,253356.0,,9999,9999063802,1,SHFE,bu1706,1,bu1706,063802,0,1601, 218448,100000011303, 213820,9999,2452.0,"",2017-04-24 14:14:33 071978,313982.0,1.0,03,20170424, 106147,0,14:08:02,"",9999cac,20170424,"",063802,10.0 12 | 10,9999,253363.0,,9999,9999063802,1,SHFE,bu1709,1,bu1709,063802,3,1601, 218454,100000011403, 213826,9999,2532.0,"",2017-04-24 14:14:33 073995,313991.0,1.0,03,20170424, 106150,0,14:08:03,"",9999cac,20170424,"",063802,10.0 13 | 11,9999,253365.0,,9999,9999063802,0,SHFE,bu1706,1,bu1706,063802,3,1601, 218455,100000011503, 213827,9999,2454.0,"",2017-04-24 14:14:33 075987,313993.0,1.0,03,20170424, 106151,0,14:08:03,"",9999cac,20170424,"",063802,10.0 14 | 12,9999,253369.0,,9999,9999063802,0,SHFE,bu1709,1,bu1709,063802,0,1601, 218459,100000011603, 213831,9999,2534.0,"",2017-04-24 14:14:33 076990,313998.0,1.0,03,20170424, 106152,0,14:08:03,"",9999cac,20170424,"",063802,10.0 15 | 13,9999,253370.0,,9999,9999063802,1,SHFE,bu1706,1,bu1706,063802,0,1601, 218460,100000011703, 213832,9999,2454.0,"",2017-04-24 14:14:33 077991,314000.0,1.0,03,20170424, 106153,0,14:08:03,"",9999cac,20170424,"",063802,10.0 16 | 14,9999,253432.0,,9999,9999063802,1,SHFE,bu1709,1,bu1709,063802,3,1601, 218500,100000011803, 213881,9999,2532.0,"",2017-04-24 14:14:33 079997,314054.0,1.0,03,20170424, 106178,0,14:08:07,"",9999cac,20170424,"",063802,10.0 17 | 15,9999,253459.0,,9999,9999063802,0,SHFE,bu1706,1,bu1706,063802,3,1601, 218518,100000012003, 213899,9999,2456.0,"",2017-04-24 14:14:33 083004,314079.0,1.0,03,20170424, 106187,0,14:08:10,"",9999cac,20170424,"",063802,10.0 18 | 16,9999,253465.0,,9999,9999063802,0,SHFE,bu1709,1,bu1709,063802,0,1601, 218522,100000012103, 213904,9999,2534.0,"",2017-04-24 14:14:33 084011,314087.0,1.0,03,20170424, 106192,0,14:08:10,"",9999cac,20170424,"",063802,10.0 19 | 17,9999,253471.0,,9999,9999063802,1,SHFE,bu1706,1,bu1706,063802,0,1601, 218525,100000012203, 213909,9999,2452.0,"",2017-04-24 14:14:33 086012,314091.0,1.0,03,20170424, 106195,0,14:08:10,"",9999cac,20170424,"",063802,10.0 20 | -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/data/trade_083849_01.csv: -------------------------------------------------------------------------------- 1 | ,BrokerID,BrokerOrderSeq,BusinessUnit,ClearingPartID,ClientID,Direction,ExchangeID,ExchangeInstID,HedgeFlag,InstrumentID,InvestorID,OffsetFlag,OperatorID,OrderLocalID,OrderRef,OrderSysID,ParticipantID,Price,PriceSource,ReceiveLocalTime,SequenceNo,SettlementID,StrategyID,TradeDate,TradeID,TradeSource,TradeTime,TradeType,TraderID,TradingDay,TradingRole,UserID,Volume 2 | 0,9999,1204.0,,9999,9999083829,0,SHFE,cu1705,1,cu1705,083849,0,1601, 711,100000000201, 299,9999,45780.0,"",2017-04-24 14:14:32 905545,249.0,1.0,01,20170421, 96,0,21:00:01,"",9999cac,20170424,"",083849,1.0 3 | 1,9999,1323.0,,9999,9999083829,1,SHFE,cu1706,1,cu1706,083849,0,1601, 819,100000000401, 413,9999,45810.0,"",2017-04-24 14:14:32 910554,418.0,1.0,01,20170421, 162,0,21:00:01,"",9999cac,20170424,"",083849,1.0 4 | 2,9999,1363.0,,9999,9999083829,0,SHFE,cu1705,1,cu1705,083849,0,1601, 851,100000000501, 453,9999,45760.0,"",2017-04-24 14:14:32 911556,475.0,1.0,01,20170421, 186,0,21:00:02,"",9999cac,20170424,"",083849,1.0 5 | 3,9999,1380.0,,9999,9999083829,1,SHFE,cu1706,1,cu1706,083849,0,1601, 864,100000000601, 470,9999,45820.0,"",2017-04-24 14:14:32 912561,494.0,1.0,01,20170421, 198,0,21:00:02,"",9999cac,20170424,"",083849,1.0 6 | 4,9999,18985.0,,9999,9999083829,1,SHFE,cu1705,1,cu1705,083849,3,1601, 19564,100000000701, 17664,9999,45590.0,"",2017-04-24 14:14:32 916570,29962.0,1.0,01,20170421, 8116,0,21:27:18,"",9999cac,20170424,"",083849,1.0 7 | 5,9999,18986.0,,9999,9999083829,0,SHFE,cu1706,1,cu1706,083849,3,1601, 19565,100000000801, 17665,9999,45650.0,"",2017-04-24 14:14:32 920583,29964.0,1.0,01,20170421, 8117,0,21:27:18,"",9999cac,20170424,"",083849,1.0 8 | 6,9999,18990.0,,9999,9999083829,1,SHFE,cu1705,1,cu1705,083849,3,1601, 19569,100000000901, 17668,9999,45590.0,"",2017-04-24 14:14:32 922594,29969.0,1.0,01,20170421, 8118,0,21:27:18,"",9999cac,20170424,"",083849,1.0 9 | 7,9999,18991.0,,9999,9999083829,0,SHFE,cu1706,1,cu1706,083849,3,1601, 19570,100000001001, 17669,9999,45650.0,"",2017-04-24 14:14:32 924594,29971.0,1.0,01,20170421, 8119,0,21:27:18,"",9999cac,20170424,"",083849,1.0 10 | -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/data/trade_083849_02.csv: -------------------------------------------------------------------------------- 1 | ,BrokerID,BrokerOrderSeq,BusinessUnit,ClearingPartID,ClientID,Direction,ExchangeID,ExchangeInstID,HedgeFlag,InstrumentID,InvestorID,OffsetFlag,OperatorID,OrderLocalID,OrderRef,OrderSysID,ParticipantID,Price,PriceSource,ReceiveLocalTime,SequenceNo,SettlementID,StrategyID,TradeDate,TradeID,TradeSource,TradeTime,TradeType,TraderID,TradingDay,TradingRole,UserID,Volume 2 | 0,9999,243007.0,,9999,9999083829,1,SHFE,rb1801,1,rb1801,083849,0,1601, 212088,100000005502, 206851,9999,2800.0,"",2017-04-24 14:14:33 222962,304597.0,1.0,02,20170424, 102628,0,13:57:13,"",9999cac,20170424,"",083849,2.0 3 | 1,9999,243008.0,,9999,9999083829,0,SHFE,rb1710,1,rb1710,083849,0,1601, 212089,100000005602, 206852,9999,2887.0,"",2017-04-24 14:14:33 225975,304599.0,1.0,02,20170424, 102629,0,13:57:13,"",9999cac,20170424,"",083849,2.0 4 | 2,9999,243013.0,,9999,9999083829,1,SHFE,rb1801,1,rb1801,083849,0,1601, 212094,100000005702, 206856,9999,2800.0,"",2017-04-24 14:14:33 227974,304605.0,1.0,02,20170424, 102630,0,13:57:13,"",9999cac,20170424,"",083849,2.0 5 | 3,9999,243014.0,,9999,9999083829,0,SHFE,rb1710,1,rb1710,083849,0,1601, 212095,100000005802, 206857,9999,2887.0,"",2017-04-24 14:14:33 228977,304607.0,1.0,02,20170424, 102631,0,13:57:13,"",9999cac,20170424,"",083849,2.0 6 | 4,9999,243015.0,,9999,9999083829,1,SHFE,rb1801,1,rb1801,083849,0,1601, 212096,100000005902, 206858,9999,2800.0,"",2017-04-24 14:14:33 231000,304609.0,1.0,02,20170424, 102632,0,13:57:13,"",9999cac,20170424,"",083849,1.0 7 | 5,9999,243016.0,,9999,9999083829,0,SHFE,rb1710,1,rb1710,083849,0,1601, 212097,100000006002, 206859,9999,2887.0,"",2017-04-24 14:14:33 231985,304611.0,1.0,02,20170424, 102633,0,13:57:13,"",9999cac,20170424,"",083849,1.0 8 | 6,9999,243114.0,,9999,9999083829,0,SHFE,rb1801,1,rb1801,083849,0,1601, 212198,100000006102, 206925,9999,2800.0,"",2017-04-24 14:14:33 257312,304795.0,1.0,02,20170424, 102680,0,13:57:23,"",9999cac,20170424,"",083849,1.0 9 | 7,9999,243139.0,,9999,9999083829,1,SHFE,rb1710,1,rb1710,083849,0,1601, 212222,100000006302, 206947,9999,2884.0,"",2017-04-24 14:14:33 261316,304808.0,1.0,02,20170424, 102685,0,13:57:24,"",9999cac,20170424,"",083849,1.0 10 | 8,9999,243142.0,,9999,9999083829,0,SHFE,rb1801,1,rb1801,083849,0,1601, 212225,100000006402, 206950,9999,2800.0,"",2017-04-24 14:14:33 263321,304812.0,1.0,02,20170424, 102686,0,13:57:24,"",9999cac,20170424,"",083849,1.0 11 | 9,9999,243143.0,,9999,9999083829,1,SHFE,rb1710,1,rb1710,083849,0,1601, 212226,100000006502, 206951,9999,2884.0,"",2017-04-24 14:14:33 265325,304814.0,1.0,02,20170424, 102687,0,13:57:24,"",9999cac,20170424,"",083849,1.0 12 | 10,9999,243144.0,,9999,9999083829,0,SHFE,rb1801,1,rb1801,083849,0,1601, 212227,100000006602, 206952,9999,2800.0,"",2017-04-24 14:14:33 277050,304816.0,1.0,02,20170424, 102688,0,13:57:24,"",9999cac,20170424,"",083849,1.0 13 | 11,9999,243145.0,,9999,9999083829,1,SHFE,rb1710,1,rb1710,083849,0,1601, 212228,100000006702, 206953,9999,2884.0,"",2017-04-24 14:14:33 278564,304818.0,1.0,02,20170424, 102689,0,13:57:24,"",9999cac,20170424,"",083849,1.0 14 | 12,9999,243146.0,,9999,9999083829,0,SHFE,rb1801,1,rb1801,083849,0,1601, 212229,100000006802, 206954,9999,2800.0,"",2017-04-24 14:14:33 280068,304820.0,1.0,02,20170424, 102690,0,13:57:25,"",9999cac,20170424,"",083849,1.0 15 | 13,9999,243147.0,,9999,9999083829,1,SHFE,rb1710,1,rb1710,083849,0,1601, 212230,100000006902, 206955,9999,2884.0,"",2017-04-24 14:14:33 281194,304822.0,1.0,02,20170424, 102691,0,13:57:25,"",9999cac,20170424,"",083849,1.0 16 | 14,9999,243157.0,,9999,9999083829,0,SHFE,rb1801,1,rb1801,083849,0,1601, 212238,100000007002, 206965,9999,2799.0,"",2017-04-24 14:14:33 283203,304845.0,1.0,02,20170424, 102700,0,13:57:25,"",9999cac,20170424,"",083849,1.0 17 | 15,9999,243167.0,,9999,9999083829,1,SHFE,rb1710,1,rb1710,083849,0,1601, 212245,100000007202, 206973,9999,2883.0,"",2017-04-24 14:14:33 287212,304854.0,1.0,02,20170424, 102703,0,13:57:25,"",9999cac,20170424,"",083849,1.0 18 | 16,9999,243169.0,,9999,9999083829,0,SHFE,rb1801,1,rb1801,083849,0,1601, 212246,100000007302, 206974,9999,2799.0,"",2017-04-24 14:14:33 291385,304856.0,1.0,02,20170424, 102704,0,13:57:26,"",9999cac,20170424,"",083849,1.0 19 | 17,9999,243177.0,,9999,9999083829,1,SHFE,rb1710,1,rb1710,083849,0,1601, 212254,100000007402, 206981,9999,2883.0,"",2017-04-24 14:14:33 293391,304872.0,1.0,02,20170424, 102709,0,13:57:26,"",9999cac,20170424,"",083849,1.0 20 | -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/data/trade_083849_03.csv: -------------------------------------------------------------------------------- 1 | ,BrokerID,BrokerOrderSeq,BusinessUnit,ClearingPartID,ClientID,Direction,ExchangeID,ExchangeInstID,HedgeFlag,InstrumentID,InvestorID,OffsetFlag,OperatorID,OrderLocalID,OrderRef,OrderSysID,ParticipantID,Price,PriceSource,ReceiveLocalTime,SequenceNo,SettlementID,StrategyID,TradeDate,TradeID,TradeSource,TradeTime,TradeType,TraderID,TradingDay,TradingRole,UserID,Volume 2 | 0,9999,168112.0,,9999,9999083829,0,SHFE,bu1709,1,bu1709,083849,0,1601, 158093,100000003503, 151338,9999,2550.0,"",2017-04-24 14:14:32 978710,233427.0,1.0,03,20170424, 72601,0,10:44:13,"",9999cac,20170424,"",083849,1.0 3 | 1,9999,168118.0,,9999,9999083829,1,SHFE,bu1706,1,bu1706,083849,0,1601, 158099,100000003603, 151342,9999,2458.0,"",2017-04-24 14:14:32 980716,233434.0,1.0,03,20170424, 72602,0,10:44:13,"",9999cac,20170424,"",083849,1.0 4 | 2,9999,168120.0,,9999,9999083829,0,SHFE,bu1709,1,bu1709,083849,0,1601, 158101,100000003703, 151344,9999,2550.0,"",2017-04-24 14:14:32 983724,233437.0,1.0,03,20170424, 72603,0,10:44:14,"",9999cac,20170424,"",083849,1.0 5 | 3,9999,168125.0,,9999,9999083829,1,SHFE,bu1706,1,bu1706,083849,0,1601, 158103,100000003803, 151348,9999,2458.0,"",2017-04-24 14:14:33 219953,233440.0,1.0,03,20170424, 72606,0,10:44:14,"",9999cac,20170424,"",083849,1.0 6 | -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/data/trade_083849_04.csv: -------------------------------------------------------------------------------- 1 | ,BrokerID,BrokerOrderSeq,BusinessUnit,ClearingPartID,ClientID,Direction,ExchangeID,ExchangeInstID,HedgeFlag,InstrumentID,InvestorID,OffsetFlag,OperatorID,OrderLocalID,OrderRef,OrderSysID,ParticipantID,Price,PriceSource,ReceiveLocalTime,SequenceNo,SettlementID,StrategyID,TradeDate,TradeID,TradeSource,TradeTime,TradeType,TraderID,TradingDay,TradingRole,UserID,Volume 2 | 0,9999,20448.0,,9999,9999083829,1,SHFE,rb1801,1,rb1801,083849,4,1601, 21064,100000001104, 19123,9999,2836.0,"",2017-04-24 14:14:32 926596,31923.0,1.0,04,20170421, 8543,0,21:29:56,"",9999cac,20170424,"",083849,1.0 3 | 1,9999,20457.0,,9999,9999083829,0,SHFE,rb1710,1,rb1710,083849,4,1601, 21074,100000001204, 19132,9999,2930.0,"",2017-04-24 14:14:32 928601,31944.0,1.0,04,20170421, 8549,0,21:29:56,"",9999cac,20170424,"",083849,1.0 4 | 2,9999,20458.0,,9999,9999083829,1,SHFE,rb1801,1,rb1801,083849,4,1601, 21075,100000001304, 19133,9999,2836.0,"",2017-04-24 14:14:32 932612,31946.0,1.0,04,20170421, 8550,0,21:29:57,"",9999cac,20170424,"",083849,1.0 5 | 3,9999,20466.0,,9999,9999083829,0,SHFE,rb1710,1,rb1710,083849,4,1601, 21083,100000001404, 19141,9999,2930.0,"",2017-04-24 14:14:32 933616,31955.0,1.0,04,20170421, 8551,0,21:29:57,"",9999cac,20170424,"",083849,1.0 6 | 4,9999,91709.0,,9999,9999083829,0,SHFE,rb1801,1,rb1801,083849,4,1601, 97161,100000002504, 88309,9999,2800.0,"",2017-04-24 14:14:32 942375,144609.0,1.0,04,20170424, 39344,0,09:06:51,"",9999cac,20170424,"",083849,1.0 7 | 5,9999,91710.0,,9999,9999083829,1,SHFE,rb1710,1,rb1710,083849,4,1601, 97162,100000002604, 88310,9999,2876.0,"",2017-04-24 14:14:32 945369,144611.0,1.0,04,20170424, 39345,0,09:06:51,"",9999cac,20170424,"",083849,1.0 8 | 6,9999,91724.0,,9999,9999083829,0,SHFE,rb1801,1,rb1801,083849,4,1601, 97168,100000002704, 88324,9999,2799.0,"",2017-04-24 14:14:32 948377,144622.0,1.0,04,20170424, 39349,0,09:06:52,"",9999cac,20170424,"",083849,1.0 9 | 7,9999,91725.0,,9999,9999083829,1,SHFE,rb1710,1,rb1710,083849,4,1601, 97169,100000002804, 88325,9999,2876.0,"",2017-04-24 14:14:32 952389,144624.0,1.0,04,20170424, 39350,0,09:06:52,"",9999cac,20170424,"",083849,1.0 10 | 8,9999,91727.0,,9999,9999083829,0,SHFE,rb1801,1,rb1801,083849,4,1601, 97171,100000002904, 88327,9999,2799.0,"",2017-04-24 14:14:32 956740,144628.0,1.0,04,20170424, 39353,0,09:06:52,"",9999cac,20170424,"",083849,1.0 11 | 9,9999,91743.0,,9999,9999083829,1,SHFE,rb1710,1,rb1710,083849,4,1601, 97187,100000003104, 88343,9999,2875.0,"",2017-04-24 14:14:32 963765,144658.0,1.0,04,20170424, 39362,0,09:06:53,"",9999cac,20170424,"",083849,1.0 12 | 10,9999,247960.0,,9999,9999083829,1,SHFE,rb1801,1,rb1801,083849,0,1601, 215526,100000010204, 210592,9999,2796.0,"",2017-04-24 14:14:33 295404,309635.0,1.0,04,20170424, 104474,0,14:03:21,"",9999cac,20170424,"",083849,3.0 13 | 11,9999,247961.0,,9999,9999083829,0,SHFE,rb1710,1,rb1710,083849,0,1601, 215527,100000010304, 210593,9999,2884.0,"",2017-04-24 14:14:33 296407,309637.0,1.0,04,20170424, 104475,0,14:03:21,"",9999cac,20170424,"",083849,3.0 14 | 12,9999,248076.0,,9999,9999083829,0,SHFE,rb1801,1,rb1801,083849,0,1601, 215597,100000010404, 210675,9999,2797.0,"",2017-04-24 14:14:33 298412,309734.0,1.0,04,20170424, 104516,0,14:03:31,"",9999cac,20170424,"",083849,2.0 15 | 13,9999,248081.0,,9999,9999083829,1,SHFE,rb1710,1,rb1710,083849,0,1601, 215602,100000010504, 210679,9999,2883.0,"",2017-04-24 14:14:33 299505,309742.0,1.0,04,20170424, 104518,0,14:03:31,"",9999cac,20170424,"",083849,2.0 16 | 14,9999,248087.0,,9999,9999083829,0,SHFE,rb1801,1,rb1801,083849,0,1601, 215607,100000010604, 210684,9999,2799.0,"",2017-04-24 14:14:33 301508,309748.0,1.0,04,20170424, 104521,0,14:03:32,"",9999cac,20170424,"",083849,1.0 17 | 15,9999,248091.0,,9999,9999083829,1,SHFE,rb1710,1,rb1710,083849,0,1601, 215611,100000010704, 210687,9999,2883.0,"",2017-04-24 14:14:33 303515,309753.0,1.0,04,20170424, 104522,0,14:03:32,"",9999cac,20170424,"",083849,1.0 18 | 16,9999,248158.0,,9999,9999083829,1,SHFE,rb1801,1,rb1801,083849,0,1601, 215707,100000010804, 210731,9999,2797.0,"",2017-04-24 14:14:33 305520,309898.0,1.0,04,20170424, 104555,0,14:03:38,"",9999cac,20170424,"",083849,1.0 19 | 17,9999,248159.0,,9999,9999083829,0,SHFE,rb1710,1,rb1710,083849,0,1601, 215708,100000010904, 210732,9999,2884.0,"",2017-04-24 14:14:33 307523,309900.0,1.0,04,20170424, 104556,0,14:03:38,"",9999cac,20170424,"",083849,1.0 20 | 18,9999,248161.0,,9999,9999083829,1,SHFE,rb1801,1,rb1801,083849,0,1601, 215710,100000011004, 210734,9999,2797.0,"",2017-04-24 14:14:33 309531,309903.0,1.0,04,20170424, 104557,0,14:03:38,"",9999cac,20170424,"",083849,1.0 21 | 19,9999,248162.0,,9999,9999083829,0,SHFE,rb1710,1,rb1710,083849,0,1601, 215711,100000011104, 210735,9999,2884.0,"",2017-04-24 14:14:33 311546,309905.0,1.0,04,20170424, 104558,0,14:03:38,"",9999cac,20170424,"",083849,1.0 22 | -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/data/trade_083849_05.csv: -------------------------------------------------------------------------------- 1 | "" 2 | -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/data/trade_083849_06.csv: -------------------------------------------------------------------------------- 1 | "" 2 | -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/data/trade_083849_07.csv: -------------------------------------------------------------------------------- 1 | ,BrokerID,BrokerOrderSeq,BusinessUnit,ClearingPartID,ClientID,Direction,ExchangeID,ExchangeInstID,HedgeFlag,InstrumentID,InvestorID,OffsetFlag,OperatorID,OrderLocalID,OrderRef,OrderSysID,ParticipantID,Price,PriceSource,ReceiveLocalTime,SequenceNo,SettlementID,StrategyID,TradeDate,TradeID,TradeSource,TradeTime,TradeType,TraderID,TradingDay,TradingRole,UserID,Volume 2 | 0,9999,73655.0,,9999,9999083829,0,SHFE,ni1705,1,ni1705,083849,0,1601, 78290,100000001507, 72073,9999,77370.0,"",2017-04-24 14:14:32 935622,115830.0,1.0,07,20170421, 30152,0,23:35:57,"",9999cac,20170424,"",083849,1.0 3 | 1,9999,73657.0,,9999,9999083829,1,SHFE,ni1709,1,ni1709,083849,0,1601, 78292,100000001607, 72075,9999,79150.0,"",2017-04-24 14:14:32 938838,115833.0,1.0,07,20170421, 30153,0,23:35:57,"",9999cac,20170424,"",083849,1.0 4 | 2,9999,91948.0,,9999,9999083829,1,SHFE,ni1705,1,ni1705,083849,3,1601, 97347,100000003207, 88548,9999,76790.0,"",2017-04-24 14:14:32 964775,144915.0,1.0,07,20170424, 39487,0,09:07:06,"",9999cac,20170424,"",083849,1.0 5 | 3,9999,91953.0,,9999,9999083829,0,SHFE,ni1709,1,ni1709,083849,3,1601, 97351,100000003407, 88553,9999,78590.0,"",2017-04-24 14:14:32 970782,144921.0,1.0,07,20170424, 39489,0,09:07:06,"",9999cac,20170424,"",083849,1.0 6 | -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/data/trade_083849_08.csv: -------------------------------------------------------------------------------- 1 | "" 2 | -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/image.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | img/rocket.ico 4 | 5 | 6 | -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/image/active.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientCore/image/active.ico -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/image/add_strategy.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientCore/image/add_strategy.ico -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/image/delete_strategy.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientCore/image/delete_strategy.ico -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/image/disactive.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientCore/image/disactive.ico -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/image/login_bee.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientCore/image/login_bee.png -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/image/trayicon_exit.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientCore/image/trayicon_exit.ico -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/image/trayicon_hide.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientCore/image/trayicon_hide.ico -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/image/trayicon_show.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientCore/image/trayicon_show.ico -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/img/add-line_horizontal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientCore/img/add-line_horizontal.png -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/img/add-line_vertical.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientCore/img/add-line_vertical.png -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/img/array_down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientCore/img/array_down.png -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/img/array_up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientCore/img/array_up.png -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/img/bee_24px_521056_easyicon.net.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientCore/img/bee_24px_521056_easyicon.net.ico -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/img/checkbox_checked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientCore/img/checkbox_checked.png -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/img/checkbox_unchecked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientCore/img/checkbox_unchecked.png -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/img/info.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientCore/img/info.png -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/img/login_bee.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientCore/img/login_bee.png -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/img/radio_normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientCore/img/radio_normal.png -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/img/radio_selected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientCore/img/radio_selected.png -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/img/read.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientCore/img/read.png -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/img/rocket.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientCore/img/rocket.ico -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/img/silvery.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientCore/img/silvery.css -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/img/sub-line_horizontal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientCore/img/sub-line_horizontal.png -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/img/sub-line_vertical.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientCore/img/sub-line_vertical.png -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/img/unread.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientCore/img/unread.png -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/login_bee.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientCore/login_bee.png -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/thostmduserapi.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientCore/thostmduserapi.dll -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/thosttraderapi.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientCore/thosttraderapi.dll -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientCore/打包_spec.bat: -------------------------------------------------------------------------------- 1 | pyinstaller --onedir --noupx ClientMain.spec 2 | pause -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientUI/QAlertBox.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """ 4 | Module implementing QAlertBox.py. 5 | """ 6 | 7 | from PyQt4.QtCore import pyqtSlot 8 | from PyQt4.QtGui import QWidget 9 | 10 | from .Ui_QAlertBox import Ui_Form 11 | 12 | 13 | class QAlertBox.py(QWidget, Ui_Form): 14 | """ 15 | Class documentation goes here. 16 | """ 17 | def __init__(self, parent=None): 18 | """ 19 | Constructor 20 | 21 | @param parent reference to the parent widget 22 | @type QWidget 23 | """ 24 | super(QAlertBox.py, self).__init__(parent) 25 | self.setupUi(self) 26 | 27 | @pyqtSlot() 28 | def on_pushButton_clicked(self): 29 | """ 30 | Slot documentation goes here. 31 | """ 32 | # TODO: not implemented yet 33 | raise NotImplementedError 34 | -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientUI/QAlertBox.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Form 4 | 5 | 6 | 7 | 0 8 | 0 9 | 405 10 | 177 11 | 12 | 13 | 14 | 信息提示窗口 15 | 16 | 17 | 18 | :/image/bee.ico:/image/bee.ico 19 | 20 | 21 | background-color: rgb(255, 255, 245); 22 | 23 | 24 | 25 | 26 | 27 | 2 28 | 29 | 30 | 31 | 32 | font: 75 10pt "微软雅黑"; 33 | 34 | 35 | 34 36 | 37 | 38 | Qt::AlignCenter 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | Qt::Horizontal 48 | 49 | 50 | 51 | 40 52 | 20 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 0 62 | 0 63 | 64 | 65 | 66 | 67 | 100 68 | 30 69 | 70 | 71 | 72 | QPushButton{ 73 | font: 100 10pt "微软雅黑"; 74 | background-color: rgb(255, 255, 255); 75 | border: 1px solid #6D6D6D; 76 | color: rgb(0, 0, 0); 77 | } 78 | 79 | QPushButton::pressed{ 80 | background-color: rgb(109, 109, 109); 81 | color: rgb(255, 255, 255); 82 | } 83 | 84 | 85 | 确定 86 | 87 | 88 | 89 | 90 | 91 | 92 | Qt::Horizontal 93 | 94 | 95 | 96 | 40 97 | 20 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientUI/QCTP.e4p: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | en_US 8 | 38ebbb11afed2ebe39aeb9f1442bb55b89ae56af 9 | Python3 10 | Qt4 11 | QCTP is the GUI of PyCTP. 12 | QCTP is friendly for traders. 13 | 0.1 14 | gmqh 15 | 16 | 17 | QAccountWidget.py 18 | QAlertBox.py 19 | QCTP.py 20 | QMessageCenter.py 21 | QStrategySetting.py 22 | Ui_QAccountWidget.py 23 | Ui_QAlertBox.py 24 | Ui_QCTP.py 25 | Ui_QLogin.py 26 | Ui_QMessageCenter.py 27 | Ui_QMessageTable.py 28 | Ui_QOrderWidget.py 29 | Ui_QStrategySetting.py 30 | img_rc.py 31 | 32 | 33 |
QAccountWidget.ui
34 |
QAlertBox.ui
35 |
QCTP.ui
36 |
QLogin.ui
37 |
QMessageCenter.ui
38 |
QMessageTable.ui
39 |
QOrderWidget.ui
40 |
QStrategySetting.ui
41 |
42 | 43 | 44 | img.qrc 45 | 46 | 47 | 48 | 49 | None 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 |
63 | -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientUI/QCTP.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """ 4 | Module implementing QCTP. 5 | """ 6 | 7 | from PyQt4.QtCore import pyqtSlot 8 | from PyQt4.QtGui import QMainWindow 9 | 10 | from .Ui_QCTP import Ui_MainWindow 11 | 12 | 13 | class QCTP(QMainWindow, Ui_MainWindow): 14 | """ 15 | Class documentation goes here. 16 | """ 17 | def __init__(self, parent=None): 18 | """ 19 | Constructor 20 | 21 | @param parent reference to the parent widget 22 | @type QWidget 23 | """ 24 | super(QCTP, self).__init__(parent) 25 | self.setupUi(self) 26 | 27 | @pyqtSlot(int) 28 | def on_tab_accounts_currentChanged(self, index): 29 | """ 30 | Slot documentation goes here. 31 | 32 | @param index DESCRIPTION 33 | @type int 34 | """ 35 | # TODO: not implemented yet 36 | raise NotImplementedError 37 | 38 | @pyqtSlot(int) 39 | def on_tab_records_currentChanged(self, index): 40 | """ 41 | Slot documentation goes here. 42 | 43 | @param index DESCRIPTION 44 | @type int 45 | """ 46 | # TODO: not implemented yet 47 | raise NotImplementedError 48 | -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientUI/QCTP.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 1425 10 | 900 11 | 12 | 13 | 14 | 15 | 0 16 | 0 17 | 18 | 19 | 20 | Qt::DefaultContextMenu 21 | 22 | 23 | 小蜜蜂套利交易系统 24 | 25 | 26 | 27 | :/image/bee.ico:/image/bee.ico 28 | 29 | 30 | 31 | 32 | 0 33 | 0 34 | 35 | 36 | 37 | 38 | 5 39 | 40 | 41 | 5 42 | 43 | 44 | 45 | 46 | 47 | 0 48 | 0 49 | 50 | 51 | 52 | Qt::Vertical 53 | 54 | 55 | 2 56 | 57 | 58 | false 59 | 60 | 61 | 62 | 63 | 0 64 | 0 65 | 66 | 67 | 68 | 69 | 0 70 | 510 71 | 72 | 73 | 74 | 75 | 76 | 77 | 0 78 | 0 79 | 80 | 81 | 82 | 83 | 0 84 | 330 85 | 86 | 87 | 88 | -1 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 0 99 | 0 100 | 1425 101 | 26 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 | toolBar 139 | 140 | 141 | TopToolBarArea 142 | 143 | 144 | false 145 | 146 | 147 | 148 | 149 | 150 | QAccountWidget 151 | QWidget 152 |
qaccountwidget.h
153 | 1 154 |
155 |
156 | 157 | 158 | 159 | 160 | 161 | 162 | 2 163 | 164 | 165 | 2 166 | 167 | 168 | true 169 | 170 | 171 | true 172 | 173 | 174 | true 175 | 176 | 177 |
178 | -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientUI/QLogin.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """ 4 | Module implementing QLoginForm. 5 | """ 6 | 7 | from PyQt4.QtCore import pyqtSlot 8 | from PyQt4.QtGui import QWidget 9 | from PyQt4 import QtGui 10 | 11 | from Ui_QLogin import Ui_LoginForm 12 | 13 | 14 | class QLoginForm(QWidget, Ui_LoginForm): 15 | """ 16 | Class documentation goes here. 17 | """ 18 | def __init__(self, parent=None): 19 | """ 20 | Constructor 21 | 22 | @param parent reference to the parent widget 23 | @type QWidget 24 | """ 25 | super(QLoginForm, self).__init__(parent) 26 | self.setupUi(self) 27 | 28 | @pyqtSlot() 29 | def on_pushButton_login_clicked(self): 30 | """ 31 | Slot documentation goes here. 32 | """ 33 | # TODO: not implemented yet 34 | raise NotImplementedError 35 | 36 | @pyqtSlot() 37 | def on_pushButton_cancel_clicked(self): 38 | """ 39 | Slot documentation goes here. 40 | """ 41 | # TODO: not implemented yet 42 | raise NotImplementedError 43 | 44 | @pyqtSlot(bool) 45 | def on_checkBox_isoffline_clicked(self, checked): 46 | """ 47 | Slot documentation goes here. 48 | 49 | @param checked DESCRIPTION 50 | @type bool 51 | """ 52 | # TODO: not implemented yet 53 | raise NotImplementedError 54 | 55 | @pyqtSlot(int) 56 | def on_checkBox_isoffline_stateChanged(self, p0): 57 | """ 58 | Slot documentation goes here. 59 | 60 | @param p0 DESCRIPTION 61 | @type int 62 | """ 63 | # TODO: not implemented yet 64 | raise NotImplementedError 65 | 66 | if __name__ == "__main__": 67 | import sys 68 | app = QtGui.QApplication(sys.argv) 69 | Form = QLoginForm() 70 | Form.show() 71 | sys.exit(app.exec_()) 72 | -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientUI/QMessageCenter.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """ 4 | Module implementing MessageCenter. 5 | """ 6 | 7 | from PyQt4.QtCore import pyqtSlot 8 | from PyQt4.QtGui import QWidget 9 | 10 | from .Ui_QMessageCenter import Ui_MessageForm 11 | 12 | 13 | class MessageCenter(QWidget, Ui_MessageForm): 14 | """ 15 | Class documentation goes here. 16 | """ 17 | def __init__(self, parent=None): 18 | """ 19 | Constructor 20 | 21 | @param parent reference to the parent widget 22 | @type QWidget 23 | """ 24 | super(MessageCenter, self).__init__(parent) 25 | self.setupUi(self) 26 | -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientUI/QMessageCenter.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MessageForm 4 | 5 | 6 | 7 | 0 8 | 0 9 | 1425 10 | 33 11 | 12 | 13 | 14 | MessageCenter 15 | 16 | 17 | 18 | 0 19 | 20 | 21 | 10 22 | 23 | 24 | 0 25 | 26 | 27 | 5 28 | 29 | 30 | 0 31 | 32 | 33 | 34 | 35 | SHFE:收盘 36 | 37 | 38 | 39 | 40 | 41 | 42 | Qt::Vertical 43 | 44 | 45 | 46 | 47 | 48 | 49 | 交易连接 50 | 51 | 52 | 53 | 54 | 55 | 56 | Qt::Vertical 57 | 58 | 59 | 60 | 61 | 62 | 63 | 行情连接 64 | 65 | 66 | 67 | 68 | 69 | 70 | Qt::Vertical 71 | 72 | 73 | 74 | 75 | 76 | 77 | 15:00:10 78 | 79 | 80 | 81 | 82 | 83 | 84 | Qt::Vertical 85 | 86 | 87 | 88 | 89 | 90 | 91 | 15:00:10 92 | 93 | 94 | 95 | 96 | 97 | 98 | Qt::Vertical 99 | 100 | 101 | 102 | 103 | 104 | 105 | 15:00:10 106 | 107 | 108 | 109 | 110 | 111 | 112 | Qt::Vertical 113 | 114 | 115 | 116 | 117 | 118 | 119 | 15:00:10 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientUI/QMessageTable.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Form 4 | 5 | 6 | 7 | 0 8 | 0 9 | 786 10 | 315 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 20 | true 21 | 22 | 23 | false 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 | -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientUI/QStrategySetting.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | """ 4 | Module implementing NewStrategy. 5 | """ 6 | 7 | from PyQt4.QtCore import pyqtSlot 8 | from PyQt4.QtGui import QWidget 9 | 10 | from .Ui_QStrategySetting import Ui_NewStrategy 11 | 12 | 13 | class NewStrategy(QWidget, Ui_NewStrategy): 14 | """ 15 | Class documentation goes here. 16 | """ 17 | def __init__(self, parent=None): 18 | """ 19 | Constructor 20 | 21 | @param parent reference to the parent widget 22 | @type QWidget 23 | """ 24 | super(NewStrategy, self).__init__(parent) 25 | self.setupUi(self) 26 | 27 | @pyqtSlot() 28 | def on_pushButton_cancel_clicked(self): 29 | """ 30 | Slot documentation goes here. 31 | """ 32 | # TODO: not implemented yet 33 | raise NotImplementedError 34 | 35 | @pyqtSlot() 36 | def on_pushButton_ok_clicked(self): 37 | """ 38 | Slot documentation goes here. 39 | """ 40 | # TODO: not implemented yet 41 | raise NotImplementedError 42 | -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientUI/QStrategySetting.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | NewStrategy 4 | 5 | 6 | 7 | 0 8 | 0 9 | 326 10 | 294 11 | 12 | 13 | 14 | 15 | 1 16 | 1 17 | 18 | 19 | 20 | 21 | 326 22 | 294 23 | 24 | 25 | 26 | 27 | 326 28 | 294 29 | 30 | 31 | 32 | 新建策略 33 | 34 | 35 | background-color: rgb(255, 255, 245); 36 | 37 | 38 | 39 | 40 | 40 41 | 40 42 | 117 43 | 16 44 | 45 | 46 | 47 | 期货账号 48 | 49 | 50 | 51 | 52 | 53 | 40 54 | 80 55 | 117 56 | 16 57 | 58 | 59 | 60 | 策略编号 61 | 62 | 63 | 64 | 65 | 66 | 40 67 | 120 68 | 117 69 | 16 70 | 71 | 72 | 73 | A合约代码 74 | 75 | 76 | 77 | 78 | 79 | 40 80 | 160 81 | 117 82 | 16 83 | 84 | 85 | 86 | B合约代码 87 | 88 | 89 | 90 | 91 | 92 | 160 93 | 40 94 | 117 95 | 21 96 | 97 | 98 | 99 | 100 | 101 | 102 | 160 103 | 120 104 | 117 105 | 21 106 | 107 | 108 | 109 | 110 | 111 | 112 | 160 113 | 160 114 | 117 115 | 21 116 | 117 | 118 | 119 | 120 | 121 | 122 | 167 123 | 240 124 | 110 125 | 28 126 | 127 | 128 | 129 | QPushButton{ 130 | font: 100 10pt "微软雅黑"; 131 | background-color: rgb(255, 255, 255); 132 | border: 1px solid #6D6D6D; 133 | color: rgb(0, 0, 0); 134 | } 135 | 136 | QPushButton::pressed{ 137 | background-color: rgb(109, 109, 109); 138 | color: rgb(255, 255, 255); 139 | } 140 | 141 | 142 | 取消 143 | 144 | 145 | 146 | 147 | 148 | 40 149 | 240 150 | 110 151 | 28 152 | 153 | 154 | 155 | QPushButton{ 156 | font: 100 10pt "微软雅黑"; 157 | background-color: rgb(255, 255, 255); 158 | border: 1px solid #6D6D6D; 159 | color: rgb(0, 0, 0); 160 | } 161 | 162 | QPushButton::pressed{ 163 | background-color: rgb(109, 109, 109); 164 | color: rgb(255, 255, 255); 165 | } 166 | 167 | 168 | 确定 169 | 170 | 171 | 172 | 173 | 174 | 42 175 | 192 176 | 237 177 | 37 178 | 179 | 180 | 181 | color: rgb(255, 0, 0); 182 | 183 | 184 | 185 | 186 | 187 | Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter 188 | 189 | 190 | 191 | 192 | 193 | 160 194 | 80 195 | 117 196 | 21 197 | 198 | 199 | 200 | 201 | 202 | comboBox_user_id 203 | lineEdit_strategy_id 204 | lineEdit_a_instrument 205 | lineEdit_b_instrument 206 | pushButton_ok 207 | pushButton_cancel 208 | 209 | 210 | 211 | 212 | -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientUI/Ui_QAlertBox.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file 'D:\CTP\PyCTP\PyCTP_Client\PyCTP_ClientUI\QAlertBox.ui' 4 | # 5 | # Created by: PyQt4 UI code generator 4.11.4 6 | # 7 | # WARNING! All changes made in this file will be lost! 8 | 9 | from PyQt4 import QtCore, QtGui 10 | 11 | try: 12 | _fromUtf8 = QtCore.QString.fromUtf8 13 | except AttributeError: 14 | def _fromUtf8(s): 15 | return s 16 | 17 | try: 18 | _encoding = QtGui.QApplication.UnicodeUTF8 19 | def _translate(context, text, disambig): 20 | return QtGui.QApplication.translate(context, text, disambig, _encoding) 21 | except AttributeError: 22 | def _translate(context, text, disambig): 23 | return QtGui.QApplication.translate(context, text, disambig) 24 | 25 | class Ui_Form(object): 26 | def setupUi(self, Form): 27 | Form.setObjectName(_fromUtf8("Form")) 28 | Form.resize(405, 177) 29 | icon = QtGui.QIcon() 30 | icon.addPixmap(QtGui.QPixmap(_fromUtf8(":/image/bee.ico")), QtGui.QIcon.Normal, QtGui.QIcon.Off) 31 | Form.setWindowIcon(icon) 32 | Form.setStyleSheet(_fromUtf8("background-color: rgb(255, 255, 245);")) 33 | self.verticalLayout_2 = QtGui.QVBoxLayout(Form) 34 | self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2")) 35 | self.verticalLayout = QtGui.QVBoxLayout() 36 | self.verticalLayout.setSpacing(2) 37 | self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) 38 | self.label = QtGui.QLabel(Form) 39 | self.label.setStyleSheet(_fromUtf8("font: 75 10pt \"微软雅黑\";")) 40 | self.label.setAlignment(QtCore.Qt.AlignCenter) 41 | self.label.setObjectName(_fromUtf8("label")) 42 | self.verticalLayout.addWidget(self.label) 43 | self.horizontalLayout = QtGui.QHBoxLayout() 44 | self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) 45 | spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) 46 | self.horizontalLayout.addItem(spacerItem) 47 | self.pushButton = QtGui.QPushButton(Form) 48 | sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Maximum) 49 | sizePolicy.setHorizontalStretch(0) 50 | sizePolicy.setVerticalStretch(0) 51 | sizePolicy.setHeightForWidth(self.pushButton.sizePolicy().hasHeightForWidth()) 52 | self.pushButton.setSizePolicy(sizePolicy) 53 | self.pushButton.setMinimumSize(QtCore.QSize(100, 30)) 54 | self.pushButton.setStyleSheet(_fromUtf8("QPushButton{\n" 55 | " font: 100 10pt \"微软雅黑\";\n" 56 | " background-color: rgb(255, 255, 255);\n" 57 | " border: 1px solid #6D6D6D;\n" 58 | " color: rgb(0, 0, 0);\n" 59 | "}\n" 60 | "\n" 61 | "QPushButton::pressed{\n" 62 | " background-color: rgb(109, 109, 109);\n" 63 | " color: rgb(255, 255, 255);\n" 64 | "}")) 65 | self.pushButton.setObjectName(_fromUtf8("pushButton")) 66 | self.horizontalLayout.addWidget(self.pushButton) 67 | spacerItem1 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) 68 | self.horizontalLayout.addItem(spacerItem1) 69 | self.verticalLayout.addLayout(self.horizontalLayout) 70 | self.verticalLayout.setStretch(0, 6) 71 | self.verticalLayout.setStretch(1, 2) 72 | self.verticalLayout_2.addLayout(self.verticalLayout) 73 | 74 | self.retranslateUi(Form) 75 | QtCore.QMetaObject.connectSlotsByName(Form) 76 | 77 | def retranslateUi(self, Form): 78 | Form.setWindowTitle(_translate("Form", "信息提示窗口", None)) 79 | self.label.setText(_translate("Form", "34", None)) 80 | self.pushButton.setText(_translate("Form", "确定", None)) 81 | 82 | import img_rc 83 | 84 | if __name__ == "__main__": 85 | import sys 86 | app = QtGui.QApplication(sys.argv) 87 | Form = QtGui.QWidget() 88 | ui = Ui_Form() 89 | ui.setupUi(Form) 90 | Form.show() 91 | sys.exit(app.exec_()) 92 | 93 | -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientUI/Ui_QCTP.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file 'D:\CTP\PyCTP\PyCTP_Client\PyCTP_ClientUI\QCTP.ui' 4 | # 5 | # Created by: PyQt4 UI code generator 4.11.4 6 | # 7 | # WARNING! All changes made in this file will be lost! 8 | 9 | from PyQt4 import QtCore, QtGui 10 | 11 | try: 12 | _fromUtf8 = QtCore.QString.fromUtf8 13 | except AttributeError: 14 | def _fromUtf8(s): 15 | return s 16 | 17 | try: 18 | _encoding = QtGui.QApplication.UnicodeUTF8 19 | def _translate(context, text, disambig): 20 | return QtGui.QApplication.translate(context, text, disambig, _encoding) 21 | except AttributeError: 22 | def _translate(context, text, disambig): 23 | return QtGui.QApplication.translate(context, text, disambig) 24 | 25 | class Ui_MainWindow(object): 26 | def setupUi(self, MainWindow): 27 | MainWindow.setObjectName(_fromUtf8("MainWindow")) 28 | MainWindow.resize(1425, 900) 29 | sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) 30 | sizePolicy.setHorizontalStretch(0) 31 | sizePolicy.setVerticalStretch(0) 32 | sizePolicy.setHeightForWidth(MainWindow.sizePolicy().hasHeightForWidth()) 33 | MainWindow.setSizePolicy(sizePolicy) 34 | MainWindow.setContextMenuPolicy(QtCore.Qt.DefaultContextMenu) 35 | icon = QtGui.QIcon() 36 | icon.addPixmap(QtGui.QPixmap(_fromUtf8(":/image/bee.ico")), QtGui.QIcon.Normal, QtGui.QIcon.Off) 37 | MainWindow.setWindowIcon(icon) 38 | self.centralWidget = QtGui.QWidget(MainWindow) 39 | sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred) 40 | sizePolicy.setHorizontalStretch(0) 41 | sizePolicy.setVerticalStretch(0) 42 | sizePolicy.setHeightForWidth(self.centralWidget.sizePolicy().hasHeightForWidth()) 43 | self.centralWidget.setSizePolicy(sizePolicy) 44 | self.centralWidget.setObjectName(_fromUtf8("centralWidget")) 45 | self.verticalLayout = QtGui.QVBoxLayout(self.centralWidget) 46 | self.verticalLayout.setMargin(5) 47 | self.verticalLayout.setSpacing(5) 48 | self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) 49 | self.splitter_mainwindow = QtGui.QSplitter(self.centralWidget) 50 | sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) 51 | sizePolicy.setHorizontalStretch(0) 52 | sizePolicy.setVerticalStretch(0) 53 | sizePolicy.setHeightForWidth(self.splitter_mainwindow.sizePolicy().hasHeightForWidth()) 54 | self.splitter_mainwindow.setSizePolicy(sizePolicy) 55 | self.splitter_mainwindow.setOrientation(QtCore.Qt.Vertical) 56 | self.splitter_mainwindow.setHandleWidth(2) 57 | self.splitter_mainwindow.setChildrenCollapsible(False) 58 | self.splitter_mainwindow.setObjectName(_fromUtf8("splitter_mainwindow")) 59 | self.widget_QAccountWidget = QAccountWidget(self.splitter_mainwindow) 60 | sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) 61 | sizePolicy.setHorizontalStretch(0) 62 | sizePolicy.setVerticalStretch(0) 63 | sizePolicy.setHeightForWidth(self.widget_QAccountWidget.sizePolicy().hasHeightForWidth()) 64 | self.widget_QAccountWidget.setSizePolicy(sizePolicy) 65 | self.widget_QAccountWidget.setObjectName(_fromUtf8("widget_QAccountWidget")) 66 | self.tab_records = QtGui.QTabWidget(self.splitter_mainwindow) 67 | sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) 68 | sizePolicy.setHorizontalStretch(0) 69 | sizePolicy.setVerticalStretch(0) 70 | sizePolicy.setHeightForWidth(self.tab_records.sizePolicy().hasHeightForWidth()) 71 | self.tab_records.setSizePolicy(sizePolicy) 72 | self.tab_records.setMinimumSize(QtCore.QSize(0, 330)) 73 | self.tab_records.setObjectName(_fromUtf8("tab_records")) 74 | self.verticalLayout.addWidget(self.splitter_mainwindow) 75 | MainWindow.setCentralWidget(self.centralWidget) 76 | self.menuBar = QtGui.QMenuBar(MainWindow) 77 | self.menuBar.setGeometry(QtCore.QRect(0, 0, 1425, 26)) 78 | self.menuBar.setObjectName(_fromUtf8("menuBar")) 79 | self.menu_file = QtGui.QMenu(self.menuBar) 80 | self.menu_file.setObjectName(_fromUtf8("menu_file")) 81 | self.menu_account = QtGui.QMenu(self.menuBar) 82 | self.menu_account.setObjectName(_fromUtf8("menu_account")) 83 | self.menu_market = QtGui.QMenu(self.menuBar) 84 | self.menu_market.setObjectName(_fromUtf8("menu_market")) 85 | self.menu_trademodel = QtGui.QMenu(self.menuBar) 86 | self.menu_trademodel.setObjectName(_fromUtf8("menu_trademodel")) 87 | self.menu_report = QtGui.QMenu(self.menuBar) 88 | self.menu_report.setObjectName(_fromUtf8("menu_report")) 89 | MainWindow.setMenuBar(self.menuBar) 90 | self.statusBar = QtGui.QStatusBar(MainWindow) 91 | self.statusBar.setObjectName(_fromUtf8("statusBar")) 92 | MainWindow.setStatusBar(self.statusBar) 93 | self.toolBar = QtGui.QToolBar(MainWindow) 94 | self.toolBar.setObjectName(_fromUtf8("toolBar")) 95 | MainWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.toolBar) 96 | self.menuBar.addAction(self.menu_file.menuAction()) 97 | self.menuBar.addAction(self.menu_account.menuAction()) 98 | self.menuBar.addAction(self.menu_market.menuAction()) 99 | self.menuBar.addAction(self.menu_trademodel.menuAction()) 100 | self.menuBar.addAction(self.menu_report.menuAction()) 101 | 102 | self.retranslateUi(MainWindow) 103 | self.tab_records.setCurrentIndex(-1) 104 | QtCore.QMetaObject.connectSlotsByName(MainWindow) 105 | 106 | def retranslateUi(self, MainWindow): 107 | MainWindow.setWindowTitle(_translate("MainWindow", "小蜜蜂套利交易系统", None)) 108 | self.menu_file.setTitle(_translate("MainWindow", "文件", None)) 109 | self.menu_account.setTitle(_translate("MainWindow", "账户", None)) 110 | self.menu_market.setTitle(_translate("MainWindow", "行情", None)) 111 | self.menu_trademodel.setTitle(_translate("MainWindow", "交易模型", None)) 112 | self.menu_report.setTitle(_translate("MainWindow", "报告", None)) 113 | self.toolBar.setWindowTitle(_translate("MainWindow", "toolBar", None)) 114 | 115 | from qaccountwidget import QAccountWidget 116 | import img_rc 117 | 118 | if __name__ == "__main__": 119 | import sys 120 | app = QtGui.QApplication(sys.argv) 121 | MainWindow = QtGui.QMainWindow() 122 | ui = Ui_MainWindow() 123 | ui.setupUi(MainWindow) 124 | MainWindow.show() 125 | sys.exit(app.exec_()) 126 | 127 | -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientUI/Ui_QMessageCenter.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file 'D:\CTP\PyCTP\PyCTP_Client\PyCTP_ClientUI\QMessageCenter.ui' 4 | # 5 | # Created by: PyQt4 UI code generator 4.11.4 6 | # 7 | # WARNING! All changes made in this file will be lost! 8 | 9 | from PyQt4 import QtCore, QtGui 10 | 11 | try: 12 | _fromUtf8 = QtCore.QString.fromUtf8 13 | except AttributeError: 14 | def _fromUtf8(s): 15 | return s 16 | 17 | try: 18 | _encoding = QtGui.QApplication.UnicodeUTF8 19 | def _translate(context, text, disambig): 20 | return QtGui.QApplication.translate(context, text, disambig, _encoding) 21 | except AttributeError: 22 | def _translate(context, text, disambig): 23 | return QtGui.QApplication.translate(context, text, disambig) 24 | 25 | class Ui_MessageForm(object): 26 | def setupUi(self, MessageForm): 27 | MessageForm.setObjectName(_fromUtf8("MessageForm")) 28 | MessageForm.resize(1425, 33) 29 | self.horizontalLayout = QtGui.QHBoxLayout(MessageForm) 30 | self.horizontalLayout.setContentsMargins(10, 0, 5, 0) 31 | self.horizontalLayout.setSpacing(0) 32 | self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) 33 | self.label_message = QtGui.QLabel(MessageForm) 34 | self.label_message.setObjectName(_fromUtf8("label_message")) 35 | self.horizontalLayout.addWidget(self.label_message) 36 | self.line = QtGui.QFrame(MessageForm) 37 | self.line.setFrameShape(QtGui.QFrame.VLine) 38 | self.line.setFrameShadow(QtGui.QFrame.Sunken) 39 | self.line.setObjectName(_fromUtf8("line")) 40 | self.horizontalLayout.addWidget(self.line) 41 | self.label_trade_connect_status = QtGui.QLabel(MessageForm) 42 | self.label_trade_connect_status.setObjectName(_fromUtf8("label_trade_connect_status")) 43 | self.horizontalLayout.addWidget(self.label_trade_connect_status) 44 | self.line_2 = QtGui.QFrame(MessageForm) 45 | self.line_2.setFrameShape(QtGui.QFrame.VLine) 46 | self.line_2.setFrameShadow(QtGui.QFrame.Sunken) 47 | self.line_2.setObjectName(_fromUtf8("line_2")) 48 | self.horizontalLayout.addWidget(self.line_2) 49 | self.label_market_connect_status = QtGui.QLabel(MessageForm) 50 | self.label_market_connect_status.setObjectName(_fromUtf8("label_market_connect_status")) 51 | self.horizontalLayout.addWidget(self.label_market_connect_status) 52 | self.line_3 = QtGui.QFrame(MessageForm) 53 | self.line_3.setFrameShape(QtGui.QFrame.VLine) 54 | self.line_3.setFrameShadow(QtGui.QFrame.Sunken) 55 | self.line_3.setObjectName(_fromUtf8("line_3")) 56 | self.horizontalLayout.addWidget(self.line_3) 57 | self.label_CFFEX_time = QtGui.QLabel(MessageForm) 58 | self.label_CFFEX_time.setObjectName(_fromUtf8("label_CFFEX_time")) 59 | self.horizontalLayout.addWidget(self.label_CFFEX_time) 60 | self.line_4 = QtGui.QFrame(MessageForm) 61 | self.line_4.setFrameShape(QtGui.QFrame.VLine) 62 | self.line_4.setFrameShadow(QtGui.QFrame.Sunken) 63 | self.line_4.setObjectName(_fromUtf8("line_4")) 64 | self.horizontalLayout.addWidget(self.line_4) 65 | self.label_SHFE_time = QtGui.QLabel(MessageForm) 66 | self.label_SHFE_time.setObjectName(_fromUtf8("label_SHFE_time")) 67 | self.horizontalLayout.addWidget(self.label_SHFE_time) 68 | self.line_5 = QtGui.QFrame(MessageForm) 69 | self.line_5.setFrameShape(QtGui.QFrame.VLine) 70 | self.line_5.setFrameShadow(QtGui.QFrame.Sunken) 71 | self.line_5.setObjectName(_fromUtf8("line_5")) 72 | self.horizontalLayout.addWidget(self.line_5) 73 | self.label_CZCE_time = QtGui.QLabel(MessageForm) 74 | self.label_CZCE_time.setObjectName(_fromUtf8("label_CZCE_time")) 75 | self.horizontalLayout.addWidget(self.label_CZCE_time) 76 | self.line_6 = QtGui.QFrame(MessageForm) 77 | self.line_6.setFrameShape(QtGui.QFrame.VLine) 78 | self.line_6.setFrameShadow(QtGui.QFrame.Sunken) 79 | self.line_6.setObjectName(_fromUtf8("line_6")) 80 | self.horizontalLayout.addWidget(self.line_6) 81 | self.label_DCE_time = QtGui.QLabel(MessageForm) 82 | self.label_DCE_time.setObjectName(_fromUtf8("label_DCE_time")) 83 | self.horizontalLayout.addWidget(self.label_DCE_time) 84 | self.horizontalLayout.setStretch(0, 14) 85 | self.horizontalLayout.setStretch(1, 1) 86 | self.horizontalLayout.setStretch(2, 1) 87 | self.horizontalLayout.setStretch(3, 1) 88 | self.horizontalLayout.setStretch(4, 1) 89 | self.horizontalLayout.setStretch(5, 1) 90 | self.horizontalLayout.setStretch(6, 1) 91 | self.horizontalLayout.setStretch(7, 1) 92 | self.horizontalLayout.setStretch(8, 1) 93 | self.horizontalLayout.setStretch(9, 1) 94 | self.horizontalLayout.setStretch(10, 1) 95 | self.horizontalLayout.setStretch(11, 1) 96 | self.horizontalLayout.setStretch(12, 1) 97 | 98 | self.retranslateUi(MessageForm) 99 | QtCore.QMetaObject.connectSlotsByName(MessageForm) 100 | 101 | def retranslateUi(self, MessageForm): 102 | MessageForm.setWindowTitle(_translate("MessageForm", "MessageCenter", None)) 103 | self.label_message.setText(_translate("MessageForm", "SHFE:收盘", None)) 104 | self.label_trade_connect_status.setText(_translate("MessageForm", "交易连接", None)) 105 | self.label_market_connect_status.setText(_translate("MessageForm", "行情连接", None)) 106 | self.label_CFFEX_time.setText(_translate("MessageForm", "15:00:10", None)) 107 | self.label_SHFE_time.setText(_translate("MessageForm", "15:00:10", None)) 108 | self.label_CZCE_time.setText(_translate("MessageForm", "15:00:10", None)) 109 | self.label_DCE_time.setText(_translate("MessageForm", "15:00:10", None)) 110 | 111 | 112 | if __name__ == "__main__": 113 | import sys 114 | app = QtGui.QApplication(sys.argv) 115 | MessageForm = QtGui.QWidget() 116 | ui = Ui_MessageForm() 117 | ui.setupUi(MessageForm) 118 | MessageForm.show() 119 | sys.exit(app.exec_()) 120 | 121 | -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientUI/Ui_QMessageTable.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file 'D:\CTP\PyCTP\PyCTP_Client\PyCTP_ClientUI\QMessageTable.ui' 4 | # 5 | # Created by: PyQt4 UI code generator 4.11.4 6 | # 7 | # WARNING! All changes made in this file will be lost! 8 | 9 | from PyQt4 import QtCore, QtGui 10 | 11 | try: 12 | _fromUtf8 = QtCore.QString.fromUtf8 13 | except AttributeError: 14 | def _fromUtf8(s): 15 | return s 16 | 17 | try: 18 | _encoding = QtGui.QApplication.UnicodeUTF8 19 | def _translate(context, text, disambig): 20 | return QtGui.QApplication.translate(context, text, disambig, _encoding) 21 | except AttributeError: 22 | def _translate(context, text, disambig): 23 | return QtGui.QApplication.translate(context, text, disambig) 24 | 25 | class Ui_Form(object): 26 | def setupUi(self, Form): 27 | Form.setObjectName(_fromUtf8("Form")) 28 | Form.resize(786, 315) 29 | self.verticalLayout = QtGui.QVBoxLayout(Form) 30 | self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) 31 | self.tableWidget = QtGui.QTableWidget(Form) 32 | self.tableWidget.setObjectName(_fromUtf8("tableWidget")) 33 | self.tableWidget.setColumnCount(2) 34 | self.tableWidget.setRowCount(8) 35 | item = QtGui.QTableWidgetItem() 36 | self.tableWidget.setVerticalHeaderItem(0, item) 37 | item = QtGui.QTableWidgetItem() 38 | self.tableWidget.setVerticalHeaderItem(1, item) 39 | item = QtGui.QTableWidgetItem() 40 | self.tableWidget.setVerticalHeaderItem(2, item) 41 | item = QtGui.QTableWidgetItem() 42 | self.tableWidget.setVerticalHeaderItem(3, item) 43 | item = QtGui.QTableWidgetItem() 44 | self.tableWidget.setVerticalHeaderItem(4, item) 45 | item = QtGui.QTableWidgetItem() 46 | self.tableWidget.setVerticalHeaderItem(5, item) 47 | item = QtGui.QTableWidgetItem() 48 | self.tableWidget.setVerticalHeaderItem(6, item) 49 | item = QtGui.QTableWidgetItem() 50 | self.tableWidget.setVerticalHeaderItem(7, item) 51 | item = QtGui.QTableWidgetItem() 52 | self.tableWidget.setHorizontalHeaderItem(0, item) 53 | item = QtGui.QTableWidgetItem() 54 | self.tableWidget.setHorizontalHeaderItem(1, item) 55 | item = QtGui.QTableWidgetItem() 56 | self.tableWidget.setItem(0, 1, item) 57 | item = QtGui.QTableWidgetItem() 58 | self.tableWidget.setItem(1, 1, item) 59 | self.tableWidget.horizontalHeader().setVisible(True) 60 | self.tableWidget.verticalHeader().setVisible(False) 61 | self.verticalLayout.addWidget(self.tableWidget) 62 | 63 | self.retranslateUi(Form) 64 | QtCore.QMetaObject.connectSlotsByName(Form) 65 | 66 | def retranslateUi(self, Form): 67 | Form.setWindowTitle(_translate("Form", "Form", None)) 68 | item = self.tableWidget.verticalHeaderItem(0) 69 | item.setText(_translate("Form", "新建行", None)) 70 | item = self.tableWidget.verticalHeaderItem(1) 71 | item.setText(_translate("Form", "新建行", None)) 72 | item = self.tableWidget.verticalHeaderItem(2) 73 | item.setText(_translate("Form", "新建行", None)) 74 | item = self.tableWidget.verticalHeaderItem(3) 75 | item.setText(_translate("Form", "新建行", None)) 76 | item = self.tableWidget.verticalHeaderItem(4) 77 | item.setText(_translate("Form", "新建行", None)) 78 | item = self.tableWidget.verticalHeaderItem(5) 79 | item.setText(_translate("Form", "新建行", None)) 80 | item = self.tableWidget.verticalHeaderItem(6) 81 | item.setText(_translate("Form", "新建行", None)) 82 | item = self.tableWidget.verticalHeaderItem(7) 83 | item.setText(_translate("Form", "新建行", None)) 84 | item = self.tableWidget.horizontalHeaderItem(0) 85 | item.setText(_translate("Form", "消息类型", None)) 86 | item = self.tableWidget.horizontalHeaderItem(1) 87 | item.setText(_translate("Form", "消息内容", None)) 88 | __sortingEnabled = self.tableWidget.isSortingEnabled() 89 | self.tableWidget.setSortingEnabled(False) 90 | item = self.tableWidget.item(0, 1) 91 | item.setText(_translate("Form", "大幅度是 大幅度是 大幅度是 大幅度是 ", None)) 92 | item = self.tableWidget.item(1, 1) 93 | item.setText(_translate("Form", " ", None)) 94 | self.tableWidget.setSortingEnabled(__sortingEnabled) 95 | 96 | 97 | if __name__ == "__main__": 98 | import sys 99 | app = QtGui.QApplication(sys.argv) 100 | Form = QtGui.QWidget() 101 | ui = Ui_Form() 102 | ui.setupUi(Form) 103 | Form.show() 104 | sys.exit(app.exec_()) 105 | 106 | -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientUI/Ui_QStrategySetting.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file 'D:\CTP\PyCTP\PyCTP_Client\PyCTP_ClientUI\QStrategySetting.ui' 4 | # 5 | # Created by: PyQt4 UI code generator 4.11.4 6 | # 7 | # WARNING! All changes made in this file will be lost! 8 | 9 | from PyQt4 import QtCore, QtGui 10 | 11 | try: 12 | _fromUtf8 = QtCore.QString.fromUtf8 13 | except AttributeError: 14 | def _fromUtf8(s): 15 | return s 16 | 17 | try: 18 | _encoding = QtGui.QApplication.UnicodeUTF8 19 | def _translate(context, text, disambig): 20 | return QtGui.QApplication.translate(context, text, disambig, _encoding) 21 | except AttributeError: 22 | def _translate(context, text, disambig): 23 | return QtGui.QApplication.translate(context, text, disambig) 24 | 25 | class Ui_NewStrategy(object): 26 | def setupUi(self, NewStrategy): 27 | NewStrategy.setObjectName(_fromUtf8("NewStrategy")) 28 | NewStrategy.resize(326, 294) 29 | sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) 30 | sizePolicy.setHorizontalStretch(1) 31 | sizePolicy.setVerticalStretch(1) 32 | sizePolicy.setHeightForWidth(NewStrategy.sizePolicy().hasHeightForWidth()) 33 | NewStrategy.setSizePolicy(sizePolicy) 34 | NewStrategy.setMinimumSize(QtCore.QSize(326, 294)) 35 | NewStrategy.setMaximumSize(QtCore.QSize(326, 294)) 36 | NewStrategy.setStyleSheet(_fromUtf8("background-color: rgb(255, 255, 245);")) 37 | self.label_user_id = QtGui.QLabel(NewStrategy) 38 | self.label_user_id.setGeometry(QtCore.QRect(40, 40, 117, 16)) 39 | self.label_user_id.setObjectName(_fromUtf8("label_user_id")) 40 | self.label_strategy_id = QtGui.QLabel(NewStrategy) 41 | self.label_strategy_id.setGeometry(QtCore.QRect(40, 80, 117, 16)) 42 | self.label_strategy_id.setObjectName(_fromUtf8("label_strategy_id")) 43 | self.label_a_instrument = QtGui.QLabel(NewStrategy) 44 | self.label_a_instrument.setGeometry(QtCore.QRect(40, 120, 117, 16)) 45 | self.label_a_instrument.setObjectName(_fromUtf8("label_a_instrument")) 46 | self.label_b_instrument = QtGui.QLabel(NewStrategy) 47 | self.label_b_instrument.setGeometry(QtCore.QRect(40, 160, 117, 16)) 48 | self.label_b_instrument.setObjectName(_fromUtf8("label_b_instrument")) 49 | self.comboBox_user_id = QtGui.QComboBox(NewStrategy) 50 | self.comboBox_user_id.setGeometry(QtCore.QRect(160, 40, 117, 21)) 51 | self.comboBox_user_id.setObjectName(_fromUtf8("comboBox_user_id")) 52 | self.lineEdit_a_instrument = QtGui.QLineEdit(NewStrategy) 53 | self.lineEdit_a_instrument.setGeometry(QtCore.QRect(160, 120, 117, 21)) 54 | self.lineEdit_a_instrument.setObjectName(_fromUtf8("lineEdit_a_instrument")) 55 | self.lineEdit_b_instrument = QtGui.QLineEdit(NewStrategy) 56 | self.lineEdit_b_instrument.setGeometry(QtCore.QRect(160, 160, 117, 21)) 57 | self.lineEdit_b_instrument.setObjectName(_fromUtf8("lineEdit_b_instrument")) 58 | self.pushButton_cancel = QtGui.QPushButton(NewStrategy) 59 | self.pushButton_cancel.setGeometry(QtCore.QRect(167, 240, 110, 28)) 60 | self.pushButton_cancel.setStyleSheet(_fromUtf8("QPushButton{\n" 61 | " font: 100 10pt \"微软雅黑\";\n" 62 | " background-color: rgb(255, 255, 255);\n" 63 | " border: 1px solid #6D6D6D;\n" 64 | " color: rgb(0, 0, 0);\n" 65 | "}\n" 66 | "\n" 67 | "QPushButton::pressed{\n" 68 | " background-color: rgb(109, 109, 109);\n" 69 | " color: rgb(255, 255, 255);\n" 70 | "}")) 71 | self.pushButton_cancel.setObjectName(_fromUtf8("pushButton_cancel")) 72 | self.pushButton_ok = QtGui.QPushButton(NewStrategy) 73 | self.pushButton_ok.setGeometry(QtCore.QRect(40, 240, 110, 28)) 74 | self.pushButton_ok.setStyleSheet(_fromUtf8("QPushButton{\n" 75 | " font: 100 10pt \"微软雅黑\";\n" 76 | " background-color: rgb(255, 255, 255);\n" 77 | " border: 1px solid #6D6D6D;\n" 78 | " color: rgb(0, 0, 0);\n" 79 | "}\n" 80 | "\n" 81 | "QPushButton::pressed{\n" 82 | " background-color: rgb(109, 109, 109);\n" 83 | " color: rgb(255, 255, 255);\n" 84 | "}")) 85 | self.pushButton_ok.setObjectName(_fromUtf8("pushButton_ok")) 86 | self.label_error_msg = QtGui.QLabel(NewStrategy) 87 | self.label_error_msg.setGeometry(QtCore.QRect(42, 192, 237, 37)) 88 | self.label_error_msg.setStyleSheet(_fromUtf8("color: rgb(255, 0, 0);")) 89 | self.label_error_msg.setText(_fromUtf8("")) 90 | self.label_error_msg.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter) 91 | self.label_error_msg.setObjectName(_fromUtf8("label_error_msg")) 92 | self.lineEdit_strategy_id = QtGui.QLineEdit(NewStrategy) 93 | self.lineEdit_strategy_id.setGeometry(QtCore.QRect(160, 80, 117, 21)) 94 | self.lineEdit_strategy_id.setObjectName(_fromUtf8("lineEdit_strategy_id")) 95 | 96 | self.retranslateUi(NewStrategy) 97 | QtCore.QMetaObject.connectSlotsByName(NewStrategy) 98 | NewStrategy.setTabOrder(self.comboBox_user_id, self.lineEdit_strategy_id) 99 | NewStrategy.setTabOrder(self.lineEdit_strategy_id, self.lineEdit_a_instrument) 100 | NewStrategy.setTabOrder(self.lineEdit_a_instrument, self.lineEdit_b_instrument) 101 | NewStrategy.setTabOrder(self.lineEdit_b_instrument, self.pushButton_ok) 102 | NewStrategy.setTabOrder(self.pushButton_ok, self.pushButton_cancel) 103 | 104 | def retranslateUi(self, NewStrategy): 105 | NewStrategy.setWindowTitle(_translate("NewStrategy", "新建策略", None)) 106 | self.label_user_id.setText(_translate("NewStrategy", "期货账号", None)) 107 | self.label_strategy_id.setText(_translate("NewStrategy", "策略编号", None)) 108 | self.label_a_instrument.setText(_translate("NewStrategy", "A合约代码", None)) 109 | self.label_b_instrument.setText(_translate("NewStrategy", "B合约代码", None)) 110 | self.pushButton_cancel.setText(_translate("NewStrategy", "取消", None)) 111 | self.pushButton_ok.setText(_translate("NewStrategy", "确定", None)) 112 | 113 | 114 | if __name__ == "__main__": 115 | import sys 116 | app = QtGui.QApplication(sys.argv) 117 | NewStrategy = QtGui.QWidget() 118 | ui = Ui_NewStrategy() 119 | ui.setupUi(NewStrategy) 120 | NewStrategy.show() 121 | sys.exit(app.exec_()) 122 | 123 | -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientUI/__pycache__/Ui_QAccountWidget.cpython-34.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientUI/__pycache__/Ui_QAccountWidget.cpython-34.pyc -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientUI/__pycache__/Ui_QLogin.cpython-34.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientUI/__pycache__/Ui_QLogin.cpython-34.pyc -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientUI/_eric6project/QCTP.e4q: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientUI/image/20161209085323652_easyicon_net_48.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientUI/image/20161209085323652_easyicon_net_48.icns -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientUI/image/20161209085326120_easyicon_net_32.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientUI/image/20161209085326120_easyicon_net_32.icns -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientUI/image/20161209085329196_easyicon_net_16.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientUI/image/20161209085329196_easyicon_net_16.icns -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientUI/image/bee.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientUI/image/bee.ico -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientUI/image/bee_16px_521056_easyicon.net.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientUI/image/bee_16px_521056_easyicon.net.ico -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientUI/image/bee_16px_521056_easyicon.net.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientUI/image/bee_16px_521056_easyicon.net.png -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientUI/image/bee_24px_521056_easyicon.net.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientUI/image/bee_24px_521056_easyicon.net.ico -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientUI/image/bee_24px_521056_easyicon.net.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientUI/image/bee_24px_521056_easyicon.net.png -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientUI/image/bee_32px_521056_easyicon.net.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientUI/image/bee_32px_521056_easyicon.net.ico -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientUI/image/bee_32px_521056_easyicon.net.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientUI/image/bee_32px_521056_easyicon.net.png -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientUI/image/bee_48px_521056_easyicon.net.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientUI/image/bee_48px_521056_easyicon.net.ico -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientUI/image/bee_64px_521056_easyicon.net.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientUI/image/bee_64px_521056_easyicon.net.ico -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientUI/image/bee_64px_521056_easyicon.net.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientUI/image/bee_64px_521056_easyicon.net.png -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientUI/image/bee_72px_521056_easyicon.net.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientUI/image/bee_72px_521056_easyicon.net.ico -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientUI/image/bee_72px_521056_easyicon.net.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientUI/image/bee_72px_521056_easyicon.net.png -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientUI/image/login_bee.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientUI/image/login_bee.png -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientUI/image/rocket.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientUI/image/rocket.ico -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientUI/img.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | image/rocket.ico 4 | image/bee.ico 5 | image/login_bee.png 6 | 7 | 8 | -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientUI/login_bee.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientUI/login_bee.png -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientUI/效果图/QCTP效果图1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientUI/效果图/QCTP效果图1.png -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientUI/效果图/QCTP效果图2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientUI/效果图/QCTP效果图2.png -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientUI/效果图/QCTP效果图3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientUI/效果图/QCTP效果图3.png -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientUI/效果图/QCTP效果图4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientUI/效果图/QCTP效果图4.png -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientUI/效果图/QCTP效果图5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientUI/效果图/QCTP效果图5.png -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientUI/效果图/QCTP效果图6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientUI/效果图/QCTP效果图6.png -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientUI/效果图/QCTP效果图定稿.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientUI/效果图/QCTP效果图定稿.png -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientUI/效果图/eric6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientUI/效果图/eric6.png -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientUI/结构导图/QCTP.mmap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientUI/结构导图/QCTP.mmap -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientUI/结构导图/QTCP_Ui_QCTP.mmap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyCTP_ClientUI/结构导图/QTCP_Ui_QCTP.mmap -------------------------------------------------------------------------------- /PyCTP_Client/PyCTP_ClientUI/结构导图/~$QCTP.mmap.~$lock: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /PyCTP_Client/PyQt_Demo/360界面.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyQt_Demo/360界面.zip -------------------------------------------------------------------------------- /PyCTP_Client/PyQt_Demo/GAS_V20160904.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyQt_Demo/GAS_V20160904.zip -------------------------------------------------------------------------------- /PyCTP_Client/PyQt_Demo/QSS.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Client/PyQt_Demo/QSS.zip -------------------------------------------------------------------------------- /PyCTP_Client/README.md: -------------------------------------------------------------------------------- 1 | PyCTP 2 | ========= 3 | 上期信息技术CTP开发(Python实现) 4 | 5 | 开发环境 6 | -------- 7 | 8 | windows10 64, lang:Python3.4.3, Eric 6.1.8 9 | 开发顺序 10 | -------- 11 | 12 | PyCTP_API -> PyCTP_QT -> PyCPT_SOCKT 13 | 14 | ## 各个目录说明 15 | * PyCTP_API 16 | * 针对CTP的API库进行的API测试,分为Market(市场行情),Trader(交易) 17 | * PyCTP_Integration 18 | * 将CTP的Market、Trader集成到一起的版本,并实现多账户管理 19 | * PyCTP_QT 20 | * 在PyCTP_Integration基础上实现界面操作 21 | * PyCTP_SOCKET 22 | * 实现PyCTP与Server之间的socket通信版本 23 | 24 | ### 更新时间:2016.09.06 25 | -------------------------------------------------------------------------------- /PyCTP_Integration/CTP_API_File/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 | -------------------------------------------------------------------------------- /PyCTP_Integration/CTP_API_File/error.dtd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | -------------------------------------------------------------------------------- /PyCTP_Integration/CTP_API_File/thostmduserapi.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Integration/CTP_API_File/thostmduserapi.dll -------------------------------------------------------------------------------- /PyCTP_Integration/CTP_API_File/thostmduserapi.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Integration/CTP_API_File/thostmduserapi.lib -------------------------------------------------------------------------------- /PyCTP_Integration/CTP_API_File/thosttraderapi.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Integration/CTP_API_File/thosttraderapi.dll -------------------------------------------------------------------------------- /PyCTP_Integration/CTP_API_File/thosttraderapi.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Integration/CTP_API_File/thosttraderapi.lib -------------------------------------------------------------------------------- /PyCTP_Integration/FunctionLog.py: -------------------------------------------------------------------------------- 1 | def fun_log(fn): 2 | def wrapper(*args, **kwargs): 3 | print("Before Calling %s" %fn.__name__) 4 | retval = fn(*args, **kwargs) 5 | # print("After Calling %s" %fn.__name__) 6 | return retval 7 | return wrapper 8 | 9 | def fun_log_message(msg): 10 | print(msg) 11 | def wrapper(fn): 12 | def new_wrapper(*args, **kwargs): 13 | print ("Before Calling %s" %fn.__name__) 14 | retval = fn(*args, **kwargs) 15 | # print ("After Calling %s" %fn.__name__) 16 | return retval 17 | return new_wrapper 18 | return wrapper 19 | -------------------------------------------------------------------------------- /PyCTP_Integration/MarketManager.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Wed Jul 27 13:50 2016 4 | @author: YuWangying 5 | """ 6 | 7 | import sys 8 | import time 9 | import os 10 | import copy 11 | import threading 12 | import chardet 13 | import pandas as pd 14 | from pandas import Series, DataFrame 15 | from PyCTP_Market import PyCTP_Market_API 16 | import Utils 17 | 18 | 19 | class MarketManager: 20 | # 已经订阅行情的合约列表,类型为list,全局变量,类外可取 21 | list_instrument_subscribed = [] 22 | 23 | # 初始化时创建一个行情API连接,多账户交易系统只需要一个行情API 24 | def __init__(self, front_address, broker_id, user_id='', password=''): 25 | # 多账户系统中,只需要创建一个行情API 26 | s_tmp = (front_address[6:]).encode() 27 | n_position = s_tmp.index(b':') 28 | s_part1 = (s_tmp[:n_position]) 29 | s_part2 = (s_tmp[n_position+1:]) 30 | s_path = b'conn/md/' + s_part1 + b'_' + s_part2 + b'/' 31 | Utils.make_dirs(s_path) # 创建流文件路劲 32 | self.__market = PyCTP_Market_API.CreateFtdcMdApi(s_path) 33 | # self.__market.set_strategy(strategy) 34 | self.__broker_id = broker_id.encode() 35 | self.__front_address = front_address.encode() 36 | self.__user_id = user_id.encode() 37 | self.__password = password.encode() 38 | print('===========================') 39 | print('连接行情前置', Utils.code_transform(self.__market.Connect(self.__front_address))) 40 | print('登陆行情账号', Utils.code_transform(self.__market.Login(self.__broker_id, self.__user_id, self.__password))) 41 | # 已经订阅行情的合约列表,为每一个合约创建一个字典,键名为instrument_id,键值为list,list元素为user_id+strategy_id 42 | # [{'cu1608': ['80065801', '80067501']}, {'cu1609': ['80065801', '80067501']}] 43 | self.__list_instrument_subscribed_detail = [] 44 | 45 | # 获取__market 46 | def get_market(self): 47 | return self.__market 48 | 49 | # 订阅行情,过滤已经订阅过的行情 50 | def sub_market(self, list_instrument_id, user_id, strategy_id): 51 | list_instrument_id_to_sub = copy.deepcopy(list_instrument_id) # 保存将要订阅的合约列表 52 | # 遍历将要订阅的合约列表 53 | for instrument_id in list_instrument_id: 54 | bool_subscribed = False # 已经订阅设置为假 55 | # 遍历已经订阅的合约列表 56 | for instrument_id_subscribed in self.__list_instrument_subscribed_detail: # instrument_id_subscribed是{b'cu1609': '80065801'} 57 | # 如果在已经订阅的合约中找到需要订阅的合约,则从将要订阅的合约列表list_instrument_id_to_sub中删除 58 | if instrument_id in instrument_id_subscribed: 59 | list_instrument_id_to_sub.remove(instrument_id) 60 | bool_subscribed = True # 已经订阅设置为真 61 | # 将合约的订阅者身份(user_id+strategy_id)添加到已经订阅的合约键值下面 62 | instrument_id_subscribed[instrument_id].append(user_id+strategy_id) 63 | break 64 | # 没有订阅,则添加该订阅信息到已经订阅的合约列表 65 | if not bool_subscribed: 66 | self.__list_instrument_subscribed_detail.append({instrument_id: [user_id+strategy_id]}) 67 | 68 | print('===========================') 69 | if len(list_instrument_id_to_sub) > 0: 70 | time.sleep(1.0) 71 | print('MarketManager.sub_market()请求订阅行情', Utils.code_transform(self.__market.SubMarketData(list_instrument_id_to_sub))) 72 | MarketManager.list_instrument_subscribed.extend(list_instrument_id_to_sub) 73 | print('MarketManager.sub_market()订阅行情详情', self.__list_instrument_subscribed_detail) 74 | 75 | # 退订行情,策略退订某一合约行情的时候需考虑是否有其他账户策略正在订阅此合约的行情 76 | def un_sub_market(self, list_instrument_id, user_id, strategy_id): 77 | # list_instrument_id_to_un_sub = copy.deepcopy(list_instrument_id) # 保存将要退订的合约列表 78 | list_instrument_id_to_un_sub = [] # 保存将要退订的合约列表 79 | # 遍历将要退订的合约列表 80 | for instrument_id in list_instrument_id: 81 | # 遍历已订阅的合约列表 82 | for instrument_id_subscribed in self.__list_instrument_subscribed_detail: # instrument_id_subscribed是{b'cu1609': '80065801'} 83 | # 找到已经订阅的合约,将对应的订阅者(user_id+strategy_id)删除 84 | if not isinstance(instrument_id, bytes): 85 | instrument_id = instrument_id.encode() 86 | if instrument_id in instrument_id_subscribed: 87 | if (user_id + strategy_id) in instrument_id_subscribed[instrument_id]: 88 | pass 89 | else: 90 | print("MarketManager.un_sub_market()退订者身份错误", (user_id + strategy_id)) 91 | return False 92 | # 将合约的订阅者身份(user_id+strategy_id)从已经订阅的合约键值里删除 93 | instrument_id_subscribed[instrument_id].remove(user_id + strategy_id) 94 | # 如果订阅者为空,从已订阅列表中删除该键 95 | if len(instrument_id_subscribed[instrument_id]) == 0: 96 | self.__list_instrument_subscribed_detail.remove(instrument_id_subscribed) 97 | list_instrument_id_to_un_sub.append(instrument_id) 98 | break 99 | if len(list_instrument_id_to_un_sub) > 0: 100 | time.sleep(1.0) 101 | print('MarketManager.un_sub_market():请求退订行情', list_instrument_id_to_un_sub, Utils.code_transform(self.__market.UnSubMarketData(list_instrument_id_to_un_sub))) 102 | # MarketManager.list_instrument_subscribed.remove(list_instrument_id_to_un_sub) 103 | MarketManager.list_instrument_subscribed = list(set(MarketManager.list_instrument_subscribed) - set(list_instrument_id_to_un_sub)) 104 | print('MarketManager.sub_market()订阅行情详情', self.__list_instrument_subscribed_detail) 105 | 106 | # 登出行情账号,包含登出、断开连接、释放实例 107 | def un_connect(self): 108 | time.sleep(1.0) 109 | print('un_connect():断开行情连接', self.__market.UnConnect()) # 包含断开连接和释放实例 110 | 111 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /PyCTP_Integration/OrderAlgorithm.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Wed Jul 20 08:46:13 2016 4 | 5 | @author: YuWanying 6 | """ 7 | 8 | import os 9 | import time 10 | import DBManager 11 | 12 | 13 | class OrderAlgorithm: 14 | # 下单算法类 15 | def __init__(self, dict_arguments, user): 16 | self.__list_order_ref = None 17 | self.__execute_flag = dict_arguments['order_algorithm'] 18 | self.__user = user 19 | pass 20 | 21 | def set_execute_flag(self, execute_flag): 22 | self.__execute_flag = execute_flag 23 | 24 | def execute(self): 25 | if self.__execute_flag == '1': 26 | self.order_algorithm_one() 27 | elif self.__execute_flag == '2': 28 | self.order_algorithm_two() 29 | 30 | def order_algorithm_one(self): 31 | pass 32 | 33 | def order_algorithm_two(self): 34 | pass 35 | -------------------------------------------------------------------------------- /PyCTP_Integration/README.md: -------------------------------------------------------------------------------- 1 | PyCTP 2 | ========= 3 | 上期信息技术CTP开发(Python实现) 4 | 5 | 开发环境 6 | -------- 7 | 8 | windows10 64, lang:Python3.4.3 9 | 开发顺序 10 | -------- 11 | 12 | PyCTP_API -> PyCTP_QT -> PyCPT_SOCKT 13 | 14 | ## 各个目录说明 15 | * PyCTP_API 16 | * 针对CTP的API库进行的API测试,分为Market(市场行情),Trader(交易) 17 | * PyCTP_Integration 18 | * 将CTP的Market、Trader集成到一起的版本,并实现多账户管理 19 | * PyCTP_QT 20 | * 在PyCTP_Integration基础上实现界面操作 21 | * PyCTP_SOCKET 22 | * 实现PyCTP与Server之间的socket通信版本 23 | 24 | ### 更新时间:2016.07.21 25 | -------------------------------------------------------------------------------- /PyCTP_Integration/Trader.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on 2016年8月12日21:49:19 4 | 5 | @author: YuWanying 6 | """ 7 | 8 | 9 | from PyCTP_Trade import PyCTP_Trader_API 10 | import Utils 11 | 12 | 13 | # 交易员类 14 | class Trader: 15 | def __init__(self, dict_argument): # trader_id, trader_name, password, is_active): 16 | # print('创建Trader: operator_id=', operator_id, 'BrokerID=', BrokerID, 'user_id=', user_id) 17 | self.__trader_id = dict_argument['trader_id'] 18 | self.__trader_name = dict_argument['trader_name'] 19 | self.__password = dict_argument['password'] 20 | self.__is_active = dict_argument['is_active'] 21 | self.__list_user = list() # 保存交易员名下的期货账户列表 22 | 23 | # 获取trader_id 24 | def get_trader_id(self): 25 | return self.__trader_id 26 | 27 | # 设置交易员密码 28 | def set_password(self, password): 29 | self.__password = password 30 | 31 | # 获取交易员密码 32 | def get_password(self): 33 | return self.__password 34 | 35 | # 设置交易员活跃状态 36 | def set_is_active(self, is_active): 37 | self.__is_active = is_active 38 | 39 | # 获取交易员活跃状态 40 | def get_is_active(self): 41 | return self.__is_active 42 | 43 | # 设置交易员名称 44 | def set_trader_name(self, trader_name): 45 | self.__trader_name = trader_name 46 | 47 | # 获取交易员名称 48 | def get_trader_name(self): 49 | return self.__trader_name 50 | 51 | # 设置交易员id 52 | def set_trader_id(self, trader_id): 53 | self.__trader_id = trader_id 54 | 55 | # 获取交易员id 56 | def get_trader_id(self): 57 | return self.__trader_id 58 | 59 | -------------------------------------------------------------------------------- /PyCTP_Integration/User.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Wed Jul 20 08:46:13 2016 4 | 5 | @author: YuWanying 6 | """ 7 | 8 | 9 | from PyCTP_Trade import PyCTP_Trader_API 10 | import Utils 11 | 12 | 13 | class User: 14 | # 初始化参数BrokerID\UserID\Password\front_address,参数格式为二进制字符串 15 | def __init__(self, dict_arguments): 16 | # 形参{'trader_id': '', 'broker_id': '', 'front_address': '', 'user_id': '', 'password': '', 'trader': ''} 17 | self.__trader_id = dict_arguments['trader_id'].encode() 18 | self.__user_id = dict_arguments['user_id'].encode() 19 | self.__BrokerID = dict_arguments['broker_id'].encode() 20 | self.__Password = dict_arguments['password'].encode() 21 | self.__FrontAddress = dict_arguments['front_address'].encode() 22 | 23 | self.__list_OnRtnOrder = [] # 保存单账户所有的OnRtnOrder回调数据 24 | self.__list_OnRtnTrade = [] # 保存单账户所有的OnRtnTrade回调数据 25 | self.__list_order_ing = [] # 以OrderRef为单个交易单元,还未执行完成的订单列表,临时存放较少的数据 26 | self.__list_SendOrder = [] # 保存单账户所有调用OrderInsert的记录 27 | self.__list_strategy = [] # 期货账户下面的所有交易策略实例列表 28 | # self.__list_InstrumentId = [] # 合约列表,记录撤单次数,在创建策略的时候添加合约, 29 | self.__dict_instrument_action_counter = dict() # 记录合约撤单次数的字典,撤单操作时添加次数,交易日换日时初始化值 30 | self.__order_ref_part2 = 0 # 所有策略共用报单引用编号 31 | 32 | # 为每个user创建独立的流文件夹 33 | s_path = b'conn/td/' + self.__user_id + b'/' 34 | Utils.make_dirs(s_path) # 创建流文件路劲 35 | self.__trade = PyCTP_Trader_API.CreateFtdcTraderApi(s_path) 36 | self.__trade.set_user(self) # 将该类设置为trade的属性 37 | print('===========================') 38 | print(self.__user_id, '连接交易前置', Utils.code_transform(self.__trade.Connect(self.__FrontAddress))) 39 | print(self.__user_id, '登陆交易账号', Utils.code_transform(self.__trade.Login(self.__BrokerID, self.__user_id, self.__Password))) 40 | print(self.__user_id, '交易日', Utils.code_transform(self.__trade.GetTradingDay())) 41 | print(self.__user_id, '投资者代码', Utils.code_transform(self.__trade.setInvestorID(self.__user_id))) 42 | self.__front_id = self.__trade.get_front_id() # 获取前置编号 43 | self.__session_id = self.__trade.get_session_id() # 获取会话编号 44 | self.__instrument_info = Utils.code_transform(self.qry_instrument()) # 查询合约,所有交易所的所有合约 45 | print("User.__init__.self.__instrument_info=", self.__instrument_info) 46 | # 获取期货账号 47 | def get_user_id(self): 48 | return self.__user_id 49 | 50 | # 获取交易员id 51 | def get_trader_id(self): 52 | return self.__trader_id 53 | 54 | # 获取trade实例(TD) 55 | def get_trade(self): 56 | return self.__trade 57 | 58 | # 获取self.__instrument_info 59 | def get_instrument_info(self): 60 | return self.__instrument_info 61 | 62 | # 获取报单引用part2 63 | def add_order_ref_part2(self): 64 | self.__order_ref_part2 += 1 65 | return self.__order_ref_part2 66 | 67 | # 添加交易策略实例,到self.__list_strategy 68 | def add_strategy(self, obj_strategy): 69 | self.__list_strategy.append(obj_strategy) # 将交易策略实例添加到本类的交易策略列表 70 | self.__trade.set_list_strategy(self.__list_strategy) # 将本类的交易策略列表转发给trade 71 | obj_strategy.set_user(self) # 将user设置为strategy属性 72 | 73 | # 添加合约代码到user类的self.__dict_instrument_action_counter 74 | def add_instrument_id_action_counter(self, list_instrument_id): 75 | for i in list_instrument_id: 76 | if i not in self.__dict_instrument_action_counter: 77 | self.__dict_instrument_action_counter[i] = 0 78 | 79 | # 撤单计数 80 | def action_counter(self, instrument_id): 81 | if instrument_id in self.__dict_instrument_action_counter: 82 | self.__dict_instrument_action_counter[instrument_id] += 1 83 | 84 | # 删除交易策略实例,从self.__list_strategy 85 | def del_strategy(self, strategy_id): 86 | for i in self.__list_strategy: 87 | if i.get_strategy_id() == strategy_id: 88 | self.__list_strategy.remove(i) 89 | 90 | # 获取list_strategy 91 | def get_list_strategy(self): 92 | return self.__list_strategy 93 | 94 | # 获取合约撤单次数的字典 95 | def get_dict_instrument_action_counter(self): 96 | return self.__dict_instrument_action_counter 97 | 98 | # 查询行情 99 | def qry_depth_market_data(self, instrument_id): 100 | return self.__trade.QryDepthMarketData(instrument_id) 101 | 102 | # 查询合约 103 | def qry_instrument(self): 104 | return self.__trade.QryInstrument() 105 | 106 | # 转PyCTP_Market_API类中回调函数OnRtnOrder 107 | def OnRtnTrade(self, Trade): 108 | # print("User.OnRtnTrade()", 'OrderRef:', Trade['OrderRef'], 'Trade:', Trade) 109 | pass 110 | 111 | # 转PyCTP_Market_API类中回调函数OnRtnOrder 112 | def OnRtnOrder(self, Order): 113 | # print("User.OnRtnOrder()", 'OrderRef:', Order['OrderRef'], 'Order:', Order) 114 | pass 115 | 116 | if __name__ == '__main__': 117 | print("User.py, if __name__ == '__main__':") 118 | pass 119 | 120 | 121 | 122 | 123 | 124 | -------------------------------------------------------------------------------- /PyCTP_Integration/__pycache__/DBManager.cpython-34.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Integration/__pycache__/DBManager.cpython-34.pyc -------------------------------------------------------------------------------- /PyCTP_Integration/__pycache__/FunctionLog.cpython-34.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Integration/__pycache__/FunctionLog.cpython-34.pyc -------------------------------------------------------------------------------- /PyCTP_Integration/__pycache__/MarketManager.cpython-34.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Integration/__pycache__/MarketManager.cpython-34.pyc -------------------------------------------------------------------------------- /PyCTP_Integration/__pycache__/MultiUserTradeSys.cpython-34.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Integration/__pycache__/MultiUserTradeSys.cpython-34.pyc -------------------------------------------------------------------------------- /PyCTP_Integration/__pycache__/OrderAlgorithm.cpython-34.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Integration/__pycache__/OrderAlgorithm.cpython-34.pyc -------------------------------------------------------------------------------- /PyCTP_Integration/__pycache__/PyCTP_Market.cpython-34.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Integration/__pycache__/PyCTP_Market.cpython-34.pyc -------------------------------------------------------------------------------- /PyCTP_Integration/__pycache__/PyCTP_Trade.cpython-34.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Integration/__pycache__/PyCTP_Trade.cpython-34.pyc -------------------------------------------------------------------------------- /PyCTP_Integration/__pycache__/Strategy.cpython-34.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Integration/__pycache__/Strategy.cpython-34.pyc -------------------------------------------------------------------------------- /PyCTP_Integration/__pycache__/Trader.cpython-34.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Integration/__pycache__/Trader.cpython-34.pyc -------------------------------------------------------------------------------- /PyCTP_Integration/__pycache__/User.cpython-34.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Integration/__pycache__/User.cpython-34.pyc -------------------------------------------------------------------------------- /PyCTP_Integration/__pycache__/Utils.cpython-34.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Integration/__pycache__/Utils.cpython-34.pyc -------------------------------------------------------------------------------- /PyCTP_Integration/command.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_Integration/command.txt -------------------------------------------------------------------------------- /PyCTP_Integration/conn/md/180.168.146.187_10010/DialogRsp.con: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /PyCTP_Integration/conn/md/180.168.146.187_10010/QueryRsp.con: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /PyCTP_Integration/conn/md/180.168.146.187_10010/TradingDay.con: -------------------------------------------------------------------------------- 1 | 4X -------------------------------------------------------------------------------- /PyCTP_Integration/conn/md/180.168.146.187_10030/DialogRsp.con: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /PyCTP_Integration/conn/md/180.168.146.187_10030/QueryRsp.con: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /PyCTP_Integration/conn/md/180.168.146.187_10030/TradingDay.con: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /PyCTP_Integration/conn/md/180.168.146.187_10031/DialogRsp.con: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /PyCTP_Integration/conn/md/180.168.146.187_10031/QueryRsp.con: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /PyCTP_Integration/conn/md/180.168.146.187_10031/TradingDay.con: -------------------------------------------------------------------------------- 1 | 4S -------------------------------------------------------------------------------- /PyCTP_Integration/conn/td/058176/DialogRsp.con: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /PyCTP_Integration/conn/td/058176/Private.con: -------------------------------------------------------------------------------- 1 | 4X -------------------------------------------------------------------------------- /PyCTP_Integration/conn/td/058176/Public.con: -------------------------------------------------------------------------------- 1 | 4Xp -------------------------------------------------------------------------------- /PyCTP_Integration/conn/td/058176/QueryRsp.con: -------------------------------------------------------------------------------- 1 | w -------------------------------------------------------------------------------- /PyCTP_Integration/conn/td/058176/TradingDay.con: -------------------------------------------------------------------------------- 1 | 4X -------------------------------------------------------------------------------- /PyCTP_Integration/conn/td/063802/DialogRsp.con: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /PyCTP_Integration/conn/td/063802/Private.con: -------------------------------------------------------------------------------- 1 | 4X; -------------------------------------------------------------------------------- /PyCTP_Integration/conn/td/063802/Public.con: -------------------------------------------------------------------------------- 1 | 4Xp -------------------------------------------------------------------------------- /PyCTP_Integration/conn/td/063802/QueryRsp.con: -------------------------------------------------------------------------------- 1 | w -------------------------------------------------------------------------------- /PyCTP_Integration/conn/td/063802/TradingDay.con: -------------------------------------------------------------------------------- 1 | 4X -------------------------------------------------------------------------------- /PyCTP_Integration/data/df_qry_data.csv: -------------------------------------------------------------------------------- 1 | ,InstrumentID,time,last,volume,amount,position,ask1,bid1,asize1,bsize1,0 2 | 0,,,,,,,,,,,"{'BidVolume1': 14, 'ActionDay': b'20160728', 'AskVolume3': 0, 'OpenPrice': 81500.0, 'BidPrice3': 1.7976931348623157e+308, 'AveragePrice': 81359.16411430425, 'CurrDelta': 1.7976931348623157e+308, 'PreDelta': 0.0, 'ExchangeID': b'SHFE', 'PreSettlementPrice': 80580.0, 'InstrumentID': b'ni1609', 'LowerLimitPrice': 75740.0, 'BidVolume5': 0, 'SettlementPrice': 1.7976931348623157e+308, 'BidPrice2': 1.7976931348623157e+308, 'BidPrice1': 80480.0, 'AskVolume5': 0, 'AskPrice3': 1.7976931348623157e+308, 'Volume': 641236, 'AskPrice4': 1.7976931348623157e+308, 'PreClosePrice': 81390.0, 'UpdateTime': b'16:43:53', 'BidVolume2': 0, 'BidPrice5': 1.7976931348623157e+308, 'OpenInterest': 328764.0, 'Turnover': 52170424960.0, 'BidPrice4': 1.7976931348623157e+308, 'AskPrice2': 1.7976931348623157e+308, 'TradingDay': b'20160729', 'AskPrice1': 80490.0, 'PreOpenInterest': 343934.0, 'HighestPrice': 82000.0, 'LowestPrice': 80300.0, 'ExchangeInstID': b'ni1609', 'AskVolume1': 8, 'BidVolume3': 0, 'ClosePrice': 1.7976931348623157e+308, 'AskVolume2': 0, 'LastPrice': 80480.0, 'UpdateMillisec': 0, 'UpperLimitPrice': 85410.0, 'AskPrice5': 1.7976931348623157e+308, 'BidVolume4': 0, 'AskVolume4': 0}" 3 | 1,,,,,,,,,,,"{'BidVolume1': 14, 'ActionDay': b'20160728', 'AskVolume3': 0, 'OpenPrice': 81500.0, 'BidPrice3': 1.7976931348623157e+308, 'AveragePrice': 81359.16411430425, 'CurrDelta': 1.7976931348623157e+308, 'PreDelta': 0.0, 'ExchangeID': b'SHFE', 'PreSettlementPrice': 80580.0, 'InstrumentID': b'ni1609', 'LowerLimitPrice': 75740.0, 'BidVolume5': 0, 'SettlementPrice': 1.7976931348623157e+308, 'BidPrice2': 1.7976931348623157e+308, 'BidPrice1': 80480.0, 'AskVolume5': 0, 'AskPrice3': 1.7976931348623157e+308, 'Volume': 641236, 'AskPrice4': 1.7976931348623157e+308, 'PreClosePrice': 81390.0, 'UpdateTime': b'16:43:53', 'BidVolume2': 0, 'BidPrice5': 1.7976931348623157e+308, 'OpenInterest': 328764.0, 'Turnover': 52170424960.0, 'BidPrice4': 1.7976931348623157e+308, 'AskPrice2': 1.7976931348623157e+308, 'TradingDay': b'20160729', 'AskPrice1': 80490.0, 'PreOpenInterest': 343934.0, 'HighestPrice': 82000.0, 'LowestPrice': 80300.0, 'ExchangeInstID': b'ni1609', 'AskVolume1': 8, 'BidVolume3': 0, 'ClosePrice': 1.7976931348623157e+308, 'AskVolume2': 0, 'LastPrice': 80480.0, 'UpdateMillisec': 500, 'UpperLimitPrice': 85410.0, 'AskPrice5': 1.7976931348623157e+308, 'BidVolume4': 0, 'AskVolume4': 0}" 4 | -------------------------------------------------------------------------------- /PyCTP_Integration/data/df_tick_data.csv: -------------------------------------------------------------------------------- 1 | ,InstrumentID,time,last,volume,amount,position,ask1,bid1,asize1,bsize1 2 | 0,ni1609,2016-07-28 16:43:52.500,80480.0,641236.0,52170424960.0,328764.0,80490.0,80480.0,8.0,14.0 3 | 1,ni1609,2016-07-28 16:43:53.000,80480.0,641236.0,52170424960.0,328764.0,80490.0,80480.0,8.0,14.0 4 | 2,ni1609,2016-07-28 16:43:53.500,80480.0,641236.0,52170424960.0,328764.0,80490.0,80480.0,8.0,14.0 5 | 3,ni1609,2016-07-28 16:43:54.500,80480.0,641244.0,52171068820.0,328756.0,80490.0,80480.0,8.0,11.0 6 | 4,ni1609,2016-07-28 16:43:55.000,80490.0,641250.0,52171551760.0,328750.0,80490.0,80480.0,5.0,13.0 7 | 5,ni1609,2016-07-28 16:43:55.500,80490.0,641252.0,52171712740.0,328748.0,80490.0,80480.0,4.0,13.0 8 | 6,ni1609,2016-07-28 16:43:56.000,80500.0,641264.0,52172678660.0,328744.0,80500.0,80490.0,96.0,7.0 9 | 7,ni1609,2016-07-28 16:43:56.500,80490.0,641294.0,52175093360.0,328716.0,80490.0,80480.0,9.0,16.0 10 | 8,ni1609,2016-07-28 16:43:57.000,80490.0,641322.0,52177347120.0,328704.0,80500.0,80480.0,94.0,18.0 11 | 9,ni1609,2016-07-28 16:43:57.500,80480.0,641326.0,52177669040.0,328704.0,80500.0,80480.0,95.0,15.0 12 | 10,ni1609,2016-07-28 16:43:58.000,80480.0,641326.0,52177669040.0,328704.0,80500.0,80490.0,95.0,1.0 13 | 11,ni1609,2016-07-28 16:43:58.500,80490.0,641328.0,52177830020.0,328704.0,80490.0,80480.0,14.0,16.0 14 | 12,ni1609,2016-07-28 16:43:59.000,80490.0,641334.0,52178312960.0,328704.0,80490.0,80480.0,10.0,15.0 15 | 13,ni1609,2016-07-28 16:43:59.500,80490.0,641352.0,52179761780.0,328714.0,80500.0,80490.0,95.0,22.0 16 | 14,ni1609,2016-07-28 16:44:00.000,80480.0,641426.0,52185717740.0,328666.0,80480.0,80470.0,74.0,28.0 17 | 15,ni1609,2016-07-28 16:44:00.500,80480.0,641480.0,52190063660.0,328654.0,80480.0,80470.0,48.0,26.0 18 | 16,ni1609,2016-07-28 16:44:01.000,80480.0,641568.0,52197145900.0,328646.0,80480.0,80470.0,4.0,26.0 19 | 17,ni1609,2016-07-28 16:44:01.500,80480.0,641578.0,52197950700.0,328646.0,80490.0,80480.0,5.0,82.0 20 | 18,ni1609,2016-07-28 16:44:02.000,80480.0,641578.0,52197950700.0,328646.0,80490.0,80480.0,5.0,69.0 21 | 19,ni1609,2016-07-28 16:44:02.500,80480.0,641578.0,52197950700.0,328646.0,80490.0,80480.0,6.0,60.0 22 | 20,ni1609,2016-07-28 16:44:03.000,80480.0,641586.0,52198594540.0,328650.0,80490.0,80480.0,6.0,56.0 23 | 21,ni1609,2016-07-28 16:44:03.500,80490.0,641606.0,52200204340.0,328644.0,80500.0,80490.0,95.0,4.0 24 | 22,ni1609,2016-07-28 16:44:04.000,80500.0,641618.0,52201170260.0,328638.0,80500.0,80490.0,93.0,2.0 25 | 23,ni1609,2016-07-28 16:44:04.500,80480.0,641678.0,52205999100.0,328586.0,80490.0,80480.0,6.0,29.0 26 | 24,ni1609,2016-07-28 16:44:05.000,80490.0,641688.0,52206803960.0,328586.0,80490.0,80480.0,3.0,29.0 27 | 25,ni1609,2016-07-28 16:44:05.500,80500.0,641706.0,52208252820.0,328580.0,80500.0,80490.0,91.0,2.0 28 | 26,ni1609,2016-07-28 16:44:06.000,80490.0,641710.0,52208574780.0,328576.0,80500.0,80490.0,92.0,1.0 29 | 27,ni1609,2016-07-28 16:44:06.500,80490.0,641712.0,52208735760.0,328574.0,80490.0,80480.0,6.0,27.0 30 | 28,ni1609,2016-07-28 16:44:07.000,80480.0,641716.0,52209057700.0,328572.0,80490.0,80480.0,3.0,26.0 31 | 29,ni1609,2016-07-28 16:44:07.500,80490.0,641722.0,52209540640.0,328572.0,80500.0,80490.0,92.0,7.0 32 | 30,ni1609,2016-07-28 16:44:08.000,80490.0,641722.0,52209540640.0,328572.0,80500.0,80490.0,102.0,17.0 33 | 31,ni1609,2016-07-28 16:44:08.500,80490.0,641756.0,52212277300.0,328572.0,80490.0,80480.0,3.0,28.0 34 | 32,ni1609,2016-07-28 16:44:09.000,80490.0,641762.0,52212760240.0,328572.0,80500.0,80490.0,103.0,2.0 35 | 33,ni1609,2016-07-28 16:44:09.500,80490.0,641774.0,52213726120.0,328566.0,80500.0,80490.0,103.0,47.0 36 | 34,ni1609,2016-07-28 16:44:10.000,80500.0,641812.0,52216785120.0,328544.0,80500.0,80490.0,84.0,47.0 37 | 35,ni1609,2016-07-28 16:44:10.500,80500.0,641822.0,52217590080.0,328538.0,80500.0,80490.0,81.0,45.0 38 | 36,ni1609,2016-07-28 16:44:11.000,80500.0,641872.0,52221615080.0,328506.0,80500.0,80490.0,57.0,45.0 39 | 37,ni1609,2016-07-28 16:44:11.500,80490.0,641968.0,52229342120.0,328410.0,80490.0,80480.0,2.0,26.0 40 | 38,ni1609,2016-07-28 16:44:12.000,80500.0,641982.0,52230469080.0,328418.0,80490.0,80480.0,4.0,26.0 41 | 39,ni1609,2016-07-28 16:44:12.500,80500.0,641986.0,52230791080.0,328418.0,80490.0,80480.0,2.0,26.0 42 | 40,ni1609,2016-07-28 16:44:13.000,80500.0,641988.0,52230952080.0,328418.0,80490.0,80480.0,1.0,26.0 43 | 41,ni1609,2016-07-28 16:44:13.500,80500.0,641988.0,52230952080.0,328418.0,80490.0,80480.0,1.0,26.0 44 | 42,ni1609,2016-07-28 16:44:14.000,80490.0,641992.0,52231274020.0,328416.0,80490.0,80480.0,1.0,25.0 45 | 43,ni1609,2016-07-28 16:44:14.500,80490.0,641994.0,52231435000.0,328416.0,80500.0,80490.0,58.0,7.0 46 | 44,ni1609,2016-07-28 16:44:15.000,80490.0,642010.0,52232722840.0,328410.0,80500.0,80490.0,63.0,9.0 47 | 45,ni1609,2016-07-28 16:44:15.500,80490.0,642010.0,52232722840.0,328410.0,80500.0,80490.0,63.0,14.0 48 | 46,ni1609,2016-07-28 16:44:16.000,80500.0,642016.0,52233205840.0,328404.0,80500.0,80490.0,62.0,15.0 49 | 47,ni1609,2016-07-28 16:44:16.500,80490.0,642036.0,52234815640.0,328406.0,80500.0,80490.0,52.0,5.0 50 | -------------------------------------------------------------------------------- /PyCTP_Integration/test.py: -------------------------------------------------------------------------------- 1 | # -*-coding: utf-8 2 | 3 | 4 | class Teacher: 5 | def __init__(self, name, sex, age): 6 | self.name = name 7 | self.sex = sex 8 | self.age = age 9 | self.list_student = [] 10 | 11 | def get_name(self): 12 | return self.name 13 | 14 | def get_sex(self): 15 | return self.sex 16 | 17 | def get_age(self): 18 | return self.age 19 | 20 | def add_student(self, student): 21 | self.list_student.append(student) 22 | 23 | def get_student(self): 24 | return self.list_student 25 | 26 | 27 | class Student: 28 | def __init__(self, name, sex, age): 29 | self.name = name 30 | self.sex = sex 31 | self.age = age 32 | 33 | def get_name(self): 34 | return self.name 35 | 36 | def get_sex(self): 37 | return self.sex 38 | 39 | def get_age(self): 40 | return self.age 41 | 42 | def set_teacher(self, teacher): 43 | self.teacher = teacher 44 | 45 | def get_teacher(self): 46 | return [self.teacher.get_name(), self.teacher.get_sex(), self.teacher.get_age()] 47 | 48 | def print_info(self): 49 | print('name:', self.name, 'sex:', self.sex, 'age:', self.age) 50 | return -6 51 | 52 | 53 | class Classes: 54 | def __init__(self, teacher, student): 55 | self.teacher = teacher 56 | self.student = student 57 | 58 | def get_teacher(self): 59 | return [self.teacher.get_name(), self.teacher.get_sex(), self.teacher.get_age()] 60 | 61 | def get_student(self): 62 | return [self.student.get_name(), self.student.get_sex(), self.student.get_age()] 63 | 64 | 65 | t1 = Teacher('ypf', 'boy', 27) 66 | s1 = Student('ywy', 'boy', 29) 67 | s2 = Student('yjx', 'boy', 27) 68 | t1.add_student(s1) 69 | t1.add_student(s2) 70 | l_student = t1.get_student() 71 | for i in l_student: 72 | i.print_info() 73 | 74 | # print('t1.get_student()', t1.get_student()) 75 | # s1.set_teacher(t1) 76 | # print('s1.get_teacher()', s1.get_teacher()) 77 | # c1 = Classes(t1, s1) 78 | # print('c1.get_teacher()', c1.get_teacher()) 79 | # print('c1.get_student()', c1.get_student()) 80 | 81 | -------------------------------------------------------------------------------- /PyCTP_Integration/test2.py: -------------------------------------------------------------------------------- 1 | # -*-coding : utf8 2 | 3 | 4 | class Car: 5 | def __init__(self, lungu): 6 | print('init class Car') 7 | self.lungu = lungu 8 | 9 | def get_lungu(self): 10 | return self.lungu 11 | 12 | 13 | class Benz(Car): 14 | def __init__(self, lungu, pailiang): 15 | Car.__init__(self, lungu=lungu) 16 | print('init class Benz') 17 | self.pailiang = pailiang 18 | 19 | def get_pailiang(self): 20 | return self.pailiang 21 | 22 | c1 = Car(4) 23 | b1 = Benz(4, 2.0) 24 | b2 = Benz(5, 3.0) 25 | print(b1.get_lungu(), b1.get_pailiang()) 26 | print(b2.get_lungu(), b2.get_pailiang()) -------------------------------------------------------------------------------- /PyCTP_SOCKT/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/PyCTP_SOCKT/README.md -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | PyCTP 2 | ========= 3 | 上期信息技术CTP开发(Python实现) 4 | 5 | 开发环境 6 | -------- 7 | 8 | windows10 64, lang:Python3.4.3 9 | 开发顺序 10 | -------- 11 | 12 | PyCTP_API -> PyCTP_QT -> PyCPT_SOCKT 13 | 14 | ## 各个目录说明 15 | * PyCTP_API 16 | * 针对CTP的API库进行的API测试,分为Market(市场行情),Trader(交易) 17 | * PyCTP_Integration 18 | * 将CTP的Market、Trader集成到一起的版本,并实现多账户管理 19 | * PyCTP_QT 20 | * 在PyCTP_Integration基础上实现界面操作 21 | * PyCTP_SOCKET 22 | * 实现PyCTP与Server之间的socket通信版本 23 | 24 | ### 更新时间:2017.06.14 25 | -------------------------------------------------------------------------------- /push.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | set d=%date:~0,10% 3 | set t=%time:~0,8% 4 | set timestamp=%d% %t% 5 | 6 | git status 7 | 8 | set /p comments=please input commit comments: 9 | 10 | git status 11 | git add . 12 | git commit -m "%timestamp% %comments%" 13 | git push origin PyCTP_Dev 14 | echo "Finished Push!" 15 | pause -------------------------------------------------------------------------------- /小蜜蜂套利系统测试文档.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yuwangying/PyCTP/dc6616bc8d2fead143b38aa8152c75f5843c71b2/小蜜蜂套利系统测试文档.xls --------------------------------------------------------------------------------