├── CallBack.h ├── CtaBase.h ├── CtaEngine.cpp ├── CtaEngine.h ├── CtaStrategyBase.cpp ├── CtaStrategyBase.h ├── CtpCommand.h ├── CtpMdApi.cpp ├── CtpMdApi.h ├── CtpTdApi.cpp ├── CtpTdApi.h ├── DataEngine.cpp ├── DataEngine.h ├── EventBase.h ├── EventEngine.cpp ├── EventEngine.h ├── GLogWrapper.cpp ├── GLogWrapper.h ├── MainEngine.cpp ├── MainEngine.h ├── MainTrade.sln ├── MainTrade.vcxproj ├── MainTrade.vcxproj.filters ├── MainTrade.vcxproj.user ├── Model ├── PositionBuffer.h └── PublicStruct.h ├── MySQLApi.cpp ├── MySQLApi.h ├── README.md ├── StrategyAtrRsi.cpp ├── StrategyAtrRsi.h ├── TableView ├── tableView_Account.cpp ├── tableView_Account.h ├── tableView_InstrumentInfo.cpp ├── tableView_InstrumentInfo.h ├── tableView_Order.cpp ├── tableView_Order.h ├── tableView_Position.cpp ├── tableView_Position.h ├── tableView_Quote.cpp └── tableView_Quote.h ├── TechIndicator.cpp ├── TechIndicator.h ├── Win32 └── Debug │ ├── thostmduserapi.dll │ └── thosttraderapi.dll ├── conn_file ├── 011800 │ └── td │ │ ├── DialogRsp.con │ │ ├── Private.con │ │ ├── Public.con │ │ ├── QueryRsp.con │ │ └── TradingDay.con ├── 057131 │ └── td │ │ ├── DialogRsp.con │ │ ├── Private.con │ │ ├── Public.con │ │ ├── QueryRsp.con │ │ └── TradingDay.con └── md │ ├── DialogRsp.con │ ├── QueryRsp.con │ └── TradingDay.con ├── cpp_basictool ├── CppQueue.hpp └── CppThread.hpp ├── ctpapi ├── ThostFtdcMdApi.h ├── ThostFtdcTraderApi.h ├── ThostFtdcUserApiDataType.h ├── ThostFtdcUserApiStruct.h ├── error.dtd ├── error.xml ├── md5.txt ├── thostmduserapi.dll ├── thostmduserapi.lib ├── thosttraderapi.dll └── thosttraderapi.lib ├── glog ├── include │ ├── log_severity.h │ ├── logging.h │ ├── raw_logging.h │ ├── stl_logging.h │ └── vlog_is_on.h └── lib │ ├── Debug │ ├── libglog.dll │ ├── libglog.lib │ └── libglog_static.lib │ └── Release │ ├── libglog.dll │ ├── libglog.lib │ └── libglog_static.lib ├── main.cpp ├── maintrade.cpp ├── maintrade.h ├── maintrade.qrc ├── maintrade.ui ├── mysql ├── include │ ├── complement.txt │ ├── my_alloc.h │ ├── my_list.h │ ├── mysql.h │ ├── mysql_com.h │ ├── mysql_time.h │ ├── mysql_version.h │ └── typelib.h └── lib │ ├── libmysql.lib │ └── mysqlclient.lib ├── qt_basictool ├── CompleteLineEdit.cpp └── CompleteLineEdit.h ├── talib ├── include │ ├── Makefile.am │ ├── ta_abstract.h │ ├── ta_common.h │ ├── ta_defs.h │ ├── ta_func.h │ └── ta_libc.h └── lib │ ├── HOLDER │ ├── about_lib.png │ ├── others.zip │ ├── ta_abstract_cdr.lib │ ├── ta_common_cdr.lib │ ├── ta_func_cdr.lib │ └── ta_libc_cdr.lib └── vnpy_V1.png /CallBack.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "EventBase.h" 7 | 8 | class slotbase 9 | { 10 | public: 11 | virtual void Execute(Event ev) = 0; 12 | }; 13 | 14 | template 15 | class slotimpl : public slotbase 16 | { 17 | public: 18 | using member_function = void (T::*)(Event); 19 | 20 | slotimpl(T* pObj, member_function pMemberFunc) 21 | { 22 | m_pObj = pObj; 23 | m_pMemberFunc = pMemberFunc; 24 | } 25 | 26 | inline void Execute(Event ev) override 27 | { 28 | (m_pObj->*m_pMemberFunc)(ev); 29 | } 30 | 31 | private: 32 | T* m_pObj; 33 | member_function m_pMemberFunc; 34 | }; 35 | 36 | class CallBack 37 | { 38 | public: 39 | template 40 | CallBack(T* pObj, void (T::*pMemberFunc)(Event)) 41 | { 42 | m_pSlotbase = new slotimpl(pObj, pMemberFunc); 43 | } 44 | ~CallBack() 45 | { 46 | delete m_pSlotbase; 47 | } 48 | 49 | inline void Execute(Event ev) 50 | { 51 | m_pSlotbase->Execute(ev); 52 | } 53 | 54 | private: 55 | slotbase* m_pSlotbase; 56 | }; -------------------------------------------------------------------------------- /CtaBase.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/CtaBase.h -------------------------------------------------------------------------------- /CtaEngine.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/CtaEngine.cpp -------------------------------------------------------------------------------- /CtaEngine.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/CtaEngine.h -------------------------------------------------------------------------------- /CtaStrategyBase.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/CtaStrategyBase.cpp -------------------------------------------------------------------------------- /CtaStrategyBase.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/CtaStrategyBase.h -------------------------------------------------------------------------------- /CtpCommand.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/CtpCommand.h -------------------------------------------------------------------------------- /CtpMdApi.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/CtpMdApi.cpp -------------------------------------------------------------------------------- /CtpMdApi.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/CtpMdApi.h -------------------------------------------------------------------------------- /CtpTdApi.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/CtpTdApi.cpp -------------------------------------------------------------------------------- /CtpTdApi.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/CtpTdApi.h -------------------------------------------------------------------------------- /DataEngine.cpp: -------------------------------------------------------------------------------- 1 | #include "DataEngine.h" 2 | 3 | bool DataEngine::de_get_contract(QString vtSymbol, InstrumentInfo& contract) 4 | { 5 | if (allInstruments.find(vtSymbol) != allInstruments.end()) 6 | { 7 | contract = allInstruments[vtSymbol]; 8 | return true; 9 | } 10 | else 11 | { 12 | return false; 13 | } 14 | } 15 | 16 | bool DataEngine::de_get_order(QString ordID, OrderInfo& ordInfo) 17 | { 18 | if (allOrderDict.find(ordID) != allOrderDict.end()) 19 | { 20 | ordInfo = allOrderDict[ordID]; 21 | return true; 22 | } 23 | else 24 | { 25 | return false; 26 | } 27 | } -------------------------------------------------------------------------------- /DataEngine.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/DataEngine.h -------------------------------------------------------------------------------- /EventBase.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/EventBase.h -------------------------------------------------------------------------------- /EventEngine.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/EventEngine.cpp -------------------------------------------------------------------------------- /EventEngine.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/EventEngine.h -------------------------------------------------------------------------------- /GLogWrapper.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/GLogWrapper.cpp -------------------------------------------------------------------------------- /GLogWrapper.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/GLogWrapper.h -------------------------------------------------------------------------------- /MainEngine.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/MainEngine.cpp -------------------------------------------------------------------------------- /MainEngine.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/MainEngine.h -------------------------------------------------------------------------------- /MainTrade.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.30501.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MainTrade", "MainTrade.vcxproj", "{BEF3A7F8-7D5D-4C80-9FFF-C1DC964C2C87}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Win32 = Debug|Win32 11 | Release|Win32 = Release|Win32 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {BEF3A7F8-7D5D-4C80-9FFF-C1DC964C2C87}.Debug|Win32.ActiveCfg = Debug|Win32 15 | {BEF3A7F8-7D5D-4C80-9FFF-C1DC964C2C87}.Debug|Win32.Build.0 = Debug|Win32 16 | {BEF3A7F8-7D5D-4C80-9FFF-C1DC964C2C87}.Release|Win32.ActiveCfg = Release|Win32 17 | {BEF3A7F8-7D5D-4C80-9FFF-C1DC964C2C87}.Release|Win32.Build.0 = Release|Win32 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /MainTrade.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;cxx;c;def 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h 11 | 12 | 13 | {99349809-55BA-4b9d-BF79-8FDBB0286EB3} 14 | ui 15 | 16 | 17 | {D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E} 18 | qrc;* 19 | false 20 | 21 | 22 | {71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11} 23 | moc;h;cpp 24 | False 25 | 26 | 27 | {14dd6481-0bb8-485c-99ff-adeefb0d4874} 28 | cpp;moc 29 | False 30 | 31 | 32 | {c8d81019-dae3-4d8c-9a45-41164274dd0d} 33 | cpp;moc 34 | False 35 | 36 | 37 | {dc03e90c-e14c-4efc-bdb8-3eb58110557d} 38 | 39 | 40 | {bb8dc0b1-0aa0-415d-9791-9ad9de8aa55d} 41 | 42 | 43 | 44 | 45 | Source Files 46 | 47 | 48 | Source Files 49 | 50 | 51 | Generated Files\Debug 52 | 53 | 54 | Generated Files\Release 55 | 56 | 57 | Generated Files 58 | 59 | 60 | Generated Files\Debug 61 | 62 | 63 | Generated Files\Release 64 | 65 | 66 | Source Files 67 | 68 | 69 | Generated Files\Debug 70 | 71 | 72 | Generated Files\Release 73 | 74 | 75 | Source Files 76 | 77 | 78 | Source Files 79 | 80 | 81 | Source Files 82 | 83 | 84 | Generated Files\Debug 85 | 86 | 87 | Generated Files\Release 88 | 89 | 90 | Generated Files\Debug 91 | 92 | 93 | Generated Files\Release 94 | 95 | 96 | TableView 97 | 98 | 99 | Generated Files\Debug 100 | 101 | 102 | Generated Files\Release 103 | 104 | 105 | TableView 106 | 107 | 108 | Generated Files\Debug 109 | 110 | 111 | Generated Files\Release 112 | 113 | 114 | TableView 115 | 116 | 117 | Generated Files\Debug 118 | 119 | 120 | Generated Files\Release 121 | 122 | 123 | TableView 124 | 125 | 126 | Generated Files\Debug 127 | 128 | 129 | Generated Files\Release 130 | 131 | 132 | Generated Files\Debug 133 | 134 | 135 | Generated Files\Release 136 | 137 | 138 | TableView 139 | 140 | 141 | TableView 142 | 143 | 144 | Generated Files\Debug 145 | 146 | 147 | Generated Files\Release 148 | 149 | 150 | Source Files 151 | 152 | 153 | Source Files 154 | 155 | 156 | Source Files 157 | 158 | 159 | Source Files 160 | 161 | 162 | Source Files 163 | 164 | 165 | Source Files 166 | 167 | 168 | Source Files 169 | 170 | 171 | 172 | 173 | Header Files 174 | 175 | 176 | Form Files 177 | 178 | 179 | Resource Files 180 | 181 | 182 | Header Files 183 | 184 | 185 | Header Files 186 | 187 | 188 | Header Files 189 | 190 | 191 | Header Files 192 | 193 | 194 | TableView 195 | 196 | 197 | TableView 198 | 199 | 200 | TableView 201 | 202 | 203 | TableView 204 | 205 | 206 | TableView 207 | 208 | 209 | TableView 210 | 211 | 212 | 213 | 214 | Generated Files 215 | 216 | 217 | Header Files 218 | 219 | 220 | Header Files 221 | 222 | 223 | Model 224 | 225 | 226 | Header Files 227 | 228 | 229 | Header Files 230 | 231 | 232 | Header Files 233 | 234 | 235 | Header Files 236 | 237 | 238 | Header Files 239 | 240 | 241 | Header Files 242 | 243 | 244 | Header Files 245 | 246 | 247 | Model 248 | 249 | 250 | Header Files 251 | 252 | 253 | Header Files 254 | 255 | 256 | -------------------------------------------------------------------------------- /MainTrade.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | PATH="$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(PATH) 5 | D:\Qt\Qt5.3.2\5.3\msvc2013 6 | 7 | 8 | PATH="$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(QTDIR)\bin%3b"$(QTDIR)\bin%3b$(PATH) 9 | D:\Qt\Qt5.3.2\5.3\msvc2013 10 | 11 | -------------------------------------------------------------------------------- /Model/PositionBuffer.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/Model/PositionBuffer.h -------------------------------------------------------------------------------- /Model/PublicStruct.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/Model/PublicStruct.h -------------------------------------------------------------------------------- /MySQLApi.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/MySQLApi.cpp -------------------------------------------------------------------------------- /MySQLApi.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/MySQLApi.h -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # cppvnpy 2 | 3 | ###一. 项目初衷 4 | 1. 学习并理解vnpy; 5 | 2. 了解并掌握程序化交易的基本模块及其实现; 6 | 3. 实现传说中现在最牛逼的事件驱动编程核心本质。 7 | 8 | ###二. 项目简介 9 | 1. 该项目是github上最火爆的开源量化交易框架vnpy的cpp版本,基本实现了其核心框架,并嵌入上期CTP接口跑通所有测试并验证数据准确性,实现初步可用。 10 | 2. 该项目基于WIN7 + VS2013 Ultimate + qt-opensource-windows-x86-msvc2013-5.3.2开发,用户可借助简单界面手动交易,也可实现其策略文件或策略类,调用内置的CTA引擎实现自动化交易。 11 | 3. 该项目理论上直接可用,用户在本地下载安装VS2013和QT5.3.2,将后者配置入前者开发环境后,可直接打开MainTrade.sln文件,编辑修改代码或编译代码实现自主配置使用。 12 | 13 | ###三. 项目声明 14 | 1. vnpy社区庞大,活跃用户近2000人,同时创始人本身也从事量化交易的研究,因此,vnpy项目本身一直在改进和升级。 15 | 2. 该cppvnpy项目,基本由我一个人开发,同时我目前主要从事自然语言处理(NLP)工作,因此,cppvnpy项目目前仅开发至截止2016年9月1日前的vnpy版本。 16 | 3. 当然,由于vnpy本身的越来越强大,比如2017年的vn.rpc计划,如果有时间,我会进一步改写该部分代码。 17 | 18 | ###四. 项目致谢 19 | 1. vnpy/vnpy项目:正是借助该项目,让我实现了3点初衷,尤其是最后一点事件驱动,在我使用cpp实现之后,有了深刻理解,并在日常工作中帮助最大; 20 | 2. cppvnpy的发起人薛*果:你将工作生活中的经验和教训毫无保留的传授给我,并实现了该项目的基本框架并转交我完善并维护,它们是我一生最宝贵的财富,会让我受益终身。 21 | 22 | ###五. 联系方式 23 | 1. QQ: 49446532 24 | 2. 知乎:https://zhuanlan.zhihu.com/flyingcat 25 | -------------------------------------------------------------------------------- /StrategyAtrRsi.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/StrategyAtrRsi.cpp -------------------------------------------------------------------------------- /StrategyAtrRsi.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/StrategyAtrRsi.h -------------------------------------------------------------------------------- /TableView/tableView_Account.cpp: -------------------------------------------------------------------------------- 1 | #include "tableView_Account.h" 2 | #include 3 | #include "MainEngine.h" 4 | 5 | extern MainEngine *me; 6 | 7 | /********************TableModel********************/ 8 | 9 | TableModelAccount::TableModelAccount(QObject *parent) 10 | : QAbstractTableModel(parent) 11 | { 12 | } 13 | void TableModelAccount::setHorizontalHeaderList(QStringList horizontalHeaderList) 14 | { 15 | horizontal_header_list = horizontalHeaderList; 16 | } 17 | void TableModelAccount::setModalDatas(QList *rowlist) 18 | { 19 | data_list = rowlist; 20 | } 21 | 22 | void TableModelAccount::refrushModel() 23 | { 24 | beginResetModel(); 25 | endResetModel(); 26 | 27 | //emit updateCount(this->rowCount(QModelIndex())); 28 | } 29 | //void TableModel::setCurrencyMap(const QMap &map) 30 | //{ 31 | // currencyMap = map; 32 | // //重置模型至原始状态,告诉所有视图,他们数据都无效,强制刷新数据 33 | // //reset(); 34 | //} 35 | 36 | //返回行数 37 | int TableModelAccount::rowCount(const QModelIndex & /* parent */) const 38 | { 39 | return data_list ? data_list->size() : 0; 40 | } 41 | //返回列数 42 | int TableModelAccount::columnCount(const QModelIndex & /* parent */) const 43 | { 44 | return horizontal_header_list.size(); 45 | } 46 | 47 | //返回一个项的任意角色的值,这个项被指定为QModelIndex 48 | QVariant TableModelAccount::data(const QModelIndex &index, int role) const 49 | { 50 | if (!index.isValid()) 51 | { 52 | return QVariant(); 53 | } 54 | 55 | if (role == Qt::TextAlignmentRole) 56 | { 57 | return int(Qt::AlignCenter | Qt::AlignVCenter); 58 | } 59 | else if (role == Qt::DisplayRole) 60 | { 61 | 62 | if (index.column() == 0) 63 | { 64 | return data_list->at(index.row()).id; 65 | } 66 | if (index.column() == 1) 67 | { 68 | return data_list->at(index.row()).balance; 69 | } 70 | if (index.column() == 2) 71 | { 72 | return data_list->at(index.row()).balance; 73 | } 74 | if (index.column() == 3) 75 | { 76 | return data_list->at(index.row()).available; 77 | } 78 | if (index.column() == 4) 79 | { 80 | return data_list->at(index.row()).commission; 81 | } 82 | if (index.column() == 5) 83 | { 84 | return data_list->at(index.row()).margin; 85 | } 86 | if (index.column() == 6) 87 | { 88 | return data_list->at(index.row()).close_profit; 89 | } 90 | if (index.column() == 7) 91 | { 92 | return data_list->at(index.row()).position_profit; 93 | } 94 | if (index.column() == 8) 95 | { 96 | return data_list->at(index.row()).gatewayName; 97 | } 98 | 99 | //QString rowCurrency = currencyAt(index.row()); 100 | //QString columnCurrency = currencyAt(index.column()); 101 | 102 | //if (currencyMap.value(rowCurrency) == 0.0) 103 | // return "####"; 104 | 105 | //double amount = currencyMap.value(columnCurrency) 106 | // / currencyMap.value(rowCurrency); 107 | 108 | //return QString("%1").arg(amount, 0, 'f', 4); 109 | } 110 | return QVariant(); 111 | } 112 | //返回表头名称,(行号或列号,水平或垂直,角色) 113 | QVariant TableModelAccount::headerData(int section, Qt::Orientation orientation, int role) const 114 | { 115 | if (role == Qt::DisplayRole) 116 | { 117 | if (orientation == Qt::Horizontal) // 水平表头 118 | { 119 | return (horizontal_header_list.size() > section) ? horizontal_header_list[section] : QVariant(); 120 | } 121 | else 122 | { 123 | // return (vertical_header_list.size() > section) ? vertical_header_list[section] : QVariant(); 124 | } 125 | } 126 | 127 | return QVariant(); 128 | } 129 | //获取当前关键字 130 | //QString TableModel::currencyAt(int offset) const 131 | //{ 132 | // return (currencyMap.begin() + offset).key(); 133 | //} 134 | 135 | /********************TableView********************/ 136 | TableView_Account::TableView_Account(QWidget *parent) 137 | : QTableView(parent) 138 | { 139 | 140 | //行背景色交替改变 141 | this->setAlternatingRowColors(true); 142 | //前景色 背景色 143 | //this->setStyleSheet("QTableView{background-color: rgb(250, 250, 115);" 144 | // "alternate-background-color: rgb(141, 163, 215);}"); 145 | //整行选中的方式 146 | this->setSelectionBehavior(QAbstractItemView::SelectRows); 147 | this->horizontalHeader()->setStretchLastSection(true); 148 | this->horizontalHeader()->setHighlightSections(false); 149 | this->verticalHeader()->setVisible(false); 150 | this->setShowGrid(true); 151 | this->setEditTriggers(QAbstractItemView::NoEditTriggers); 152 | this->setSelectionMode(QAbstractItemView::ExtendedSelection); 153 | 154 | this->header << QStringLiteral("账户") << QStringLiteral("昨结") << QStringLiteral("净值") 155 | << QStringLiteral("可用") << QStringLiteral("手续费") << QStringLiteral("保证金") 156 | << QStringLiteral("平仓盈亏") << QStringLiteral("持仓盈亏") << QStringLiteral("接口"); 157 | 158 | model = new TableModelAccount(); 159 | model->setModalDatas(&grid_data_list); 160 | model->setHorizontalHeaderList(header); 161 | 162 | this->setModel(model); 163 | 164 | // 刷新用户资金信息表格 165 | me->register_event(EVENT_ACCOUNT, this, &TableView_Account::updateData); 166 | } 167 | 168 | TableView_Account::~TableView_Account(void) 169 | { 170 | //if (progressbar_delegate) { 171 | // delete progressbar_delegate; 172 | // progressbar_delegate = NULL; 173 | //} 174 | 175 | if (model) 176 | { 177 | delete model; 178 | model = NULL; 179 | } 180 | } 181 | 182 | void TableView_Account::updateData(Event ev) 183 | { 184 | initData(ev); 185 | model->refrushModel(); 186 | } 187 | 188 | void TableView_Account::initData(Event ev) 189 | { 190 | grid_data_list.clear(); 191 | 192 | AccountInfo&& account_info = me->me_getAccountInfo(); 193 | grid_data_list.append(account_info); 194 | } -------------------------------------------------------------------------------- /TableView/tableView_Account.h: -------------------------------------------------------------------------------- 1 | #ifndef TABLEVIEW_ACCOUNT_ 2 | #define TABLEVIEW_ACCOUNT_ 3 | 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include "Model/PublicStruct.h" 13 | #include "EventBase.h" 14 | 15 | /********************TableModel********************/ 16 | class TableModelAccount : public QAbstractTableModel 17 | { 18 | public: 19 | TableModelAccount(QObject *parent = 0); 20 | void setHorizontalHeaderList(QStringList horizontalHeaderList); 21 | void setModalDatas(QList *rowlist); 22 | void refrushModel(); 23 | 24 | //void setCurrencyMap(const QMap &map); 25 | int rowCount(const QModelIndex &parent) const; 26 | int columnCount(const QModelIndex &parent) const; 27 | QVariant data(const QModelIndex &index, int role) const; 28 | QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; 29 | 30 | private: 31 | //QString currencyAt(int offset) const; 32 | QStringList horizontal_header_list; 33 | //QStringList vertical_header_list; 34 | 35 | QList *data_list; 36 | //QMap currencyMap; 37 | }; 38 | 39 | // 资金账户监控模块 40 | /********************ReadOnlyTableView********************/ 41 | class TableView_Account : public QTableView 42 | { 43 | Q_OBJECT 44 | 45 | public: 46 | 47 | TableView_Account(QWidget *parent = 0); 48 | ~TableView_Account(void); 49 | 50 | public slots: 51 | //更新表格 52 | void updateData(Event ev); 53 | 54 | private: 55 | void initData(Event ev); 56 | TableModelAccount *model; 57 | QStringList header; 58 | 59 | QList grid_data_list; 60 | //ProgressBarDelegate *progressbar_delegate; 61 | //更新table 62 | QTimer *updateTimer; 63 | 64 | }; 65 | #endif // !TABLEVIEW_ACCOUNT_ -------------------------------------------------------------------------------- /TableView/tableView_InstrumentInfo.cpp: -------------------------------------------------------------------------------- 1 | #include "tableView_InstrumentInfo.h" 2 | #include 3 | #include "MainEngine.h" 4 | 5 | 6 | extern MainEngine *me; 7 | /********************TableModel********************/ 8 | 9 | TableModelInstrumentInfo::TableModelInstrumentInfo(QObject *parent) 10 | : QAbstractTableModel(parent) 11 | { 12 | } 13 | void TableModelInstrumentInfo::setHorizontalHeaderList(QStringList horizontalHeaderList) 14 | { 15 | horizontal_header_list = horizontalHeaderList; 16 | } 17 | void TableModelInstrumentInfo::setModalDatas(QList *rowlist) 18 | { 19 | data_list = rowlist; 20 | } 21 | 22 | void TableModelInstrumentInfo::refrushModel() 23 | { 24 | beginResetModel(); 25 | endResetModel(); 26 | 27 | //emit updateCount(this->rowCount(QModelIndex())); 28 | } 29 | //void TableModel::setCurrencyMap(const QMap &map) 30 | //{ 31 | // currencyMap = map; 32 | // //重置模型至原始状态,告诉所有视图,他们数据都无效,强制刷新数据 33 | // //reset(); 34 | //} 35 | 36 | //返回行数 37 | int TableModelInstrumentInfo::rowCount(const QModelIndex & /* parent */) const 38 | { 39 | return data_list ? data_list->size() : 0; 40 | } 41 | //返回列数 42 | int TableModelInstrumentInfo::columnCount(const QModelIndex & /* parent */) const 43 | { 44 | return horizontal_header_list.size(); 45 | } 46 | 47 | //返回一个项的任意角色的值,这个项被指定为QModelIndex 48 | QVariant TableModelInstrumentInfo::data(const QModelIndex &index, int role) const 49 | { 50 | if (!index.isValid()) 51 | { 52 | return QVariant(); 53 | } 54 | 55 | 56 | if (role == Qt::TextAlignmentRole) 57 | { 58 | return int(Qt::AlignCenter | Qt::AlignVCenter); 59 | } 60 | else if (role == Qt::DisplayRole) 61 | { 62 | 63 | if (index.column() == 0) 64 | { 65 | return data_list->at(index.row()).id; 66 | } 67 | if (index.column() == 1) 68 | { 69 | return data_list->at(index.row()).name; 70 | } 71 | if (index.column() == 2) 72 | { 73 | return data_list->at(index.row()).exchangeId; 74 | } 75 | if (index.column() == 3) 76 | { 77 | return data_list->at(index.row()).deadline; 78 | } 79 | if (index.column() == 4) 80 | { 81 | return data_list->at(index.row()).marginRate; 82 | } 83 | if (index.column() == 5) 84 | { 85 | return data_list->at(index.row()).multiplier; 86 | } 87 | if (index.column() == 6) 88 | { 89 | return data_list->at(index.row()).openCommission; 90 | } 91 | if (index.column() == 7) 92 | { 93 | return data_list->at(index.row()).closeCommission; 94 | } 95 | if (index.column() == 8) 96 | { 97 | return data_list->at(index.row()).closeTodayCommission; 98 | } 99 | if (index.column() == 9) 100 | { 101 | return data_list->at(index.row()).minimumUnit; 102 | } 103 | if (index.column() == 10) 104 | { 105 | return data_list->at(index.row()).tradable; 106 | } 107 | 108 | //QString rowCurrency = currencyAt(index.row()); 109 | //QString columnCurrency = currencyAt(index.column()); 110 | 111 | //if (currencyMap.value(rowCurrency) == 0.0) 112 | // return "####"; 113 | 114 | //double amount = currencyMap.value(columnCurrency) 115 | // / currencyMap.value(rowCurrency); 116 | 117 | //return QString("%1").arg(amount, 0, 'f', 4); 118 | } 119 | 120 | return QVariant(); 121 | } 122 | //返回表头名称,(行号或列号,水平或垂直,角色) 123 | QVariant TableModelInstrumentInfo::headerData(int section, Qt::Orientation orientation, int role) const 124 | { 125 | if (role == Qt::DisplayRole) 126 | { 127 | if (orientation == Qt::Horizontal) // 水平表头 128 | { 129 | return (horizontal_header_list.size() > section) ? horizontal_header_list[section] : QVariant(); 130 | } 131 | else 132 | { 133 | // return (vertical_header_list.size() > section) ? vertical_header_list[section] : QVariant(); 134 | } 135 | } 136 | 137 | return QVariant(); 138 | } 139 | //获取当前关键字 140 | //QString TableModel::currencyAt(int offset) const 141 | //{ 142 | // return (currencyMap.begin() + offset).key(); 143 | //} 144 | 145 | /********************TableView********************/ 146 | TableView_InstrumentInfo::TableView_InstrumentInfo(QWidget *parent) 147 | : QTableView(parent) 148 | { 149 | 150 | //行背景色交替改变 151 | this->setAlternatingRowColors(true); 152 | //前景色 背景色 153 | //this->setStyleSheet("QTableView{background-color: rgb(250, 250, 115);" 154 | // "alternate-background-color: rgb(141, 163, 215);}"); 155 | //整行选中的方式 156 | this->setSelectionBehavior(QAbstractItemView::SelectRows); 157 | this->horizontalHeader()->setStretchLastSection(true); 158 | this->horizontalHeader()->setHighlightSections(false); 159 | this->verticalHeader()->setVisible(false); 160 | this->setShowGrid(true); 161 | this->setEditTriggers(QAbstractItemView::NoEditTriggers); 162 | this->setSelectionMode(QAbstractItemView::ExtendedSelection); 163 | 164 | this->header << QStringLiteral("合约代码") << QStringLiteral("名称") << QStringLiteral("交易所") 165 | << QStringLiteral("最后交割日") << QStringLiteral("保证金率") << QStringLiteral("合约乘数") 166 | << QStringLiteral("开仓手续费") << QStringLiteral("平仓手续费") 167 | << QStringLiteral("平今手续费") << QStringLiteral("最小变动单位") 168 | << QStringLiteral("是否可以交易"); 169 | 170 | 171 | model = new TableModelInstrumentInfo(); 172 | model->setModalDatas(&grid_data_list); 173 | model->setHorizontalHeaderList(header); 174 | 175 | this->setModel(model); 176 | 177 | // 更新合约窗口事件 178 | me->register_event(EVENT_CONTRACT, this, &TableView_InstrumentInfo::updateData); 179 | } 180 | 181 | TableView_InstrumentInfo::~TableView_InstrumentInfo(void) 182 | { 183 | //if (progressbar_delegate) { 184 | // delete progressbar_delegate; 185 | // progressbar_delegate = NULL; 186 | //} 187 | 188 | if (model) 189 | { 190 | delete model; 191 | model = nullptr; 192 | } 193 | } 194 | void TableView_InstrumentInfo::updateData(Event ev) 195 | { 196 | initData(ev); 197 | model->refrushModel(); 198 | } 199 | void TableView_InstrumentInfo::initData(Event ev) 200 | { 201 | grid_data_list.clear(); 202 | 203 | QMap && all_contracts = me->me_getInstrumentInfo(); 204 | 205 | QMap ::iterator it; 206 | for (it = all_contracts.begin(); it != all_contracts.end(); ++it) 207 | { 208 | InstrumentInfo qm; 209 | qm.id = (it->id); 210 | qm.name = (it->name); 211 | qm.exchangeId = (it->exchangeId); 212 | qm.deadline = (it->deadline); 213 | qm.marginRate = (it->marginRate); 214 | qm.multiplier = (it->multiplier); 215 | qm.openCommission = (it->openCommission); 216 | qm.closeCommission = (it->closeCommission); 217 | qm.closeTodayCommission = (it->closeTodayCommission); 218 | qm.minimumUnit = (it->minimumUnit); 219 | qm.tradable = (it->tradable); 220 | 221 | grid_data_list.append(qm); 222 | } 223 | } -------------------------------------------------------------------------------- /TableView/tableView_InstrumentInfo.h: -------------------------------------------------------------------------------- 1 | #ifndef TABLEVIEW_INSTRUMENTINFO_ 2 | #define TABLEVIEW_INSTRUMENTINFO_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include "ctpapi/ThostFtdcMdApi.h" 12 | #include "Model/PublicStruct.h" 13 | #include "EventBase.h" 14 | 15 | 16 | /********************TableModel********************/ 17 | class TableModelInstrumentInfo : public QAbstractTableModel 18 | { 19 | public: 20 | TableModelInstrumentInfo(QObject *parent = 0); 21 | void setHorizontalHeaderList(QStringList horizontalHeaderList); 22 | void setModalDatas(QList *rowlist); 23 | void refrushModel(); 24 | 25 | //void setCurrencyMap(const QMap &map); 26 | int rowCount(const QModelIndex &parent) const; 27 | int columnCount(const QModelIndex &parent) const; 28 | QVariant data(const QModelIndex &index, int role) const; 29 | QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; 30 | 31 | private: 32 | //QString currencyAt(int offset) const; 33 | QStringList horizontal_header_list; 34 | //QStringList vertical_header_list; 35 | 36 | QList *data_list; 37 | //QMap currencyMap; 38 | }; 39 | 40 | 41 | // 合约监控模块 42 | /********************ReadOnlyTableView********************/ 43 | class TableView_InstrumentInfo : public QTableView 44 | { 45 | Q_OBJECT 46 | 47 | public: 48 | TableView_InstrumentInfo(QWidget *parent = 0); 49 | ~TableView_InstrumentInfo(void); 50 | 51 | public slots: 52 | //更新表格 53 | void updateData(Event ev); 54 | 55 | private: 56 | 57 | void initData(Event ev); 58 | TableModelInstrumentInfo *model; 59 | QStringList header; 60 | 61 | QList grid_data_list; 62 | //ProgressBarDelegate *progressbar_delegate; 63 | //更新table 64 | QTimer *updateTimer; 65 | 66 | }; 67 | #endif -------------------------------------------------------------------------------- /TableView/tableView_Order.cpp: -------------------------------------------------------------------------------- 1 | #include "tableView_Order.h" 2 | #include 3 | #include "MainEngine.h" 4 | 5 | extern MainEngine *me; 6 | /********************TableModel********************/ 7 | 8 | TableModelOrder::TableModelOrder(QObject *parent) 9 | : QAbstractTableModel(parent) 10 | { 11 | } 12 | void TableModelOrder::setHorizontalHeaderList(QStringList horizontalHeaderList) 13 | { 14 | horizontal_header_list = horizontalHeaderList; 15 | } 16 | void TableModelOrder::setModalDatas(QList *rowlist) 17 | { 18 | data_list = rowlist; 19 | } 20 | 21 | void TableModelOrder::refrushModel() 22 | { 23 | beginResetModel(); 24 | endResetModel(); 25 | 26 | //emit updateCount(this->rowCount(QModelIndex())); 27 | } 28 | //void TableModel::setCurrencyMap(const QMap &map) 29 | //{ 30 | // currencyMap = map; 31 | // //重置模型至原始状态,告诉所有视图,他们数据都无效,强制刷新数据 32 | // //reset(); 33 | //} 34 | 35 | //返回行数 36 | int TableModelOrder::rowCount(const QModelIndex & /* parent */) const 37 | { 38 | return data_list ? data_list->size() : 0; 39 | } 40 | //返回列数 41 | int TableModelOrder::columnCount(const QModelIndex & /* parent */) const 42 | { 43 | return horizontal_header_list.size(); 44 | } 45 | 46 | //返回一个项的任意角色的值,这个项被指定为QModelIndex 47 | QVariant TableModelOrder::data(const QModelIndex &index, int role) const 48 | { 49 | if (!index.isValid()) 50 | { 51 | return QVariant(); 52 | } 53 | 54 | if (role == Qt::TextAlignmentRole) 55 | { 56 | return int(Qt::AlignCenter | Qt::AlignVCenter); 57 | } 58 | else if (role == Qt::DisplayRole) 59 | { 60 | 61 | if (index.column() == 0) 62 | { 63 | return data_list->at(index.row()).orderID; 64 | } 65 | if (index.column() == 1) 66 | { 67 | return data_list->at(index.row()).symbol; 68 | } 69 | if (index.column() == 2) 70 | { 71 | return data_list->at(index.row()).symbol; 72 | } 73 | if (index.column() == 3) 74 | { 75 | return data_list->at(index.row()).direction; 76 | } 77 | if (index.column() == 4) 78 | { 79 | return data_list->at(index.row()).offset; 80 | } 81 | if (index.column() == 5) 82 | { 83 | return data_list->at(index.row()).price; 84 | } 85 | if (index.column() == 6) 86 | { 87 | return data_list->at(index.row()).totalVolume; 88 | } 89 | if (index.column() == 7) 90 | { 91 | return data_list->at(index.row()).tradeVolume; 92 | } 93 | if (index.column() == 8) 94 | { 95 | return data_list->at(index.row()).status; 96 | } 97 | if (index.column() == 9) 98 | { 99 | return data_list->at(index.row()).orderTime; 100 | } 101 | if (index.column() == 10) 102 | { 103 | return data_list->at(index.row()).cancelTime; 104 | } 105 | if (index.column() == 11) 106 | { 107 | return data_list->at(index.row()).frontID; 108 | } 109 | if (index.column() == 12) 110 | { 111 | return data_list->at(index.row()).sessionID; 112 | } 113 | if (index.column() == 13) 114 | { 115 | return data_list->at(index.row()).gatewayName; 116 | } 117 | 118 | //QString rowCurrency = currencyAt(index.row()); 119 | //QString columnCurrency = currencyAt(index.column()); 120 | 121 | //if (currencyMap.value(rowCurrency) == 0.0) 122 | // return "####"; 123 | 124 | //double amount = currencyMap.value(columnCurrency) 125 | // / currencyMap.value(rowCurrency); 126 | 127 | //return QString("%1").arg(amount, 0, 'f', 4); 128 | } 129 | return QVariant(); 130 | } 131 | //返回表头名称,(行号或列号,水平或垂直,角色) 132 | QVariant TableModelOrder::headerData(int section, Qt::Orientation orientation, int role) const 133 | { 134 | if (role == Qt::DisplayRole) 135 | { 136 | if (orientation == Qt::Horizontal) // 水平表头 137 | { 138 | return (horizontal_header_list.size() > section) ? horizontal_header_list[section] : QVariant(); 139 | } 140 | else 141 | { 142 | // return (vertical_header_list.size() > section) ? vertical_header_list[section] : QVariant(); 143 | } 144 | } 145 | 146 | return QVariant(); 147 | } 148 | //获取当前关键字 149 | //QString TableModel::currencyAt(int offset) const 150 | //{ 151 | // return (currencyMap.begin() + offset).key(); 152 | //} 153 | 154 | /********************TableView********************/ 155 | TableView_Order::TableView_Order(QWidget *parent) 156 | : QTableView(parent) 157 | { 158 | //行背景色交替改变 159 | this->setAlternatingRowColors(true); 160 | //前景色 背景色 161 | //this->setStyleSheet("QTableView{background-color: rgb(250, 250, 115);" 162 | // "alternate-background-color: rgb(141, 163, 215);}"); 163 | //整行选中的方式 164 | this->setSelectionBehavior(QAbstractItemView::SelectRows); 165 | this->horizontalHeader()->setStretchLastSection(true); 166 | this->horizontalHeader()->setHighlightSections(false); 167 | this->verticalHeader()->setVisible(false); 168 | this->setShowGrid(true); 169 | this->setEditTriggers(QAbstractItemView::NoEditTriggers); 170 | this->setSelectionMode(QAbstractItemView::ExtendedSelection); 171 | 172 | this->header << QStringLiteral("委托编号") << QStringLiteral("合约代码") << QStringLiteral("名称") 173 | << QStringLiteral("方向") << QStringLiteral("开平") << QStringLiteral("价格") 174 | << QStringLiteral("委托数量") << QStringLiteral("成交数量") << QStringLiteral("状态") 175 | << QStringLiteral("委托时间") << QStringLiteral("撤销时间") << QStringLiteral("前置编号") 176 | << QStringLiteral("会话编号") << QStringLiteral("接口"); 177 | 178 | model = new TableModelOrder(); 179 | model->setModalDatas(&grid_data_list); 180 | model->setHorizontalHeaderList(header); 181 | 182 | this->setModel(model); 183 | 184 | // 刷新用户持仓信息表格 185 | me->register_event(EVENT_ORDER, this, &TableView_Order::updateData); 186 | } 187 | 188 | TableView_Order::~TableView_Order(void) 189 | { 190 | //if (progressbar_delegate) { 191 | // delete progressbar_delegate; 192 | // progressbar_delegate = NULL; 193 | //} 194 | 195 | if (model) 196 | { 197 | delete model; 198 | model = NULL; 199 | } 200 | } 201 | void TableView_Order::updateData(Event ev) 202 | { 203 | initData(ev); 204 | model->refrushModel(); 205 | } 206 | void TableView_Order::initData(Event ev) 207 | { 208 | grid_data_list.clear(); 209 | 210 | QMap && all_order = me->me_getOrderInfo(); 211 | 212 | QMap ::iterator it; 213 | for (it = all_order.begin(); it != all_order.end(); ++it) 214 | { 215 | grid_data_list.append(*it); 216 | } 217 | } -------------------------------------------------------------------------------- /TableView/tableView_Order.h: -------------------------------------------------------------------------------- 1 | #ifndef TABLEVIEW_ORDER_ 2 | #define TABLEVIEW_ORDER_ 3 | 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include "Model/PublicStruct.h" 13 | #include "EventBase.h" 14 | 15 | /********************TableModel********************/ 16 | class TableModelOrder : public QAbstractTableModel 17 | { 18 | public: 19 | TableModelOrder(QObject *parent = 0); 20 | void setHorizontalHeaderList(QStringList horizontalHeaderList); 21 | void setModalDatas(QList *rowlist); 22 | void refrushModel(); 23 | 24 | //void setCurrencyMap(const QMap &map); 25 | int rowCount(const QModelIndex &parent) const; 26 | int columnCount(const QModelIndex &parent) const; 27 | QVariant data(const QModelIndex &index, int role) const; 28 | QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; 29 | 30 | private: 31 | //QString currencyAt(int offset) const; 32 | QStringList horizontal_header_list; 33 | //QStringList vertical_header_list; 34 | 35 | QList *data_list; 36 | //QMap currencyMap; 37 | }; 38 | 39 | // 持仓监控模块 40 | /********************ReadOnlyTableView********************/ 41 | class TableView_Order : public QTableView 42 | { 43 | Q_OBJECT 44 | 45 | public: 46 | TableView_Order(QWidget *parent = 0); 47 | ~TableView_Order(void); 48 | 49 | public slots: 50 | //更新表格 51 | void updateData(Event ev); 52 | 53 | private: 54 | 55 | void initData(Event ev); 56 | TableModelOrder *model; 57 | QStringList header; 58 | 59 | QList grid_data_list; 60 | //ProgressBarDelegate *progressbar_delegate; 61 | //更新table 62 | QTimer *updateTimer; 63 | 64 | }; 65 | #endif // !TABLEVIEW_POSITION_ -------------------------------------------------------------------------------- /TableView/tableView_Position.cpp: -------------------------------------------------------------------------------- 1 | #include "tableView_Position.h" 2 | #include 3 | #include "MainEngine.h" 4 | 5 | extern MainEngine *me; 6 | /********************TableModel********************/ 7 | 8 | TableModelPosition::TableModelPosition(QObject *parent) 9 | : QAbstractTableModel(parent) 10 | { 11 | } 12 | void TableModelPosition::setHorizontalHeaderList(QStringList horizontalHeaderList) 13 | { 14 | horizontal_header_list = horizontalHeaderList; 15 | } 16 | void TableModelPosition::setModalDatas(QList *rowlist) 17 | { 18 | data_list = rowlist; 19 | } 20 | 21 | void TableModelPosition::refrushModel() 22 | { 23 | beginResetModel(); 24 | endResetModel(); 25 | 26 | //emit updateCount(this->rowCount(QModelIndex())); 27 | } 28 | //void TableModel::setCurrencyMap(const QMap &map) 29 | //{ 30 | // currencyMap = map; 31 | // //重置模型至原始状态,告诉所有视图,他们数据都无效,强制刷新数据 32 | // //reset(); 33 | //} 34 | 35 | //返回行数 36 | int TableModelPosition::rowCount(const QModelIndex & /* parent */) const 37 | { 38 | return data_list ? data_list->size() : 0; 39 | } 40 | //返回列数 41 | int TableModelPosition::columnCount(const QModelIndex & /* parent */) const 42 | { 43 | return horizontal_header_list.size(); 44 | } 45 | 46 | //返回一个项的任意角色的值,这个项被指定为QModelIndex 47 | QVariant TableModelPosition::data(const QModelIndex &index, int role) const 48 | { 49 | if (!index.isValid()) 50 | { 51 | return QVariant(); 52 | } 53 | 54 | if (role == Qt::TextAlignmentRole) 55 | { 56 | return int(Qt::AlignCenter | Qt::AlignVCenter); 57 | } 58 | else if (role == Qt::DisplayRole) 59 | { 60 | 61 | if (index.column() == 0) 62 | { 63 | return data_list->at(index.row()).symbol; 64 | } 65 | if (index.column() == 1) 66 | { 67 | return data_list->at(index.row()).vtSymbol; 68 | } 69 | if (index.column() == 2) 70 | { 71 | return data_list->at(index.row()).directName; 72 | } 73 | if (index.column() == 3) 74 | { 75 | return data_list->at(index.row()).position; 76 | } 77 | if (index.column() == 4) 78 | { 79 | return data_list->at(index.row()).ydPosition; 80 | } 81 | if (index.column() == 5) 82 | { 83 | return data_list->at(index.row()).frozen; 84 | } 85 | if (index.column() == 6) 86 | { 87 | return data_list->at(index.row()).price; 88 | } 89 | if (index.column() == 7) 90 | { 91 | return data_list->at(index.row()).gatewayName; 92 | } 93 | 94 | //QString rowCurrency = currencyAt(index.row()); 95 | //QString columnCurrency = currencyAt(index.column()); 96 | 97 | //if (currencyMap.value(rowCurrency) == 0.0) 98 | // return "####"; 99 | 100 | //double amount = currencyMap.value(columnCurrency) 101 | // / currencyMap.value(rowCurrency); 102 | 103 | //return QString("%1").arg(amount, 0, 'f', 4); 104 | } 105 | return QVariant(); 106 | } 107 | //返回表头名称,(行号或列号,水平或垂直,角色) 108 | QVariant TableModelPosition::headerData(int section, Qt::Orientation orientation, int role) const 109 | { 110 | if (role == Qt::DisplayRole) 111 | { 112 | if (orientation == Qt::Horizontal) // 水平表头 113 | { 114 | return (horizontal_header_list.size() > section) ? horizontal_header_list[section] : QVariant(); 115 | } 116 | else 117 | { 118 | // return (vertical_header_list.size() > section) ? vertical_header_list[section] : QVariant(); 119 | } 120 | } 121 | 122 | return QVariant(); 123 | } 124 | //获取当前关键字 125 | //QString TableModel::currencyAt(int offset) const 126 | //{ 127 | // return (currencyMap.begin() + offset).key(); 128 | //} 129 | 130 | /********************TableView********************/ 131 | TableView_Position::TableView_Position(QWidget *parent) 132 | : QTableView(parent) 133 | { 134 | //行背景色交替改变 135 | this->setAlternatingRowColors(true); 136 | //前景色 背景色 137 | //this->setStyleSheet("QTableView{background-color: rgb(250, 250, 115);" 138 | // "alternate-background-color: rgb(141, 163, 215);}"); 139 | //整行选中的方式 140 | this->setSelectionBehavior(QAbstractItemView::SelectRows); 141 | this->horizontalHeader()->setStretchLastSection(true); 142 | this->horizontalHeader()->setHighlightSections(false); 143 | this->verticalHeader()->setVisible(false); 144 | this->setShowGrid(true); 145 | this->setEditTriggers(QAbstractItemView::NoEditTriggers); 146 | this->setSelectionMode(QAbstractItemView::ExtendedSelection); 147 | 148 | this->header << QStringLiteral("合约代码") << QStringLiteral("名称") << QStringLiteral("方向") 149 | << QStringLiteral("持仓量") << QStringLiteral("昨持仓") << QStringLiteral("冻结量") 150 | << QStringLiteral("价格") << QStringLiteral("接口"); 151 | 152 | model = new TableModelPosition(); 153 | model->setModalDatas(&grid_data_list); 154 | model->setHorizontalHeaderList(header); 155 | 156 | this->setModel(model); 157 | 158 | // 刷新用户持仓信息表格 159 | me->register_event(EVENT_POSITION_UI, this, &TableView_Position::updateData); 160 | } 161 | 162 | TableView_Position::~TableView_Position(void) 163 | { 164 | //if (progressbar_delegate) { 165 | // delete progressbar_delegate; 166 | // progressbar_delegate = NULL; 167 | //} 168 | 169 | if (model) 170 | { 171 | delete model; 172 | model = NULL; 173 | } 174 | } 175 | void TableView_Position::updateData(Event ev) 176 | { 177 | initData(ev); 178 | model->refrushModel(); 179 | } 180 | void TableView_Position::initData(Event ev) 181 | { 182 | grid_data_list.clear(); 183 | 184 | QMap && all_position = me->me_getPositionInfo(); 185 | 186 | QMap ::iterator it; 187 | for (it = all_position.begin(); it != all_position.end(); ++it) 188 | { 189 | grid_data_list.append(*it); 190 | } 191 | } -------------------------------------------------------------------------------- /TableView/tableView_Position.h: -------------------------------------------------------------------------------- 1 | #ifndef TABLEVIEW_POSITION_ 2 | #define TABLEVIEW_POSITION_ 3 | 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include "Model/PositionBuffer.h" 13 | #include "EventBase.h" 14 | 15 | /********************TableModel********************/ 16 | class TableModelPosition : public QAbstractTableModel 17 | { 18 | public: 19 | TableModelPosition(QObject *parent = 0); 20 | void setHorizontalHeaderList(QStringList horizontalHeaderList); 21 | void setModalDatas(QList *rowlist); 22 | void refrushModel(); 23 | 24 | //void setCurrencyMap(const QMap &map); 25 | int rowCount(const QModelIndex &parent) const; 26 | int columnCount(const QModelIndex &parent) const; 27 | QVariant data(const QModelIndex &index, int role) const; 28 | QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; 29 | 30 | private: 31 | //QString currencyAt(int offset) const; 32 | QStringList horizontal_header_list; 33 | //QStringList vertical_header_list; 34 | 35 | QList *data_list; 36 | //QMap currencyMap; 37 | }; 38 | 39 | // 持仓监控模块 40 | /********************ReadOnlyTableView********************/ 41 | class TableView_Position : public QTableView 42 | { 43 | Q_OBJECT 44 | 45 | public: 46 | 47 | TableView_Position(QWidget *parent = 0); 48 | ~TableView_Position(void); 49 | 50 | public slots: 51 | //更新表格 52 | void updateData(Event ev); 53 | 54 | private: 55 | 56 | void initData(Event ev); 57 | TableModelPosition *model; 58 | QStringList header; 59 | 60 | QList grid_data_list; 61 | //ProgressBarDelegate *progressbar_delegate; 62 | //更新table 63 | QTimer *updateTimer; 64 | 65 | }; 66 | #endif // !TABLEVIEW_POSITION_ -------------------------------------------------------------------------------- /TableView/tableView_Quote.cpp: -------------------------------------------------------------------------------- 1 | #include "tableView_Quote.h" 2 | #include 3 | #include 4 | 5 | #include "MainEngine.h" 6 | 7 | extern MainEngine *me; 8 | /********************TableModel********************/ 9 | 10 | TableModelQuote::TableModelQuote(QObject *parent) 11 | : QAbstractTableModel(parent) 12 | { 13 | } 14 | void TableModelQuote::setHorizontalHeaderList(QStringList horizontalHeaderList) 15 | { 16 | horizontal_header_list = horizontalHeaderList; 17 | } 18 | void TableModelQuote::setModalDatas(QList *rowlist) 19 | { 20 | data_list = rowlist; 21 | } 22 | 23 | void TableModelQuote::refrushModel() 24 | { 25 | beginResetModel(); 26 | endResetModel(); 27 | 28 | //emit updateCount(this->rowCount(QModelIndex())); 29 | } 30 | //void TableModel::setCurrencyMap(const QMap &map) 31 | //{ 32 | // currencyMap = map; 33 | // //重置模型至原始状态,告诉所有视图,他们数据都无效,强制刷新数据 34 | // //reset(); 35 | //} 36 | 37 | //返回行数 38 | int TableModelQuote::rowCount(const QModelIndex & /* parent */) const 39 | { 40 | return data_list ? data_list->size() : 0; 41 | } 42 | //返回列数 43 | int TableModelQuote::columnCount(const QModelIndex & /* parent */) const 44 | { 45 | return horizontal_header_list.size(); 46 | } 47 | 48 | //返回一个项的任意角色的值,这个项被指定为QModelIndex 49 | QVariant TableModelQuote::data(const QModelIndex &index, int role) const 50 | { 51 | if (!index.isValid()) 52 | { 53 | return QVariant(); 54 | } 55 | 56 | if (role == Qt::TextAlignmentRole) 57 | { 58 | return int(Qt::AlignCenter | Qt::AlignVCenter); 59 | } 60 | else if (role == Qt::DisplayRole) 61 | { 62 | 63 | if (index.column() == 0) 64 | { 65 | return data_list->at(index.row()).symbol; 66 | } 67 | if (index.column() == 1) 68 | { 69 | return data_list->at(index.row()).vtSymbol; 70 | } 71 | if (index.column() == 2) 72 | { 73 | return data_list->at(index.row()).lastPrice; 74 | } 75 | if (index.column() == 3) 76 | { 77 | return data_list->at(index.row()).preClosePrice; 78 | } 79 | if (index.column() == 4) 80 | { 81 | return data_list->at(index.row()).volume; 82 | } 83 | if (index.column() == 5) 84 | { 85 | return data_list->at(index.row()).openInterest; 86 | } 87 | if (index.column() == 6) 88 | { 89 | return data_list->at(index.row()).openPrice; 90 | } 91 | if (index.column() == 7) 92 | { 93 | return data_list->at(index.row()).highPrice; 94 | } 95 | if (index.column() == 8) 96 | { 97 | return data_list->at(index.row()).lowPrice; 98 | } 99 | if (index.column() == 9) 100 | { 101 | return data_list->at(index.row()).bidPrice1; 102 | } 103 | if (index.column() == 10) 104 | { 105 | return data_list->at(index.row()).bidVolume1; 106 | } 107 | if (index.column() == 11) 108 | { 109 | return data_list->at(index.row()).askPrice1; 110 | } 111 | if (index.column() == 12) 112 | { 113 | return data_list->at(index.row()).askVolume1; 114 | } 115 | if (index.column() == 13) 116 | { 117 | return data_list->at(index.row()).time; 118 | } 119 | if (index.column() == 14) 120 | { 121 | return data_list->at(index.row()).gatewayName; 122 | } 123 | 124 | //QString rowCurrency = currencyAt(index.row()); 125 | //QString columnCurrency = currencyAt(index.column()); 126 | 127 | //if (currencyMap.value(rowCurrency) == 0.0) 128 | // return "####"; 129 | 130 | //double amount = currencyMap.value(columnCurrency) 131 | // / currencyMap.value(rowCurrency); 132 | 133 | //return QString("%1").arg(amount, 0, 'f', 4); 134 | } 135 | return QVariant(); 136 | } 137 | //返回表头名称,(行号或列号,水平或垂直,角色) 138 | QVariant TableModelQuote::headerData(int section, Qt::Orientation orientation, int role) const 139 | { 140 | if (role == Qt::DisplayRole) 141 | { 142 | if (orientation == Qt::Horizontal) // 水平表头 143 | { 144 | return (horizontal_header_list.size() > section) ? horizontal_header_list[section] : QVariant(); 145 | } 146 | else 147 | { 148 | // return (vertical_header_list.size() > section) ? vertical_header_list[section] : QVariant(); 149 | } 150 | } 151 | 152 | return QVariant(); 153 | } 154 | //获取当前关键字 155 | //QString TableModel::currencyAt(int offset) const 156 | //{ 157 | // return (currencyMap.begin() + offset).key(); 158 | //} 159 | 160 | /********************TableView********************/ 161 | TableView_Quote::TableView_Quote(QWidget *parent) 162 | : QTableView(parent) 163 | { 164 | 165 | //行背景色交替改变 166 | this->setAlternatingRowColors(true); 167 | //前景色 背景色 168 | //this->setStyleSheet("QTableView{background-color: rgb(250, 250, 115);" 169 | // "alternate-background-color: rgb(141, 163, 215);}"); 170 | //整行选中的方式 171 | this->setSelectionBehavior(QAbstractItemView::SelectRows); 172 | this->horizontalHeader()->setStretchLastSection(true); 173 | this->horizontalHeader()->setHighlightSections(false); 174 | this->verticalHeader()->setVisible(false); 175 | this->setShowGrid(true); 176 | this->setEditTriggers(QAbstractItemView::NoEditTriggers); 177 | this->setSelectionMode(QAbstractItemView::ExtendedSelection); 178 | 179 | this->header << QStringLiteral("合约代码") << QStringLiteral("名称") << QStringLiteral("最新价") 180 | << QStringLiteral("昨收盘价") << QStringLiteral("成交量") << QStringLiteral("持仓量") 181 | << QStringLiteral("开盘价") << QStringLiteral("最高价") << QStringLiteral("最低价") 182 | << QStringLiteral("买一价") << QStringLiteral("买一量") << QStringLiteral("卖一价") 183 | << QStringLiteral("卖一量") << QStringLiteral("时间") << QStringLiteral("接口"); 184 | 185 | model = new TableModelQuote(); 186 | model->setModalDatas(&grid_data_list); 187 | model->setHorizontalHeaderList(header); 188 | 189 | this->setModel(model); 190 | 191 | // MV模式中定时器自动刷新行情报价 192 | updateTimer = new QTimer(this); 193 | updateTimer->setSingleShot(false); 194 | connect(updateTimer, SIGNAL(timeout()), this, SLOT(updateData())); 195 | updateTimer->start(3000); // 页面行情报价3秒快照刷新 196 | } 197 | 198 | TableView_Quote::~TableView_Quote(void) 199 | { 200 | //if (progressbar_delegate) { 201 | // delete progressbar_delegate; 202 | // progressbar_delegate = NULL; 203 | //} 204 | 205 | if (model) 206 | { 207 | delete model; 208 | model = NULL; 209 | } 210 | } 211 | void TableView_Quote::updateData() 212 | { 213 | initData(); 214 | model->refrushModel(); 215 | } 216 | void TableView_Quote::initData() 217 | { 218 | grid_data_list.clear(); 219 | 220 | QMap && market_set = me->me_getLastMarketData(); 221 | 222 | QMap ::iterator it; 223 | for (it = market_set.begin(); it != market_set.end(); ++it) 224 | { 225 | QuoteInfo qm; 226 | qm.symbol = (it->InstrumentID); 227 | //qm.vtSymbol = (me->getInstrumentInfo()[it->InstrumentID].getName()); 228 | qm.lastPrice = (it->LastPrice); 229 | qm.preClosePrice = (it->PreClosePrice); 230 | qm.volume = (it->Volume); 231 | qm.openInterest = (it->OpenInterest); 232 | qm.openPrice = (it->OpenPrice); 233 | qm.highPrice = (it->HighestPrice); 234 | qm.lowPrice = (it->LowestPrice); 235 | qm.bidPrice1 = (it->BidPrice1); 236 | qm.bidVolume1 = (it->BidVolume1); 237 | qm.askPrice1 = (it->AskPrice1); 238 | qm.askVolume1 = (it->AskVolume1); 239 | //qm.setTime(QString(QLatin1String(it->UpdateTime) + "%1%2").arg(":").arg(QString::number(it->UpdateMillisec))); 240 | qm.time = (it->UpdateTime); 241 | qm.gatewayName = ("CTP"); 242 | 243 | grid_data_list.append(qm); 244 | } 245 | } -------------------------------------------------------------------------------- /TableView/tableView_Quote.h: -------------------------------------------------------------------------------- 1 | #ifndef TABLEVIEW_QUOTE_ 2 | #define TABLEVIEW_QUOTE_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include "Model/PublicStruct.h" 12 | #include "EventBase.h" 13 | 14 | /********************TableModel********************/ 15 | class TableModelQuote : public QAbstractTableModel 16 | { 17 | public: 18 | TableModelQuote(QObject *parent = 0); 19 | void setHorizontalHeaderList(QStringList horizontalHeaderList); 20 | void setModalDatas(QList *rowlist); 21 | void refrushModel(); 22 | 23 | //void setCurrencyMap(const QMap &map); 24 | int rowCount(const QModelIndex &parent) const; 25 | int columnCount(const QModelIndex &parent) const; 26 | QVariant data(const QModelIndex &index, int role) const; 27 | QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; 28 | 29 | private: 30 | //QString currencyAt(int offset) const; 31 | QStringList horizontal_header_list; 32 | //QStringList vertical_header_list; 33 | 34 | QList *data_list; 35 | //QMap currencyMap; 36 | }; 37 | 38 | 39 | // 行情报价监控模块 40 | /********************ReadOnlyTableView********************/ 41 | class TableView_Quote : public QTableView 42 | { 43 | Q_OBJECT 44 | 45 | public: 46 | 47 | TableView_Quote(QWidget *parent = 0); 48 | ~TableView_Quote(void); 49 | 50 | public slots: 51 | //更新表格 52 | void updateData(); 53 | 54 | private: 55 | 56 | void initData(); 57 | TableModelQuote *model; 58 | QStringList header; 59 | 60 | QList grid_data_list; 61 | //ProgressBarDelegate *progressbar_delegate; 62 | 63 | //更新table 64 | QTimer *updateTimer; 65 | 66 | }; 67 | #endif -------------------------------------------------------------------------------- /TechIndicator.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/TechIndicator.cpp -------------------------------------------------------------------------------- /TechIndicator.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/TechIndicator.h -------------------------------------------------------------------------------- /Win32/Debug/thostmduserapi.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/Win32/Debug/thostmduserapi.dll -------------------------------------------------------------------------------- /Win32/Debug/thosttraderapi.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/Win32/Debug/thosttraderapi.dll -------------------------------------------------------------------------------- /conn_file/011800/td/DialogRsp.con: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /conn_file/011800/td/Private.con: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/conn_file/011800/td/Private.con -------------------------------------------------------------------------------- /conn_file/011800/td/Public.con: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/conn_file/011800/td/Public.con -------------------------------------------------------------------------------- /conn_file/011800/td/QueryRsp.con: -------------------------------------------------------------------------------- 1 | z -------------------------------------------------------------------------------- /conn_file/011800/td/TradingDay.con: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/conn_file/011800/td/TradingDay.con -------------------------------------------------------------------------------- /conn_file/057131/td/DialogRsp.con: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /conn_file/057131/td/Private.con: -------------------------------------------------------------------------------- 1 | 4A -------------------------------------------------------------------------------- /conn_file/057131/td/Public.con: -------------------------------------------------------------------------------- 1 | 4A< -------------------------------------------------------------------------------- /conn_file/057131/td/QueryRsp.con: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /conn_file/057131/td/TradingDay.con: -------------------------------------------------------------------------------- 1 | 4A -------------------------------------------------------------------------------- /conn_file/md/DialogRsp.con: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /conn_file/md/QueryRsp.con: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /conn_file/md/TradingDay.con: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/conn_file/md/TradingDay.con -------------------------------------------------------------------------------- /cpp_basictool/CppQueue.hpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/cpp_basictool/CppQueue.hpp -------------------------------------------------------------------------------- /cpp_basictool/CppThread.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | using function_type = void(*)(void*); 8 | using id_type = std::thread::id; 9 | 10 | class CppThread 11 | { 12 | public: 13 | inline static void controll_function(void* data) 14 | { 15 | assert(data); 16 | CppThread* thread = (CppThread*)data; 17 | 18 | thread->_stop.store(false); 19 | thread->_exit.store(false); 20 | 21 | assert(thread->_function); 22 | thread->_function(thread); 23 | 24 | thread->_exit.store(true); 25 | } 26 | 27 | inline id_type get_id() 28 | { 29 | return _self.get_id(); 30 | } 31 | 32 | inline bool create_thread(function_type funct) 33 | { 34 | // business function outside 35 | _function = funct; 36 | 37 | // movable construct transformation 38 | _self = std::move(std::thread(controll_function, this)); 39 | 40 | return true; 41 | } 42 | 43 | inline void close_thread() 44 | { 45 | _stop.store(true); 46 | _self.join(); 47 | } 48 | 49 | inline void set_data(void* data) 50 | { 51 | _data.store(data); 52 | } 53 | 54 | inline void* get_data() 55 | { 56 | return _data.load(); 57 | } 58 | 59 | inline bool is_stop() 60 | { 61 | return _stop.load(); 62 | } 63 | 64 | inline void set_stop(bool flag) 65 | { 66 | _stop.store(flag); 67 | } 68 | 69 | inline void set_thread_index(size_t idx) 70 | { 71 | _index.store(idx); 72 | } 73 | 74 | inline size_t get_thread_index() 75 | { 76 | return _index.load(); 77 | } 78 | 79 | private: 80 | std::thread _self; // real thread object 81 | function_type _function{ nullptr }; // real thread function 82 | std::atomic _data{ nullptr }; 83 | 84 | std::atomic _stop{ true }; 85 | std::atomic _exit{ true }; 86 | 87 | std::atomic _index{ 0 }; // several threads flag which call the same function 88 | }; -------------------------------------------------------------------------------- /ctpapi/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 OnRtnDepthMarketData(CThostFtdcDepthMarketDataField *pDepthMarketData) {}; 66 | }; 67 | 68 | class MD_API_EXPORT CThostFtdcMdApi 69 | { 70 | public: 71 | ///创建MdApi 72 | ///@param pszFlowPath 存贮订阅信息文件的目录,默认为当前目录 73 | ///@return 创建出的UserApi 74 | ///modify for udp marketdata 75 | static CThostFtdcMdApi *CreateFtdcMdApi(const char *pszFlowPath = "", const bool bIsUsingUdp=false, const bool bIsMulticast=false); 76 | 77 | ///删除接口对象本身 78 | ///@remark 不再使用本接口对象时,调用该函数删除接口对象 79 | virtual void Release() = 0; 80 | 81 | ///初始化 82 | ///@remark 初始化运行环境,只有调用后,接口才开始工作 83 | virtual void Init() = 0; 84 | 85 | ///等待接口线程结束运行 86 | ///@return 线程退出代码 87 | virtual int Join() = 0; 88 | 89 | ///获取当前交易日 90 | ///@retrun 获取到的交易日 91 | ///@remark 只有登录成功后,才能得到正确的交易日 92 | virtual const char *GetTradingDay() = 0; 93 | 94 | ///注册前置机网络地址 95 | ///@param pszFrontAddress:前置机网络地址。 96 | ///@remark 网络地址的格式为:“protocol://ipaddress:port”,如:”tcp://127.0.0.1:17001”。 97 | ///@remark “tcp”代表传输协议,“127.0.0.1”代表服务器地址。”17001”代表服务器端口号。 98 | virtual void RegisterFront(char *pszFrontAddress) = 0; 99 | 100 | ///注册名字服务器网络地址 101 | ///@param pszNsAddress:名字服务器网络地址。 102 | ///@remark 网络地址的格式为:“protocol://ipaddress:port”,如:”tcp://127.0.0.1:12001”。 103 | ///@remark “tcp”代表传输协议,“127.0.0.1”代表服务器地址。”12001”代表服务器端口号。 104 | ///@remark RegisterNameServer优先于RegisterFront 105 | virtual void RegisterNameServer(char *pszNsAddress) = 0; 106 | 107 | ///注册名字服务器用户信息 108 | ///@param pFensUserInfo:用户信息。 109 | virtual void RegisterFensUserInfo(CThostFtdcFensUserInfoField * pFensUserInfo) = 0; 110 | 111 | ///注册回调接口 112 | ///@param pSpi 派生自回调接口类的实例 113 | virtual void RegisterSpi(CThostFtdcMdSpi *pSpi) = 0; 114 | 115 | ///订阅行情。 116 | ///@param ppInstrumentID 合约ID 117 | ///@param nCount 要订阅/退订行情的合约个数 118 | ///@remark 119 | virtual int SubscribeMarketData(char *ppInstrumentID[], int nCount) = 0; 120 | 121 | ///退订行情。 122 | ///@param ppInstrumentID 合约ID 123 | ///@param nCount 要订阅/退订行情的合约个数 124 | ///@remark 125 | virtual int UnSubscribeMarketData(char *ppInstrumentID[], int nCount) = 0; 126 | 127 | ///用户登录请求 128 | virtual int ReqUserLogin(CThostFtdcReqUserLoginField *pReqUserLoginField, int nRequestID) = 0; 129 | 130 | 131 | ///登出请求 132 | virtual int ReqUserLogout(CThostFtdcUserLogoutField *pUserLogout, int nRequestID) = 0; 133 | protected: 134 | ~CThostFtdcMdApi(){}; 135 | }; 136 | 137 | #endif 138 | -------------------------------------------------------------------------------- /ctpapi/ThostFtdcTraderApi.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////// 2 | ///@system 新一代交易所系统 3 | ///@company 上海期货信息技术有限公司 4 | ///@file ThostFtdcTraderApi.h 5 | ///@brief 定义了客户端接口 6 | ///@history 7 | ///20060106 赵鸿昊 创建该文件 8 | ///////////////////////////////////////////////////////////////////////// 9 | 10 | #if !defined(THOST_FTDCTRADERAPI_H) 11 | #define THOST_FTDCTRADERAPI_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_TRADER_API_EXPORT 21 | #define TRADER_API_EXPORT __declspec(dllexport) 22 | #else 23 | #define TRADER_API_EXPORT __declspec(dllimport) 24 | #endif 25 | #else 26 | #define TRADER_API_EXPORT 27 | #endif 28 | 29 | class CThostFtdcTraderSpi 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 | virtual void OnRspAuthenticate(CThostFtdcRspAuthenticateField *pRspAuthenticateField, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 50 | 51 | 52 | ///登录请求响应 53 | virtual void OnRspUserLogin(CThostFtdcRspUserLoginField *pRspUserLogin, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 54 | 55 | ///登出请求响应 56 | virtual void OnRspUserLogout(CThostFtdcUserLogoutField *pUserLogout, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 57 | 58 | ///用户口令更新请求响应 59 | virtual void OnRspUserPasswordUpdate(CThostFtdcUserPasswordUpdateField *pUserPasswordUpdate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 60 | 61 | ///资金账户口令更新请求响应 62 | virtual void OnRspTradingAccountPasswordUpdate(CThostFtdcTradingAccountPasswordUpdateField *pTradingAccountPasswordUpdate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 63 | 64 | ///报单录入请求响应 65 | virtual void OnRspOrderInsert(CThostFtdcInputOrderField *pInputOrder, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 66 | 67 | ///预埋单录入请求响应 68 | virtual void OnRspParkedOrderInsert(CThostFtdcParkedOrderField *pParkedOrder, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 69 | 70 | ///预埋撤单录入请求响应 71 | virtual void OnRspParkedOrderAction(CThostFtdcParkedOrderActionField *pParkedOrderAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 72 | 73 | ///报单操作请求响应 74 | virtual void OnRspOrderAction(CThostFtdcInputOrderActionField *pInputOrderAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 75 | 76 | ///查询最大报单数量响应 77 | virtual void OnRspQueryMaxOrderVolume(CThostFtdcQueryMaxOrderVolumeField *pQueryMaxOrderVolume, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 78 | 79 | ///投资者结算结果确认响应 80 | virtual void OnRspSettlementInfoConfirm(CThostFtdcSettlementInfoConfirmField *pSettlementInfoConfirm, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 81 | 82 | ///删除预埋单响应 83 | virtual void OnRspRemoveParkedOrder(CThostFtdcRemoveParkedOrderField *pRemoveParkedOrder, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 84 | 85 | ///删除预埋撤单响应 86 | virtual void OnRspRemoveParkedOrderAction(CThostFtdcRemoveParkedOrderActionField *pRemoveParkedOrderAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 87 | 88 | ///请求查询报单响应 89 | virtual void OnRspQryOrder(CThostFtdcOrderField *pOrder, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 90 | 91 | ///请求查询成交响应 92 | virtual void OnRspQryTrade(CThostFtdcTradeField *pTrade, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 93 | 94 | ///请求查询投资者持仓响应 95 | virtual void OnRspQryInvestorPosition(CThostFtdcInvestorPositionField *pInvestorPosition, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 96 | 97 | ///请求查询资金账户响应 98 | virtual void OnRspQryTradingAccount(CThostFtdcTradingAccountField *pTradingAccount, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 99 | 100 | ///请求查询投资者响应 101 | virtual void OnRspQryInvestor(CThostFtdcInvestorField *pInvestor, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 102 | 103 | ///请求查询交易编码响应 104 | virtual void OnRspQryTradingCode(CThostFtdcTradingCodeField *pTradingCode, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 105 | 106 | ///请求查询合约保证金率响应 107 | virtual void OnRspQryInstrumentMarginRate(CThostFtdcInstrumentMarginRateField *pInstrumentMarginRate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 108 | 109 | ///请求查询合约手续费率响应 110 | virtual void OnRspQryInstrumentCommissionRate(CThostFtdcInstrumentCommissionRateField *pInstrumentCommissionRate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 111 | 112 | ///请求查询交易所响应 113 | virtual void OnRspQryExchange(CThostFtdcExchangeField *pExchange, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 114 | 115 | ///请求查询产品响应 116 | virtual void OnRspQryProduct(CThostFtdcProductField *pProduct, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 117 | 118 | ///请求查询合约响应 119 | virtual void OnRspQryInstrument(CThostFtdcInstrumentField *pInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 120 | 121 | ///请求查询行情响应 122 | virtual void OnRspQryDepthMarketData(CThostFtdcDepthMarketDataField *pDepthMarketData, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 123 | 124 | ///请求查询投资者结算结果响应 125 | virtual void OnRspQrySettlementInfo(CThostFtdcSettlementInfoField *pSettlementInfo, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 126 | 127 | ///请求查询转帐银行响应 128 | virtual void OnRspQryTransferBank(CThostFtdcTransferBankField *pTransferBank, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 129 | 130 | ///请求查询投资者持仓明细响应 131 | virtual void OnRspQryInvestorPositionDetail(CThostFtdcInvestorPositionDetailField *pInvestorPositionDetail, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 132 | 133 | ///请求查询客户通知响应 134 | virtual void OnRspQryNotice(CThostFtdcNoticeField *pNotice, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 135 | 136 | ///请求查询结算信息确认响应 137 | virtual void OnRspQrySettlementInfoConfirm(CThostFtdcSettlementInfoConfirmField *pSettlementInfoConfirm, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 138 | 139 | ///请求查询投资者持仓明细响应 140 | virtual void OnRspQryInvestorPositionCombineDetail(CThostFtdcInvestorPositionCombineDetailField *pInvestorPositionCombineDetail, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 141 | 142 | ///查询保证金监管系统经纪公司资金账户密钥响应 143 | virtual void OnRspQryCFMMCTradingAccountKey(CThostFtdcCFMMCTradingAccountKeyField *pCFMMCTradingAccountKey, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 144 | 145 | ///请求查询仓单折抵信息响应 146 | virtual void OnRspQryEWarrantOffset(CThostFtdcEWarrantOffsetField *pEWarrantOffset, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 147 | 148 | ///请求查询投资者品种/跨品种保证金响应 149 | virtual void OnRspQryInvestorProductGroupMargin(CThostFtdcInvestorProductGroupMarginField *pInvestorProductGroupMargin, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 150 | 151 | ///请求查询交易所保证金率响应 152 | virtual void OnRspQryExchangeMarginRate(CThostFtdcExchangeMarginRateField *pExchangeMarginRate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 153 | 154 | ///请求查询交易所调整保证金率响应 155 | virtual void OnRspQryExchangeMarginRateAdjust(CThostFtdcExchangeMarginRateAdjustField *pExchangeMarginRateAdjust, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 156 | 157 | ///请求查询汇率响应 158 | virtual void OnRspQryExchangeRate(CThostFtdcExchangeRateField *pExchangeRate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 159 | 160 | ///请求查询二级代理操作员银期权限响应 161 | virtual void OnRspQrySecAgentACIDMap(CThostFtdcSecAgentACIDMapField *pSecAgentACIDMap, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 162 | 163 | ///请求查询转帐流水响应 164 | virtual void OnRspQryTransferSerial(CThostFtdcTransferSerialField *pTransferSerial, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 165 | 166 | ///请求查询银期签约关系响应 167 | virtual void OnRspQryAccountregister(CThostFtdcAccountregisterField *pAccountregister, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 168 | 169 | ///错误应答 170 | virtual void OnRspError(CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 171 | 172 | ///报单通知 173 | virtual void OnRtnOrder(CThostFtdcOrderField *pOrder) {}; 174 | 175 | ///成交通知 176 | virtual void OnRtnTrade(CThostFtdcTradeField *pTrade) {}; 177 | 178 | ///报单录入错误回报 179 | virtual void OnErrRtnOrderInsert(CThostFtdcInputOrderField *pInputOrder, CThostFtdcRspInfoField *pRspInfo) {}; 180 | 181 | ///报单操作错误回报 182 | virtual void OnErrRtnOrderAction(CThostFtdcOrderActionField *pOrderAction, CThostFtdcRspInfoField *pRspInfo) {}; 183 | 184 | ///合约交易状态通知 185 | virtual void OnRtnInstrumentStatus(CThostFtdcInstrumentStatusField *pInstrumentStatus) {}; 186 | 187 | ///交易通知 188 | virtual void OnRtnTradingNotice(CThostFtdcTradingNoticeInfoField *pTradingNoticeInfo) {}; 189 | 190 | ///提示条件单校验错误 191 | virtual void OnRtnErrorConditionalOrder(CThostFtdcErrorConditionalOrderField *pErrorConditionalOrder) {}; 192 | 193 | ///请求查询签约银行响应 194 | virtual void OnRspQryContractBank(CThostFtdcContractBankField *pContractBank, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 195 | 196 | ///请求查询预埋单响应 197 | virtual void OnRspQryParkedOrder(CThostFtdcParkedOrderField *pParkedOrder, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 198 | 199 | ///请求查询预埋撤单响应 200 | virtual void OnRspQryParkedOrderAction(CThostFtdcParkedOrderActionField *pParkedOrderAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 201 | 202 | ///请求查询交易通知响应 203 | virtual void OnRspQryTradingNotice(CThostFtdcTradingNoticeField *pTradingNotice, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 204 | 205 | ///请求查询经纪公司交易参数响应 206 | virtual void OnRspQryBrokerTradingParams(CThostFtdcBrokerTradingParamsField *pBrokerTradingParams, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 207 | 208 | ///请求查询经纪公司交易算法响应 209 | virtual void OnRspQryBrokerTradingAlgos(CThostFtdcBrokerTradingAlgosField *pBrokerTradingAlgos, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 210 | 211 | ///银行发起银行资金转期货通知 212 | virtual void OnRtnFromBankToFutureByBank(CThostFtdcRspTransferField *pRspTransfer) {}; 213 | 214 | ///银行发起期货资金转银行通知 215 | virtual void OnRtnFromFutureToBankByBank(CThostFtdcRspTransferField *pRspTransfer) {}; 216 | 217 | ///银行发起冲正银行转期货通知 218 | virtual void OnRtnRepealFromBankToFutureByBank(CThostFtdcRspRepealField *pRspRepeal) {}; 219 | 220 | ///银行发起冲正期货转银行通知 221 | virtual void OnRtnRepealFromFutureToBankByBank(CThostFtdcRspRepealField *pRspRepeal) {}; 222 | 223 | ///期货发起银行资金转期货通知 224 | virtual void OnRtnFromBankToFutureByFuture(CThostFtdcRspTransferField *pRspTransfer) {}; 225 | 226 | ///期货发起期货资金转银行通知 227 | virtual void OnRtnFromFutureToBankByFuture(CThostFtdcRspTransferField *pRspTransfer) {}; 228 | 229 | ///系统运行时期货端手工发起冲正银行转期货请求,银行处理完毕后报盘发回的通知 230 | virtual void OnRtnRepealFromBankToFutureByFutureManual(CThostFtdcRspRepealField *pRspRepeal) {}; 231 | 232 | ///系统运行时期货端手工发起冲正期货转银行请求,银行处理完毕后报盘发回的通知 233 | virtual void OnRtnRepealFromFutureToBankByFutureManual(CThostFtdcRspRepealField *pRspRepeal) {}; 234 | 235 | ///期货发起查询银行余额通知 236 | virtual void OnRtnQueryBankBalanceByFuture(CThostFtdcNotifyQueryAccountField *pNotifyQueryAccount) {}; 237 | 238 | ///期货发起银行资金转期货错误回报 239 | virtual void OnErrRtnBankToFutureByFuture(CThostFtdcReqTransferField *pReqTransfer, CThostFtdcRspInfoField *pRspInfo) {}; 240 | 241 | ///期货发起期货资金转银行错误回报 242 | virtual void OnErrRtnFutureToBankByFuture(CThostFtdcReqTransferField *pReqTransfer, CThostFtdcRspInfoField *pRspInfo) {}; 243 | 244 | ///系统运行时期货端手工发起冲正银行转期货错误回报 245 | virtual void OnErrRtnRepealBankToFutureByFutureManual(CThostFtdcReqRepealField *pReqRepeal, CThostFtdcRspInfoField *pRspInfo) {}; 246 | 247 | ///系统运行时期货端手工发起冲正期货转银行错误回报 248 | virtual void OnErrRtnRepealFutureToBankByFutureManual(CThostFtdcReqRepealField *pReqRepeal, CThostFtdcRspInfoField *pRspInfo) {}; 249 | 250 | ///期货发起查询银行余额错误回报 251 | virtual void OnErrRtnQueryBankBalanceByFuture(CThostFtdcReqQueryAccountField *pReqQueryAccount, CThostFtdcRspInfoField *pRspInfo) {}; 252 | 253 | ///期货发起冲正银行转期货请求,银行处理完毕后报盘发回的通知 254 | virtual void OnRtnRepealFromBankToFutureByFuture(CThostFtdcRspRepealField *pRspRepeal) {}; 255 | 256 | ///期货发起冲正期货转银行请求,银行处理完毕后报盘发回的通知 257 | virtual void OnRtnRepealFromFutureToBankByFuture(CThostFtdcRspRepealField *pRspRepeal) {}; 258 | 259 | ///期货发起银行资金转期货应答 260 | virtual void OnRspFromBankToFutureByFuture(CThostFtdcReqTransferField *pReqTransfer, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 261 | 262 | ///期货发起期货资金转银行应答 263 | virtual void OnRspFromFutureToBankByFuture(CThostFtdcReqTransferField *pReqTransfer, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 264 | 265 | ///期货发起查询银行余额应答 266 | virtual void OnRspQueryBankAccountMoneyByFuture(CThostFtdcReqQueryAccountField *pReqQueryAccount, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {}; 267 | 268 | ///银行发起银期开户通知 269 | virtual void OnRtnOpenAccountByBank(CThostFtdcOpenAccountField *pOpenAccount) {}; 270 | 271 | ///银行发起银期销户通知 272 | virtual void OnRtnCancelAccountByBank(CThostFtdcCancelAccountField *pCancelAccount) {}; 273 | 274 | ///银行发起变更银行账号通知 275 | virtual void OnRtnChangeAccountByBank(CThostFtdcChangeAccountField *pChangeAccount) {}; 276 | }; 277 | 278 | class TRADER_API_EXPORT CThostFtdcTraderApi 279 | { 280 | public: 281 | ///创建TraderApi 282 | ///@param pszFlowPath 存贮订阅信息文件的目录,默认为当前目录 283 | ///@return 创建出的UserApi 284 | static CThostFtdcTraderApi *CreateFtdcTraderApi(const char *pszFlowPath = ""); 285 | 286 | ///删除接口对象本身 287 | ///@remark 不再使用本接口对象时,调用该函数删除接口对象 288 | virtual void Release() = 0; 289 | 290 | ///初始化 291 | ///@remark 初始化运行环境,只有调用后,接口才开始工作 292 | virtual void Init() = 0; 293 | 294 | ///等待接口线程结束运行 295 | ///@return 线程退出代码 296 | virtual int Join() = 0; 297 | 298 | ///获取当前交易日 299 | ///@retrun 获取到的交易日 300 | ///@remark 只有登录成功后,才能得到正确的交易日 301 | virtual const char *GetTradingDay() = 0; 302 | 303 | ///注册前置机网络地址 304 | ///@param pszFrontAddress:前置机网络地址。 305 | ///@remark 网络地址的格式为:“protocol://ipaddress:port”,如:”tcp://127.0.0.1:17001”。 306 | ///@remark “tcp”代表传输协议,“127.0.0.1”代表服务器地址。”17001”代表服务器端口号。 307 | virtual void RegisterFront(char *pszFrontAddress) = 0; 308 | 309 | ///注册名字服务器网络地址 310 | ///@param pszNsAddress:名字服务器网络地址。 311 | ///@remark 网络地址的格式为:“protocol://ipaddress:port”,如:”tcp://127.0.0.1:12001”。 312 | ///@remark “tcp”代表传输协议,“127.0.0.1”代表服务器地址。”12001”代表服务器端口号。 313 | ///@remark RegisterNameServer优先于RegisterFront 314 | virtual void RegisterNameServer(char *pszNsAddress) = 0; 315 | 316 | ///注册名字服务器用户信息 317 | ///@param pFensUserInfo:用户信息。 318 | virtual void RegisterFensUserInfo(CThostFtdcFensUserInfoField * pFensUserInfo) = 0; 319 | 320 | ///注册回调接口 321 | ///@param pSpi 派生自回调接口类的实例 322 | virtual void RegisterSpi(CThostFtdcTraderSpi *pSpi) = 0; 323 | 324 | ///订阅私有流。 325 | ///@param nResumeType 私有流重传方式 326 | /// THOST_TERT_RESTART:从本交易日开始重传 327 | /// THOST_TERT_RESUME:从上次收到的续传 328 | /// THOST_TERT_QUICK:只传送登录后私有流的内容 329 | ///@remark 该方法要在Init方法前调用。若不调用则不会收到私有流的数据。 330 | virtual void SubscribePrivateTopic(THOST_TE_RESUME_TYPE nResumeType) = 0; 331 | 332 | ///订阅公共流。 333 | ///@param nResumeType 公共流重传方式 334 | /// THOST_TERT_RESTART:从本交易日开始重传 335 | /// THOST_TERT_RESUME:从上次收到的续传 336 | /// THOST_TERT_QUICK:只传送登录后公共流的内容 337 | ///@remark 该方法要在Init方法前调用。若不调用则不会收到公共流的数据。 338 | virtual void SubscribePublicTopic(THOST_TE_RESUME_TYPE nResumeType) = 0; 339 | 340 | ///客户端认证请求 341 | virtual int ReqAuthenticate(CThostFtdcReqAuthenticateField *pReqAuthenticateField, int nRequestID) = 0; 342 | 343 | ///用户登录请求 344 | virtual int ReqUserLogin(CThostFtdcReqUserLoginField *pReqUserLoginField, int nRequestID) = 0; 345 | 346 | 347 | ///登出请求 348 | virtual int ReqUserLogout(CThostFtdcUserLogoutField *pUserLogout, int nRequestID) = 0; 349 | 350 | ///用户口令更新请求 351 | virtual int ReqUserPasswordUpdate(CThostFtdcUserPasswordUpdateField *pUserPasswordUpdate, int nRequestID) = 0; 352 | 353 | ///资金账户口令更新请求 354 | virtual int ReqTradingAccountPasswordUpdate(CThostFtdcTradingAccountPasswordUpdateField *pTradingAccountPasswordUpdate, int nRequestID) = 0; 355 | 356 | ///报单录入请求 357 | virtual int ReqOrderInsert(CThostFtdcInputOrderField *pInputOrder, int nRequestID) = 0; 358 | 359 | ///预埋单录入请求 360 | virtual int ReqParkedOrderInsert(CThostFtdcParkedOrderField *pParkedOrder, int nRequestID) = 0; 361 | 362 | ///预埋撤单录入请求 363 | virtual int ReqParkedOrderAction(CThostFtdcParkedOrderActionField *pParkedOrderAction, int nRequestID) = 0; 364 | 365 | ///报单操作请求 366 | virtual int ReqOrderAction(CThostFtdcInputOrderActionField *pInputOrderAction, int nRequestID) = 0; 367 | 368 | ///查询最大报单数量请求 369 | virtual int ReqQueryMaxOrderVolume(CThostFtdcQueryMaxOrderVolumeField *pQueryMaxOrderVolume, int nRequestID) = 0; 370 | 371 | ///投资者结算结果确认 372 | virtual int ReqSettlementInfoConfirm(CThostFtdcSettlementInfoConfirmField *pSettlementInfoConfirm, int nRequestID) = 0; 373 | 374 | ///请求删除预埋单 375 | virtual int ReqRemoveParkedOrder(CThostFtdcRemoveParkedOrderField *pRemoveParkedOrder, int nRequestID) = 0; 376 | 377 | ///请求删除预埋撤单 378 | virtual int ReqRemoveParkedOrderAction(CThostFtdcRemoveParkedOrderActionField *pRemoveParkedOrderAction, int nRequestID) = 0; 379 | 380 | ///请求查询报单 381 | virtual int ReqQryOrder(CThostFtdcQryOrderField *pQryOrder, int nRequestID) = 0; 382 | 383 | ///请求查询成交 384 | virtual int ReqQryTrade(CThostFtdcQryTradeField *pQryTrade, int nRequestID) = 0; 385 | 386 | ///请求查询投资者持仓 387 | virtual int ReqQryInvestorPosition(CThostFtdcQryInvestorPositionField *pQryInvestorPosition, int nRequestID) = 0; 388 | 389 | ///请求查询资金账户 390 | virtual int ReqQryTradingAccount(CThostFtdcQryTradingAccountField *pQryTradingAccount, int nRequestID) = 0; 391 | 392 | ///请求查询投资者 393 | virtual int ReqQryInvestor(CThostFtdcQryInvestorField *pQryInvestor, int nRequestID) = 0; 394 | 395 | ///请求查询交易编码 396 | virtual int ReqQryTradingCode(CThostFtdcQryTradingCodeField *pQryTradingCode, int nRequestID) = 0; 397 | 398 | ///请求查询合约保证金率 399 | virtual int ReqQryInstrumentMarginRate(CThostFtdcQryInstrumentMarginRateField *pQryInstrumentMarginRate, int nRequestID) = 0; 400 | 401 | ///请求查询合约手续费率 402 | virtual int ReqQryInstrumentCommissionRate(CThostFtdcQryInstrumentCommissionRateField *pQryInstrumentCommissionRate, int nRequestID) = 0; 403 | 404 | ///请求查询交易所 405 | virtual int ReqQryExchange(CThostFtdcQryExchangeField *pQryExchange, int nRequestID) = 0; 406 | 407 | ///请求查询产品 408 | virtual int ReqQryProduct(CThostFtdcQryProductField *pQryProduct, int nRequestID) = 0; 409 | 410 | ///请求查询合约 411 | virtual int ReqQryInstrument(CThostFtdcQryInstrumentField *pQryInstrument, int nRequestID) = 0; 412 | 413 | ///请求查询行情 414 | virtual int ReqQryDepthMarketData(CThostFtdcQryDepthMarketDataField *pQryDepthMarketData, int nRequestID) = 0; 415 | 416 | ///请求查询投资者结算结果 417 | virtual int ReqQrySettlementInfo(CThostFtdcQrySettlementInfoField *pQrySettlementInfo, int nRequestID) = 0; 418 | 419 | ///请求查询转帐银行 420 | virtual int ReqQryTransferBank(CThostFtdcQryTransferBankField *pQryTransferBank, int nRequestID) = 0; 421 | 422 | ///请求查询投资者持仓明细 423 | virtual int ReqQryInvestorPositionDetail(CThostFtdcQryInvestorPositionDetailField *pQryInvestorPositionDetail, int nRequestID) = 0; 424 | 425 | ///请求查询客户通知 426 | virtual int ReqQryNotice(CThostFtdcQryNoticeField *pQryNotice, int nRequestID) = 0; 427 | 428 | ///请求查询结算信息确认 429 | virtual int ReqQrySettlementInfoConfirm(CThostFtdcQrySettlementInfoConfirmField *pQrySettlementInfoConfirm, int nRequestID) = 0; 430 | 431 | ///请求查询投资者持仓明细 432 | virtual int ReqQryInvestorPositionCombineDetail(CThostFtdcQryInvestorPositionCombineDetailField *pQryInvestorPositionCombineDetail, int nRequestID) = 0; 433 | 434 | ///请求查询保证金监管系统经纪公司资金账户密钥 435 | virtual int ReqQryCFMMCTradingAccountKey(CThostFtdcQryCFMMCTradingAccountKeyField *pQryCFMMCTradingAccountKey, int nRequestID) = 0; 436 | 437 | ///请求查询仓单折抵信息 438 | virtual int ReqQryEWarrantOffset(CThostFtdcQryEWarrantOffsetField *pQryEWarrantOffset, int nRequestID) = 0; 439 | 440 | ///请求查询投资者品种/跨品种保证金 441 | virtual int ReqQryInvestorProductGroupMargin(CThostFtdcQryInvestorProductGroupMarginField *pQryInvestorProductGroupMargin, int nRequestID) = 0; 442 | 443 | ///请求查询交易所保证金率 444 | virtual int ReqQryExchangeMarginRate(CThostFtdcQryExchangeMarginRateField *pQryExchangeMarginRate, int nRequestID) = 0; 445 | 446 | ///请求查询交易所调整保证金率 447 | virtual int ReqQryExchangeMarginRateAdjust(CThostFtdcQryExchangeMarginRateAdjustField *pQryExchangeMarginRateAdjust, int nRequestID) = 0; 448 | 449 | ///请求查询汇率 450 | virtual int ReqQryExchangeRate(CThostFtdcQryExchangeRateField *pQryExchangeRate, int nRequestID) = 0; 451 | 452 | ///请求查询二级代理操作员银期权限 453 | virtual int ReqQrySecAgentACIDMap(CThostFtdcQrySecAgentACIDMapField *pQrySecAgentACIDMap, int nRequestID) = 0; 454 | 455 | ///请求查询转帐流水 456 | virtual int ReqQryTransferSerial(CThostFtdcQryTransferSerialField *pQryTransferSerial, int nRequestID) = 0; 457 | 458 | ///请求查询银期签约关系 459 | virtual int ReqQryAccountregister(CThostFtdcQryAccountregisterField *pQryAccountregister, int nRequestID) = 0; 460 | 461 | ///请求查询签约银行 462 | virtual int ReqQryContractBank(CThostFtdcQryContractBankField *pQryContractBank, int nRequestID) = 0; 463 | 464 | ///请求查询预埋单 465 | virtual int ReqQryParkedOrder(CThostFtdcQryParkedOrderField *pQryParkedOrder, int nRequestID) = 0; 466 | 467 | ///请求查询预埋撤单 468 | virtual int ReqQryParkedOrderAction(CThostFtdcQryParkedOrderActionField *pQryParkedOrderAction, int nRequestID) = 0; 469 | 470 | ///请求查询交易通知 471 | virtual int ReqQryTradingNotice(CThostFtdcQryTradingNoticeField *pQryTradingNotice, int nRequestID) = 0; 472 | 473 | ///请求查询经纪公司交易参数 474 | virtual int ReqQryBrokerTradingParams(CThostFtdcQryBrokerTradingParamsField *pQryBrokerTradingParams, int nRequestID) = 0; 475 | 476 | ///请求查询经纪公司交易算法 477 | virtual int ReqQryBrokerTradingAlgos(CThostFtdcQryBrokerTradingAlgosField *pQryBrokerTradingAlgos, int nRequestID) = 0; 478 | 479 | ///期货发起银行资金转期货请求 480 | virtual int ReqFromBankToFutureByFuture(CThostFtdcReqTransferField *pReqTransfer, int nRequestID) = 0; 481 | 482 | ///期货发起期货资金转银行请求 483 | virtual int ReqFromFutureToBankByFuture(CThostFtdcReqTransferField *pReqTransfer, int nRequestID) = 0; 484 | 485 | ///期货发起查询银行余额请求 486 | virtual int ReqQueryBankAccountMoneyByFuture(CThostFtdcReqQueryAccountField *pReqQueryAccount, int nRequestID) = 0; 487 | protected: 488 | ~CThostFtdcTraderApi(){}; 489 | }; 490 | 491 | #endif 492 | -------------------------------------------------------------------------------- /ctpapi/error.dtd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | -------------------------------------------------------------------------------- /ctpapi/error.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/ctpapi/error.xml -------------------------------------------------------------------------------- /ctpapi/md5.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/ctpapi/md5.txt -------------------------------------------------------------------------------- /ctpapi/thostmduserapi.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/ctpapi/thostmduserapi.dll -------------------------------------------------------------------------------- /ctpapi/thostmduserapi.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/ctpapi/thostmduserapi.lib -------------------------------------------------------------------------------- /ctpapi/thosttraderapi.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/ctpapi/thosttraderapi.dll -------------------------------------------------------------------------------- /ctpapi/thosttraderapi.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/ctpapi/thosttraderapi.lib -------------------------------------------------------------------------------- /glog/include/log_severity.h: -------------------------------------------------------------------------------- 1 | // This file is automatically generated from src/glog/log_severity.h 2 | // using src/windows/preprocess.sh. 3 | // DO NOT EDIT! 4 | 5 | // Copyright (c) 2007, Google Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are 10 | // met: 11 | // 12 | // * Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // * Redistributions in binary form must reproduce the above 15 | // copyright notice, this list of conditions and the following disclaimer 16 | // in the documentation and/or other materials provided with the 17 | // distribution. 18 | // * Neither the name of Google Inc. nor the names of its 19 | // contributors may be used to endorse or promote products derived from 20 | // this software without specific prior written permission. 21 | // 22 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 26 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | 34 | #ifndef BASE_LOG_SEVERITY_H__ 35 | #define BASE_LOG_SEVERITY_H__ 36 | 37 | // Annoying stuff for windows -- makes sure clients can import these functions 38 | #ifndef GOOGLE_GLOG_DLL_DECL 39 | # if defined(_WIN32) && !defined(__CYGWIN__) 40 | # define GOOGLE_GLOG_DLL_DECL __declspec(dllimport) 41 | # else 42 | # define GOOGLE_GLOG_DLL_DECL 43 | # endif 44 | #endif 45 | 46 | // Variables of type LogSeverity are widely taken to lie in the range 47 | // [0, NUM_SEVERITIES-1]. Be careful to preserve this assumption if 48 | // you ever need to change their values or add a new severity. 49 | typedef int LogSeverity; 50 | 51 | const int GLOG_INFO = 0, GLOG_WARNING = 1, GLOG_ERROR = 2, GLOG_FATAL = 3, 52 | NUM_SEVERITIES = 4; 53 | #ifndef GLOG_NO_ABBREVIATED_SEVERITIES 54 | # ifdef ERROR 55 | # error ERROR macro is defined. Define GLOG_NO_ABBREVIATED_SEVERITIES before including logging.h. See the document for detail. 56 | # endif 57 | const int INFO = GLOG_INFO, WARNING = GLOG_WARNING, 58 | ERROR = GLOG_ERROR, FATAL = GLOG_FATAL; 59 | #endif 60 | 61 | // DFATAL is FATAL in debug mode, ERROR in normal mode 62 | #ifdef NDEBUG 63 | #define DFATAL_LEVEL ERROR 64 | #else 65 | #define DFATAL_LEVEL FATAL 66 | #endif 67 | 68 | extern GOOGLE_GLOG_DLL_DECL const char* const LogSeverityNames[NUM_SEVERITIES]; 69 | 70 | // NDEBUG usage helpers related to (RAW_)DCHECK: 71 | // 72 | // DEBUG_MODE is for small !NDEBUG uses like 73 | // if (DEBUG_MODE) foo.CheckThatFoo(); 74 | // instead of substantially more verbose 75 | // #ifndef NDEBUG 76 | // foo.CheckThatFoo(); 77 | // #endif 78 | // 79 | // IF_DEBUG_MODE is for small !NDEBUG uses like 80 | // IF_DEBUG_MODE( string error; ) 81 | // DCHECK(Foo(&error)) << error; 82 | // instead of substantially more verbose 83 | // #ifndef NDEBUG 84 | // string error; 85 | // DCHECK(Foo(&error)) << error; 86 | // #endif 87 | // 88 | #ifdef NDEBUG 89 | enum { DEBUG_MODE = 0 }; 90 | #define IF_DEBUG_MODE(x) 91 | #else 92 | enum { DEBUG_MODE = 1 }; 93 | #define IF_DEBUG_MODE(x) x 94 | #endif 95 | 96 | #endif // BASE_LOG_SEVERITY_H__ 97 | -------------------------------------------------------------------------------- /glog/include/raw_logging.h: -------------------------------------------------------------------------------- 1 | // This file is automatically generated from src/glog/raw_logging.h.in 2 | // using src/windows/preprocess.sh. 3 | // DO NOT EDIT! 4 | 5 | // Copyright (c) 2006, Google Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are 10 | // met: 11 | // 12 | // * Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // * Redistributions in binary form must reproduce the above 15 | // copyright notice, this list of conditions and the following disclaimer 16 | // in the documentation and/or other materials provided with the 17 | // distribution. 18 | // * Neither the name of Google Inc. nor the names of its 19 | // contributors may be used to endorse or promote products derived from 20 | // this software without specific prior written permission. 21 | // 22 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 26 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | // 34 | // Author: Maxim Lifantsev 35 | // 36 | // Thread-safe logging routines that do not allocate any memory or 37 | // acquire any locks, and can therefore be used by low-level memory 38 | // allocation and synchronization code. 39 | 40 | #ifndef BASE_RAW_LOGGING_H_ 41 | #define BASE_RAW_LOGGING_H_ 42 | 43 | #include 44 | 45 | namespace google { 46 | 47 | #include "glog/log_severity.h" 48 | #include "glog/vlog_is_on.h" 49 | 50 | // Annoying stuff for windows -- makes sure clients can import these functions 51 | #ifndef GOOGLE_GLOG_DLL_DECL 52 | # if defined(_WIN32) && !defined(__CYGWIN__) 53 | # define GOOGLE_GLOG_DLL_DECL __declspec(dllimport) 54 | # else 55 | # define GOOGLE_GLOG_DLL_DECL 56 | # endif 57 | #endif 58 | 59 | // This is similar to LOG(severity) << format... and VLOG(level) << format.., 60 | // but 61 | // * it is to be used ONLY by low-level modules that can't use normal LOG() 62 | // * it is desiged to be a low-level logger that does not allocate any 63 | // memory and does not need any locks, hence: 64 | // * it logs straight and ONLY to STDERR w/o buffering 65 | // * it uses an explicit format and arguments list 66 | // * it will silently chop off really long message strings 67 | // Usage example: 68 | // RAW_LOG(ERROR, "Failed foo with %i: %s", status, error); 69 | // RAW_VLOG(3, "status is %i", status); 70 | // These will print an almost standard log lines like this to stderr only: 71 | // E0821 211317 file.cc:123] RAW: Failed foo with 22: bad_file 72 | // I0821 211317 file.cc:142] RAW: status is 20 73 | #define RAW_LOG(severity, ...) \ 74 | do { \ 75 | switch (google::GLOG_ ## severity) { \ 76 | case 0: \ 77 | RAW_LOG_INFO(__VA_ARGS__); \ 78 | break; \ 79 | case 1: \ 80 | RAW_LOG_WARNING(__VA_ARGS__); \ 81 | break; \ 82 | case 2: \ 83 | RAW_LOG_ERROR(__VA_ARGS__); \ 84 | break; \ 85 | case 3: \ 86 | RAW_LOG_FATAL(__VA_ARGS__); \ 87 | break; \ 88 | default: \ 89 | break; \ 90 | } \ 91 | } while (0) 92 | 93 | // The following STRIP_LOG testing is performed in the header file so that it's 94 | // possible to completely compile out the logging code and the log messages. 95 | #if STRIP_LOG == 0 96 | #define RAW_VLOG(verboselevel, ...) \ 97 | do { \ 98 | if (VLOG_IS_ON(verboselevel)) { \ 99 | RAW_LOG_INFO(__VA_ARGS__); \ 100 | } \ 101 | } while (0) 102 | #else 103 | #define RAW_VLOG(verboselevel, ...) RawLogStub__(0, __VA_ARGS__) 104 | #endif // STRIP_LOG == 0 105 | 106 | #if STRIP_LOG == 0 107 | #define RAW_LOG_INFO(...) google::RawLog__(google::GLOG_INFO, \ 108 | __FILE__, __LINE__, __VA_ARGS__) 109 | #else 110 | #define RAW_LOG_INFO(...) google::RawLogStub__(0, __VA_ARGS__) 111 | #endif // STRIP_LOG == 0 112 | 113 | #if STRIP_LOG <= 1 114 | #define RAW_LOG_WARNING(...) google::RawLog__(google::GLOG_WARNING, \ 115 | __FILE__, __LINE__, __VA_ARGS__) 116 | #else 117 | #define RAW_LOG_WARNING(...) google::RawLogStub__(0, __VA_ARGS__) 118 | #endif // STRIP_LOG <= 1 119 | 120 | #if STRIP_LOG <= 2 121 | #define RAW_LOG_ERROR(...) google::RawLog__(google::GLOG_ERROR, \ 122 | __FILE__, __LINE__, __VA_ARGS__) 123 | #else 124 | #define RAW_LOG_ERROR(...) google::RawLogStub__(0, __VA_ARGS__) 125 | #endif // STRIP_LOG <= 2 126 | 127 | #if STRIP_LOG <= 3 128 | #define RAW_LOG_FATAL(...) google::RawLog__(google::GLOG_FATAL, \ 129 | __FILE__, __LINE__, __VA_ARGS__) 130 | #else 131 | #define RAW_LOG_FATAL(...) \ 132 | do { \ 133 | google::RawLogStub__(0, __VA_ARGS__); \ 134 | exit(1); \ 135 | } while (0) 136 | #endif // STRIP_LOG <= 3 137 | 138 | // Similar to CHECK(condition) << message, 139 | // but for low-level modules: we use only RAW_LOG that does not allocate memory. 140 | // We do not want to provide args list here to encourage this usage: 141 | // if (!cond) RAW_LOG(FATAL, "foo ...", hard_to_compute_args); 142 | // so that the args are not computed when not needed. 143 | #define RAW_CHECK(condition, message) \ 144 | do { \ 145 | if (!(condition)) { \ 146 | RAW_LOG(FATAL, "Check %s failed: %s", #condition, message); \ 147 | } \ 148 | } while (0) 149 | 150 | // Debug versions of RAW_LOG and RAW_CHECK 151 | #ifndef NDEBUG 152 | 153 | #define RAW_DLOG(severity, ...) RAW_LOG(severity, __VA_ARGS__) 154 | #define RAW_DCHECK(condition, message) RAW_CHECK(condition, message) 155 | 156 | #else // NDEBUG 157 | 158 | #define RAW_DLOG(severity, ...) \ 159 | while (false) \ 160 | RAW_LOG(severity, __VA_ARGS__) 161 | #define RAW_DCHECK(condition, message) \ 162 | while (false) \ 163 | RAW_CHECK(condition, message) 164 | 165 | #endif // NDEBUG 166 | 167 | // Stub log function used to work around for unused variable warnings when 168 | // building with STRIP_LOG > 0. 169 | static inline void RawLogStub__(int /* ignored */, ...) { 170 | } 171 | 172 | // Helper function to implement RAW_LOG and RAW_VLOG 173 | // Logs format... at "severity" level, reporting it 174 | // as called from file:line. 175 | // This does not allocate memory or acquire locks. 176 | GOOGLE_GLOG_DLL_DECL void RawLog__(LogSeverity severity, 177 | const char* file, 178 | int line, 179 | const char* format, ...) 180 | ; 181 | 182 | // Hack to propagate time information into this module so that 183 | // this module does not have to directly call localtime_r(), 184 | // which could allocate memory. 185 | GOOGLE_GLOG_DLL_DECL void RawLog__SetLastTime(const struct tm& t, int usecs); 186 | 187 | } 188 | 189 | #endif // BASE_RAW_LOGGING_H_ 190 | -------------------------------------------------------------------------------- /glog/include/stl_logging.h: -------------------------------------------------------------------------------- 1 | // This file is automatically generated from src/glog/stl_logging.h.in 2 | // using src/windows/preprocess.sh. 3 | // DO NOT EDIT! 4 | 5 | // Copyright (c) 2003, Google Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are 10 | // met: 11 | // 12 | // * Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // * Redistributions in binary form must reproduce the above 15 | // copyright notice, this list of conditions and the following disclaimer 16 | // in the documentation and/or other materials provided with the 17 | // distribution. 18 | // * Neither the name of Google Inc. nor the names of its 19 | // contributors may be used to endorse or promote products derived from 20 | // this software without specific prior written permission. 21 | // 22 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 26 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | // 34 | // Stream output operators for STL containers; to be used for logging *only*. 35 | // Inclusion of this file lets you do: 36 | // 37 | // list x; 38 | // LOG(INFO) << "data: " << x; 39 | // vector v1, v2; 40 | // CHECK_EQ(v1, v2); 41 | // 42 | // If you want to use this header file with hash_compare maps or slist, you 43 | // need to define macros before including this file: 44 | // 45 | // - GLOG_STL_LOGGING_FOR_UNORDERED - and 46 | // - GLOG_STL_LOGGING_FOR_TR1_UNORDERED - 47 | // - GLOG_STL_LOGGING_FOR_EXT_HASH - 48 | // - GLOG_STL_LOGGING_FOR_EXT_SLIST - 49 | // 50 | 51 | #ifndef UTIL_GTL_STL_LOGGING_INL_H_ 52 | #define UTIL_GTL_STL_LOGGING_INL_H_ 53 | 54 | #if !1 55 | # error We do not support stl_logging for this compiler 56 | #endif 57 | 58 | #include 59 | #include 60 | #include 61 | #include 62 | #include 63 | #include 64 | #include 65 | 66 | #ifdef GLOG_STL_LOGGING_FOR_UNORDERED 67 | # include 68 | # include 69 | #endif 70 | 71 | #ifdef GLOG_STL_LOGGING_FOR_TR1_UNORDERED 72 | # include 73 | # include 74 | #endif 75 | 76 | #ifdef GLOG_STL_LOGGING_FOR_EXT_HASH 77 | # include 78 | # include 79 | #endif 80 | #ifdef GLOG_STL_LOGGING_FOR_EXT_SLIST 81 | # include 82 | #endif 83 | 84 | // Forward declare these two, and define them after all the container streams 85 | // operators so that we can recurse from pair -> container -> container -> pair 86 | // properly. 87 | template 88 | std::ostream& operator<<(std::ostream& out, const std::pair& p); 89 | 90 | namespace google { 91 | 92 | template 93 | void PrintSequence(std::ostream& out, Iter begin, Iter end); 94 | 95 | } 96 | 97 | #define OUTPUT_TWO_ARG_CONTAINER(Sequence) \ 98 | template \ 99 | inline std::ostream& operator<<(std::ostream& out, \ 100 | const Sequence& seq) { \ 101 | google::PrintSequence(out, seq.begin(), seq.end()); \ 102 | return out; \ 103 | } 104 | 105 | OUTPUT_TWO_ARG_CONTAINER(std::vector) 106 | OUTPUT_TWO_ARG_CONTAINER(std::deque) 107 | OUTPUT_TWO_ARG_CONTAINER(std::list) 108 | #ifdef GLOG_STL_LOGGING_FOR_EXT_SLIST 109 | OUTPUT_TWO_ARG_CONTAINER(__gnu_cxx::slist) 110 | #endif 111 | 112 | #undef OUTPUT_TWO_ARG_CONTAINER 113 | 114 | #define OUTPUT_THREE_ARG_CONTAINER(Sequence) \ 115 | template \ 116 | inline std::ostream& operator<<(std::ostream& out, \ 117 | const Sequence& seq) { \ 118 | google::PrintSequence(out, seq.begin(), seq.end()); \ 119 | return out; \ 120 | } 121 | 122 | OUTPUT_THREE_ARG_CONTAINER(std::set) 123 | OUTPUT_THREE_ARG_CONTAINER(std::multiset) 124 | 125 | #undef OUTPUT_THREE_ARG_CONTAINER 126 | 127 | #define OUTPUT_FOUR_ARG_CONTAINER(Sequence) \ 128 | template \ 129 | inline std::ostream& operator<<(std::ostream& out, \ 130 | const Sequence& seq) { \ 131 | google::PrintSequence(out, seq.begin(), seq.end()); \ 132 | return out; \ 133 | } 134 | 135 | OUTPUT_FOUR_ARG_CONTAINER(std::map) 136 | OUTPUT_FOUR_ARG_CONTAINER(std::multimap) 137 | #ifdef GLOG_STL_LOGGING_FOR_UNORDERED 138 | OUTPUT_FOUR_ARG_CONTAINER(std::unordered_set) 139 | OUTPUT_FOUR_ARG_CONTAINER(std::unordered_multiset) 140 | #endif 141 | #ifdef GLOG_STL_LOGGING_FOR_TR1_UNORDERED 142 | OUTPUT_FOUR_ARG_CONTAINER(std::tr1::unordered_set) 143 | OUTPUT_FOUR_ARG_CONTAINER(std::tr1::unordered_multiset) 144 | #endif 145 | #ifdef GLOG_STL_LOGGING_FOR_EXT_HASH 146 | OUTPUT_FOUR_ARG_CONTAINER(__gnu_cxx::hash_set) 147 | OUTPUT_FOUR_ARG_CONTAINER(__gnu_cxx::hash_multiset) 148 | #endif 149 | 150 | #undef OUTPUT_FOUR_ARG_CONTAINER 151 | 152 | #define OUTPUT_FIVE_ARG_CONTAINER(Sequence) \ 153 | template \ 154 | inline std::ostream& operator<<(std::ostream& out, \ 155 | const Sequence& seq) { \ 156 | google::PrintSequence(out, seq.begin(), seq.end()); \ 157 | return out; \ 158 | } 159 | 160 | #ifdef GLOG_STL_LOGGING_FOR_UNORDERED 161 | OUTPUT_FIVE_ARG_CONTAINER(std::unordered_map) 162 | OUTPUT_FIVE_ARG_CONTAINER(std::unordered_multimap) 163 | #endif 164 | #ifdef GLOG_STL_LOGGING_FOR_TR1_UNORDERED 165 | OUTPUT_FIVE_ARG_CONTAINER(std::tr1::unordered_map) 166 | OUTPUT_FIVE_ARG_CONTAINER(std::tr1::unordered_multimap) 167 | #endif 168 | #ifdef GLOG_STL_LOGGING_FOR_EXT_HASH 169 | OUTPUT_FIVE_ARG_CONTAINER(__gnu_cxx::hash_map) 170 | OUTPUT_FIVE_ARG_CONTAINER(__gnu_cxx::hash_multimap) 171 | #endif 172 | 173 | #undef OUTPUT_FIVE_ARG_CONTAINER 174 | 175 | template 176 | inline std::ostream& operator<<(std::ostream& out, 177 | const std::pair& p) { 178 | out << '(' << p.first << ", " << p.second << ')'; 179 | return out; 180 | } 181 | 182 | namespace google { 183 | 184 | template 185 | inline void PrintSequence(std::ostream& out, Iter begin, Iter end) { 186 | // Output at most 100 elements -- appropriate if used for logging. 187 | for (int i = 0; begin != end && i < 100; ++i, ++begin) { 188 | if (i > 0) out << ' '; 189 | out << *begin; 190 | } 191 | if (begin != end) { 192 | out << " ..."; 193 | } 194 | } 195 | 196 | } 197 | 198 | // Note that this is technically undefined behavior! We are adding things into 199 | // the std namespace for a reason though -- we are providing new operations on 200 | // types which are themselves defined with this namespace. Without this, these 201 | // operator overloads cannot be found via ADL. If these definitions are not 202 | // found via ADL, they must be #included before they're used, which requires 203 | // this header to be included before apparently independent other headers. 204 | // 205 | // For example, base/logging.h defines various template functions to implement 206 | // CHECK_EQ(x, y) and stream x and y into the log in the event the check fails. 207 | // It does so via the function template MakeCheckOpValueString: 208 | // template 209 | // void MakeCheckOpValueString(strstream* ss, const T& v) { 210 | // (*ss) << v; 211 | // } 212 | // Because 'glog/logging.h' is included before 'glog/stl_logging.h', 213 | // subsequent CHECK_EQ(v1, v2) for vector<...> typed variable v1 and v2 can only 214 | // find these operator definitions via ADL. 215 | // 216 | // Even this solution has problems -- it may pull unintended operators into the 217 | // namespace as well, allowing them to also be found via ADL, and creating code 218 | // that only works with a particular order of includes. Long term, we need to 219 | // move all of the *definitions* into namespace std, bet we need to ensure no 220 | // one references them first. This lets us take that step. We cannot define them 221 | // in both because that would create ambiguous overloads when both are found. 222 | namespace std { using ::operator<<; } 223 | 224 | #endif // UTIL_GTL_STL_LOGGING_INL_H_ 225 | -------------------------------------------------------------------------------- /glog/include/vlog_is_on.h: -------------------------------------------------------------------------------- 1 | // This file is automatically generated from src/glog/vlog_is_on.h.in 2 | // using src/windows/preprocess.sh. 3 | // DO NOT EDIT! 4 | 5 | // Copyright (c) 1999, 2007, Google Inc. 6 | // All rights reserved. 7 | // 8 | // Redistribution and use in source and binary forms, with or without 9 | // modification, are permitted provided that the following conditions are 10 | // met: 11 | // 12 | // * Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // * Redistributions in binary form must reproduce the above 15 | // copyright notice, this list of conditions and the following disclaimer 16 | // in the documentation and/or other materials provided with the 17 | // distribution. 18 | // * Neither the name of Google Inc. nor the names of its 19 | // contributors may be used to endorse or promote products derived from 20 | // this software without specific prior written permission. 21 | // 22 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 26 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | // 34 | // Author: Ray Sidney and many others 35 | // 36 | // Defines the VLOG_IS_ON macro that controls the variable-verbosity 37 | // conditional logging. 38 | // 39 | // It's used by VLOG and VLOG_IF in logging.h 40 | // and by RAW_VLOG in raw_logging.h to trigger the logging. 41 | // 42 | // It can also be used directly e.g. like this: 43 | // if (VLOG_IS_ON(2)) { 44 | // // do some logging preparation and logging 45 | // // that can't be accomplished e.g. via just VLOG(2) << ...; 46 | // } 47 | // 48 | // The truth value that VLOG_IS_ON(level) returns is determined by 49 | // the three verbosity level flags: 50 | // --v= Gives the default maximal active V-logging level; 51 | // 0 is the default. 52 | // Normally positive values are used for V-logging levels. 53 | // --vmodule= Gives the per-module maximal V-logging levels to override 54 | // the value given by --v. 55 | // E.g. "my_module=2,foo*=3" would change the logging level 56 | // for all code in source files "my_module.*" and "foo*.*" 57 | // ("-inl" suffixes are also disregarded for this matching). 58 | // 59 | // SetVLOGLevel helper function is provided to do limited dynamic control over 60 | // V-logging by overriding the per-module settings given via --vmodule flag. 61 | // 62 | // CAVEAT: --vmodule functionality is not available in non gcc compilers. 63 | // 64 | 65 | #ifndef BASE_VLOG_IS_ON_H_ 66 | #define BASE_VLOG_IS_ON_H_ 67 | 68 | #include "glog/include/log_severity.h" 69 | 70 | // Annoying stuff for windows -- makes sure clients can import these functions 71 | #ifndef GOOGLE_GLOG_DLL_DECL 72 | # if defined(_WIN32) && !defined(__CYGWIN__) 73 | # define GOOGLE_GLOG_DLL_DECL __declspec(dllimport) 74 | # else 75 | # define GOOGLE_GLOG_DLL_DECL 76 | # endif 77 | #endif 78 | 79 | #if defined(__GNUC__) 80 | // We emit an anonymous static int* variable at every VLOG_IS_ON(n) site. 81 | // (Normally) the first time every VLOG_IS_ON(n) site is hit, 82 | // we determine what variable will dynamically control logging at this site: 83 | // it's either FLAGS_v or an appropriate internal variable 84 | // matching the current source file that represents results of 85 | // parsing of --vmodule flag and/or SetVLOGLevel calls. 86 | #define VLOG_IS_ON(verboselevel) \ 87 | __extension__ \ 88 | ({ static google::int32* vlocal__ = &google::kLogSiteUninitialized; \ 89 | google::int32 verbose_level__ = (verboselevel); \ 90 | (*vlocal__ >= verbose_level__) && \ 91 | ((vlocal__ != &google::kLogSiteUninitialized) || \ 92 | (google::InitVLOG3__(&vlocal__, &FLAGS_v, \ 93 | __FILE__, verbose_level__))); }) 94 | #else 95 | // GNU extensions not available, so we do not support --vmodule. 96 | // Dynamic value of FLAGS_v always controls the logging level. 97 | #define VLOG_IS_ON(verboselevel) (FLAGS_v >= (verboselevel)) 98 | #endif 99 | 100 | // Set VLOG(_IS_ON) level for module_pattern to log_level. 101 | // This lets us dynamically control what is normally set by the --vmodule flag. 102 | // Returns the level that previously applied to module_pattern. 103 | // NOTE: To change the log level for VLOG(_IS_ON) sites 104 | // that have already executed after/during InitGoogleLogging, 105 | // one needs to supply the exact --vmodule pattern that applied to them. 106 | // (If no --vmodule pattern applied to them 107 | // the value of FLAGS_v will continue to control them.) 108 | extern GOOGLE_GLOG_DLL_DECL int SetVLOGLevel(const char* module_pattern, 109 | int log_level); 110 | 111 | // Various declarations needed for VLOG_IS_ON above: ========================= 112 | 113 | // Special value used to indicate that a VLOG_IS_ON site has not been 114 | // initialized. We make this a large value, so the common-case check 115 | // of "*vlocal__ >= verbose_level__" in VLOG_IS_ON definition 116 | // passes in such cases and InitVLOG3__ is then triggered. 117 | extern google::int32 kLogSiteUninitialized; 118 | 119 | // Helper routine which determines the logging info for a particalur VLOG site. 120 | // site_flag is the address of the site-local pointer to the controlling 121 | // verbosity level 122 | // site_default is the default to use for *site_flag 123 | // fname is the current source file name 124 | // verbose_level is the argument to VLOG_IS_ON 125 | // We will return the return value for VLOG_IS_ON 126 | // and if possible set *site_flag appropriately. 127 | extern GOOGLE_GLOG_DLL_DECL bool InitVLOG3__( 128 | google::int32** site_flag, 129 | google::int32* site_default, 130 | const char* fname, 131 | google::int32 verbose_level); 132 | 133 | #endif // BASE_VLOG_IS_ON_H_ 134 | -------------------------------------------------------------------------------- /glog/lib/Debug/libglog.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/glog/lib/Debug/libglog.dll -------------------------------------------------------------------------------- /glog/lib/Debug/libglog.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/glog/lib/Debug/libglog.lib -------------------------------------------------------------------------------- /glog/lib/Debug/libglog_static.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/glog/lib/Debug/libglog_static.lib -------------------------------------------------------------------------------- /glog/lib/Release/libglog.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/glog/lib/Release/libglog.dll -------------------------------------------------------------------------------- /glog/lib/Release/libglog.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/glog/lib/Release/libglog.lib -------------------------------------------------------------------------------- /glog/lib/Release/libglog_static.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/glog/lib/Release/libglog_static.lib -------------------------------------------------------------------------------- /main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/main.cpp -------------------------------------------------------------------------------- /maintrade.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/maintrade.cpp -------------------------------------------------------------------------------- /maintrade.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/maintrade.h -------------------------------------------------------------------------------- /maintrade.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /mysql/include/complement.txt: -------------------------------------------------------------------------------- 1 | http://code.taobao.org/p/OceanBase/src/trunk/oceanbase/tools/benchmark/runner/mysql_5.5/include/ -------------------------------------------------------------------------------- /mysql/include/my_alloc.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License as published by 5 | the Free Software Foundation; version 2 of the License. 6 | 7 | This program is distributed in the hope that it will be useful, 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | GNU General Public License for more details. 11 | 12 | You should have received a copy of the GNU General Public License 13 | along with this program; if not, write to the Free Software 14 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 15 | 16 | /* 17 | Data structures for mysys/my_alloc.c (root memory allocator) 18 | */ 19 | 20 | #ifndef _my_alloc_h 21 | #define _my_alloc_h 22 | 23 | #define ALLOC_MAX_BLOCK_TO_DROP 4096 24 | #define ALLOC_MAX_BLOCK_USAGE_BEFORE_DROP 10 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | typedef struct st_used_mem 31 | { /* struct for once_alloc (block) */ 32 | struct st_used_mem *next; /* Next block in use */ 33 | unsigned int left; /* memory left in block */ 34 | unsigned int size; /* size of block */ 35 | } USED_MEM; 36 | 37 | 38 | typedef struct st_mem_root 39 | { 40 | USED_MEM *free; /* blocks with free memory in it */ 41 | USED_MEM *used; /* blocks almost without free memory */ 42 | USED_MEM *pre_alloc; /* preallocated block */ 43 | /* if block have less memory it will be put in 'used' list */ 44 | size_t min_malloc; 45 | size_t block_size; /* initial block size */ 46 | unsigned int block_num; /* allocated blocks counter */ 47 | /* 48 | first free block in queue test counter (if it exceed 49 | MAX_BLOCK_USAGE_BEFORE_DROP block will be dropped in 'used' list) 50 | */ 51 | unsigned int first_block_usage; 52 | 53 | void (*error_handler)(void); 54 | } MEM_ROOT; 55 | 56 | #ifdef __cplusplus 57 | } 58 | #endif 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /mysql/include/my_list.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License as published by 5 | the Free Software Foundation; version 2 of the License. 6 | 7 | This program is distributed in the hope that it will be useful, 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | GNU General Public License for more details. 11 | 12 | You should have received a copy of the GNU General Public License 13 | along with this program; if not, write to the Free Software 14 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 15 | 16 | #ifndef _list_h_ 17 | #define _list_h_ 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | typedef struct st_list { 24 | struct st_list *prev,*next; 25 | void *data; 26 | } LIST; 27 | 28 | typedef int (*list_walk_action)(void *,void *); 29 | 30 | extern LIST *list_add(LIST *root,LIST *element); 31 | extern LIST *list_delete(LIST *root,LIST *element); 32 | extern LIST *list_cons(void *data,LIST *root); 33 | extern LIST *list_reverse(LIST *root); 34 | extern void list_free(LIST *root,unsigned int free_data); 35 | extern unsigned int list_length(LIST *); 36 | extern int list_walk(LIST *,list_walk_action action,unsigned char * argument); 37 | 38 | #define list_rest(a) ((a)->next) 39 | #define list_push(a,b) (a)=list_cons((b),(a)) 40 | #define list_pop(A) {LIST *old=(A); (A)=list_delete(old,old); my_free(old); } 41 | 42 | #ifdef __cplusplus 43 | } 44 | #endif 45 | #endif -------------------------------------------------------------------------------- /mysql/include/mysql_com.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License as published by 5 | the Free Software Foundation; version 2 of the License. 6 | 7 | This program is distributed in the hope that it will be useful, 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | GNU General Public License for more details. 11 | 12 | You should have received a copy of the GNU General Public License 13 | along with this program; if not, write to the Free Software 14 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ 15 | 16 | /* 17 | ** Common definition between mysql server & client 18 | */ 19 | 20 | #ifndef _mysql_com_h 21 | #define _mysql_com_h 22 | 23 | #define HOSTNAME_LENGTH 60 24 | #define SYSTEM_CHARSET_MBMAXLEN 3 25 | #define NAME_CHAR_LEN 64 /* Field/table name length */ 26 | #define USERNAME_CHAR_LENGTH 16 27 | #define NAME_LEN (NAME_CHAR_LEN*SYSTEM_CHARSET_MBMAXLEN) 28 | #define USERNAME_LENGTH (USERNAME_CHAR_LENGTH*SYSTEM_CHARSET_MBMAXLEN) 29 | 30 | #define MYSQL_AUTODETECT_CHARSET_NAME "auto" 31 | 32 | #define SERVER_VERSION_LENGTH 60 33 | #define SQLSTATE_LENGTH 5 34 | 35 | /* 36 | Maximum length of comments 37 | */ 38 | #define TABLE_COMMENT_INLINE_MAXLEN 180 /* pre 6.0: 60 characters */ 39 | #define TABLE_COMMENT_MAXLEN 2048 40 | #define COLUMN_COMMENT_MAXLEN 1024 41 | #define INDEX_COMMENT_MAXLEN 1024 42 | 43 | /* 44 | USER_HOST_BUFF_SIZE -- length of string buffer, that is enough to contain 45 | username and hostname parts of the user identifier with trailing zero in 46 | MySQL standard format: 47 | user_name_part@host_name_part\0 48 | */ 49 | #define USER_HOST_BUFF_SIZE HOSTNAME_LENGTH + USERNAME_LENGTH + 2 50 | 51 | #define LOCAL_HOST "localhost" 52 | #define LOCAL_HOST_NAMEDPIPE "." 53 | 54 | 55 | #if defined(__WIN__) && !defined( _CUSTOMCONFIG_) 56 | #define MYSQL_NAMEDPIPE "MySQL" 57 | #define MYSQL_SERVICENAME "MySQL" 58 | #endif /* __WIN__ */ 59 | 60 | /* 61 | You should add new commands to the end of this list, otherwise old 62 | servers won't be able to handle them as 'unsupported'. 63 | */ 64 | 65 | enum enum_server_command 66 | { 67 | COM_SLEEP, COM_QUIT, COM_INIT_DB, COM_QUERY, COM_FIELD_LIST, 68 | COM_CREATE_DB, COM_DROP_DB, COM_REFRESH, COM_SHUTDOWN, COM_STATISTICS, 69 | COM_PROCESS_INFO, COM_CONNECT, COM_PROCESS_KILL, COM_DEBUG, COM_PING, 70 | COM_TIME, COM_DELAYED_INSERT, COM_CHANGE_USER, COM_BINLOG_DUMP, 71 | COM_TABLE_DUMP, COM_CONNECT_OUT, COM_REGISTER_SLAVE, 72 | COM_STMT_PREPARE, COM_STMT_EXECUTE, COM_STMT_SEND_LONG_DATA, COM_STMT_CLOSE, 73 | COM_STMT_RESET, COM_SET_OPTION, COM_STMT_FETCH, COM_DAEMON, 74 | /* don't forget to update const char *command_name[] in sql_parse.cc */ 75 | 76 | /* Must be last */ 77 | COM_END 78 | }; 79 | 80 | 81 | /* 82 | Length of random string sent by server on handshake; this is also length of 83 | obfuscated password, recieved from client 84 | */ 85 | #define SCRAMBLE_LENGTH 20 86 | #define SCRAMBLE_LENGTH_323 8 87 | /* length of password stored in the db: new passwords are preceeded with '*' */ 88 | #define SCRAMBLED_PASSWORD_CHAR_LENGTH (SCRAMBLE_LENGTH*2+1) 89 | #define SCRAMBLED_PASSWORD_CHAR_LENGTH_323 (SCRAMBLE_LENGTH_323*2) 90 | 91 | 92 | #define NOT_NULL_FLAG 1 /* Field can't be NULL */ 93 | #define PRI_KEY_FLAG 2 /* Field is part of a primary key */ 94 | #define UNIQUE_KEY_FLAG 4 /* Field is part of a unique key */ 95 | #define MULTIPLE_KEY_FLAG 8 /* Field is part of a key */ 96 | #define BLOB_FLAG 16 /* Field is a blob */ 97 | #define UNSIGNED_FLAG 32 /* Field is unsigned */ 98 | #define ZEROFILL_FLAG 64 /* Field is zerofill */ 99 | #define BINARY_FLAG 128 /* Field is binary */ 100 | 101 | /* The following are only sent to new clients */ 102 | #define ENUM_FLAG 256 /* field is an enum */ 103 | #define AUTO_INCREMENT_FLAG 512 /* field is a autoincrement field */ 104 | #define TIMESTAMP_FLAG 1024 /* Field is a timestamp */ 105 | #define SET_FLAG 2048 /* field is a set */ 106 | #define NO_DEFAULT_VALUE_FLAG 4096 /* Field doesn't have default value */ 107 | #define ON_UPDATE_NOW_FLAG 8192 /* Field is set to NOW on UPDATE */ 108 | #define NUM_FLAG 32768 /* Field is num (for clients) */ 109 | #define PART_KEY_FLAG 16384 /* Intern; Part of some key */ 110 | #define GROUP_FLAG 32768 /* Intern: Group field */ 111 | #define UNIQUE_FLAG 65536 /* Intern: Used by sql_yacc */ 112 | #define BINCMP_FLAG 131072 /* Intern: Used by sql_yacc */ 113 | #define GET_FIXED_FIELDS_FLAG (1 << 18) /* Used to get fields in item tree */ 114 | #define FIELD_IN_PART_FUNC_FLAG (1 << 19)/* Field part of partition func */ 115 | #define FIELD_IN_ADD_INDEX (1<< 20) /* Intern: Field used in ADD INDEX */ 116 | #define FIELD_IS_RENAMED (1<< 21) /* Intern: Field is being renamed */ 117 | #define FIELD_FLAGS_STORAGE_MEDIA 22 /* Field storage media, bit 22-23, 118 | reserved by MySQL Cluster */ 119 | #define FIELD_FLAGS_COLUMN_FORMAT 24 /* Field column format, bit 24-25, 120 | reserved by MySQL Cluster */ 121 | 122 | #define REFRESH_GRANT 1 /* Refresh grant tables */ 123 | #define REFRESH_LOG 2 /* Start on new log file */ 124 | #define REFRESH_TABLES 4 /* close all tables */ 125 | #define REFRESH_HOSTS 8 /* Flush host cache */ 126 | #define REFRESH_STATUS 16 /* Flush status variables */ 127 | #define REFRESH_THREADS 32 /* Flush thread cache */ 128 | #define REFRESH_SLAVE 64 /* Reset master info and restart slave 129 | thread */ 130 | #define REFRESH_MASTER 128 /* Remove all bin logs in the index 131 | and truncate the index */ 132 | #define REFRESH_ERROR_LOG 256 /* Rotate only the erorr log */ 133 | #define REFRESH_ENGINE_LOG 512 /* Flush all storage engine logs */ 134 | #define REFRESH_BINARY_LOG 1024 /* Flush the binary log */ 135 | #define REFRESH_RELAY_LOG 2048 /* Flush the relay log */ 136 | #define REFRESH_GENERAL_LOG 4096 /* Flush the general log */ 137 | #define REFRESH_SLOW_LOG 8192 /* Flush the slow query log */ 138 | 139 | /* The following can't be set with mysql_refresh() */ 140 | #define REFRESH_READ_LOCK 16384 /* Lock tables for read */ 141 | #define REFRESH_FAST 32768 /* Intern flag */ 142 | 143 | /* RESET (remove all queries) from query cache */ 144 | #define REFRESH_QUERY_CACHE 65536 145 | #define REFRESH_QUERY_CACHE_FREE 0x20000L /* pack query cache */ 146 | #define REFRESH_DES_KEY_FILE 0x40000L 147 | #define REFRESH_USER_RESOURCES 0x80000L 148 | 149 | #define CLIENT_LONG_PASSWORD 1 /* new more secure passwords */ 150 | #define CLIENT_FOUND_ROWS 2 /* Found instead of affected rows */ 151 | #define CLIENT_LONG_FLAG 4 /* Get all column flags */ 152 | #define CLIENT_CONNECT_WITH_DB 8 /* One can specify db on connect */ 153 | #define CLIENT_NO_SCHEMA 16 /* Don't allow database.table.column */ 154 | #define CLIENT_COMPRESS 32 /* Can use compression protocol */ 155 | #define CLIENT_ODBC 64 /* Odbc client */ 156 | #define CLIENT_LOCAL_FILES 128 /* Can use LOAD DATA LOCAL */ 157 | #define CLIENT_IGNORE_SPACE 256 /* Ignore spaces before '(' */ 158 | #define CLIENT_PROTOCOL_41 512 /* New 4.1 protocol */ 159 | #define CLIENT_INTERACTIVE 1024 /* This is an interactive client */ 160 | #define CLIENT_SSL 2048 /* Switch to SSL after handshake */ 161 | #define CLIENT_IGNORE_SIGPIPE 4096 /* IGNORE sigpipes */ 162 | #define CLIENT_TRANSACTIONS 8192 /* Client knows about transactions */ 163 | #define CLIENT_RESERVED 16384 /* Old flag for 4.1 protocol */ 164 | #define CLIENT_SECURE_CONNECTION 32768 /* New 4.1 authentication */ 165 | #define CLIENT_MULTI_STATEMENTS (1UL << 16) /* Enable/disable multi-stmt support */ 166 | #define CLIENT_MULTI_RESULTS (1UL << 17) /* Enable/disable multi-results */ 167 | #define CLIENT_PS_MULTI_RESULTS (1UL << 18) /* Multi-results in PS-protocol */ 168 | 169 | #define CLIENT_PLUGIN_AUTH (1UL << 19) /* Client supports plugin authentication */ 170 | 171 | #define CLIENT_SSL_VERIFY_SERVER_CERT (1UL << 30) 172 | #define CLIENT_REMEMBER_OPTIONS (1UL << 31) 173 | 174 | #ifdef HAVE_COMPRESS 175 | #define CAN_CLIENT_COMPRESS CLIENT_COMPRESS 176 | #else 177 | #define CAN_CLIENT_COMPRESS 0 178 | #endif 179 | 180 | /* Gather all possible capabilites (flags) supported by the server */ 181 | #define CLIENT_ALL_FLAGS (CLIENT_LONG_PASSWORD | \ 182 | CLIENT_FOUND_ROWS | \ 183 | CLIENT_LONG_FLAG | \ 184 | CLIENT_CONNECT_WITH_DB | \ 185 | CLIENT_NO_SCHEMA | \ 186 | CLIENT_COMPRESS | \ 187 | CLIENT_ODBC | \ 188 | CLIENT_LOCAL_FILES | \ 189 | CLIENT_IGNORE_SPACE | \ 190 | CLIENT_PROTOCOL_41 | \ 191 | CLIENT_INTERACTIVE | \ 192 | CLIENT_SSL | \ 193 | CLIENT_IGNORE_SIGPIPE | \ 194 | CLIENT_TRANSACTIONS | \ 195 | CLIENT_RESERVED | \ 196 | CLIENT_SECURE_CONNECTION | \ 197 | CLIENT_MULTI_STATEMENTS | \ 198 | CLIENT_MULTI_RESULTS | \ 199 | CLIENT_PS_MULTI_RESULTS | \ 200 | CLIENT_SSL_VERIFY_SERVER_CERT | \ 201 | CLIENT_REMEMBER_OPTIONS | \ 202 | CLIENT_PLUGIN_AUTH) 203 | 204 | /* 205 | Switch off the flags that are optional and depending on build flags 206 | If any of the optional flags is supported by the build it will be switched 207 | on before sending to the client during the connection handshake. 208 | */ 209 | #define CLIENT_BASIC_FLAGS (((CLIENT_ALL_FLAGS & ~CLIENT_SSL) \ 210 | & ~CLIENT_COMPRESS) \ 211 | & ~CLIENT_SSL_VERIFY_SERVER_CERT) 212 | 213 | /** 214 | Is raised when a multi-statement transaction 215 | has been started, either explicitly, by means 216 | of BEGIN or COMMIT AND CHAIN, or 217 | implicitly, by the first transactional 218 | statement, when autocommit=off. 219 | */ 220 | #define SERVER_STATUS_IN_TRANS 1 221 | #define SERVER_STATUS_AUTOCOMMIT 2 /* Server in auto_commit mode */ 222 | #define SERVER_MORE_RESULTS_EXISTS 8 /* Multi query - next query exists */ 223 | #define SERVER_QUERY_NO_GOOD_INDEX_USED 16 224 | #define SERVER_QUERY_NO_INDEX_USED 32 225 | /** 226 | The server was able to fulfill the clients request and opened a 227 | read-only non-scrollable cursor for a query. This flag comes 228 | in reply to COM_STMT_EXECUTE and COM_STMT_FETCH commands. 229 | */ 230 | #define SERVER_STATUS_CURSOR_EXISTS 64 231 | /** 232 | This flag is sent when a read-only cursor is exhausted, in reply to 233 | COM_STMT_FETCH command. 234 | */ 235 | #define SERVER_STATUS_LAST_ROW_SENT 128 236 | #define SERVER_STATUS_DB_DROPPED 256 /* A database was dropped */ 237 | #define SERVER_STATUS_NO_BACKSLASH_ESCAPES 512 238 | /** 239 | Sent to the client if after a prepared statement reprepare 240 | we discovered that the new statement returns a different 241 | number of result set columns. 242 | */ 243 | #define SERVER_STATUS_METADATA_CHANGED 1024 244 | #define SERVER_QUERY_WAS_SLOW 2048 245 | 246 | /** 247 | To mark ResultSet containing output parameter values. 248 | */ 249 | #define SERVER_PS_OUT_PARAMS 4096 250 | 251 | /** 252 | Server status flags that must be cleared when starting 253 | execution of a new SQL statement. 254 | Flags from this set are only added to the 255 | current server status by the execution engine, but 256 | never removed -- the execution engine expects them 257 | to disappear automagically by the next command. 258 | */ 259 | #define SERVER_STATUS_CLEAR_SET (SERVER_QUERY_NO_GOOD_INDEX_USED| \ 260 | SERVER_QUERY_NO_INDEX_USED|\ 261 | SERVER_MORE_RESULTS_EXISTS|\ 262 | SERVER_STATUS_METADATA_CHANGED |\ 263 | SERVER_QUERY_WAS_SLOW |\ 264 | SERVER_STATUS_DB_DROPPED |\ 265 | SERVER_STATUS_CURSOR_EXISTS|\ 266 | SERVER_STATUS_LAST_ROW_SENT) 267 | 268 | #define MYSQL_ERRMSG_SIZE 512 269 | #define NET_READ_TIMEOUT 30 /* Timeout on read */ 270 | #define NET_WRITE_TIMEOUT 60 /* Timeout on write */ 271 | #define NET_WAIT_TIMEOUT 8*60*60 /* Wait for new query */ 272 | 273 | #define ONLY_KILL_QUERY 1 274 | 275 | 276 | struct st_vio; /* Only C */ 277 | typedef struct st_vio Vio; 278 | 279 | #define MAX_TINYINT_WIDTH 3 /* Max width for a TINY w.o. sign */ 280 | #define MAX_SMALLINT_WIDTH 5 /* Max width for a SHORT w.o. sign */ 281 | #define MAX_MEDIUMINT_WIDTH 8 /* Max width for a INT24 w.o. sign */ 282 | #define MAX_INT_WIDTH 10 /* Max width for a LONG w.o. sign */ 283 | #define MAX_BIGINT_WIDTH 20 /* Max width for a LONGLONG */ 284 | #define MAX_CHAR_WIDTH 255 /* Max length for a CHAR colum */ 285 | #define MAX_BLOB_WIDTH 16777216 /* Default width for blob */ 286 | 287 | typedef struct st_net { 288 | #if !defined(CHECK_EMBEDDED_DIFFERENCES) || !defined(EMBEDDED_LIBRARY) 289 | Vio *vio; 290 | unsigned char *buff,*buff_end,*write_pos,*read_pos; 291 | my_socket fd; /* For Perl DBI/dbd */ 292 | /* 293 | The following variable is set if we are doing several queries in one 294 | command ( as in LOAD TABLE ... FROM MASTER ), 295 | and do not want to confuse the client with OK at the wrong time 296 | */ 297 | unsigned long remain_in_buf,length, buf_length, where_b; 298 | unsigned long max_packet,max_packet_size; 299 | unsigned int pkt_nr,compress_pkt_nr; 300 | unsigned int write_timeout, read_timeout, retry_count; 301 | int fcntl; 302 | unsigned int *return_status; 303 | unsigned char reading_or_writing; 304 | char save_char; 305 | my_bool unused1; /* Please remove with the next incompatible ABI change. */ 306 | my_bool unused2; /* Please remove with the next incompatible ABI change */ 307 | my_bool compress; 308 | my_bool unused3; /* Please remove with the next incompatible ABI change. */ 309 | /* 310 | Pointer to query object in query cache, do not equal NULL (0) for 311 | queries in cache that have not stored its results yet 312 | */ 313 | #endif 314 | /* 315 | Unused, please remove with the next incompatible ABI change. 316 | */ 317 | unsigned char *unused; 318 | unsigned int last_errno; 319 | unsigned char error; 320 | my_bool unused4; /* Please remove with the next incompatible ABI change. */ 321 | my_bool unused5; /* Please remove with the next incompatible ABI change. */ 322 | /** Client library error message buffer. Actually belongs to struct MYSQL. */ 323 | char last_error[MYSQL_ERRMSG_SIZE]; 324 | /** Client library sqlstate buffer. Set along with the error message. */ 325 | char sqlstate[SQLSTATE_LENGTH+1]; 326 | void *extension; 327 | #if defined(MYSQL_SERVER) && !defined(EMBEDDED_LIBRARY) 328 | /* 329 | Controls whether a big packet should be skipped. 330 | 331 | Initially set to FALSE by default. Unauthenticated sessions must have 332 | this set to FALSE so that the server can't be tricked to read packets 333 | indefinitely. 334 | */ 335 | my_bool skip_big_packet; 336 | #endif 337 | } NET; 338 | 339 | 340 | #define packet_error (~(unsigned long) 0) 341 | 342 | enum enum_field_types { MYSQL_TYPE_DECIMAL, MYSQL_TYPE_TINY, 343 | MYSQL_TYPE_SHORT, MYSQL_TYPE_LONG, 344 | MYSQL_TYPE_FLOAT, MYSQL_TYPE_DOUBLE, 345 | MYSQL_TYPE_NULL, MYSQL_TYPE_TIMESTAMP, 346 | MYSQL_TYPE_LONGLONG,MYSQL_TYPE_INT24, 347 | MYSQL_TYPE_DATE, MYSQL_TYPE_TIME, 348 | MYSQL_TYPE_DATETIME, MYSQL_TYPE_YEAR, 349 | MYSQL_TYPE_NEWDATE, MYSQL_TYPE_VARCHAR, 350 | MYSQL_TYPE_BIT, 351 | MYSQL_TYPE_NEWDECIMAL=246, 352 | MYSQL_TYPE_ENUM=247, 353 | MYSQL_TYPE_SET=248, 354 | MYSQL_TYPE_TINY_BLOB=249, 355 | MYSQL_TYPE_MEDIUM_BLOB=250, 356 | MYSQL_TYPE_LONG_BLOB=251, 357 | MYSQL_TYPE_BLOB=252, 358 | MYSQL_TYPE_VAR_STRING=253, 359 | MYSQL_TYPE_STRING=254, 360 | MYSQL_TYPE_GEOMETRY=255 361 | 362 | }; 363 | 364 | /* For backward compatibility */ 365 | #define CLIENT_MULTI_QUERIES CLIENT_MULTI_STATEMENTS 366 | #define FIELD_TYPE_DECIMAL MYSQL_TYPE_DECIMAL 367 | #define FIELD_TYPE_NEWDECIMAL MYSQL_TYPE_NEWDECIMAL 368 | #define FIELD_TYPE_TINY MYSQL_TYPE_TINY 369 | #define FIELD_TYPE_SHORT MYSQL_TYPE_SHORT 370 | #define FIELD_TYPE_LONG MYSQL_TYPE_LONG 371 | #define FIELD_TYPE_FLOAT MYSQL_TYPE_FLOAT 372 | #define FIELD_TYPE_DOUBLE MYSQL_TYPE_DOUBLE 373 | #define FIELD_TYPE_NULL MYSQL_TYPE_NULL 374 | #define FIELD_TYPE_TIMESTAMP MYSQL_TYPE_TIMESTAMP 375 | #define FIELD_TYPE_LONGLONG MYSQL_TYPE_LONGLONG 376 | #define FIELD_TYPE_INT24 MYSQL_TYPE_INT24 377 | #define FIELD_TYPE_DATE MYSQL_TYPE_DATE 378 | #define FIELD_TYPE_TIME MYSQL_TYPE_TIME 379 | #define FIELD_TYPE_DATETIME MYSQL_TYPE_DATETIME 380 | #define FIELD_TYPE_YEAR MYSQL_TYPE_YEAR 381 | #define FIELD_TYPE_NEWDATE MYSQL_TYPE_NEWDATE 382 | #define FIELD_TYPE_ENUM MYSQL_TYPE_ENUM 383 | #define FIELD_TYPE_SET MYSQL_TYPE_SET 384 | #define FIELD_TYPE_TINY_BLOB MYSQL_TYPE_TINY_BLOB 385 | #define FIELD_TYPE_MEDIUM_BLOB MYSQL_TYPE_MEDIUM_BLOB 386 | #define FIELD_TYPE_LONG_BLOB MYSQL_TYPE_LONG_BLOB 387 | #define FIELD_TYPE_BLOB MYSQL_TYPE_BLOB 388 | #define FIELD_TYPE_VAR_STRING MYSQL_TYPE_VAR_STRING 389 | #define FIELD_TYPE_STRING MYSQL_TYPE_STRING 390 | #define FIELD_TYPE_CHAR MYSQL_TYPE_TINY 391 | #define FIELD_TYPE_INTERVAL MYSQL_TYPE_ENUM 392 | #define FIELD_TYPE_GEOMETRY MYSQL_TYPE_GEOMETRY 393 | #define FIELD_TYPE_BIT MYSQL_TYPE_BIT 394 | 395 | 396 | /* Shutdown/kill enums and constants */ 397 | 398 | /* Bits for THD::killable. */ 399 | #define MYSQL_SHUTDOWN_KILLABLE_CONNECT (unsigned char)(1 << 0) 400 | #define MYSQL_SHUTDOWN_KILLABLE_TRANS (unsigned char)(1 << 1) 401 | #define MYSQL_SHUTDOWN_KILLABLE_LOCK_TABLE (unsigned char)(1 << 2) 402 | #define MYSQL_SHUTDOWN_KILLABLE_UPDATE (unsigned char)(1 << 3) 403 | 404 | enum mysql_enum_shutdown_level { 405 | /* 406 | We want levels to be in growing order of hardness (because we use number 407 | comparisons). Note that DEFAULT does not respect the growing property, but 408 | it's ok. 409 | */ 410 | SHUTDOWN_DEFAULT = 0, 411 | /* wait for existing connections to finish */ 412 | SHUTDOWN_WAIT_CONNECTIONS= MYSQL_SHUTDOWN_KILLABLE_CONNECT, 413 | /* wait for existing trans to finish */ 414 | SHUTDOWN_WAIT_TRANSACTIONS= MYSQL_SHUTDOWN_KILLABLE_TRANS, 415 | /* wait for existing updates to finish (=> no partial MyISAM update) */ 416 | SHUTDOWN_WAIT_UPDATES= MYSQL_SHUTDOWN_KILLABLE_UPDATE, 417 | /* flush InnoDB buffers and other storage engines' buffers*/ 418 | SHUTDOWN_WAIT_ALL_BUFFERS= (MYSQL_SHUTDOWN_KILLABLE_UPDATE << 1), 419 | /* don't flush InnoDB buffers, flush other storage engines' buffers*/ 420 | SHUTDOWN_WAIT_CRITICAL_BUFFERS= (MYSQL_SHUTDOWN_KILLABLE_UPDATE << 1) + 1, 421 | /* Now the 2 levels of the KILL command */ 422 | #if MYSQL_VERSION_ID >= 50000 423 | KILL_QUERY= 254, 424 | #endif 425 | KILL_CONNECTION= 255 426 | }; 427 | 428 | 429 | enum enum_cursor_type 430 | { 431 | CURSOR_TYPE_NO_CURSOR= 0, 432 | CURSOR_TYPE_READ_ONLY= 1, 433 | CURSOR_TYPE_FOR_UPDATE= 2, 434 | CURSOR_TYPE_SCROLLABLE= 4 435 | }; 436 | 437 | 438 | /* options for mysql_set_option */ 439 | enum enum_mysql_set_option 440 | { 441 | MYSQL_OPTION_MULTI_STATEMENTS_ON, 442 | MYSQL_OPTION_MULTI_STATEMENTS_OFF 443 | }; 444 | 445 | #define net_new_transaction(net) ((net)->pkt_nr=0) 446 | 447 | #ifdef __cplusplus 448 | extern "C" { 449 | #endif 450 | 451 | my_bool my_net_init(NET *net, Vio* vio); 452 | void my_net_local_init(NET *net); 453 | void net_end(NET *net); 454 | void net_clear(NET *net, my_bool clear_buffer); 455 | my_bool net_realloc(NET *net, size_t length); 456 | my_bool net_flush(NET *net); 457 | my_bool my_net_write(NET *net,const unsigned char *packet, size_t len); 458 | my_bool net_write_command(NET *net,unsigned char command, 459 | const unsigned char *header, size_t head_len, 460 | const unsigned char *packet, size_t len); 461 | int net_real_write(NET *net,const unsigned char *packet, size_t len); 462 | unsigned long my_net_read(NET *net); 463 | 464 | #ifdef _global_h 465 | void my_net_set_write_timeout(NET *net, uint timeout); 466 | void my_net_set_read_timeout(NET *net, uint timeout); 467 | #endif 468 | 469 | struct sockaddr; 470 | int my_connect(my_socket s, const struct sockaddr *name, unsigned int namelen, 471 | unsigned int timeout); 472 | 473 | struct rand_struct { 474 | unsigned long seed1,seed2,max_value; 475 | double max_value_dbl; 476 | }; 477 | 478 | #ifdef __cplusplus 479 | } 480 | #endif 481 | 482 | /* The following is for user defined functions */ 483 | 484 | enum Item_result {STRING_RESULT=0, REAL_RESULT, INT_RESULT, ROW_RESULT, 485 | DECIMAL_RESULT}; 486 | 487 | typedef struct st_udf_args 488 | { 489 | unsigned int arg_count; /* Number of arguments */ 490 | enum Item_result *arg_type; /* Pointer to item_results */ 491 | char **args; /* Pointer to argument */ 492 | unsigned long *lengths; /* Length of string arguments */ 493 | char *maybe_null; /* Set to 1 for all maybe_null args */ 494 | char **attributes; /* Pointer to attribute name */ 495 | unsigned long *attribute_lengths; /* Length of attribute arguments */ 496 | void *extension; 497 | } UDF_ARGS; 498 | 499 | /* This holds information about the result */ 500 | 501 | typedef struct st_udf_init 502 | { 503 | my_bool maybe_null; /* 1 if function can return NULL */ 504 | unsigned int decimals; /* for real functions */ 505 | unsigned long max_length; /* For string functions */ 506 | char *ptr; /* free pointer for function data */ 507 | my_bool const_item; /* 1 if function always returns the same value */ 508 | void *extension; 509 | } UDF_INIT; 510 | /* 511 | TODO: add a notion for determinism of the UDF. 512 | See Item_udf_func::update_used_tables () 513 | */ 514 | 515 | /* Constants when using compression */ 516 | #define NET_HEADER_SIZE 4 /* standard header size */ 517 | #define COMP_HEADER_SIZE 3 /* compression header extra size */ 518 | 519 | /* Prototypes to password functions */ 520 | 521 | #ifdef __cplusplus 522 | extern "C" { 523 | #endif 524 | 525 | /* 526 | These functions are used for authentication by client and server and 527 | implemented in sql/password.c 528 | */ 529 | 530 | void randominit(struct rand_struct *, unsigned long seed1, 531 | unsigned long seed2); 532 | double my_rnd(struct rand_struct *); 533 | void create_random_string(char *to, unsigned int length, struct rand_struct *rand_st); 534 | 535 | void hash_password(unsigned long *to, const char *password, unsigned int password_len); 536 | void make_scrambled_password_323(char *to, const char *password); 537 | void scramble_323(char *to, const char *message, const char *password); 538 | my_bool check_scramble_323(const unsigned char *reply, const char *message, 539 | unsigned long *salt); 540 | void get_salt_from_password_323(unsigned long *res, const char *password); 541 | void make_password_from_salt_323(char *to, const unsigned long *salt); 542 | 543 | void make_scrambled_password(char *to, const char *password); 544 | void scramble(char *to, const char *message, const char *password); 545 | my_bool check_scramble(const unsigned char *reply, const char *message, 546 | const unsigned char *hash_stage2); 547 | void get_salt_from_password(unsigned char *res, const char *password); 548 | void make_password_from_salt(char *to, const unsigned char *hash_stage2); 549 | char *octet2hex(char *to, const char *str, unsigned int len); 550 | 551 | /* end of password.c */ 552 | 553 | char *get_tty_password(const char *opt_message); 554 | const char *mysql_errno_to_sqlstate(unsigned int mysql_errno); 555 | 556 | /* Some other useful functions */ 557 | 558 | my_bool my_thread_init(void); 559 | void my_thread_end(void); 560 | 561 | #ifdef _global_h 562 | ulong STDCALL net_field_length(uchar **packet); 563 | my_ulonglong net_field_length_ll(uchar **packet); 564 | uchar *net_store_length(uchar *pkg, ulonglong length); 565 | #endif 566 | 567 | #ifdef __cplusplus 568 | } 569 | #endif 570 | 571 | #define NULL_LENGTH ((unsigned long) ~0) /* For net_store_length */ 572 | #define MYSQL_STMT_HEADER 4 573 | #define MYSQL_LONG_DATA_HEADER 6 574 | 575 | #define NOT_FIXED_DEC 31 576 | #endif -------------------------------------------------------------------------------- /mysql/include/mysql_time.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2004 MySQL AB 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License as published by 5 | the Free Software Foundation; version 2 of the License. 6 | 7 | This program is distributed in the hope that it will be useful, 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | GNU General Public License for more details. 11 | 12 | You should have received a copy of the GNU General Public License 13 | along with this program; if not, write to the Free Software 14 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 15 | 16 | #ifndef _mysql_time_h_ 17 | #define _mysql_time_h_ 18 | 19 | /* 20 | Time declarations shared between the server and client API: 21 | you should not add anything to this header unless it's used 22 | (and hence should be visible) in mysql.h. 23 | If you're looking for a place to add new time-related declaration, 24 | it's most likely my_time.h. See also "C API Handling of Date 25 | and Time Values" chapter in documentation. 26 | */ 27 | 28 | enum enum_mysql_timestamp_type 29 | { 30 | MYSQL_TIMESTAMP_NONE= -2, MYSQL_TIMESTAMP_ERROR= -1, 31 | MYSQL_TIMESTAMP_DATE= 0, MYSQL_TIMESTAMP_DATETIME= 1, MYSQL_TIMESTAMP_TIME= 2 32 | }; 33 | 34 | 35 | /* 36 | Structure which is used to represent datetime values inside MySQL. 37 | 38 | We assume that values in this structure are normalized, i.e. year <= 9999, 39 | month <= 12, day <= 31, hour <= 23, hour <= 59, hour <= 59. Many functions 40 | in server such as my_system_gmt_sec() or make_time() family of functions 41 | rely on this (actually now usage of make_*() family relies on a bit weaker 42 | restriction). Also functions that produce MYSQL_TIME as result ensure this. 43 | There is one exception to this rule though if this structure holds time 44 | value (time_type == MYSQL_TIMESTAMP_TIME) days and hour member can hold 45 | bigger values. 46 | */ 47 | typedef struct st_mysql_time 48 | { 49 | unsigned int year, month, day, hour, minute, second; 50 | unsigned long second_part; 51 | my_bool neg; 52 | enum enum_mysql_timestamp_type time_type; 53 | } MYSQL_TIME; 54 | 55 | #endif /* _mysql_time_h_ */ -------------------------------------------------------------------------------- /mysql/include/mysql_version.h: -------------------------------------------------------------------------------- 1 | /* Copyright Abandoned 1996, 1999, 2001 MySQL AB 2 | This file is public domain and comes with NO WARRANTY of any kind */ 3 | 4 | /* Version numbers for protocol & mysqld */ 5 | 6 | #ifndef _mysql_version_h 7 | #define _mysql_version_h 8 | #ifdef _CUSTOMCONFIG_ 9 | #include 10 | #else 11 | #define PROTOCOL_VERSION 10 12 | #define MYSQL_SERVER_VERSION "5.5.25" 13 | #define MYSQL_BASE_VERSION "mysqld-5.5" 14 | #define MYSQL_SERVER_SUFFIX_DEF "" 15 | #define FRM_VER 6 16 | #define MYSQL_VERSION_ID 50525 17 | #define MYSQL_PORT 3306 18 | #define MYSQL_PORT_DEFAULT 0 19 | #define MYSQL_UNIX_ADDR "/tmp/mysql.sock" 20 | #define MYSQL_CONFIG_NAME "my" 21 | #define MYSQL_COMPILATION_COMMENT "Source distribution" 22 | 23 | /* mysqld compile time options */ 24 | #endif /* _CUSTOMCONFIG_ */ 25 | 26 | #ifndef LICENSE 27 | #define LICENSE GPL 28 | #endif /* LICENSE */ 29 | 30 | #endif /* _mysql_version_h */ -------------------------------------------------------------------------------- /mysql/include/typelib.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. 2 | 3 | This program is free software; you can redistribute it and/or modify 4 | it under the terms of the GNU General Public License as published by 5 | the Free Software Foundation; version 2 of the License. 6 | 7 | This program is distributed in the hope that it will be useful, 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | GNU General Public License for more details. 11 | 12 | You should have received a copy of the GNU General Public License 13 | along with this program; if not, write to the Free Software 14 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 15 | 16 | 17 | #ifndef _typelib_h 18 | #define _typelib_h 19 | 20 | #include "my_alloc.h" 21 | 22 | typedef struct st_typelib { /* Different types saved here */ 23 | unsigned int count; /* How many types */ 24 | const char *name; /* Name of typelib */ 25 | const char **type_names; 26 | unsigned int *type_lengths; 27 | } TYPELIB; 28 | 29 | extern my_ulonglong find_typeset(char *x, TYPELIB *typelib,int *error_position); 30 | extern int find_type_or_exit(const char *x, TYPELIB *typelib, 31 | const char *option); 32 | #define FIND_TYPE_BASIC 0 33 | /** makes @c find_type() require the whole name, no prefix */ 34 | #define FIND_TYPE_NO_PREFIX (1 << 0) 35 | /** always implicitely on, so unused, but old code may pass it */ 36 | #define FIND_TYPE_NO_OVERWRITE (1 << 1) 37 | /** makes @c find_type() accept a number */ 38 | #define FIND_TYPE_ALLOW_NUMBER (1 << 2) 39 | /** makes @c find_type() treat ',' as terminator */ 40 | #define FIND_TYPE_COMMA_TERM (1 << 3) 41 | 42 | extern int find_type(const char *x, const TYPELIB *typelib, unsigned int flags); 43 | extern void make_type(char *to,unsigned int nr,TYPELIB *typelib); 44 | extern const char *get_type(TYPELIB *typelib,unsigned int nr); 45 | extern TYPELIB *copy_typelib(MEM_ROOT *root, TYPELIB *from); 46 | 47 | extern TYPELIB sql_protocol_typelib; 48 | 49 | my_ulonglong find_set_from_flags(const TYPELIB *lib, unsigned int default_name, 50 | my_ulonglong cur_set, my_ulonglong default_set, 51 | const char *str, unsigned int length, 52 | char **err_pos, unsigned int *err_len); 53 | 54 | #endif /* _typelib_h */ -------------------------------------------------------------------------------- /mysql/lib/libmysql.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/mysql/lib/libmysql.lib -------------------------------------------------------------------------------- /mysql/lib/mysqlclient.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/mysql/lib/mysqlclient.lib -------------------------------------------------------------------------------- /qt_basictool/CompleteLineEdit.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/qt_basictool/CompleteLineEdit.cpp -------------------------------------------------------------------------------- /qt_basictool/CompleteLineEdit.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/qt_basictool/CompleteLineEdit.h -------------------------------------------------------------------------------- /talib/include/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | bin_PRORAMS = libta_include 3 | 4 | libta_includedir=$(includedir)/ta-lib/ 5 | 6 | libta_include_HEADERS = ta_abstract.h 7 | ta_defs.h \ 8 | ta_libc.h \ 9 | ta_common.h \ 10 | ta_func.h \ 11 | func_list.txt 12 | -------------------------------------------------------------------------------- /talib/include/ta_abstract.h: -------------------------------------------------------------------------------- 1 | /* TA-LIB Copyright (c) 1999-2007, Mario Fortier 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or 5 | * without modification, are permitted provided that the following 6 | * conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * - Neither name of author nor the names of its contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 30 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | #ifndef TA_ABSTRACT_H 35 | #define TA_ABSTRACT_H 36 | 37 | #ifndef TA_COMMON_H 38 | #include "ta_common.h" 39 | #endif 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | /* This file defines the interface for calling all the TA functions without 46 | * knowing at priori the parameters. 47 | * 48 | * This capability is particularly useful for an application who needs 49 | * to support the complete list of TA functions without having to 50 | * re-write new code each time a new function is added to TA-Lib. 51 | * 52 | * Example 1: 53 | * Lets say you are doing a charting software. When the user select 54 | * a price bar, a side list offers blindly all the TA functions 55 | * that could be applied to a price bar. The user selects one of 56 | * these, then a dialog open for allowing to adjust some parameter 57 | * (TA-LIB will tell your software which parameter are needed and the 58 | * valid range for each). Once all the parameter are set, you can 59 | * call blindly the corresponding TA function. The returned 60 | * information can then also blindly be drawn on the chart (some 61 | * output flags allows to get some hint about how the data shall be 62 | * displayed). 63 | * The same "abstract" logic apply to all the TA functions. 64 | * Some TA Functions works only on volume, or can work indiferently 65 | * with any time serie data (the open, close, another indicator...). 66 | * All the applicable functions to the currently selected/available 67 | * data can be determined through this "virtual" interface. 68 | * 69 | * Example 2: 70 | * Let's say you do not like the direct interface for 71 | * calling the TA Functions, you can write a code that 72 | * re-generate a different interface. This is already 73 | * done even for the 'C' interface (ta_func.h is generated). 74 | * 75 | * Example 3: 76 | * With the abstract interface you can easily generate 77 | * glue code. Like generating an interface that integrates 78 | * well within Perl... see the project SWIG if you are 79 | * interested by such things. 80 | * 81 | * The abstract interface is used within TA-Lib to perform at least 82 | * the following: 83 | * - used by gen_code to generate all the glue code. 84 | * - used by the Excel interface to call all the TA functions. 85 | * - used to generate a XML representation of the TA functions. 86 | */ 87 | 88 | /* The following functions are used to obtain the name of all the 89 | * TA function groups ("Market Strength", "Trend Indicator" etc...). 90 | * 91 | * On success, it becomes the responsibility of the caller to 92 | * call TA_GroupTableFree once the 'table' is no longuer needed. 93 | * 94 | * Example: 95 | * This code snippet will print out the name of all the supported 96 | * function group available: 97 | * 98 | * TA_StringTable *table; 99 | * TA_RetCode retCode; 100 | * int i; 101 | * 102 | * retCode = TA_GroupTableAlloc( &table ); 103 | * 104 | * if( retCode == TA_SUCCESS ) 105 | * { 106 | * for( i=0; i < table->size; i++ ) 107 | * printf( "%s\n", table->string[i] ); 108 | * 109 | * TA_GroupTableFree( table ); 110 | * } 111 | */ 112 | TA_RetCode TA_GroupTableAlloc( TA_StringTable **table ); 113 | TA_RetCode TA_GroupTableFree ( TA_StringTable *table ); 114 | 115 | /* The following functions are used to obtain the name of all the 116 | * function provided in a certain group. 117 | * 118 | * On success, it becomes the responsibility of the caller to 119 | * call TA_FuncTableFree once the 'table' is no longuer needed. 120 | * 121 | * Passing NULL as the group string will return ALL the TA functions. 122 | * (Note: All TA_Functions have a unique string identifier even when in 123 | * seperate group). 124 | * 125 | * Example: 126 | * This code snippet will print out the name of all the supported 127 | * function in the "market strength" category: 128 | * 129 | * TA_StringTable *table; 130 | * TA_RetCode retCode; 131 | * int i; 132 | * 133 | * retCode = TA_FuncTableAlloc( "Market Strength", &table ); 134 | * 135 | * if( retCode == TA_SUCCESS ) 136 | * { 137 | * for( i=0; i < table->size; i++ ) 138 | * printf( "%s\n", table->string[i] ); 139 | * 140 | * TA_FuncTableFree( table ); 141 | * } 142 | */ 143 | TA_RetCode TA_FuncTableAlloc( const char *group, TA_StringTable **table ); 144 | TA_RetCode TA_FuncTableFree ( TA_StringTable *table ); 145 | 146 | /* Using the name, you can obtain an handle unique to this function. 147 | * This handle is further used for obtaining information on the 148 | * parameters needed and also for potentially calling this TA function. 149 | * 150 | * For convenience, this handle can also be found in 151 | * the TA_FuncInfo structure (see below). 152 | */ 153 | typedef unsigned int TA_FuncHandle; 154 | TA_RetCode TA_GetFuncHandle( const char *name, 155 | const TA_FuncHandle **handle ); 156 | 157 | /* Get some basic information about a function. 158 | * 159 | * A const pointer will be set on the corresponding TA_FuncInfo structure. 160 | * The whole structure are hard coded constants and it can be assumed they 161 | * will not change at runtime. 162 | * 163 | * Example: 164 | * Print the number of inputs used by the MA (moving average) function. 165 | * 166 | * TA_RetCode retCode; 167 | * TA_FuncHandle *handle; 168 | * const TA_FuncInfo *theInfo; 169 | * 170 | * retCode = TA_GetFuncHandle( "MA", &handle ); 171 | * 172 | * if( retCode == TA_SUCCESS ) 173 | * { 174 | * retCode = TA_GetFuncInfo( handle, &theInfo ); 175 | * if( retCode == TA_SUCCESS ) 176 | * printf( "Nb Input = %d\n", theInfo->nbInput ); 177 | * } 178 | * 179 | */ 180 | typedef int TA_FuncFlags; 181 | #define TA_FUNC_FLG_OVERLAP 0x01000000 /* Output scale same as input data. */ 182 | #define TA_FUNC_FLG_VOLUME 0x04000000 /* Output shall be over the volume data. */ 183 | #define TA_FUNC_FLG_UNST_PER 0x08000000 /* Indicate if this function have an unstable 184 | * initial period. Some additional code exist 185 | * for these functions for allowing to set that 186 | * unstable period. See Documentation. 187 | */ 188 | #define TA_FUNC_FLG_CANDLESTICK 0x10000000 /* Output shall be a candlestick */ 189 | 190 | typedef struct TA_FuncInfo 191 | { 192 | /* Constant information about the function. The 193 | * information found in this structure is guarantee 194 | * to not change at runtime. 195 | */ 196 | const char * name; 197 | const char * group; 198 | 199 | const char * hint; 200 | const char * camelCaseName; 201 | TA_FuncFlags flags; 202 | 203 | unsigned int nbInput; 204 | unsigned int nbOptInput; 205 | unsigned int nbOutput; 206 | 207 | const TA_FuncHandle *handle; 208 | } TA_FuncInfo; 209 | 210 | TA_RetCode TA_GetFuncInfo( const TA_FuncHandle *handle, 211 | const TA_FuncInfo **funcInfo ); 212 | 213 | 214 | /* An alternate way to access all the functions is through the 215 | * use of the TA_ForEachFunc(). You can setup a function to be 216 | * call back for each TA function in the TA-Lib. 217 | * 218 | * Example: 219 | * This code will print the group and name of all available functions. 220 | * 221 | * void printFuncInfo( const TA_FuncInfo *funcInfo, void *opaqueData ) 222 | * { 223 | * printf( "Group=%s Name=%s\n", funcInfo->group, funcInfo->name ); 224 | * } 225 | * 226 | * void displayListOfTAFunctions( void ) 227 | * { 228 | * TA_ForEachFunc( printFuncInfo, NULL ); 229 | * } 230 | */ 231 | typedef void (*TA_CallForEachFunc)(const TA_FuncInfo *funcInfo, void *opaqueData ); 232 | 233 | TA_RetCode TA_ForEachFunc( TA_CallForEachFunc functionToCall, void *opaqueData ); 234 | 235 | /* The next section includes the data structures and function allowing to 236 | * proceed with the call of a Tech. Analysis function. 237 | * 238 | * At first, it may seems a little bit complicated, but it is worth to take the 239 | * effort to learn about it. Once you succeed to interface with TA-Abstract you get 240 | * access to the complete library of TA functions at once without further effort. 241 | */ 242 | 243 | /* Structures representing extended information on a parameter. */ 244 | 245 | typedef struct TA_RealRange 246 | { 247 | TA_Real min; 248 | TA_Real max; 249 | TA_Integer precision; /* nb of digit after the '.' */ 250 | 251 | /* The following suggested value are used by Tech. Analysis software 252 | * doing parameter "optimization". Can be ignored by most user. 253 | */ 254 | TA_Real suggested_start; 255 | TA_Real suggested_end; 256 | TA_Real suggested_increment; 257 | } TA_RealRange; 258 | 259 | typedef struct TA_IntegerRange 260 | { 261 | TA_Integer min; 262 | TA_Integer max; 263 | 264 | /* The following suggested value are used by Tech. Analysis software 265 | * doing parameter "optimization". Can be ignored by most user. 266 | */ 267 | TA_Integer suggested_start; 268 | TA_Integer suggested_end; 269 | TA_Integer suggested_increment; 270 | } TA_IntegerRange; 271 | 272 | typedef struct TA_RealDataPair 273 | { 274 | /* A TA_Real value and the corresponding string. */ 275 | TA_Real value; 276 | const char *string; 277 | } TA_RealDataPair; 278 | 279 | typedef struct TA_IntegerDataPair 280 | { 281 | /* A TA_Integer value and the corresponding string. */ 282 | TA_Integer value; 283 | const char *string; 284 | } TA_IntegerDataPair; 285 | 286 | typedef struct TA_RealList 287 | { 288 | const TA_RealDataPair *data; 289 | unsigned int nbElement; 290 | } TA_RealList; 291 | 292 | typedef struct TA_IntegerList 293 | { 294 | const TA_IntegerDataPair *data; 295 | unsigned int nbElement; 296 | } TA_IntegerList; 297 | 298 | typedef enum 299 | { 300 | TA_Input_Price, 301 | TA_Input_Real, 302 | TA_Input_Integer 303 | } TA_InputParameterType; 304 | 305 | typedef enum 306 | { 307 | TA_OptInput_RealRange, 308 | TA_OptInput_RealList, 309 | TA_OptInput_IntegerRange, 310 | TA_OptInput_IntegerList 311 | } TA_OptInputParameterType; 312 | 313 | typedef enum 314 | { 315 | TA_Output_Real, 316 | TA_Output_Integer 317 | } TA_OutputParameterType; 318 | 319 | /* When the input is a TA_Input_Price, the following 320 | * TA_InputFlags indicates the required components. 321 | * These can be combined for functions requiring more 322 | * than one component. 323 | * 324 | * Example: 325 | * (TA_IN_PRICE_OPEN|TA_IN_PRICE_HIGH) 326 | * Indicates that the functions requires two inputs 327 | * that must be specifically the open and the high. 328 | */ 329 | typedef int TA_InputFlags; 330 | #define TA_IN_PRICE_OPEN 0x00000001 331 | #define TA_IN_PRICE_HIGH 0x00000002 332 | #define TA_IN_PRICE_LOW 0x00000004 333 | #define TA_IN_PRICE_CLOSE 0x00000008 334 | #define TA_IN_PRICE_VOLUME 0x00000010 335 | #define TA_IN_PRICE_OPENINTEREST 0x00000020 336 | #define TA_IN_PRICE_TIMESTAMP 0x00000040 337 | 338 | /* The following are flags for optional inputs. 339 | * 340 | * TA_OPTIN_IS_PERCENT: Input is a percentage. 341 | * 342 | * TA_OPTIN_IS_DEGREE: Input is a degree (0-360). 343 | * 344 | * TA_OPTIN_IS_CURRENCY: Input is a currency. 345 | * 346 | * TA_OPTIN_ADVANCED: 347 | * Used for parameters who are rarely changed. 348 | * Most application can hide these advanced optional inputs to their 349 | * end-user (or make it harder to change). 350 | */ 351 | typedef int TA_OptInputFlags; 352 | #define TA_OPTIN_IS_PERCENT 0x00100000 /* Input is a percentage. */ 353 | #define TA_OPTIN_IS_DEGREE 0x00200000 /* Input is a degree (0-360). */ 354 | #define TA_OPTIN_IS_CURRENCY 0x00400000 /* Input is a currency. */ 355 | #define TA_OPTIN_ADVANCED 0x01000000 356 | 357 | 358 | /* The following are flags giving hint on what 359 | * could be done with the output. 360 | */ 361 | typedef int TA_OutputFlags; 362 | #define TA_OUT_LINE 0x00000001 /* Suggest to display as a connected line. */ 363 | #define TA_OUT_DOT_LINE 0x00000002 /* Suggest to display as a 'dotted' line. */ 364 | #define TA_OUT_DASH_LINE 0x00000004 /* Suggest to display as a 'dashed' line. */ 365 | #define TA_OUT_DOT 0x00000008 /* Suggest to display with dots only. */ 366 | #define TA_OUT_HISTO 0x00000010 /* Suggest to display as an histogram. */ 367 | #define TA_OUT_PATTERN_BOOL 0x00000020 /* Indicates if pattern exists (!=0) or not (0) */ 368 | #define TA_OUT_PATTERN_BULL_BEAR 0x00000040 /* =0 no pattern, > 0 bullish, < 0 bearish */ 369 | #define TA_OUT_PATTERN_STRENGTH 0x00000080 /* =0 neutral, ]0..100] getting bullish, ]100..200] bullish, [-100..0[ getting bearish, [-200..100[ bearish */ 370 | #define TA_OUT_POSITIVE 0x00000100 /* Output can be positive */ 371 | #define TA_OUT_NEGATIVE 0x00000200 /* Output can be negative */ 372 | #define TA_OUT_ZERO 0x00000400 /* Output can be zero */ 373 | #define TA_OUT_UPPER_LIMIT 0x00000800 /* Indicates that the values represent an upper limit. */ 374 | #define TA_OUT_LOWER_LIMIT 0x00001000 /* Indicates that the values represent a lower limit. */ 375 | 376 | 377 | /* The following 3 structures will exist for each input, optional 378 | * input and output. 379 | * 380 | * These structures tells you everything you need to know for identifying 381 | * the parameters applicable to the function. 382 | */ 383 | typedef struct TA_InputParameterInfo 384 | { 385 | TA_InputParameterType type; 386 | const char *paramName; 387 | TA_InputFlags flags; 388 | 389 | } TA_InputParameterInfo; 390 | 391 | typedef struct TA_OptInputParameterInfo 392 | { 393 | TA_OptInputParameterType type; 394 | const char *paramName; 395 | TA_OptInputFlags flags; 396 | 397 | const char *displayName; 398 | const void *dataSet; 399 | TA_Real defaultValue; 400 | const char *hint; 401 | const char *helpFile; 402 | 403 | } TA_OptInputParameterInfo; 404 | 405 | typedef struct TA_OutputParameterInfo 406 | { 407 | TA_OutputParameterType type; 408 | const char *paramName; 409 | TA_OutputFlags flags; 410 | 411 | } TA_OutputParameterInfo; 412 | 413 | /* Functions to get a const ptr on the "TA_XXXXXXParameterInfo". 414 | * Max value for the 'paramIndex' can be found in the TA_FuncInfo structure. 415 | * The 'handle' can be obtained from TA_GetFuncHandle or from a TA_FuncInfo. 416 | * 417 | * Short example: 418 | * 419 | * void displayInputType( const TA_FuncInfo *funcInfo ) 420 | * { 421 | * unsigned int i; 422 | * const TA_InputParameterInfo *paramInfo; 423 | * 424 | * for( i=0; i < funcInfo->nbInput; i++ ) 425 | * { 426 | * TA_GetInputParameterInfo( funcInfo->handle, i, ¶mInfo ); 427 | * switch( paramInfo->type ) 428 | * { 429 | * case TA_Input_Price: 430 | * printf( "This function needs price bars as input\n" ); 431 | * break; 432 | * case TA_Input_Real: 433 | * printf( "This function needs an array of floats as input\n" ); 434 | * break; 435 | * (... etc. ...) 436 | * } 437 | * } 438 | * } 439 | */ 440 | TA_RetCode TA_GetInputParameterInfo( const TA_FuncHandle *handle, 441 | unsigned int paramIndex, 442 | const TA_InputParameterInfo **info ); 443 | 444 | TA_RetCode TA_GetOptInputParameterInfo( const TA_FuncHandle *handle, 445 | unsigned int paramIndex, 446 | const TA_OptInputParameterInfo **info ); 447 | 448 | TA_RetCode TA_GetOutputParameterInfo( const TA_FuncHandle *handle, 449 | unsigned int paramIndex, 450 | const TA_OutputParameterInfo **info ); 451 | 452 | /* Alloc a structure allowing to build the list of parameters 453 | * for doing a call. 454 | * 455 | * All input and output parameters must be setup. If not, TA_BAD_PARAM 456 | * will be returned when TA_CallFunc is called. 457 | * 458 | * The optional input are not required to be setup. A default value 459 | * will always be used in that case. 460 | * 461 | * If there is an attempts to set a parameter with the wrong function 462 | * (and thus the wrong type), TA_BAD_PARAM will be immediatly returned. 463 | * 464 | * Although this mechanism looks complicated, it is written for being fairly solid. 465 | * If you provide a wrong parameter value, or wrong type, or wrong pointer etc. the 466 | * library shall return TA_BAD_PARAM or TA_BAD_OBJECT and not hang. 467 | */ 468 | typedef struct TA_ParamHolder 469 | { 470 | /* Implementation is hidden. */ 471 | void *hiddenData; 472 | } TA_ParamHolder; 473 | 474 | TA_RetCode TA_ParamHolderAlloc( const TA_FuncHandle *handle, 475 | TA_ParamHolder **allocatedParams ); 476 | 477 | TA_RetCode TA_ParamHolderFree( TA_ParamHolder *params ); 478 | 479 | /* Setup the values of the data input parameters. 480 | * 481 | * paramIndex is zero for the first input. 482 | */ 483 | TA_RetCode TA_SetInputParamIntegerPtr( TA_ParamHolder *params, 484 | unsigned int paramIndex, 485 | const TA_Integer *value ); 486 | 487 | TA_RetCode TA_SetInputParamRealPtr( TA_ParamHolder *params, 488 | unsigned int paramIndex, 489 | const TA_Real *value ); 490 | 491 | TA_RetCode TA_SetInputParamPricePtr( TA_ParamHolder *params, 492 | unsigned int paramIndex, 493 | const TA_Real *open, 494 | const TA_Real *high, 495 | const TA_Real *low, 496 | const TA_Real *close, 497 | const TA_Real *volume, 498 | const TA_Real *openInterest ); 499 | 500 | /* Setup the values of the optional input parameters. 501 | * If an optional input is not set, a default value will be used. 502 | * 503 | * paramIndex is zero for the first optional input. 504 | */ 505 | TA_RetCode TA_SetOptInputParamInteger( TA_ParamHolder *params, 506 | unsigned int paramIndex, 507 | TA_Integer optInValue ); 508 | 509 | TA_RetCode TA_SetOptInputParamReal( TA_ParamHolder *params, 510 | unsigned int paramIndex, 511 | TA_Real optInValue ); 512 | 513 | /* Setup the parameters indicating where to store the output. 514 | * 515 | * The caller is responsible to allocate sufficient memory. A safe bet is to 516 | * always do: nb of output elements == (endIdx-startIdx+1) 517 | * 518 | * paramIndex is zero for the first output. 519 | * 520 | */ 521 | TA_RetCode TA_SetOutputParamIntegerPtr( TA_ParamHolder *params, 522 | unsigned int paramIndex, 523 | TA_Integer *out ); 524 | 525 | TA_RetCode TA_SetOutputParamRealPtr( TA_ParamHolder *params, 526 | unsigned int paramIndex, 527 | TA_Real *out ); 528 | 529 | /* Once the optional parameter are set, it is possible to 530 | * get the lookback for this call. This information can be 531 | * used to calculate the optimal size for the output buffers. 532 | * (See the documentation for method to calculate the output size). 533 | */ 534 | TA_RetCode TA_GetLookback( const TA_ParamHolder *params, 535 | TA_Integer *lookback ); 536 | 537 | /* Finally, call the TA function with the parameters. 538 | * 539 | * The TA function who is going to be called was specified 540 | * when the TA_ParamHolderAlloc was done. 541 | */ 542 | TA_RetCode TA_CallFunc( const TA_ParamHolder *params, 543 | TA_Integer startIdx, 544 | TA_Integer endIdx, 545 | TA_Integer *outBegIdx, 546 | TA_Integer *outNbElement ); 547 | 548 | 549 | /* Return XML representation of all the TA functions. 550 | * The returned array is the same as the ta_func_api.xml file. 551 | */ 552 | const char *TA_FunctionDescriptionXML( void ); 553 | 554 | #ifdef __cplusplus 555 | } 556 | #endif 557 | 558 | #endif 559 | 560 | -------------------------------------------------------------------------------- /talib/include/ta_common.h: -------------------------------------------------------------------------------- 1 | /* TA-LIB Copyright (c) 1999-2007, Mario Fortier 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or 5 | * without modification, are permitted provided that the following 6 | * conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * - Neither name of author nor the names of its contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 30 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | #ifndef TA_COMMON_H 34 | #define TA_COMMON_H 35 | 36 | /* The following macros are used to return internal errors. 37 | * The Id can be from 1 to 999 and translate to the user 38 | * as the return code 5000 to 5999. 39 | * 40 | * Everytime you wish to add a new fatal error code, 41 | * use the "NEXT AVAILABLE NUMBER" and increment the 42 | * number in this file. 43 | * 44 | * NEXT AVAILABLE NUMBER: 181 45 | */ 46 | #define TA_INTERNAL_ERROR(Id) ((TA_RetCode)(TA_INTERNAL_ERROR+Id)) 47 | 48 | #ifdef __cplusplus 49 | extern "C" { 50 | #endif 51 | 52 | #include 53 | #include 54 | #include 55 | 56 | #ifndef TA_DEFS_H 57 | #include "ta_defs.h" 58 | #endif 59 | 60 | /* Some functions to get the version of TA-Lib. 61 | * 62 | * Format is "Major.Minor.Patch (Month Day Year Hour:Min:Sec)" 63 | * 64 | * Example: "1.2.0 (Jan 17 2004 23:59:59)" 65 | * 66 | * Major increments indicates an "Highly Recommended" update. 67 | * 68 | * Minor increments indicates arbitrary milestones in the 69 | * development of the next major version. 70 | * 71 | * Patch are fixes to a "Major.Minor" release. 72 | */ 73 | const char *TA_GetVersionString( void ); 74 | 75 | /* Get individual component of the Version string */ 76 | const char *TA_GetVersionMajor ( void ); 77 | const char *TA_GetVersionMinor ( void ); 78 | const char *TA_GetVersionBuild ( void ); 79 | const char *TA_GetVersionDate ( void ); 80 | const char *TA_GetVersionTime ( void ); 81 | 82 | /* Misc. declaration used throughout the library code. */ 83 | typedef double TA_Real; 84 | typedef int TA_Integer; 85 | 86 | /* General purpose structure containing an array of string. 87 | * 88 | * Example of usage: 89 | * void printStringTable( TA_StringTable *table ) 90 | * { 91 | * int i; 92 | * for( i=0; i < table->size; i++ ) 93 | * cout << table->string[i] << endl; 94 | * } 95 | * 96 | */ 97 | typedef struct TA_StringTable 98 | { 99 | unsigned int size; /* Number of string. */ 100 | const char **string; /* Pointer to the strings. */ 101 | 102 | /* Hidden data for internal use by TA-Lib. Do not modify. */ 103 | void *hiddenData; 104 | } TA_StringTable; 105 | /* End-user can get additional information related to a TA_RetCode. 106 | * 107 | * Example: 108 | * TA_RetCodeInfo info; 109 | * 110 | * retCode = TA_Initialize( ... ); 111 | * 112 | * if( retCode != TA_SUCCESS ) 113 | * { 114 | * TA_SetRetCodeInfo( retCode, &info ); 115 | * printf( "Error %d(%s): %s\n", 116 | * retCode, 117 | * info.enumStr, 118 | * info.infoStr ); 119 | * } 120 | * 121 | * Would display: 122 | * "Error 1(TA_LIB_NOT_INITIALIZE): TA_Initialize was not sucessfully called" 123 | */ 124 | typedef struct TA_RetCodeInfo 125 | { 126 | const char *enumStr; /* Like "TA_IP_SOCKETERROR" */ 127 | const char *infoStr; /* Like "Error creating socket" */ 128 | } TA_RetCodeInfo; 129 | 130 | /* Info is always returned, even when 'theRetCode' is invalid. */ 131 | void TA_SetRetCodeInfo( TA_RetCode theRetCode, TA_RetCodeInfo *retCodeInfo ); 132 | 133 | /* TA_Initialize() initialize the ressources used by TA-Lib. This 134 | * function must be called once prior to any other functions declared in 135 | * this file. 136 | * 137 | * TA_Shutdown() allows to free all ressources used by TA-Lib. Following 138 | * a shutdown, TA_Initialize() must be called again for re-using TA-Lib. 139 | * 140 | * TA_Shutdown() should be called prior to exiting the application code. 141 | */ 142 | TA_RetCode TA_Initialize( void ); 143 | TA_RetCode TA_Shutdown( void ); 144 | 145 | #ifdef __cplusplus 146 | } 147 | #endif 148 | 149 | #endif 150 | -------------------------------------------------------------------------------- /talib/include/ta_defs.h: -------------------------------------------------------------------------------- 1 | /* TA-LIB Copyright (c) 1999-2007, Mario Fortier 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or 5 | * without modification, are permitted provided that the following 6 | * conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * - Neither name of author nor the names of its contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 30 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | #ifndef TA_DEFS_H 34 | #define TA_DEFS_H 35 | 36 | /*** The following block of code is to define: 37 | *** 38 | *** UInt32 : 32 bits unsigned integer. 39 | *** Int32 : 32 bits signed integer. 40 | *** UInt64 : 64 bits unsigned integer. 41 | *** Int64 : 64 bits signed integer. 42 | *** 43 | *** INT_MIN : The minimal value for Int32 44 | *** INT_MAX : The maximal value for Int32 45 | ***/ 46 | #ifndef FD_DEFS_H 47 | #if defined( _MANAGED ) 48 | /* Int32, UInt32, Int64 and UInt64 are built-in for .NET */ 49 | #define INT_MIN (Int32::MinValue) 50 | #define INT_MAX (Int32::MaxValue) 51 | #elif defined( _JAVA ) 52 | #define INT_MIN Integer.MIN_VALUE 53 | #define INT_MAX Integer.MAX_VALUE 54 | #else 55 | #include 56 | 57 | /* Identify if 64 bits platform with __64BIT__. 58 | * Can also be done from compiler command line. 59 | */ 60 | #if defined(_WIN64) 61 | #define __64BIT__ 1 62 | #endif 63 | 64 | #if defined( __LP64__ ) || defined( _LP64 ) 65 | #define __64BIT__ 1 66 | #endif 67 | 68 | /* Check also for some known GCC def for 64 bits platform. */ 69 | #if defined(__alpha__)\ 70 | ||defined(__ia64__)\ 71 | ||defined(__ppc64__)\ 72 | ||defined(__s390x__)\ 73 | ||defined(__x86_64__) 74 | #define __64BIT__ 1 75 | #endif 76 | 77 | #if !defined(__MACTYPES__) 78 | typedef signed int Int32; 79 | typedef unsigned int UInt32; 80 | 81 | #if defined(_WIN32) || defined(_WIN64) 82 | /* See "Windows Data Types". Platform SDK. MSDN documentation. */ 83 | typedef signed __int64 Int64; 84 | typedef unsigned __int64 UInt64; 85 | #else 86 | #if defined(__64BIT__) 87 | /* Standard LP64 model for 64 bits Unix platform. */ 88 | typedef signed long Int64; 89 | typedef unsigned long UInt64; 90 | #else 91 | /* Standard ILP32 model for 32 bits Unix platform. */ 92 | typedef signed long long Int64; 93 | typedef unsigned long long UInt64; 94 | #endif 95 | #endif 96 | #endif 97 | #endif 98 | #endif 99 | 100 | /* Enumeration and macros to abstract syntax differences 101 | * between C, C++, managed C++ and Java. 102 | */ 103 | #if defined( _MANAGED ) 104 | 105 | /* CMJ is the "CManagedJava" macro. It allows to write variant 106 | * for the 3 different languages. 107 | */ 108 | #define CMJ(c,managed,java) managed 109 | 110 | /* Enumeration abstraction */ 111 | #define ENUM_BEGIN(w) enum class w { 112 | #define ENUM_DEFINE(x,y) y 113 | #define ENUM_VALUE(w,x,y) (w::y) 114 | #define ENUM_CASE(w,x,y) (w::y) 115 | #define ENUM_DECLARATION(w) w 116 | #define ENUM_END(w) }; 117 | 118 | /* Structure abstraction */ 119 | #define STRUCT_BEGIN(x) struct x { 120 | #define STRUCT_END(x) }; 121 | 122 | /* Pointer/reference abstraction */ 123 | #define VALUE_HANDLE_INT(name) int name 124 | #define VALUE_HANDLE_DEREF(name) name 125 | #define VALUE_HANDLE_DEREF_TO_ZERO(name) name = 0 126 | #define VALUE_HANDLE_OUT(name) name 127 | 128 | #define VALUE_HANDLE_GET(name) name 129 | #define VALUE_HANDLE_SET(name,x) name = x 130 | 131 | /* Misc. */ 132 | #define CONSTANT_DOUBLE(x) const double x 133 | #define NAMESPACE(x) x:: 134 | #define UNUSED_VARIABLE(x) (void)x 135 | 136 | #elif defined( _JAVA ) 137 | #define CMJ(c,managed,java) java 138 | 139 | #define ENUM_BEGIN(w) public enum w { 140 | #define ENUM_DEFINE(x,y) y 141 | #define ENUM_VALUE(w,x,y) w.y 142 | #define ENUM_CASE(w,x,y) y 143 | #define ENUM_DECLARATION(w) w 144 | #define ENUM_END(w) }; 145 | 146 | #define STRUCT_BEGIN(x) public class x { 147 | #define STRUCT_END(x) }; 148 | 149 | #define VALUE_HANDLE_INT(name) MInteger name = new MInteger() 150 | #define VALUE_HANDLE_DEREF(name) name.value 151 | #define VALUE_HANDLE_DEREF_TO_ZERO(name) name.value = 0 152 | #define VALUE_HANDLE_OUT(name) name 153 | 154 | #define VALUE_HANDLE_GET(name) name.value 155 | #define VALUE_HANDLE_SET(name,x) name.value = x 156 | 157 | #define CONSTANT_DOUBLE(x) final double x 158 | #define NAMESPACE(x) x. 159 | #define UNUSED_VARIABLE(x) 160 | 161 | #else 162 | 163 | #define CMJ(c,managed,java) c 164 | 165 | #define ENUM_BEGIN(w) typedef enum { 166 | #define ENUM_DEFINE(x,y) x 167 | #define ENUM_VALUE(w,x,y) x 168 | #define ENUM_CASE(w,x,y) x 169 | #define ENUM_DECLARATION(w) TA_##w 170 | #define ENUM_END(w) } TA_##w; 171 | 172 | #define STRUCT_BEGIN(x) typedef struct { 173 | #define STRUCT_END(x) } x; 174 | 175 | #define VALUE_HANDLE_INT(name) int name 176 | #define VALUE_HANDLE_DEREF(name) (*name) 177 | #define VALUE_HANDLE_DEREF_TO_ZERO(name) (*name) = 0 178 | #define VALUE_HANDLE_OUT(name) &name 179 | 180 | #define VALUE_HANDLE_GET(name) name 181 | #define VALUE_HANDLE_SET(name,x) name = x 182 | 183 | #define CONSTANT_DOUBLE(x) const double x 184 | #define NAMESPACE(x) 185 | #define UNUSED_VARIABLE(x) (void)x 186 | #endif 187 | 188 | /* Abstraction of function calls within the library. 189 | * Needed because Java/.NET allows overloading, while for C the 190 | * TA_PREFIX allows to select variant of the same function. 191 | */ 192 | #define FUNCTION_CALL(x) TA_PREFIX(x) 193 | #define FUNCTION_CALL_DOUBLE(x) TA_##x 194 | #define LOOKBACK_CALL(x) TA_##x##_Lookback 195 | 196 | /* min/max value for a TA_Integer */ 197 | #define TA_INTEGER_MIN (INT_MIN+1) 198 | #define TA_INTEGER_MAX (INT_MAX) 199 | 200 | /* min/max value for a TA_Real 201 | * 202 | * Use fix value making sense in the 203 | * context of TA-Lib (avoid to use DBL_MIN 204 | * and DBL_MAX standard macro because they 205 | * are troublesome with some compiler). 206 | */ 207 | #define TA_REAL_MIN (-3e+37) 208 | #define TA_REAL_MAX (3e+37) 209 | 210 | /* A value outside of the min/max range 211 | * indicates an undefined or default value. 212 | */ 213 | #define TA_INTEGER_DEFAULT (INT_MIN) 214 | #define TA_REAL_DEFAULT (-4e+37) 215 | 216 | /* Part of this file is generated by gen_code */ 217 | 218 | ENUM_BEGIN( RetCode ) 219 | /* 0 */ ENUM_DEFINE( TA_SUCCESS, Success ), /* No error */ 220 | /* 1 */ ENUM_DEFINE( TA_LIB_NOT_INITIALIZE, LibNotInitialize ), /* TA_Initialize was not sucessfully called */ 221 | /* 2 */ ENUM_DEFINE( TA_BAD_PARAM, BadParam ), /* A parameter is out of range */ 222 | /* 3 */ ENUM_DEFINE( TA_ALLOC_ERR, AllocErr ), /* Possibly out-of-memory */ 223 | /* 4 */ ENUM_DEFINE( TA_GROUP_NOT_FOUND, GroupNotFound ), 224 | /* 5 */ ENUM_DEFINE( TA_FUNC_NOT_FOUND, FuncNotFound ), 225 | /* 6 */ ENUM_DEFINE( TA_INVALID_HANDLE, InvalidHandle ), 226 | /* 7 */ ENUM_DEFINE( TA_INVALID_PARAM_HOLDER, InvalidParamHolder ), 227 | /* 8 */ ENUM_DEFINE( TA_INVALID_PARAM_HOLDER_TYPE, InvalidParamHolderType ), 228 | /* 9 */ ENUM_DEFINE( TA_INVALID_PARAM_FUNCTION, InvalidParamFunction ), 229 | /* 10 */ ENUM_DEFINE( TA_INPUT_NOT_ALL_INITIALIZE, InputNotAllInitialize ), 230 | /* 11 */ ENUM_DEFINE( TA_OUTPUT_NOT_ALL_INITIALIZE, OutputNotAllInitialize ), 231 | /* 12 */ ENUM_DEFINE( TA_OUT_OF_RANGE_START_INDEX, OutOfRangeStartIndex ), 232 | /* 13 */ ENUM_DEFINE( TA_OUT_OF_RANGE_END_INDEX, OutOfRangeEndIndex ), 233 | /* 14 */ ENUM_DEFINE( TA_INVALID_LIST_TYPE, InvalidListType ), 234 | /* 15 */ ENUM_DEFINE( TA_BAD_OBJECT, BadObject ), 235 | /* 16 */ ENUM_DEFINE( TA_NOT_SUPPORTED, NotSupported ), 236 | /* 5000 */ ENUM_DEFINE( TA_INTERNAL_ERROR, InternalError ) = 5000, 237 | /* 0xFFFF */ ENUM_DEFINE( TA_UNKNOWN_ERR, UnknownErr ) = 0xFFFF 238 | ENUM_END( RetCode ) 239 | 240 | ENUM_BEGIN( Compatibility ) 241 | ENUM_DEFINE( TA_COMPATIBILITY_DEFAULT, Default ), 242 | ENUM_DEFINE( TA_COMPATIBILITY_METASTOCK, Metastock ) 243 | ENUM_END( Compatibility ) 244 | 245 | ENUM_BEGIN( MAType ) 246 | ENUM_DEFINE( TA_MAType_SMA, Sma ) =0, 247 | ENUM_DEFINE( TA_MAType_EMA, Ema ) =1, 248 | ENUM_DEFINE( TA_MAType_WMA, Wma ) =2, 249 | ENUM_DEFINE( TA_MAType_DEMA, Dema ) =3, 250 | ENUM_DEFINE( TA_MAType_TEMA, Tema ) =4, 251 | ENUM_DEFINE( TA_MAType_TRIMA, Trima ) =5, 252 | ENUM_DEFINE( TA_MAType_KAMA, Kama ) =6, 253 | ENUM_DEFINE( TA_MAType_MAMA, Mama ) =7, 254 | ENUM_DEFINE( TA_MAType_T3, T3 ) =8 255 | ENUM_END( MAType ) 256 | 257 | 258 | /**** START GENCODE SECTION 1 - DO NOT DELETE THIS LINE ****/ 259 | /* Generated */ 260 | /* Generated */ ENUM_BEGIN( FuncUnstId ) 261 | /* Generated */ /* 000 */ ENUM_DEFINE( TA_FUNC_UNST_ADX, Adx), 262 | /* Generated */ /* 001 */ ENUM_DEFINE( TA_FUNC_UNST_ADXR, Adxr), 263 | /* Generated */ /* 002 */ ENUM_DEFINE( TA_FUNC_UNST_ATR, Atr), 264 | /* Generated */ /* 003 */ ENUM_DEFINE( TA_FUNC_UNST_CMO, Cmo), 265 | /* Generated */ /* 004 */ ENUM_DEFINE( TA_FUNC_UNST_DX, Dx), 266 | /* Generated */ /* 005 */ ENUM_DEFINE( TA_FUNC_UNST_EMA, Ema), 267 | /* Generated */ /* 006 */ ENUM_DEFINE( TA_FUNC_UNST_HT_DCPERIOD, HtDcPeriod), 268 | /* Generated */ /* 007 */ ENUM_DEFINE( TA_FUNC_UNST_HT_DCPHASE, HtDcPhase), 269 | /* Generated */ /* 008 */ ENUM_DEFINE( TA_FUNC_UNST_HT_PHASOR, HtPhasor), 270 | /* Generated */ /* 009 */ ENUM_DEFINE( TA_FUNC_UNST_HT_SINE, HtSine), 271 | /* Generated */ /* 010 */ ENUM_DEFINE( TA_FUNC_UNST_HT_TRENDLINE, HtTrendline), 272 | /* Generated */ /* 011 */ ENUM_DEFINE( TA_FUNC_UNST_HT_TRENDMODE, HtTrendMode), 273 | /* Generated */ /* 012 */ ENUM_DEFINE( TA_FUNC_UNST_KAMA, Kama), 274 | /* Generated */ /* 013 */ ENUM_DEFINE( TA_FUNC_UNST_MAMA, Mama), 275 | /* Generated */ /* 014 */ ENUM_DEFINE( TA_FUNC_UNST_MFI, Mfi), 276 | /* Generated */ /* 015 */ ENUM_DEFINE( TA_FUNC_UNST_MINUS_DI, MinusDI), 277 | /* Generated */ /* 016 */ ENUM_DEFINE( TA_FUNC_UNST_MINUS_DM, MinusDM), 278 | /* Generated */ /* 017 */ ENUM_DEFINE( TA_FUNC_UNST_NATR, Natr), 279 | /* Generated */ /* 018 */ ENUM_DEFINE( TA_FUNC_UNST_PLUS_DI, PlusDI), 280 | /* Generated */ /* 019 */ ENUM_DEFINE( TA_FUNC_UNST_PLUS_DM, PlusDM), 281 | /* Generated */ /* 020 */ ENUM_DEFINE( TA_FUNC_UNST_RSI, Rsi), 282 | /* Generated */ /* 021 */ ENUM_DEFINE( TA_FUNC_UNST_STOCHRSI, StochRsi), 283 | /* Generated */ /* 022 */ ENUM_DEFINE( TA_FUNC_UNST_T3, T3), 284 | /* Generated */ ENUM_DEFINE( TA_FUNC_UNST_ALL, FuncUnstAll), 285 | /* Generated */ ENUM_DEFINE( TA_FUNC_UNST_NONE, FuncUnstNone) = -1 286 | /* Generated */ ENUM_END( FuncUnstId ) 287 | /* Generated */ 288 | /**** END GENCODE SECTION 1 - DO NOT DELETE THIS LINE ****/ 289 | 290 | /* The TA_RangeType enum specifies the types of range that can be considered 291 | * when to compare a part of a candle to other candles 292 | */ 293 | 294 | ENUM_BEGIN( RangeType ) 295 | ENUM_DEFINE( TA_RangeType_RealBody, RealBody ), 296 | ENUM_DEFINE( TA_RangeType_HighLow, HighLow ), 297 | ENUM_DEFINE( TA_RangeType_Shadows, Shadows ) 298 | ENUM_END( RangeType ) 299 | 300 | /* The TA_CandleSettingType enum specifies which kind of setting to consider; 301 | * the settings are based on the parts of the candle and the common words 302 | * indicating the length (short, long, very long) 303 | */ 304 | ENUM_BEGIN( CandleSettingType ) 305 | ENUM_DEFINE( TA_BodyLong, BodyLong ), 306 | ENUM_DEFINE( TA_BodyVeryLong, BodyVeryLong ), 307 | ENUM_DEFINE( TA_BodyShort, BodyShort ), 308 | ENUM_DEFINE( TA_BodyDoji, BodyDoji ), 309 | ENUM_DEFINE( TA_ShadowLong, ShadowLong ), 310 | ENUM_DEFINE( TA_ShadowVeryLong, ShadowVeryLong ), 311 | ENUM_DEFINE( TA_ShadowShort, ShadowShort ), 312 | ENUM_DEFINE( TA_ShadowVeryShort, ShadowVeryShort ), 313 | ENUM_DEFINE( TA_Near, Near ), 314 | ENUM_DEFINE( TA_Far, Far ), 315 | ENUM_DEFINE( TA_Equal, Equal ), 316 | ENUM_DEFINE( TA_AllCandleSettings, AllCandleSettings ) 317 | ENUM_END( CandleSettingType ) 318 | 319 | #endif 320 | -------------------------------------------------------------------------------- /talib/include/ta_libc.h: -------------------------------------------------------------------------------- 1 | /* TA-LIB Copyright (c) 1999-2007, Mario Fortier 2 | * All rights reserved. 3 | * 4 | * Redistribution and use in source and binary forms, with or 5 | * without modification, are permitted provided that the following 6 | * conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 11 | * - Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in 13 | * the documentation and/or other materials provided with the 14 | * distribution. 15 | * 16 | * - Neither name of author nor the names of its contributors 17 | * may be used to endorse or promote products derived from this 18 | * software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | * REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 30 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 31 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | #ifndef TA_LIBC_H 34 | #define TA_LIBC_H 35 | 36 | /* Includes all headers needed for using the ta-lib 'C' library. */ 37 | 38 | #ifndef TA_COMMON_H 39 | #include "ta_common.h" 40 | #endif 41 | 42 | #ifndef TA_FUNC_H 43 | #include "ta_func.h" 44 | #endif 45 | 46 | #ifndef TA_ABSTRACT_H 47 | #include "ta_abstract.h" 48 | #endif 49 | 50 | #endif 51 | 52 | -------------------------------------------------------------------------------- /talib/lib/HOLDER: -------------------------------------------------------------------------------- 1 | Do not erase this file. 2 | Some maintenance tools ignore empty directory. This file prevents this directory to be empty. 3 | -------------------------------------------------------------------------------- /talib/lib/about_lib.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/talib/lib/about_lib.png -------------------------------------------------------------------------------- /talib/lib/others.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/talib/lib/others.zip -------------------------------------------------------------------------------- /talib/lib/ta_abstract_cdr.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/talib/lib/ta_abstract_cdr.lib -------------------------------------------------------------------------------- /talib/lib/ta_common_cdr.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/talib/lib/ta_common_cdr.lib -------------------------------------------------------------------------------- /talib/lib/ta_func_cdr.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/talib/lib/ta_func_cdr.lib -------------------------------------------------------------------------------- /talib/lib/ta_libc_cdr.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/talib/lib/ta_libc_cdr.lib -------------------------------------------------------------------------------- /vnpy_V1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jiaminzou888/cppvnpy/af353590737c18d5aef7c8079a4aca251baec494/vnpy_V1.png --------------------------------------------------------------------------------