diff --git a/QuantBox_CTP_Quote/QuantBox_CTP_Quote.vcxproj b/QuantBox_CTP_Quote/QuantBox_CTP_Quote.vcxproj
index 4cf345a..4a78ef8 100644
--- a/QuantBox_CTP_Quote/QuantBox_CTP_Quote.vcxproj
+++ b/QuantBox_CTP_Quote/QuantBox_CTP_Quote.vcxproj
@@ -94,7 +94,7 @@
true
- C:\Program Files\SmartQuant Ltd\OpenQuant 2014\XAPI\CTP\x86
+ ..\bin
true
diff --git a/QuantBox_CTP_Trade/QuantBox_CTP_Trade.vcxproj b/QuantBox_CTP_Trade/QuantBox_CTP_Trade.vcxproj
index fa3fed2..3bc056e 100644
--- a/QuantBox_CTP_Trade/QuantBox_CTP_Trade.vcxproj
+++ b/QuantBox_CTP_Trade/QuantBox_CTP_Trade.vcxproj
@@ -94,7 +94,7 @@
true
- C:\Program Files\SmartQuant Ltd\OpenQuant 2014\XAPI\CTP\x86
+ ..\bin
true
diff --git a/QuantBox_KingstarStock_Trade/QuantBox_KingstarStock_Trade.vcxproj b/QuantBox_KingstarStock_Trade/QuantBox_KingstarStock_Trade.vcxproj
index 46072b1..226460a 100644
--- a/QuantBox_KingstarStock_Trade/QuantBox_KingstarStock_Trade.vcxproj
+++ b/QuantBox_KingstarStock_Trade/QuantBox_KingstarStock_Trade.vcxproj
@@ -70,7 +70,7 @@ xcopy "$(SolutionDir)include\Kingstar_Stock\win32\*.dll" "$(SolutionDir)XAPI\Ki
MaxSpeed
true
true
- WIN32;NDEBUG;_WINDOWS;_USRDLL;QUANTBOX_KINGSTARSTOCK_TRADE_EXPORTS;%(PreprocessorDefinitions)
+ WIN32;NDEBUG;_WINDOWS;_USRDLL;QUANTBOX_KINGSTARSTOCK_TRADE_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
true
diff --git a/QuantBox_LTS_Trade/QuantBox_LTS_Trade.vcxproj b/QuantBox_LTS_Trade/QuantBox_LTS_Trade.vcxproj
index d974675..d7405a1 100644
--- a/QuantBox_LTS_Trade/QuantBox_LTS_Trade.vcxproj
+++ b/QuantBox_LTS_Trade/QuantBox_LTS_Trade.vcxproj
@@ -75,7 +75,7 @@
true
- C:\Program Files\SmartQuant Ltd\OpenQuant 2014\XAPI\LTS\x86
+ $(SolutionDir)$(Configuration)\
true
diff --git a/QuantBox_Queue/ArrayLockFreeQueue.h b/QuantBox_Queue/ArrayLockFreeQueue.h
index 4ed39b1..a4b749d 100644
--- a/QuantBox_Queue/ArrayLockFreeQueue.h
+++ b/QuantBox_Queue/ArrayLockFreeQueue.h
@@ -31,6 +31,7 @@ class ArrayLockFreeQueue
ELEM_T m_thequeue[Q_SIZE];
+
volatile QUEUE_INT m_count;
volatile QUEUE_INT m_writeIndex;
diff --git a/QuantBox_Queue/ArrayLockFreeQueueImp.h b/QuantBox_Queue/ArrayLockFreeQueueImp.h
index 9493003..f4366fb 100644
--- a/QuantBox_Queue/ArrayLockFreeQueueImp.h
+++ b/QuantBox_Queue/ArrayLockFreeQueueImp.h
@@ -28,6 +28,7 @@ inline QUEUE_INT ArrayLockFreeQueue::countToIndex(QUEUE_INT a_co
return (a_count % Q_SIZE);
}
+
template
QUEUE_INT ArrayLockFreeQueue::size()
{
@@ -76,6 +77,7 @@ bool ArrayLockFreeQueue::try_dequeue(ELEM_T &a_data)
return dequeue(a_data);
}
+
template
bool ArrayLockFreeQueue::dequeue(ELEM_T &a_data)
{
diff --git a/QuantBox_Queue/MsgQueue.cpp b/QuantBox_Queue/MsgQueue.cpp
index 50df4a4..14e563f 100644
--- a/QuantBox_Queue/MsgQueue.cpp
+++ b/QuantBox_Queue/MsgQueue.cpp
@@ -1,7 +1,8 @@
#include "stdafx.h"
#include "MsgQueue.h"
-CMsgQueue::CMsgQueue()//:m_queue(1024)
+//CMsgQueue::CMsgQueue():m_queue(1024)
+CMsgQueue::CMsgQueue()
{
m_hThread = nullptr;
m_bRunning = false;
diff --git a/QuantBox_Queue/QuantBox_Queue.vcxproj b/QuantBox_Queue/QuantBox_Queue.vcxproj
index b497faf..9d525b7 100644
--- a/QuantBox_Queue/QuantBox_Queue.vcxproj
+++ b/QuantBox_Queue/QuantBox_Queue.vcxproj
@@ -94,8 +94,8 @@
true
+ ..\bin
QuantBox_Queue_x86
- C:\Program Files\SmartQuant Ltd\OpenQuant 2014\XAPI\LTS\x86
true
@@ -114,7 +114,7 @@
false
QuantBox_Queue_x86
- C:\Program Files\SmartQuant Ltd\OpenQuant 2014\XAPI\TongShi\x86
+ $(SolutionDir)$(Configuration)\
false
@@ -194,7 +194,7 @@
MaxSpeed
true
true
- WIN32;NDEBUG;_WINDOWS;_USRDLL;BUILDING_DLL;%(PreprocessorDefinitions)
+ WIN32;NDEBUG;_WINDOWS;_USRDLL;BUILDING_DLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
true
@@ -233,6 +233,9 @@
+
+
+
diff --git a/QuantBox_Queue/QuantBox_Queue.vcxproj.filters b/QuantBox_Queue/QuantBox_Queue.vcxproj.filters
index f77e535..6b0fe4d 100644
--- a/QuantBox_Queue/QuantBox_Queue.vcxproj.filters
+++ b/QuantBox_Queue/QuantBox_Queue.vcxproj.filters
@@ -48,6 +48,15 @@
Header Files
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
diff --git a/QuantBox_Queue/atom_opt.h b/QuantBox_Queue/atom_opt.h
index 149b3a7..f1a5891 100644
--- a/QuantBox_Queue/atom_opt.h
+++ b/QuantBox_Queue/atom_opt.h
@@ -7,7 +7,6 @@
#define AtomicSub(a_ptr,a_count) __sync_fetch_and_sub (a_ptr, a_count)
#include // sched_yield()
#else
-
#include
#ifdef _WIN64
#define CAS(a_ptr, a_oldVal, a_newVal) (a_oldVal == InterlockedCompareExchange64(a_ptr, a_newVal, a_oldVal))
diff --git a/QuantBox_TongShi_Quote/QuantBox_TongShi_Quote.vcxproj b/QuantBox_TongShi_Quote/QuantBox_TongShi_Quote.vcxproj
index ba0ee99..62948c7 100644
--- a/QuantBox_TongShi_Quote/QuantBox_TongShi_Quote.vcxproj
+++ b/QuantBox_TongShi_Quote/QuantBox_TongShi_Quote.vcxproj
@@ -81,7 +81,7 @@
MaxSpeed
true
true
- WIN32;_WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions)
+ WIN32;_WINDOWS;NDEBUG;_USRDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
true
@@ -89,7 +89,8 @@
true
true
true
- .\QuantBox_TongShi_Quote.def
+
+
false
diff --git a/QuantBox_XAPI/QuantBox_XAPI.vcxproj b/QuantBox_XAPI/QuantBox_XAPI.vcxproj
index 4057688..6be678c 100644
--- a/QuantBox_XAPI/QuantBox_XAPI.vcxproj
+++ b/QuantBox_XAPI/QuantBox_XAPI.vcxproj
@@ -69,7 +69,7 @@
MaxSpeed
true
true
- WIN32;NDEBUG;_WINDOWS;_USRDLL;QUANTBOX_XAPI_EXPORTS;%(PreprocessorDefinitions)
+ WIN32;NDEBUG;_WINDOWS;_USRDLL;QUANTBOX_XAPI_EXPORTS;_CRT_SECURE_NO_WARNINGS;BUILDING_DLL;%(PreprocessorDefinitions)
true
diff --git a/QuantBox_XAPI_TEST/QuantBox_XAPI_TEST.cpp b/QuantBox_XAPI_TEST/QuantBox_XAPI_TEST.cpp
index 6c7798f..aba3041 100644
--- a/QuantBox_XAPI_TEST/QuantBox_XAPI_TEST.cpp
+++ b/QuantBox_XAPI_TEST/QuantBox_XAPI_TEST.cpp
@@ -44,9 +44,9 @@ class CXSpiImpl :public CXSpi
int x = mon + i;
int a = x / 12;
int b = x % 12;
- sprintf(buf, "IF%d%02d", (1900 + timeinfo->tm_year + a) % 100, b + 1);
+ sprintf(buf, "au%d%02d", (1900 + timeinfo->tm_year + a) % 100, b + 1);
pApi->Subscribe(buf, "");
- sprintf(buf, "TF%d%02d", (1900 + timeinfo->tm_year + a) % 100, b + 1);
+ sprintf(buf, "ag%d%02d", (1900 + timeinfo->tm_year + a) % 100, b + 1);
pApi->Subscribe(buf, "");
}
}
@@ -252,7 +252,8 @@ int main_4(int argc, char* argv[])
{
CXSpiImpl* p = new CXSpiImpl();
#if defined WINDOWS || _WIN32
- char DLLPath1[250] = "C:\\Program Files\\SmartQuant Ltd\\OpenQuant 2014\\XAPI\\CTP\\x86\\QuantBox_CTP_Quote.dll";
+ //char DLLPath1[250] = "C:\\Program Files\\SmartQuant Ltd\\OpenQuant 2014\\XAPI\\CTP\\x86\\QuantBox_CTP_Quote.dll";
+ char DLLPath1[250] = ".\\QuantBox_CTP_Quote.dll";
#else
char DLLPath1[250] = "libQuantBox_CTP_Quote.so";
#endif
@@ -298,4 +299,4 @@ int main_4(int argc, char* argv[])
}
return 0;
-}
\ No newline at end of file
+}
diff --git a/QuantBox_XAPI_TEST/QuantBox_XAPI_TEST.vcxproj b/QuantBox_XAPI_TEST/QuantBox_XAPI_TEST.vcxproj
index fbd5aa9..b2bb13e 100644
--- a/QuantBox_XAPI_TEST/QuantBox_XAPI_TEST.vcxproj
+++ b/QuantBox_XAPI_TEST/QuantBox_XAPI_TEST.vcxproj
@@ -65,7 +65,7 @@
MaxSpeed
true
true
- WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)
+ WIN32;NDEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
true
diff --git a/QuantBox_XAPI_Windows.sln b/QuantBox_XAPI_Windows.sln
index 198ac46..cab8055 100644
--- a/QuantBox_XAPI_Windows.sln
+++ b/QuantBox_XAPI_Windows.sln
@@ -53,6 +53,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "QuantBox_XAPI", "QuantBox_X
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "QuantBox_XAPI_TEST", "QuantBox_XAPI_TEST\QuantBox_XAPI_TEST.vcxproj", "{C77ADBF7-E610-4E57-BE4D-C122FC5BE611}"
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Qubit_HL_Quote", "Qubit_HL_Quote\Qubit_HL_Quote.vcxproj", "{BE164B27-EC28-4B7A-89C4-0B7EA38F8846}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -525,6 +527,24 @@ Global
{C77ADBF7-E610-4E57-BE4D-C122FC5BE611}.Release|Win32.ActiveCfg = Release|Win32
{C77ADBF7-E610-4E57-BE4D-C122FC5BE611}.Release|Win32.Build.0 = Release|Win32
{C77ADBF7-E610-4E57-BE4D-C122FC5BE611}.Release|x64.ActiveCfg = Release|Win32
+ {BE164B27-EC28-4B7A-89C4-0B7EA38F8846}.Debug|Any CPU.ActiveCfg = Debug|Win32
+ {BE164B27-EC28-4B7A-89C4-0B7EA38F8846}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
+ {BE164B27-EC28-4B7A-89C4-0B7EA38F8846}.Debug|Mixed Platforms.Build.0 = Debug|Win32
+ {BE164B27-EC28-4B7A-89C4-0B7EA38F8846}.Debug|Win32.ActiveCfg = Debug|Win32
+ {BE164B27-EC28-4B7A-89C4-0B7EA38F8846}.Debug|Win32.Build.0 = Debug|Win32
+ {BE164B27-EC28-4B7A-89C4-0B7EA38F8846}.Debug|x64.ActiveCfg = Debug|Win32
+ {BE164B27-EC28-4B7A-89C4-0B7EA38F8846}.Debug64|Any CPU.ActiveCfg = Debug|Win32
+ {BE164B27-EC28-4B7A-89C4-0B7EA38F8846}.Debug64|Mixed Platforms.ActiveCfg = Debug|Win32
+ {BE164B27-EC28-4B7A-89C4-0B7EA38F8846}.Debug64|Mixed Platforms.Build.0 = Debug|Win32
+ {BE164B27-EC28-4B7A-89C4-0B7EA38F8846}.Debug64|Win32.ActiveCfg = Debug|Win32
+ {BE164B27-EC28-4B7A-89C4-0B7EA38F8846}.Debug64|Win32.Build.0 = Debug|Win32
+ {BE164B27-EC28-4B7A-89C4-0B7EA38F8846}.Debug64|x64.ActiveCfg = Debug|Win32
+ {BE164B27-EC28-4B7A-89C4-0B7EA38F8846}.Release|Any CPU.ActiveCfg = Release|Win32
+ {BE164B27-EC28-4B7A-89C4-0B7EA38F8846}.Release|Mixed Platforms.ActiveCfg = Release|Win32
+ {BE164B27-EC28-4B7A-89C4-0B7EA38F8846}.Release|Mixed Platforms.Build.0 = Release|Win32
+ {BE164B27-EC28-4B7A-89C4-0B7EA38F8846}.Release|Win32.ActiveCfg = Release|Win32
+ {BE164B27-EC28-4B7A-89C4-0B7EA38F8846}.Release|Win32.Build.0 = Release|Win32
+ {BE164B27-EC28-4B7A-89C4-0B7EA38F8846}.Release|x64.ActiveCfg = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/Qubit_HL_Quote/Qubit_HL_Quote.cpp b/Qubit_HL_Quote/Qubit_HL_Quote.cpp
new file mode 100644
index 0000000..11615f0
--- /dev/null
+++ b/Qubit_HL_Quote/Qubit_HL_Quote.cpp
@@ -0,0 +1,405 @@
+// Qubit_HL_Quote.cpp : 定义 DLL 的初始化例程。
+//
+
+#include "stdafx.h"
+#include "Qubit_HL_Quote.h"
+#include "../include/QueueEnum.h"
+
+#include "../include/ApiHeader.h"
+#include "../include/ApiStruct.h"
+
+#include "../include/toolkit.h"
+
+#include "../QuantBox_Queue/MsgQueue.h"
+#ifdef _REMOTE
+#include "../QuantBox_Queue/RemoteQueue.h"
+#endif
+
+#include
+#include
+
+#include
+#include
+using namespace std;
+
+void* __stdcall Query(char type, void* pApi1, void* pApi2, double double1, double double2, void* ptr1, int size1, void* ptr2, int size2, void* ptr3, int size3)
+{
+ // 由内部调用,不用检查是否为空
+ CMdUserApi* pApi = (CMdUserApi*)pApi2;
+ pApi->QueryInThread(type, pApi1, pApi2, double1, double2, ptr1, size1, ptr2, size2, ptr3, size3);
+ return nullptr;
+}
+
+CMdUserApi::CMdUserApi(void)
+{
+ m_pApi = nullptr;
+ m_lRequestID = 0;
+ m_nSleep = 1;
+
+ // 自己维护两个消息队列
+ m_msgQueue = new CMsgQueue();
+ m_msgQueue_Query = new CMsgQueue();
+
+ m_msgQueue_Query->Register((void*)Query, this);
+ m_msgQueue_Query->StartThread();
+
+ //m_msgQueue->m_bDirectOutput = true;
+
+ m_remoteQueue = nullptr;
+}
+
+CMdUserApi::~CMdUserApi(void)
+{
+ Disconnect();
+}
+
+void CMdUserApi::QueryInThread(char type, void* pApi1, void* pApi2, double double1, double double2, void* ptr1, int size1, void* ptr2, int size2, void* ptr3, int size3)
+{
+ int iRet = 0;
+ switch (type)
+ {
+ case E_Init:
+ iRet = _Init();
+ break;
+ case E_ReqUserLoginField:
+ iRet = _ReqUserLogin(type, pApi1, pApi2, double1, double2, ptr1, size1, ptr2, size2, ptr3, size3);
+ break;
+ default:
+ break;
+ }
+
+ if (0 == iRet)
+ {
+ //返回成功,填加到已发送池
+ m_nSleep = 1;
+ }
+ else
+ {
+ m_msgQueue_Query->Input_Copy(type, pApi1, pApi2, double1, double2, ptr1, size1, ptr2, size2, ptr3, size3);
+ //失败,按4的幂进行延时,但不超过1s
+ m_nSleep *= 4;
+ m_nSleep %= 1023;
+ }
+ this_thread::sleep_for(chrono::milliseconds(m_nSleep));
+}
+
+void CMdUserApi::Register(void* pCallback, void* pClass)
+{
+ m_pClass = pClass;
+ if (m_msgQueue == nullptr)
+ return;
+
+ m_msgQueue_Query->Register((void*)Query, this);
+ m_msgQueue->Register(pCallback, this);
+ if (pCallback)
+ {
+ m_msgQueue_Query->StartThread();
+ m_msgQueue->StartThread();
+ }
+ else
+ {
+ m_msgQueue_Query->StopThread();
+ m_msgQueue->StopThread();
+ }
+}
+
+ConfigInfoField* CMdUserApi::Config(ConfigInfoField* pConfigInfo)
+{
+ return nullptr;
+}
+
+void CMdUserApi::Connect(const string& szPath,
+ ServerInfoField* pServerInfo,
+ UserInfoField* pUserInfo,
+ int count)
+{
+ m_szPath = szPath;
+ memcpy(&m_ServerInfo, pServerInfo, sizeof(ServerInfoField));
+ memcpy(&m_UserInfo, pUserInfo, sizeof(UserInfoField));
+
+ m_msgQueue_Query->Input_NoCopy(RequestType::E_Init, m_msgQueue_Query, this, 0, 0,
+ nullptr, 0, nullptr, 0, nullptr, 0);
+
+#ifdef _REMOTE
+ // 将收到的行情通过ZeroMQ发送出去
+ if (strlen(m_ServerInfo.ExtendInformation) > 0)
+ {
+ m_remoteQueue = new CRemoteQueue(m_ServerInfo.ExtendInformation);
+ m_remoteQueue->StartThread();
+ }
+#endif
+}
+
+int CMdUserApi::_Init()
+{
+ //sprintf(pszPath, "%s/%s/%s/Md/%d/", m_szPath.c_str(), m_ServerInfo.BrokerID, m_UserInfo.UserID, rand());
+ //makedirs(pszPath);
+
+ m_pApi = HLQuoteApi::CreateHLQuoteApi();
+
+ m_msgQueue->Input_NoCopy(ResponeType::OnConnectionStatus, m_msgQueue, m_pClass, ConnectionStatus::Initialized, 0, nullptr, 0, nullptr, 0, nullptr, 0);
+
+ if (m_pApi)
+ {
+ m_pApi->RegisterSpi(this);
+
+ //添加地址
+ size_t len = strlen(m_ServerInfo.Address) + 1;
+ char* buf = new char[len];
+ strncpy(buf, m_ServerInfo.Address, len);
+
+ char* token = strtok(buf, _QUANTBOX_SEPS_);
+ while (token)
+ {
+ if (strlen(token)>0)
+ {
+ m_pApi->RegisterNetwork(m_ServerInfo.Port, token);
+ }
+ token = strtok(NULL, _QUANTBOX_SEPS_);
+ }
+ delete[] buf;
+
+ //初始化连接
+ m_pApi->Init();
+ m_msgQueue->Input_NoCopy(ResponeType::OnConnectionStatus, m_msgQueue, m_pClass, ConnectionStatus::Connecting, 0, nullptr, 0, nullptr, 0, nullptr, 0);
+ }
+
+ return 0;
+}
+
+void CMdUserApi::ReqUserLogin()
+{
+ HLApiReqUserLoginData* pBody = (HLApiReqUserLoginData*)m_msgQueue_Query->new_block(sizeof(HLApiReqUserLoginData));
+
+ strncpy(pBody->chClientID, m_UserInfo.UserID, sizeof(pBody->chClientID));
+ strncpy(pBody->chPassword, m_UserInfo.Password, sizeof(pBody->chPassword));
+
+ m_msgQueue_Query->Input_NoCopy(RequestType::E_ReqUserLoginField, m_msgQueue_Query, this, 0, 0,
+ pBody, sizeof(HLApiReqUserLoginData), nullptr, 0, nullptr, 0);
+}
+
+int CMdUserApi::_ReqUserLogin(char type, void* pApi1, void* pApi2, double double1, double double2, void* ptr1, int size1, void* ptr2, int size2, void* ptr3, int size3)
+{
+ m_msgQueue->Input_NoCopy(ResponeType::OnConnectionStatus, m_msgQueue, m_pClass, ConnectionStatus::Logining, 0, nullptr, 0, nullptr, 0, nullptr, 0);
+ return m_pApi->ReqUserLogin((HLApiReqUserLoginData*)ptr1, ++m_lRequestID);
+}
+
+void CMdUserApi::Disconnect()
+{
+ // 清理查询队列
+ if (m_msgQueue_Query)
+ {
+ m_msgQueue_Query->StopThread();
+ m_msgQueue_Query->Register(nullptr, nullptr);
+ m_msgQueue_Query->Clear();
+ delete m_msgQueue_Query;
+ m_msgQueue_Query = nullptr;
+ }
+
+ if (m_pApi)
+ {
+ m_pApi->RegisterSpi(NULL);
+ m_pApi->Release();
+ m_pApi = NULL;
+
+ // 全清理,只留最后一个
+ m_msgQueue->Clear();
+ m_msgQueue->Input_NoCopy(ResponeType::OnConnectionStatus, m_msgQueue, m_pClass, ConnectionStatus::Disconnected, 0, nullptr, 0, nullptr, 0, nullptr, 0);
+ // 主动触发
+ m_msgQueue->Process();
+ }
+
+ // 清理响应队列
+ if (m_msgQueue)
+ {
+ m_msgQueue->StopThread();
+ m_msgQueue->Register(nullptr, nullptr);
+ m_msgQueue->Clear();
+ delete m_msgQueue;
+ m_msgQueue = nullptr;
+ }
+
+ // 清理队列
+ if (m_remoteQueue)
+ {
+ m_remoteQueue->StopThread();
+ m_remoteQueue->Register(nullptr, nullptr);
+ m_remoteQueue->Clear();
+ delete m_remoteQueue;
+ m_remoteQueue = nullptr;
+ }
+}
+
+
+void CMdUserApi::OnFrontConnected()
+{
+ m_msgQueue->Input_NoCopy(ResponeType::OnConnectionStatus, m_msgQueue, m_pClass, ConnectionStatus::Connected, 0, nullptr, 0, nullptr, 0, nullptr, 0);
+
+ //连接成功后自动请求登录
+ ReqUserLogin();
+}
+
+void CMdUserApi::OnFrontDisconnected(int nReason)
+{
+ RspUserLoginField* pField = (RspUserLoginField*)m_msgQueue->new_block(sizeof(RspUserLoginField));
+ //连接失败返回的信息是拼接而成,主要是为了统一输出
+ pField->ErrorID = nReason;
+ GetOnFrontDisconnectedMsg(nReason, pField->ErrorMsg);
+
+ m_msgQueue->Input_NoCopy(ResponeType::OnConnectionStatus, m_msgQueue, m_pClass, ConnectionStatus::Disconnected, 0, pField, sizeof(RspUserLoginField), nullptr, 0, nullptr, 0);
+}
+
+void CMdUserApi::OnRspUserLogin(HLApiRspUserLoginData *pRspUserLogin, CHLRspInfoData *pRspInfo, int nRequestID, char cIsLast)
+{
+ RspUserLoginField* pField = (RspUserLoginField*)m_msgQueue->new_block(sizeof(RspUserLoginField));
+
+ if (pRspInfo->ErrorID == 0)
+ {
+ pField->TradingDay = GetDate(pRspUserLogin->chTradingDay);
+ pField->LoginTime = GetTime(pRspUserLogin->chLoginTime);
+
+ sprintf_s(pField->SessionID, "%d", pRspUserLogin->nSessionID);
+
+ m_msgQueue->Input_NoCopy(ResponeType::OnConnectionStatus, m_msgQueue, m_pClass, ConnectionStatus::Logined, 0, pField, sizeof(RspUserLoginField), nullptr, 0, nullptr, 0);
+ m_msgQueue->Input_NoCopy(ResponeType::OnConnectionStatus, m_msgQueue, m_pClass, ConnectionStatus::Done, 0, nullptr, 0, nullptr, 0, nullptr, 0);
+
+ HLApiReqCodeTable req = { 0 };
+ for (int i = 0; i < pRspUserLogin->nMarkets; i++)
+ {
+ //req.nDate = pRspUserLogin->nDynDate[i];
+ memcpy(req.chMarket, pRspUserLogin->chMarketFlag + i, API_MARKET_LEN);
+ m_pApi->ReqCodeTable(&req, ++m_lRequestID);
+ }
+ }
+ else
+ {
+ pField->ErrorID = pRspInfo->ErrorID;
+ strncpy(pField->ErrorMsg, pRspInfo->ErrorMsg, sizeof(ErrorMsgType));
+
+ m_msgQueue->Input_NoCopy(ResponeType::OnConnectionStatus, m_msgQueue, m_pClass, ConnectionStatus::Disconnected, 0, pField, sizeof(RspUserLoginField), nullptr, 0, nullptr, 0);
+ }
+}
+
+void CMdUserApi::OnRspCodeTable(HLApiRspCodeTable *pRspCodeTable, CHLRspInfoData *pRspInfo, int nRequestID, char cIsLast)
+{
+ HLApiReqMarketData data = { 0 };
+ strncpy(data.chMarket, pRspCodeTable->chMarketFlag, sizeof (data.chMarket));
+ m_pApi->ReqMarketData(&data, ++m_lRequestID);
+}
+
+//行情回调,得保证此函数尽快返回
+void CMdUserApi::OnRtnMarketData(HLApiMarketData *pMarketData, int nSize)
+{
+ //for (int i = 0; i < 50; ++i)
+ //{
+ // // 测试平台穿越速度,用完后需要注释掉
+ // WriteLog("CTP:OnRtnDepthMarketData:%s %f %s.%03d", pDepthMarketData->InstrumentID, pDepthMarketData->LastPrice, pDepthMarketData->UpdateTime, pDepthMarketData->UpdateMillisec);
+
+ DepthMarketDataField* pField = (DepthMarketDataField*)m_msgQueue->new_block(sizeof(DepthMarketDataField));
+
+
+ sprintf(pField->Symbol, "%s.%s", pField->InstrumentID, pField->ExchangeID);
+
+ //TODO:CTP大连没有ActionDay,所以API中是将TradingDay填到了这里,所以这里这种用法可能会出错,要测
+ GetExchangeTime(pDepthMarketData->TradingDay, pDepthMarketData->ActionDay, pDepthMarketData->UpdateTime
+ , &pField->TradingDay, &pField->ActionDay, &pField->UpdateTime, &pField->UpdateMillisec);
+
+ pField->UpdateMillisec = pDepthMarketData->UpdateMillisec;
+
+ pField->LastPrice = pDepthMarketData->LastPrice == DBL_MAX ? 0 : pDepthMarketData->LastPrice;
+ pField->Volume = pDepthMarketData->Volume;
+ pField->Turnover = pDepthMarketData->Turnover;
+ pField->OpenInterest = pDepthMarketData->OpenInterest;
+ pField->AveragePrice = pDepthMarketData->AveragePrice;
+
+ if (pDepthMarketData->OpenPrice != DBL_MAX)
+ {
+ pField->OpenPrice = pDepthMarketData->OpenPrice;
+ pField->HighestPrice = pDepthMarketData->HighestPrice;
+ pField->LowestPrice = pDepthMarketData->LowestPrice;
+ }
+ else
+ {
+ pField->OpenPrice = 0;
+ pField->HighestPrice = 0;
+ pField->LowestPrice = 0;
+ }
+ pField->SettlementPrice = pDepthMarketData->SettlementPrice != DBL_MAX ? pDepthMarketData->SettlementPrice : 0;
+
+ pField->UpperLimitPrice = pDepthMarketData->UpperLimitPrice;
+ pField->LowerLimitPrice = pDepthMarketData->LowerLimitPrice;
+ pField->PreClosePrice = pDepthMarketData->PreClosePrice;
+ pField->PreSettlementPrice = pDepthMarketData->PreSettlementPrice;
+ pField->PreOpenInterest = pDepthMarketData->PreOpenInterest;
+
+ do
+ {
+ if (pDepthMarketData->BidVolume1 == 0)
+ break;
+ pField->BidPrice1 = pDepthMarketData->BidPrice1;
+ pField->BidVolume1 = pDepthMarketData->BidVolume1;
+
+ if (pDepthMarketData->BidVolume2 == 0)
+ break;
+ pField->BidPrice2 = pDepthMarketData->BidPrice2;
+ pField->BidVolume2 = pDepthMarketData->BidVolume2;
+
+ if (pDepthMarketData->BidVolume3 == 0)
+ break;
+ pField->BidPrice3 = pDepthMarketData->BidPrice3;
+ pField->BidVolume3 = pDepthMarketData->BidVolume3;
+
+ if (pDepthMarketData->BidVolume4 == 0)
+ break;
+ pField->BidPrice4 = pDepthMarketData->BidPrice4;
+ pField->BidVolume4 = pDepthMarketData->BidVolume4;
+
+ if (pDepthMarketData->BidVolume5 == 0)
+ break;
+ pField->BidPrice5 = pDepthMarketData->BidPrice5;
+ pField->BidVolume5 = pDepthMarketData->BidVolume5;
+ } while (false);
+
+ do
+ {
+ if (pDepthMarketData->AskVolume1 == 0)
+ break;
+ pField->AskPrice1 = pDepthMarketData->AskPrice1;
+ pField->AskVolume1 = pDepthMarketData->AskVolume1;
+
+ if (pDepthMarketData->AskVolume2 == 0)
+ break;
+ pField->AskPrice2 = pDepthMarketData->AskPrice2;
+ pField->AskVolume2 = pDepthMarketData->AskVolume2;
+
+ if (pDepthMarketData->AskVolume3 == 0)
+ break;
+ pField->AskPrice3 = pDepthMarketData->AskPrice3;
+ pField->AskVolume3 = pDepthMarketData->AskVolume3;
+
+ if (pDepthMarketData->AskVolume4 == 0)
+ break;
+ pField->AskPrice4 = pDepthMarketData->AskPrice4;
+ pField->AskVolume4 = pDepthMarketData->AskVolume4;
+
+ if (pDepthMarketData->AskVolume5 == 0)
+ break;
+ pField->AskPrice5 = pDepthMarketData->AskPrice5;
+ pField->AskVolume5 = pDepthMarketData->AskVolume5;
+ } while (false);
+
+ // 这两个队列先头循序不要搞混,有删除功能的语句要放在后面
+ // 如果放前面,会导致远程收到乱码
+#ifdef _REMOTE
+ if (m_remoteQueue)
+ {
+ m_remoteQueue->Input_Copy(ResponeType::OnRtnDepthMarketData, m_msgQueue, m_pClass, 0, 0, pField, sizeof(DepthMarketDataField), nullptr, 0, nullptr, 0);
+ }
+#endif
+
+ m_msgQueue->Input_NoCopy(ResponeType::OnRtnDepthMarketData, m_msgQueue, m_pClass, 0, 0, pField, sizeof(DepthMarketDataField), nullptr, 0, nullptr, 0);
+ // 要关注一下其内的
+ //}
+}
+
+
diff --git a/Qubit_HL_Quote/Qubit_HL_Quote.def b/Qubit_HL_Quote/Qubit_HL_Quote.def
new file mode 100644
index 0000000..f79f590
--- /dev/null
+++ b/Qubit_HL_Quote/Qubit_HL_Quote.def
@@ -0,0 +1,6 @@
+; Qubit_HL_Quote.def : 声明 DLL 的模块参数。
+
+LIBRARY
+
+EXPORTS
+ ; 此处可以是显式导出
diff --git a/Qubit_HL_Quote/Qubit_HL_Quote.h b/Qubit_HL_Quote/Qubit_HL_Quote.h
new file mode 100644
index 0000000..4fab409
--- /dev/null
+++ b/Qubit_HL_Quote/Qubit_HL_Quote.h
@@ -0,0 +1,126 @@
+// Qubit_HL_Quote.h : Qubit_HL_Quote DLL 的主头文件
+//
+
+#pragma once
+
+#ifndef __AFXWIN_H__
+ #error "在包含此文件之前包含“stdafx.h”以生成 PCH 文件"
+#endif
+
+#include "resource.h" // 主符号
+
+
+// CQubit_HL_QuoteApp
+// 有关此类实现的信息,请参阅 Qubit_HL_Quote.cpp
+//
+
+#pragma once
+
+#include "../include/ApiStruct.h"
+#include "../include/HLAPI/HLQuoteApi.h"
+
+#pragma comment(lib, "../include/HLAPI/HLQuoteApi.lib")
+#pragma comment(lib, "../lib/QuantBox_Queue_x86.lib")
+
+#include
+#include
+#include
+#include
+
+using namespace std;
+
+class CMsgQueue;
+
+class CMdUserApi :
+ public HLQuoteSpi
+{
+ enum RequestType
+ {
+ E_Init,
+ E_ReqUserLoginField,
+ };
+
+public:
+ CMdUserApi(void);
+ virtual ~CMdUserApi(void);
+
+ void Register(void* pCallback, void* pClass);
+ ConfigInfoField* Config(ConfigInfoField* pConfigInfo);
+
+ void Connect(const string& szPath,
+ ServerInfoField* pServerInfo,
+ UserInfoField* pUserInfo,
+ int count);
+ void Disconnect();
+
+ void Subscribe(const string& szInstrumentIDs, const string& szExchageID);
+ void Unsubscribe(const string& szInstrumentIDs, const string& szExchageID);
+
+ void SubscribeQuote(const string& szInstrumentIDs, const string& szExchageID);
+ void UnsubscribeQuote(const string& szInstrumentIDs, const string& szExchageID);
+
+private:
+ friend void* __stdcall Query(char type, void* pApi1, void* pApi2, double double1, double double2, void* ptr1, int size1, void* ptr2, int size2, void* ptr3, int size3);
+ void QueryInThread(char type, void* pApi1, void* pApi2, double double1, double double2, void* ptr1, int size1, void* ptr2, int size2, void* ptr3, int size3);
+
+ int _Init();
+ //登录请求
+ void ReqUserLogin();
+ int _ReqUserLogin(char type, void* pApi1, void* pApi2, double double1, double double2, void* ptr1, int size1, void* ptr2, int size2, void* ptr3, int size3);
+
+ //订阅行情
+ void Subscribe(const set& instrumentIDs, const string& szExchageID);
+ void SubscribeQuote(const set& instrumentIDs, const string& szExchageID);
+
+ ///当客户端与交易后台建立起通信连接,客户端需要进行登录。
+ virtual void OnFrontConnected();
+
+ ///当客户端与交易后台通信连接断开时,该方法被调用,客户端不需要处理,API会自动重连。
+ virtual void OnFrontDisconnected(int nReason);
+
+ ///错误应答
+ //@cIsLast 包标志 API_PACKET_FIRST | API_PACKET_LAST 下同
+ virtual void OnRspError(CHLRspInfoData *pRspInfo, int nRequestID, char cIsLast);
+
+ ///用户登录应答
+ virtual void OnRspUserLogin(HLApiRspUserLoginData *pRspUserLogin, CHLRspInfoData *pRspInfo, int nRequestID, char cIsLast);
+
+ ///用户退出应答
+ //virtual void OnRspUserLogout(void *pRspUserLogout, void *pRspInfo, int nRequestID, char cIsLast) {};
+
+ ///市场索引请求应答
+ virtual void OnRspCodeTable(HLApiRspCodeTable *pRspCodeTable, CHLRspInfoData *pRspInfo, int nRequestID, char cIsLast);
+
+ ///行情订阅请求应答
+ virtual void OnRspMarketData(HLApiRspMarketData *pRspMarketData, CHLRspInfoData *pRspInfo, int nRequestID, char cIsLast);
+
+ //订阅行情变化通知
+ virtual void OnRtnMarketData(HLApiMarketData *pMarketData);
+
+ //全市场行情变化通知(订阅股票代码为空时,为全市场行情推送)
+ virtual void OnRtnMarketData(HLApiMarketData *pMarketData, int nSize);
+ virtual void OnRtnPushStkData(HLApiMarketData *pMarketData, int nSize = 1);
+
+private:
+ mutex m_csMapInstrumentIDs;
+ mutex m_csMapQuoteInstrumentIDs;
+
+ atomic m_lRequestID; //请求ID,每次请求前自增
+
+ set m_setInstrumentIDs; //正在订阅的合约
+ set m_setQuoteInstrumentIDs; //正在订阅的合约
+ HLQuoteApi* m_pApi; //行情API
+
+ string m_szPath; //生成配置文件的路径
+ ServerInfoField m_ServerInfo;
+ UserInfoField m_UserInfo;
+ int m_nSleep;
+
+ CMsgQueue* m_msgQueue; //消息队列指针
+ CMsgQueue* m_msgQueue_Query;
+ void* m_pClass;
+
+ CMsgQueue* m_remoteQueue;
+};
+
+
diff --git a/Qubit_HL_Quote/Qubit_HL_Quote.rc b/Qubit_HL_Quote/Qubit_HL_Quote.rc
new file mode 100644
index 0000000..8a539f5
Binary files /dev/null and b/Qubit_HL_Quote/Qubit_HL_Quote.rc differ
diff --git a/Qubit_HL_Quote/Qubit_HL_Quote.vcxproj b/Qubit_HL_Quote/Qubit_HL_Quote.vcxproj
new file mode 100644
index 0000000..54c4448
--- /dev/null
+++ b/Qubit_HL_Quote/Qubit_HL_Quote.vcxproj
@@ -0,0 +1,124 @@
+锘
+
+
+
+ Debug
+ Win32
+
+
+ Release
+ Win32
+
+
+
+ {BE164B27-EC28-4B7A-89C4-0B7EA38F8846}
+ Qubit_HL_Quote
+ MFCDLLProj
+
+
+
+ DynamicLibrary
+ true
+ v120
+ Unicode
+ Static
+
+
+ DynamicLibrary
+ false
+ v120
+ true
+ Unicode
+ Static
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+
+
+ false
+
+
+
+ Use
+ Level3
+ Disabled
+ WIN32;_WINDOWS;_DEBUG;_USRDLL;%(PreprocessorDefinitions)
+
+
+ Windows
+ true
+ .\Qubit_HL_Quote.def
+
+
+ false
+ _DEBUG;%(PreprocessorDefinitions)
+
+
+ 0x0804
+ _DEBUG;%(PreprocessorDefinitions)
+ $(IntDir);%(AdditionalIncludeDirectories)
+
+
+
+
+ Level3
+ Use
+ MaxSpeed
+ true
+ true
+ WIN32;_WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions)
+
+
+ Windows
+ true
+ true
+ true
+ .\Qubit_HL_Quote.def
+
+
+ false
+ NDEBUG;%(PreprocessorDefinitions)
+
+
+ 0x0804
+ NDEBUG;%(PreprocessorDefinitions)
+ $(IntDir);%(AdditionalIncludeDirectories)
+
+
+
+
+
+
+
+
+ Create
+ Create
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Qubit_HL_Quote/Qubit_HL_Quote.vcxproj.filters b/Qubit_HL_Quote/Qubit_HL_Quote.vcxproj.filters
new file mode 100644
index 0000000..0266cbc
--- /dev/null
+++ b/Qubit_HL_Quote/Qubit_HL_Quote.vcxproj.filters
@@ -0,0 +1,55 @@
+锘
+
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+ {93995380-89BD-4b04-88EB-625FBE52EBFB}
+ h;hh;hpp;hxx;hm;inl;inc;xsd
+
+
+ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
+ rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
+
+
+
+
+
+
+
+ 婧愭枃浠
+
+
+ 婧愭枃浠
+
+
+
+
+ 澶存枃浠
+
+
+ 澶存枃浠
+
+
+ 澶存枃浠
+
+
+ 澶存枃浠
+
+
+
+
+ 婧愭枃浠
+
+
+ 璧勬簮鏂囦欢
+
+
+
+
+ 璧勬簮鏂囦欢
+
+
+
\ No newline at end of file
diff --git a/Qubit_HL_Quote/ReadMe.txt b/Qubit_HL_Quote/ReadMe.txt
new file mode 100644
index 0000000..1c5ba0a
--- /dev/null
+++ b/Qubit_HL_Quote/ReadMe.txt
@@ -0,0 +1,45 @@
+锘========================================================================
+ MICROSOFT 鍩虹绫诲簱 : Qubit_HL_Quote 椤圭洰姒傝堪
+========================================================================
+
+
+搴旂敤绋嬪簭鍚戝宸蹭负鎮ㄥ垱寤轰簡姝 Qubit_HL_Quote DLL銆傛 DLL 涓嶄粎婕旂ず Microsoft 鍩虹绫荤殑鍩烘湰浣跨敤鏂规硶锛岃繕鍙綔涓烘偍缂栧啓 DLL 鐨勮捣鐐广
+
+鏈枃浠舵瑕佷粙缁嶇粍鎴 Qubit_HL_Quote DLL 鐨勬瘡涓枃浠剁殑鍐呭銆
+
+Qubit_HL_Quote.vcxproj
+ 杩欐槸浣跨敤搴旂敤绋嬪簭鍚戝鐢熸垚鐨 VC++ 椤圭洰鐨勪富椤圭洰鏂囦欢锛屽叾涓寘鍚敓鎴愯鏂囦欢鐨 Visual C++ 鐨勭増鏈俊鎭紝浠ュ強鏈夊叧浣跨敤搴旂敤绋嬪簭鍚戝閫夋嫨鐨勫钩鍙般侀厤缃拰椤圭洰鍔熻兘鐨勪俊鎭
+
+Qubit_HL_Quote.vcxproj.filters
+ 杩欐槸浣跨敤鈥滃簲鐢ㄧ▼搴忓悜瀵尖濈敓鎴愮殑 VC++ 椤圭洰绛涢夊櫒鏂囦欢銆傚畠鍖呭惈鏈夊叧椤圭洰鏂囦欢涓庣瓫閫夊櫒涔嬮棿鐨勫叧鑱斾俊鎭傚湪 IDE 涓紝閫氳繃杩欑鍏宠仈锛屽湪鐗瑰畾鑺傜偣涓嬩互鍒嗙粍褰㈠紡鏄剧ず鍏锋湁鐩镐技鎵╁睍鍚嶇殑鏂囦欢銆備緥濡傦紝鈥.cpp鈥濇枃浠朵笌鈥滄簮鏂囦欢鈥濈瓫閫夊櫒鍏宠仈銆
+
+Qubit_HL_Quote.h
+ 杩欐槸 DLL 鐨勪富澶存枃浠躲傚畠澹版槑浜 CQubit_HL_QuoteApp 绫汇
+
+Qubit_HL_Quote.cpp
+ 杩欐槸涓 DLL 婧愭枃浠躲傚畠鍖呭惈 CQubit_HL_QuoteApp 绫汇
+
+Qubit_HL_Quote.rc
+ 杩欐槸绋嬪簭浣跨敤鐨勬墍鏈 Microsoft Windows 璧勬簮鐨勫垪琛ㄣ傚畠鍖呮嫭 RES 瀛愮洰褰曚腑瀛樺偍鐨勫浘鏍囥佷綅鍥惧拰鍏夋爣銆傛鏂囦欢鍙互鐩存帴鍦 Microsoft Visual C++ 涓繘琛岀紪杈戙
+
+res\Qubit_HL_Quote.rc2
+ 姝ゆ枃浠跺寘鍚笉鍦 Microsoft Visual C++ 涓繘琛岀紪杈戠殑璧勬簮銆傛偍搴旇灏嗕笉鍙敱璧勬簮缂栬緫鍣ㄧ紪杈戠殑鎵鏈夎祫婧愭斁鍦ㄦ鏂囦欢涓
+
+Qubit_HL_Quote.def
+ 姝ゆ枃浠跺寘鍚湪 Microsoft Windows 涓繍琛屾墍蹇呴渶鐨 DLL 鐨勬湁鍏充俊鎭傚畠瀹氫箟浜 DLL 鐨勫悕绉板拰璇存槑绛夊弬鏁帮紝鑰屼笖杩樹粠 DLL 瀵煎嚭鍑芥暟銆
+
+/////////////////////////////////////////////////////////////////////////////
+鍏朵粬鏍囧噯鏂囦欢:
+
+StdAfx.h, StdAfx.cpp
+ 杩欎簺鏂囦欢鐢ㄤ簬鐢熸垚鍚嶄负 Qubit_HL_Quote.pch 鐨勯缂栬瘧澶 (PCH) 鏂囦欢鍜屽悕涓 StdAfx.obj 鐨勯缂栬瘧绫诲瀷鏂囦欢銆
+
+Resource.h
+ 杩欐槸鏍囧噯澶存枃浠讹紝鍙敤浜庡畾涔夋柊鐨勮祫婧 ID銆侻icrosoft Visual C++ 灏嗚鍙栧苟鏇存柊姝ゆ枃浠躲
+
+/////////////////////////////////////////////////////////////////////////////
+鍏朵粬娉ㄩ噴:
+
+搴旂敤绋嬪簭鍚戝浣跨敤鈥淭ODO:鈥濇潵鎸囩ず搴旀坊鍔犳垨鑷畾涔夌殑婧愪唬鐮侀儴鍒嗐
+
+/////////////////////////////////////////////////////////////////////////////
diff --git a/Qubit_HL_Quote/Resource.h b/Qubit_HL_Quote/Resource.h
new file mode 100644
index 0000000..26ae6ba
--- /dev/null
+++ b/Qubit_HL_Quote/Resource.h
@@ -0,0 +1,16 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ generated include file.
+// Used by Qubit_HL_Quote.rc
+//
+
+// 新对象的下一组默认值
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+
+#define _APS_NEXT_RESOURCE_VALUE 1000
+#define _APS_NEXT_CONTROL_VALUE 1000
+#define _APS_NEXT_SYMED_VALUE 1000
+#define _APS_NEXT_COMMAND_VALUE 32771
+#endif
+#endif
diff --git a/Qubit_HL_Quote/dllmain.cpp b/Qubit_HL_Quote/dllmain.cpp
new file mode 100644
index 0000000..574e92d
--- /dev/null
+++ b/Qubit_HL_Quote/dllmain.cpp
@@ -0,0 +1,24 @@
+// dllmain.cpp : Defines the entry point for the DLL application.
+#include "stdafx.h"
+#ifdef _X86_
+extern "C" { int _afxForceUSRDLL; }
+#else
+extern "C" { int __afxForceUSRDLL; }
+#endif
+
+BOOL APIENTRY DllMain( HMODULE hModule,
+ DWORD ul_reason_for_call,
+ LPVOID lpReserved
+ )
+{
+ switch (ul_reason_for_call)
+ {
+ case DLL_PROCESS_ATTACH:
+ case DLL_THREAD_ATTACH:
+ case DLL_THREAD_DETACH:
+ case DLL_PROCESS_DETACH:
+ break;
+ }
+ return TRUE;
+}
+
diff --git a/Qubit_HL_Quote/main.cpp b/Qubit_HL_Quote/main.cpp
new file mode 100644
index 0000000..bd01ba9
--- /dev/null
+++ b/Qubit_HL_Quote/main.cpp
@@ -0,0 +1,75 @@
+#include "stdafx.h"
+#include "../include/ApiHeader.h"
+
+#include "../include/QueueEnum.h"
+#include "Qubit_HL_Quote.h"
+
+#include "../include/CrossPlatform.h"
+
+inline CMdUserApi* GetApi(void* pApi)
+{
+ return static_cast(pApi);
+}
+
+ void* __stdcall XRequest(char type, void* pApi1, void* pApi2, double double1, double double2, void* ptr1, int size1, void* ptr2, int size2, void* ptr3, int size3)
+{
+ RequestType rt = (RequestType)type;
+ switch (rt)
+ {
+ case GetApiType:
+ return (void*)(ApiType::MarketData | ApiType::QuoteRequest);
+ case GetApiVersion:
+ return (void*)"0.2.0.20150618";
+ case GetApiName:
+ return (void*)"CTP";
+ case Create:
+ return new CMdUserApi();
+ default:
+ break;
+ }
+
+ if (pApi1 == nullptr)
+ {
+ return nullptr;
+ }
+
+ CMdUserApi* pApi = GetApi(pApi1);
+
+ switch (rt)
+ {
+ case Release:
+ delete pApi;
+ return 0;
+ case Register:
+ pApi->Register(ptr1,ptr2);
+ break;
+ case Config:
+ return (void*)pApi->Config((ConfigInfoField*)ptr1);
+ case Connect:
+ pApi->Connect((const char*)ptr3, (ServerInfoField*)ptr1, (UserInfoField*)ptr2,size2);
+ break;
+ case Disconnect:
+ pApi->Disconnect();
+ break;
+
+ case ReqCodeTable:
+ pApi->ReqCodeTable((const char*)ptr1);
+ break;
+ //case Subscribe:
+ // pApi->Subscribe((const char*)ptr1, (const char*)ptr2);
+ // break;
+ //case Unsubscribe:
+ // pApi->Unsubscribe((const char*)ptr1, (const char*)ptr2);
+ // break;
+ //case SubscribeQuote:
+ // pApi->SubscribeQuote((const char*)ptr1, (const char*)ptr2);
+ // break;
+ //case UnsubscribeQuote:
+ // pApi->UnsubscribeQuote((const char*)ptr1, (const char*)ptr2);
+ // break;
+ default:
+ break;
+ }
+
+ return pApi1;
+}
diff --git a/Qubit_HL_Quote/res/Qubit_HL_Quote.rc2 b/Qubit_HL_Quote/res/Qubit_HL_Quote.rc2
new file mode 100644
index 0000000..0f8ae34
Binary files /dev/null and b/Qubit_HL_Quote/res/Qubit_HL_Quote.rc2 differ
diff --git a/Qubit_HL_Quote/stdafx.cpp b/Qubit_HL_Quote/stdafx.cpp
new file mode 100644
index 0000000..4cbc68f
--- /dev/null
+++ b/Qubit_HL_Quote/stdafx.cpp
@@ -0,0 +1,7 @@
+// stdafx.cpp : 只包括标准包含文件的源文件
+// Qubit_HL_Quote.pch 将作为预编译头
+// stdafx.obj 将包含预编译类型信息
+
+#include "stdafx.h"
+
+
diff --git a/Qubit_HL_Quote/stdafx.h b/Qubit_HL_Quote/stdafx.h
new file mode 100644
index 0000000..bde7e92
--- /dev/null
+++ b/Qubit_HL_Quote/stdafx.h
@@ -0,0 +1,39 @@
+// stdafx.h : 标准系统包含文件的包含文件,
+// 或是经常使用但不常更改的
+// 特定于项目的包含文件
+
+#pragma once
+
+#ifndef VC_EXTRALEAN
+#define VC_EXTRALEAN // 从 Windows 头中排除极少使用的资料
+#endif
+
+#include "targetver.h"
+
+#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // 某些 CString 构造函数将是显式的
+
+#include // MFC 核心组件和标准组件
+#include // MFC 扩展
+
+#ifndef _AFX_NO_OLE_SUPPORT
+#include // MFC OLE 类
+#include // MFC OLE 对话框类
+#include // MFC 自动化类
+#endif // _AFX_NO_OLE_SUPPORT
+
+#ifndef _AFX_NO_DB_SUPPORT
+#include // MFC ODBC 数据库类
+#endif // _AFX_NO_DB_SUPPORT
+
+#ifndef _AFX_NO_DAO_SUPPORT
+#include // MFC DAO 数据库类
+#endif // _AFX_NO_DAO_SUPPORT
+
+#ifndef _AFX_NO_OLE_SUPPORT
+#include // MFC 对 Internet Explorer 4 公共控件的支持
+#endif
+#ifndef _AFX_NO_AFXCMN_SUPPORT
+#include // MFC 对 Windows 公共控件的支持
+#endif // _AFX_NO_AFXCMN_SUPPORT
+
+
diff --git a/Qubit_HL_Quote/targetver.h b/Qubit_HL_Quote/targetver.h
new file mode 100644
index 0000000..7a7d2c8
--- /dev/null
+++ b/Qubit_HL_Quote/targetver.h
@@ -0,0 +1,8 @@
+#pragma once
+
+// 包括 SDKDDKVer.h 将定义可用的最高版本的 Windows 平台。
+
+// 如果要为以前的 Windows 平台生成应用程序,请包括 WinSDKVer.h,并将
+// WIN32_WINNT 宏设置为要支持的平台,然后再包括 SDKDDKVer.h。
+
+#include
diff --git a/csharp/QuantBox.XAPI/GB2312Marshaler.cs b/csharp/QuantBox.XAPI/GB2312Marshaler.cs
index 66f3b31..6b3ff17 100644
--- a/csharp/QuantBox.XAPI/GB2312Marshaler.cs
+++ b/csharp/QuantBox.XAPI/GB2312Marshaler.cs
@@ -33,7 +33,7 @@ public IntPtr MarshalManagedToNative(object managedObj)
Marshal.WriteByte(buffer + strbuf.Length, 0);
return buffer;
}
-
+
public unsafe object MarshalNativeToManaged(IntPtr pNativeData)
{
byte* walk = (byte*)pNativeData;
@@ -52,7 +52,7 @@ public unsafe object MarshalNativeToManaged(IntPtr pNativeData)
string data = encodingGB2312.GetString(strbuf);
return data;
}
-
+
public void CleanUpNativeData(IntPtr pNativeData)
{
Marshal.FreeHGlobal(pNativeData);
diff --git a/csharp/QuantBox.XAPI/QuantBox.XAPI.csproj b/csharp/QuantBox.XAPI/QuantBox.XAPI.csproj
index 2bd8fc1..3785065 100644
--- a/csharp/QuantBox.XAPI/QuantBox.XAPI.csproj
+++ b/csharp/QuantBox.XAPI/QuantBox.XAPI.csproj
@@ -16,7 +16,7 @@
true
full
false
- ..\..\..\QuantBox.DataReceiver\bin\Debug\
+ ..\bin\
DEBUG;TRACE
prompt
4
@@ -31,6 +31,7 @@
TRACE
prompt
4
+ true
diff --git a/include/HLAPI/ApiDataType.h b/include/HLAPI/ApiDataType.h
new file mode 100644
index 0000000..d0e59a3
--- /dev/null
+++ b/include/HLAPI/ApiDataType.h
@@ -0,0 +1,159 @@
+#ifndef _API_DATA_TYPE_H_
+#define _API_DATA_TYPE_H_
+
+/////////////////////////////////////////////////////////////////////////
+///ErrorIDType是一个错误代码类型
+/////////////////////////////////////////////////////////////////////////
+typedef int ErrorIDType;
+
+/////////////////////////////////////////////////////////////////////////
+///ErrorMsgType是一个错误信息类型
+/////////////////////////////////////////////////////////////////////////
+typedef char ErrorMsgType[256];
+
+/////////////////////////////////////////////////////////////////////////
+///PriceType是一个价格类型
+/////////////////////////////////////////////////////////////////////////
+typedef double PriceType;
+
+/////////////////////////////////////////////////////////////////////////
+///VolumeType是一个交易量类型
+/////////////////////////////////////////////////////////////////////////
+typedef int VolumeType;
+
+/////////////////////////////////////////////////////////////////////////
+///QtyType是一个交易量类型
+/////////////////////////////////////////////////////////////////////////
+typedef double QtyType;
+
+/////////////////////////////////////////////////////////////////////////
+///LargeVolumeType是一个大额数量类型
+/////////////////////////////////////////////////////////////////////////
+typedef double LargeVolumeType;
+
+/////////////////////////////////////////////////////////////////////////
+///InstrumentIDType是一个合约代码类型
+/////////////////////////////////////////////////////////////////////////
+typedef char InstrumentIDType[31];
+
+/////////////////////////////////////////////////////////////////////////
+///SymbolType是一个合约唯一符号类型
+/////////////////////////////////////////////////////////////////////////
+typedef char SymbolType[64];
+
+/////////////////////////////////////////////////////////////////////////
+///DateTimeType是一个日期时间类型
+/////////////////////////////////////////////////////////////////////////
+typedef char DateTimeType[32];
+
+/////////////////////////////////////////////////////////////////////////
+///ExchangeIDType是一个交易所代码类型
+/////////////////////////////////////////////////////////////////////////
+typedef char ExchangeIDType[9];
+
+/////////////////////////////////////////////////////////////////////////
+///MoneyType是一个资金类型
+/////////////////////////////////////////////////////////////////////////
+typedef double MoneyType;
+
+/////////////////////////////////////////////////////////////////////////
+///DateType是一个日期类型
+/////////////////////////////////////////////////////////////////////////
+typedef char DateType[9];
+typedef int DateIntType;
+
+/////////////////////////////////////////////////////////////////////////
+///TimeType是一个时间类型
+/////////////////////////////////////////////////////////////////////////
+typedef char TimeType[9];
+typedef int TimeIntType;
+
+/////////////////////////////////////////////////////////////////////////
+///UserIDType是一个用户代码类型
+/////////////////////////////////////////////////////////////////////////
+typedef char UserIDType[32];
+
+///UserAccountNo是一个用户代码类型
+/////////////////////////////////////////////////////////////////////////
+typedef char UserAccountNoType[32];
+
+/////////////////////////////////////////////////////////////////////////
+///TFtdcPasswordType是一个密码类型
+/////////////////////////////////////////////////////////////////////////
+typedef char PasswordType[41];
+
+/////////////////////////////////////////////////////////////////////////
+///ProductInfoType是一个产品信息类型
+/////////////////////////////////////////////////////////////////////////
+typedef char ProductInfoType[11];
+
+/////////////////////////////////////////////////////////////////////////
+///BrokerIDType是一个经纪公司代码类型
+/////////////////////////////////////////////////////////////////////////
+typedef char BrokerIDType[21];
+
+/////////////////////////////////////////////////////////////////////////
+///AuthCodeType是一个客户端认证码类型
+/////////////////////////////////////////////////////////////////////////
+typedef char AuthCodeType[17];
+
+/////////////////////////////////////////////////////////////////////////
+///AddressType是一个地址类型
+/////////////////////////////////////////////////////////////////////////
+typedef char AddressType[512];
+///ExtendInformationType是一个扩展信息类型
+/////////////////////////////////////////////////////////////////////////
+typedef char ExtendInformationType[128];
+/////////////////////////////////////////////////////////////////////////
+///VolumeMultipleType是一个合约数量乘数类型
+/////////////////////////////////////////////////////////////////////////
+typedef int VolumeMultipleType;
+
+/////////////////////////////////////////////////////////////////////////
+///InstrumentNameType是一个合约名称类型
+/////////////////////////////////////////////////////////////////////////
+typedef char InstrumentNameType[31];
+
+/////////////////////////////////////////////////////////////////////////
+///ContentType是一个消息正文类型
+/////////////////////////////////////////////////////////////////////////
+typedef char ContentType[501];
+
+/////////////////////////////////////////////////////////////////////////
+///SessionIDType是一个会话编号类型
+/////////////////////////////////////////////////////////////////////////
+typedef char SessionIDType[32];
+
+/////////////////////////////////////////////////////////////////////////
+///OrderIDType是一个订单唯一编号类型
+/////////////////////////////////////////////////////////////////////////
+typedef char OrderIDType[64];
+
+/////////////////////////////////////////////////////////////////////////
+///TradeIDType是一个成交编号类型
+/////////////////////////////////////////////////////////////////////////
+typedef char TradeIDType[64];
+
+/////////////////////////////////////////////////////////////////////////
+///PositionIDType是一个持仓编号类型
+/////////////////////////////////////////////////////////////////////////
+typedef char PositionIDType[64];
+
+/////////////////////////////////////////////////////////////////////////
+///BarSizeType是一个BarSize类型
+/////////////////////////////////////////////////////////////////////////
+typedef long BarSizeType;
+
+/////////////////////////////////////////////////////////////////////////
+///ReferIDType是一个请求ID回调索引值类型
+/////////////////////////////////////////////////////////////////////////
+typedef int ReferIDType;
+
+/////////////////////////////////////////////////////////////////////////
+///BrokerIDType是一个经纪公司代码类型
+/////////////////////////////////////////////////////////////////////////
+typedef char ShareholderIDType[11];
+
+typedef int SizeType;
+
+#endif
\ No newline at end of file
diff --git a/include/HLAPI/ApiEnum.h b/include/HLAPI/ApiEnum.h
new file mode 100644
index 0000000..c2b1f77
--- /dev/null
+++ b/include/HLAPI/ApiEnum.h
@@ -0,0 +1,210 @@
+#ifndef _API_ENUM_H_
+#define _API_ENUM_H_
+
+enum LogLevel
+{
+ E_Fatal,
+ E_Critical,
+ E_Error,
+ E_Warning,
+ E_Notice,
+ E_Information,
+ E_Debug,
+ E_Trace,
+};
+
+
+//连接状态枚举
+enum ConnectionStatus :char
+{
+ Uninitialized, //未初始化
+ Initialized, //已经初始化
+ Disconnected, //连接已经断开
+ Connecting, //连接中
+ Connected, //连接成功
+ Authorizing, //授权中
+ Authorized, //授权成功
+ Logining, //登录中
+ Logined, //登录成功
+ Confirming, //结算单确认中
+ Confirmed, //已经确认
+ Doing,
+ Done, //完成
+ Unknown, //未知
+ ConnectFailed,
+ InitializedFailed,
+ LoginFailed,
+ Logout,
+};
+
+enum ApiType :char
+{
+ Nono = 0,
+ Trade = 1,
+ MarketData = 2,
+ Level2 = 4,
+ QuoteRequest = 8,
+ HistoricalData = 16,
+ Instrument = 32,
+};
+
+enum DepthLevelType:char
+{
+ L0,
+ L1,
+ L5,
+ L10,
+ FULL,
+};
+
+enum ResumeType :char
+{
+ Restart,
+ Resume,
+ Quick,
+};
+
+enum PutCall :char
+{
+ Put,
+ Call,
+};
+
+enum OrderStatus :char
+{
+ NotSent,
+ PendingNew,
+ New,
+ Rejected,
+ PartiallyFilled,
+ Filled,
+ PendingCancel,
+ Cancelled,
+ Expired,
+ PendingReplace,
+ Replaced,
+};
+
+enum OrderSide :char
+{
+ Buy,
+ Sell,
+ Creation,//申购
+ Redemption,//赎回
+ Merger,//合并
+ Demerger,//拆分
+};
+
+enum OrderType :char
+{
+ Market,
+ Stop,
+ Limit,
+ StopLimit,
+ MarketOnClose,
+ TrailingStop,
+ TrailingStopLimit,
+};
+
+enum TimeInForce :char
+{
+ ATC,
+ Day,
+ GTC,
+ IOC,
+ OPG,
+ OC,
+ FOK,
+ GTX,
+ GTD,
+ GFS,
+};
+
+
+
+enum PositionSide :char
+{
+ Long,
+ Short,
+};
+
+enum ExecType : char
+{
+ ExecNew,
+ ExecRejected,
+ ExecTrade,
+ ExecPendingCancel,
+ ExecCancelled,
+ ExecCancelReject,
+ ExecPendingReplace,
+ ExecReplace,
+ ExecReplaceReject,
+};
+
+enum OpenCloseType :char
+{
+ Open,
+ Close,
+ CloseToday,
+};
+
+enum HedgeFlagType :char
+{
+ Speculation,
+ Arbitrage,
+ Hedge,
+ MarketMaker,
+};
+
+enum InstrumentType :char
+{
+ Stock,
+ Future,
+ Option,
+ FutureOption,
+ Bond,
+ FX,
+ Index,
+ ETF,
+ MultiLeg,
+ Synthetic,
+ LOF,
+ Other,
+};
+
+enum BarType :char
+{
+ Time,
+ Tick,
+ Volume,
+ Range,
+};
+
+enum DataObjetType : char
+{
+ Tick_,
+ Bid,
+ Ask,
+ Trade_,
+ Quote,
+ Bar,
+ Level2_,
+ Level2Snapshot,
+ Level2Update,
+};
+
+enum ExchangeType :char
+{
+ Undefined_,
+ SHFE, // 上期所
+ DCE, // 大商所
+ CZCE, // 郑商所
+ CFFEX, // 中金所
+ INE, // 能源中心
+ SSE, // 上交所
+ SZE, // 深交所
+ NEEQ, // 全国中小企业股份转让系统,三板,临时这么写
+ HKEx,
+};
+
+#endif
diff --git a/include/HLAPI/ApiStruct.h b/include/HLAPI/ApiStruct.h
new file mode 100644
index 0000000..2f42366
--- /dev/null
+++ b/include/HLAPI/ApiStruct.h
@@ -0,0 +1,604 @@
+#ifndef _API_STRUCT_H_
+#define _API_STRUCT_H_
+
+#include "ApiDataType.h"
+#include "ApiEnum.h"
+
+
+struct PositionField
+{
+ ///唯一符号
+ SymbolType Symbol;
+ ///合约代码
+ InstrumentIDType InstrumentID;
+ ///交易所代码
+ ExchangeIDType ExchangeID;
+
+ PositionSide Side;
+ /// 总持仓
+ QtyType Position;
+ /// 今日持仓
+ QtyType TdPosition;
+ /// 昨日持仓
+ QtyType YdPosition;
+ /// 可用持仓
+ QtyType AvbPosition;
+ /// 可用昨日持仓
+ QtyType AvbYdPosition;
+ /// 可用申赎数
+ QtyType AvbETFPosition;
+
+ InstrumentIDType InstrumentName;
+ //QtyType
+ /// 成本价
+ PriceType HoldPrice;
+ /// 市值
+ PriceType MktValue;
+
+ HedgeFlagType HedgeFlag;
+
+ int StockAskFrn; //卖出冻结
+ int StockBidFrn; //买入冻结
+ //TThostFtdcPositionDateType 还没处理
+};
+
+struct QuoteField
+{
+ InstrumentIDType InstrumentID;
+ ExchangeIDType ExchangeID;
+
+ QtyType AskQty;
+ PriceType AskPrice;
+ OpenCloseType AskOpenClose;
+ HedgeFlagType AskHedgeFlag;
+
+ QtyType BidQty;
+ PriceType BidPrice;
+ OpenCloseType BidOpenClose;
+ HedgeFlagType BidHedgeFlag;
+
+ ///询价编号
+ OrderIDType QuoteReqID;
+
+ OrderIDType ID;
+ OrderIDType AskID;
+ OrderIDType BidID;
+ OrderIDType AskOrderID;
+ OrderIDType BidOrderID;
+ OrderStatus Status;
+ ExecType ExecType;
+ ErrorIDType ErrorID;
+ ErrorMsgType Text;
+
+ /*
+ QtyType LeavesQty;
+ QtyType CumQty;
+ PriceType AvgPx;
+
+
+
+
+ long DateTime;*/
+};
+
+struct EtfSubscribeField
+{
+ ///用户代码
+ UserIDType UserID;
+ //用户资金账号
+ UserAccountNoType UserAccountNo;
+ InstrumentIDType InstrumentID;
+ QtyType Qty;
+ OrderSide Side;
+ OrderIDType OrderID;
+};
+
+struct OrderField
+{
+ InstrumentNameType InstrumentName;
+ InstrumentIDType InstrumentID;
+ ExchangeIDType ExchangeID;
+ OrderType Type;
+ OrderSide Side;
+ QtyType Qty;
+ PriceType Price;
+ OpenCloseType OpenClose;
+ HedgeFlagType HedgeFlag;
+
+ PriceType StopPx;
+ TimeInForce TimeInForce;
+
+ OrderStatus Status;
+ ExecType ExecType;
+ QtyType LeavesQty;
+ QtyType CumQty;
+ PriceType AvgPx;
+ ErrorIDType ErrorID;
+ ErrorMsgType Text;
+
+ OrderIDType ID;
+ OrderIDType OrderID;
+ int DateTime;
+
+
+ TimeType Time;
+ long OrderRef;
+ ShareholderIDType ShareHolderID;
+};
+
+struct OrderCancelField
+{
+
+ ///用户代码
+ UserIDType UserID;
+ //用户资金账号
+ UserAccountNoType UserAccountNo;
+ //撤销合同号
+ OrderIDType OrderID;
+};
+
+struct TradeField
+{
+ InstrumentIDType InstrumentID;
+ ExchangeIDType ExchangeID;
+
+ OrderSide Side;
+ QtyType Qty;
+ PriceType Price;
+ OpenCloseType OpenClose;
+ HedgeFlagType HedgeFlag;
+ MoneyType Commission;
+ int MatchedDate; //成交或撤单日期
+ TimeType Time;
+ OrderIDType ID;
+ TradeIDType TradeID;
+
+ InstrumentNameType InstrumentName;
+ ShareholderIDType ShareHolderID;
+ OrderStatus Status;
+ QtyType LeavesQty;
+ OrderStatus OdStatus;
+ OrderIDType RefID;
+
+};
+
+struct ServerInfoField
+{
+ bool IsUsingUdp;
+ bool IsMulticast;
+ int TopicId;
+ int Port;
+ ResumeType MarketDataTopicResumeType;
+ ResumeType PrivateTopicResumeType;
+ ResumeType PublicTopicResumeType;
+ ResumeType UserTopicResumeType;
+ BrokerIDType BrokerID;
+ ProductInfoType UserProductInfo;
+ AuthCodeType AuthCode;
+ AddressType Address;
+ ExtendInformationType ExtendInformation;
+};
+
+struct ConfigInfoField
+{
+
+};
+
+// 用户信息
+struct UserInfoField
+{
+ ///用户代码
+ UserIDType UserID;
+ //用户资金账号
+ UserAccountNoType UserAccountNo;
+ ///密码
+ PasswordType Password;
+};
+
+
+// 错误信息
+struct ErrorField
+{
+ // 错误代码
+ ErrorIDType ErrorID;
+ // 错误信息
+ ErrorMsgType ErrorMsg;
+};
+
+
+// 登录回报
+struct RspUserLoginField
+{
+ ///交易日
+ DateType TradingDay;
+ // 时间
+ TimeType LoginTime;
+ // 会话ID
+ SessionIDType SessionID;
+ // 错误代码
+ ErrorIDType ErrorID;
+ // 错误信息
+ ErrorMsgType ErrorMsg;
+ // 交易所编号
+ ExchangeIDType ExchangeID;
+ // 股东编号
+ UserIDType SecurityID;
+ // 请求索引
+ ReferIDType ReferID;
+
+};
+
+
+
+///深度行情
+struct DepthMarketDataField
+{
+ ///交易所时间
+ DateIntType TradingDay; // 交易日,用于给数据接收器划分到同一文件使用,基本没啥别的用处
+ DateIntType ActionDay;
+ TimeIntType UpdateTime;
+ TimeIntType UpdateMillisec;
+
+ ///唯一符号
+ SymbolType Symbol;
+ ///合约代码
+ InstrumentIDType InstrumentID;
+ ///交易所代码
+ ExchangeIDType ExchangeID;
+
+ ///最新价
+ PriceType LastPrice;
+ ///数量
+ LargeVolumeType Volume;
+ ///成交金额
+ MoneyType Turnover;
+ ///持仓量
+ LargeVolumeType OpenInterest;
+ ///当日均价
+ PriceType AveragePrice;
+
+
+ ///今开盘
+ PriceType OpenPrice;
+ ///最高价
+ PriceType HighestPrice;
+ ///最低价
+ PriceType LowestPrice;
+ ///今收盘
+ PriceType ClosePrice;
+ ///本次结算价
+ PriceType SettlementPrice;
+
+ ///涨停板价
+ PriceType UpperLimitPrice;
+ ///跌停板价
+ PriceType LowerLimitPrice;
+ ///昨收盘
+ PriceType PreClosePrice;
+ ///上次结算价
+ PriceType PreSettlementPrice;
+ ///昨持仓量
+ LargeVolumeType PreOpenInterest;
+
+
+ ///申买价一
+ PriceType BidPrice1;
+ ///申买量一
+ VolumeType BidVolume1;
+ ///申卖价一
+ PriceType AskPrice1;
+ ///申卖量一
+ VolumeType AskVolume1;
+ ///申买价二
+ PriceType BidPrice2;
+ ///申买量二
+ VolumeType BidVolume2;
+ ///申卖价二
+ PriceType AskPrice2;
+ ///申卖量二
+ VolumeType AskVolume2;
+ ///申买价三
+ PriceType BidPrice3;
+ ///申买量三
+ VolumeType BidVolume3;
+ ///申卖价三
+ PriceType AskPrice3;
+ ///申卖量三
+ VolumeType AskVolume3;
+ ///申买价四
+ PriceType BidPrice4;
+ ///申买量四
+ VolumeType BidVolume4;
+ ///申卖价四
+ PriceType AskPrice4;
+ ///申卖量四
+ VolumeType AskVolume4;
+ ///申买价五
+ PriceType BidPrice5;
+ ///申买量五
+ VolumeType BidVolume5;
+ ///申卖价五
+ PriceType AskPrice5;
+ ///申卖量五
+ VolumeType AskVolume5;
+};
+
+///Tick行情
+struct TickField
+{
+ ///交易所时间
+ DateIntType Date;
+ TimeIntType Time;
+ TimeIntType Millisecond;
+
+ PriceType LastPrice;
+ ///数量
+ LargeVolumeType Volume;
+ ///持仓量
+ LargeVolumeType OpenInterest;
+ PriceType BidPrice1;
+ PriceType AskPrice1;
+ VolumeType BidSize1;
+ VolumeType AskSize1;
+};
+
+
+///Bar行情
+struct BarField
+{
+ ///交易所时间
+ DateIntType Date;
+ TimeIntType Time;
+
+ ///开
+ PriceType Open;
+ ///高
+ PriceType High;
+ ///低
+ PriceType Low;
+ ///收
+ PriceType Close;
+ ///数量
+ LargeVolumeType Volume;
+ ///持仓量
+ LargeVolumeType OpenInterest;
+ ///成交金额
+ MoneyType Turnover;
+};
+
+///发给做市商的询价请求
+struct QuoteRequestField
+{
+ ///唯一符号
+ SymbolType Symbol;
+ ///合约代码
+ InstrumentIDType InstrumentID;
+ ///交易所代码
+ ExchangeIDType ExchangeID;
+ ///交易日
+ DateType TradingDay;
+ ///询价编号
+ OrderIDType QuoteID;
+ ///询价时间
+ TimeType QuoteTime;
+};
+
+///合约
+struct InstrumentField
+{
+ ///唯一符号
+ SymbolType Symbol;
+ ///合约代码
+ InstrumentIDType InstrumentID;
+ ///交易所代码
+ ExchangeIDType ExchangeID;
+ ///合约名称
+ InstrumentNameType InstrumentName;
+
+ ///合约类型
+ InstrumentType Type;
+ ///合约数量乘数
+ VolumeMultipleType VolumeMultiple;
+ ///最小变动价位
+ PriceType PriceTick;
+ ///到期日
+ DateType ExpireDate;
+ ///基础商品代码
+ InstrumentIDType UnderlyingInstrID;
+ ///执行价
+ PriceType StrikePrice;
+ ///期权类型
+ PutCall OptionsType;
+};
+
+///账号
+struct AccountField
+{
+ ///上次结算准备金
+ MoneyType PreBalance;
+ ///当前保证金总额
+ MoneyType CurrMargin;
+ ///平仓盈亏
+ MoneyType CloseProfit;
+ ///持仓盈亏
+ MoneyType PositionProfit;
+ ///期货结算准备金
+ MoneyType Balance;
+ ///可用资金
+ MoneyType Available;
+
+ ///入金金额
+ MoneyType Deposit;
+ ///出金金额
+ MoneyType Withdraw;
+
+ ///冻结的过户费
+ MoneyType FrozenTransferFee;
+ ///冻结的印花税
+ MoneyType FrozenStampTax;
+ ///冻结的手续费
+ MoneyType FrozenCommission;
+ ///冻结的资金
+ MoneyType FrozenCash;
+
+ ///过户费
+ MoneyType TransferFee;
+ ///印花税
+ MoneyType StampTax;
+ ///手续费
+ MoneyType Commission;
+ ///资金差额
+ MoneyType CashIn;
+
+};
+
+///账号
+struct SettlementInfoField
+{
+ ///交易日
+ DateType TradingDay;
+ ///消息正文
+ ContentType Content;
+};
+
+struct HistoricalDataRequestField
+{
+ ///唯一符号
+ SymbolType Symbol;
+ ///合约代码
+ InstrumentIDType InstrumentID;
+ ///交易所代码
+ ExchangeIDType ExchangeID;
+
+ int Date1;
+ int Date2;
+ int Time1;
+ int Time2;
+
+ DataObjetType DataType;
+ BarType BarType;
+ long BarSize;
+
+ int RequestId;
+ int CurrentDate;
+ int lRequest;
+};
+
+//ETF清单请求响应
+struct ETFListField
+{
+ //ETF代码
+ InstrumentIDType ETFInstrumentID;
+ //ETF名称
+ InstrumentNameType ETFInstrumentName;
+ ///交易所代码
+ ExchangeIDType ExchangeID; //一级交易板块
+ double dMaxCashRatio; //现金替代比例上限
+ int nCreationRedemption; //基金当天申购赎回状态(1,0)
+ int nCreationRedemptionUnit; //最小申购赎回单位
+ PriceType dEstimateCashComponent; //T日预估现金余额
+ int nTradingDay; //T日日期
+ InstrumentIDType InstrumentID;
+ PriceType dCashComponent; //T-1日现金差额(单位:元)
+ double dNAVperCU; //T-1日最小申购、赎回单位资产净值(单位:元)
+ int nItemDataSize; //成份股数量
+ int size;
+
+};
+
+struct ETFListDataField
+{
+ InstrumentIDType InstrumentID; //股票代码
+ InstrumentNameType InstrumentName;//股票名称
+ ExchangeIDType ExchangeID; //交易所代码
+ int nNum; //股票数量
+ int nFlag; //现金替代标志
+ double dRatio; //溢价比例
+ double dReplaceAmount; //替代金额
+};
+
+
+//ETF申赎请求
+struct ETFSubscribeInfo
+{
+ int eSubscribeFlag; //申赎标志
+ InstrumentIDType InstrumentID; //ETF代码
+ int nSubscribeQty; //申赎份额
+ OrderIDType OrderID; //合同序号
+};
+
+//分级基金
+struct RspStruFundInfoQry
+{
+ InstrumentIDType FundInstrumentID;
+ InstrumentNameType FundInstrumentName;
+ InstrumentIDType FundAInstrumentID;
+ InstrumentNameType FundAInstrumentName;
+ InstrumentIDType FundBInstrumentID;
+ InstrumentNameType FundBInstrumentName;
+ int nFundAShare; //分级A比例(0,100), 默认:50
+ int nFundBShare; //分级B比例(0,100), 默认:50
+};
+///深度行情N档
+struct DepthMarketDataNField
+{
+ ///占用总字节大小
+ SizeType Size;
+ ///交易所时间
+ DateIntType TradingDay; // 交易日,用于给数据接收器划分到同一文件使用,基本没啥别的用处
+ DateIntType ActionDay;
+ TimeIntType UpdateTime;
+ TimeIntType UpdateMillisec;
+
+ ///交易所代码
+ ExchangeType Exchange;
+ ///唯一符号
+ SymbolType Symbol;
+ ///合约代码
+ InstrumentIDType InstrumentID;
+
+ ///最新价
+ PriceType LastPrice;
+ ///数量
+ LargeVolumeType Volume;
+ ///成交金额
+ MoneyType Turnover;
+ ///持仓量
+ LargeVolumeType OpenInterest;
+ ///当日均价
+ PriceType AveragePrice;
+
+
+ ///今开盘
+ PriceType OpenPrice;
+ ///最高价
+ PriceType HighestPrice;
+ ///最低价
+ PriceType LowestPrice;
+ ///今收盘
+ PriceType ClosePrice;
+ ///本次结算价
+ PriceType SettlementPrice;
+
+ ///涨停板价
+ PriceType UpperLimitPrice;
+ ///跌停板价
+ PriceType LowerLimitPrice;
+ ///昨收盘
+ PriceType PreClosePrice;
+ ///上次结算价
+ PriceType PreSettlementPrice;
+ ///昨持仓量
+ LargeVolumeType PreOpenInterest;
+ ///买档个数
+ SizeType BidCount;
+ char status;
+};
+
+struct DepthField
+{
+ PriceType Price;
+ VolumeType Size;
+ VolumeType Count;
+};
+#endif
diff --git a/include/HLAPI/HLQuoteApi.dll b/include/HLAPI/HLQuoteApi.dll
new file mode 100644
index 0000000..4e822f5
Binary files /dev/null and b/include/HLAPI/HLQuoteApi.dll differ
diff --git a/include/HLAPI/HLQuoteApi.h b/include/HLAPI/HLQuoteApi.h
new file mode 100644
index 0000000..5800448
--- /dev/null
+++ b/include/HLAPI/HLQuoteApi.h
@@ -0,0 +1,97 @@
+#ifndef HLQUOTEAPI_HHH_
+#define HLQUOTEAPI_HHH_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#include "HLUserApiDefine.h"
+
+#if defined(ISLIB) && defined(WIN32)
+#ifdef LIB_HLQUOTEAPI_EXPORT
+#define HLQUOTEAPI_EXPORT __declspec(dllexport)
+#else
+#define HLQUOTEAPI_EXPORT __declspec(dllimport)
+#endif
+#else
+#define HLQUOTEAPI_EXPORT
+#endif
+
+
+class HLQUOTEAPI_EXPORT HLQuoteSpi
+{
+public:
+ //当客户端与交易后台建立起通信连接,客户端需要进行登录。
+ virtual void OnFrontConnected() {};
+
+ //当客户端与交易后台通信连接断开时,该方法被调用,客户端不需要处理,API会自动重连。
+ virtual void OnFrontDisconnected(int nReason) {};
+
+ //错误应答
+ //@cIsLast 包标志 API_PACKET_FIRST | API_PACKET_LAST 下同
+ virtual void OnRspError(CHLRspInfoData* pRspInfo, int nRequestID, char cIsLast) {};
+
+ //用户登录应答
+ virtual void OnRspUserLogin(HLApiRspUserLoginData* pRspUserLogin, CHLRspInfoData* pRspInfo, int nRequestID, char cIsLast) {};
+
+ //用户退出应答
+ //virtual void OnRspUserLogout(void *pRspUserLogout, void *pRspInfo, int nRequestID, char cIsLast) {};
+
+ //市场代码表请求应答
+ virtual void OnRspCodeTable(HLApiRspCodeTable* pRspCodeTable, CHLRspInfoData* pRspInfo, int nRequestID, char cIsLast) {};
+
+ //行情订阅请求应答
+ virtual void OnRspMarketData(HLApiRspMarketData* pRspMarketData, CHLRspInfoData* pRspInfo, int nRequestID, char cIsLast) {};
+
+ //行情变化通知
+ virtual void OnRtnMarketData(HLApiMarketData* pMarketData) {};
+
+ //全市场行情变化通知(订阅股票代码为空时,为全市场行情推送)
+ virtual void OnRtnMarketData(HLApiMarketData* pMarketData, int nSize) {};
+
+ //TCP实时推送的行情
+ virtual void OnRtnPushStkData(HLApiMarketData* pMarketData, int nSize = 1) {};
+
+ //组播实时推送的行情
+ virtual void OnRtnMarketData_MC(HLApiMarketData* pMarketData, int nSize = 1) {};
+
+protected:
+ virtual ~HLQuoteSpi(void) = 0 {};
+};
+
+class HLQUOTEAPI_EXPORT HLQuoteApi
+{
+public:
+ //创建一个HLQuoteApi
+ static HLQuoteApi* CreateHLQuoteApi(void);
+
+ //获取行情API版本号
+ static const char* GetVersion(void);
+
+ //注册行情服务器地址
+ virtual void RegisterNetwork(unsigned short nPort, const char* pszFrontAddr, const char* pszMCGroup="") = 0;
+
+ //注册行情回调接口
+ virtual void RegisterSpi(HLQuoteSpi* pSpi) = 0;
+
+ //行情API初始化
+ virtual int Init(void) = 0;
+
+ //用户登录请求
+ virtual int ReqUserLogin(HLApiReqUserLoginData* pReqUserLogin, int nRequestID) = 0;
+
+ //市场代码表请求
+ virtual int ReqCodeTable(HLApiReqCodeTable* pReqCodeTable, int nRequestID) = 0;
+
+ //行情订阅请求
+ virtual int ReqMarketData(HLApiReqMarketData* pReqMarketData, int nRequestID) = 0;
+
+ //行情API反初始化
+ virtual void Release(void) = 0;
+
+protected:
+ virtual ~HLQuoteApi(void);
+};
+
+#endif /*HLQUOTEAPI_HHH_*/
+
diff --git a/include/HLAPI/HLQuoteApi.lib b/include/HLAPI/HLQuoteApi.lib
new file mode 100644
index 0000000..b8ce349
Binary files /dev/null and b/include/HLAPI/HLQuoteApi.lib differ
diff --git a/include/HLAPI/HLTradeApi.dll b/include/HLAPI/HLTradeApi.dll
new file mode 100644
index 0000000..3640713
Binary files /dev/null and b/include/HLAPI/HLTradeApi.dll differ
diff --git a/include/HLAPI/HLTradeApi.h b/include/HLAPI/HLTradeApi.h
new file mode 100644
index 0000000..7453708
--- /dev/null
+++ b/include/HLAPI/HLTradeApi.h
@@ -0,0 +1,147 @@
+#ifndef HLTRADEAPI_HHH_
+#define HLTRADEAPI_HHH_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#include "HLUserApiDefine.h"
+
+
+#if defined(ISLIB) && defined(WIN32)
+ #ifdef LIB_HLTRADEAPI_EXPORT
+ #define HLTRADEAPI_EXPORT __declspec(dllexport)
+ #else
+ #define HLTRADEAPI_EXPORT __declspec(dllimport)
+ #endif
+#else
+ #define HLTRADEAPI_EXPORT
+#endif
+
+class HLTRADEAPI_EXPORT HLTradeSpi
+{
+public:
+ ///当客户端与交易后台建立起通信连接,客户端需要进行登录。
+ virtual void OnFrontConnected() {};
+
+ ///当客户端与交易后台通信连接断开时,该方法被调用,客户端不需要处理,API会自动重连。
+ virtual void OnFrontDisconnected(int nReason) {};
+
+ ///错误应答
+ //@cIsLast 包标志 API_PACKET_FIRST | API_PACKET_LAST 下同
+ virtual void OnRspError(CHLRspInfoData* pRspInfo, int nRequestID, char cIsLast) {};
+
+ ///用户登录_应答
+ virtual void OnRspUserLogin(HLApiRspUserLoginData* pRspUserLogin, CHLRspInfoData* pRspInfo, int nRequestID, char cIsLast) {};
+
+ ///用户退出_应答
+ //virtual void OnRspUserLogout(void *pRspUserLogout, void *pRspInfo, int nRequestID, char cIsLast) {};
+
+ ///用户委托请求_应答
+ virtual void OnRspOrder(HLApiRspOrder* pRspOrder, CHLRspInfoData* pRspInfo, int nRequestID, char cIsLast) {};
+
+ ///用户撤单请求_应答
+ virtual void OnRspCancelOrder(HLApiRspCancelOrder* pRspCancelOrder, CHLRspInfoData* pRspInfo, int nRequestID, char cIsLast) {};
+
+ ///ETF清单请求_应答
+ virtual void OnRspETFList(HLApiRspETFList* pRspETFList, CHLRspInfoData* pRspInfo, int nRequestID, char cIsLast) {};
+
+ ///ETF申赎请求_应答
+ virtual void OnRspETFSubscribe(HLApiRspETFSubscribe* pRspETFSubscribe, CHLRspInfoData* pRspInfo, int nRequestID, char cIsLast) {};
+
+ ///查委托请求_应答
+ virtual void OnRspOrderQry(HLApiRspOrderQry* pRspQryOrder, CHLRspInfoData* pRspInfo, int nRequestID, char cIsLast) {};
+
+ ///查当日成交请求_应答
+ virtual void OnRspTodayDealQry(HLApiRspTodayDealQry* pRspQryTodayDeal, CHLRspInfoData* pRspInfo, int nRequestID, char cIsLast) {};
+
+ ///查资金请求_应答
+ virtual void OnRspMoneyInfoQry(HLApiRspMoneyInfoQry* pRspQryMoneyInfo, CHLRspInfoData* pRspInfo, int nRequestID, char cIsLast) {};
+
+ ///可用证券查询请求_应答
+ virtual void OnRspAvlStockInfoQry(HLApiRspAvlStocksInfoQry* pReqQryAvlStockInfo, CHLRspInfoData* pRspInfo, int nRequestID, char cIsLast) {};
+
+ ///委托、撤单、撤单失败通知
+ virtual void OnRtnOrderInfo(HLApiRtnOrderInfo* pRtnOrderInfo, CHLRspInfoData* pRspInfo, int nRequestID) {};
+
+ ///成交通知
+ virtual void OnRtnMatchInfo(HLApiRtnMatchInfo* pRtnMatchInfo, CHLRspInfoData* pRspInfo, int nRequestID) {};
+
+ ///可用证券变化通知
+ virtual void OnRtnAvlStockInfo(HLApiRtnAvlStockInfo* pRtnAvlStockInfo, CHLRspInfoData* pRspInfo, int nRequestID) {};
+
+ ///资金变化通知
+ virtual void OnRtnMoneyInfo(HLApiRtnMoneyInfo* pRtnMoneyInfo, CHLRspInfoData* pRspInfo, int nRequestID) {};
+
+ ///分级基金成分信息查询_应答
+ virtual void OnRspStruFundInfoQry(HLApiRspStruFundInfoQry* pRspQryStruFundInfo, CHLRspInfoData* pRspInfo, int nRequestID, char cIsLast) {};
+
+
+protected:
+ virtual ~HLTradeSpi(void) {};
+};
+
+
+class HLTRADEAPI_EXPORT HLTradeApi
+{
+public:
+ ///创建一个HLTradeApi,可以创建多个,一个API最多只有一个网络通道
+ static HLTradeApi* CreateHLTradeApi(void);
+
+ ///获取系统版本号
+ ///@return 系统版本号标识字符串
+ static const char* GetVersion(void);
+
+ virtual void RegisterNetwork(unsigned short nPort, const char* pszFrontAddr) = 0;
+
+ virtual void RegisterSpi(HLTradeSpi* pHLTradeSpi) = 0;
+
+ virtual int Init(void) = 0;
+
+ virtual void Release (void) = 0;
+
+ ///用户登录请求
+ virtual int ReqUserLogin(HLApiReqUserLoginData* pReqUserLogin, int nRequestID) = 0;
+
+ ///委托请求
+ virtual int ReqOrder(HLApiCmdOrder* pReqOrder, int nRequestID) = 0;
+
+ ///撤单请求
+ virtual int ReqCancelOrder(HLApiCmdCancelOrder* pReqOrder, int nRequestID) = 0;
+
+ ///批量委托请求
+ virtual int ReqBatchOrder(HLApiCmdBatchOrder* pReqBatchOrder, int nRequestID) = 0;
+
+ ///ETF清单请求
+ virtual int ReqETFList(HLApiReqETFList* pReqETFList, int nRequestID) = 0;
+
+ ///ETF申赎请求
+ virtual int ReqETFSubscribe(HLApiCmdETFSubscribe* pReqETFSubscribe, int nRequestID) = 0;
+
+ ///查委托请求
+ virtual int ReqQryOrder(HLApiCmdOrderQry* pReqQryOrder, int nRequestID) = 0;
+
+ ///资金查询请求
+ virtual int ReqQryMoneyInfo(HLApiCmdMoneyInfoQry* pReqQryAvailableMoneyInfo, int nRequestID) = 0;
+
+ ///可用证券查询请求
+ virtual int ReqQryAvlStockInfo(HLApiCmdAvlStocksInfoQry* pReqQryAvailableStockInfo, int nRequestID) = 0;
+
+ ///当日成交查询请求
+ virtual int ReqQryTodayDeal(HLApiCmdTodayDealQry* pReqQryTodayDeal, int nRequestID) = 0;
+
+ ///分级基金成分信息查询
+ virtual int ReqQryStruFundInfo(const HLApiCmdStruFundInfoQry* pReqQryStruFundInfo, int nRequestID) = 0;
+
+ ///修改委托状态请求
+ virtual int ReqChangeOrderStatus (HLApiRspOrder *pReqUserLogin, int nRequestID) = 0;
+
+protected:
+ virtual ~HLTradeApi (void);
+
+};
+
+
+#endif /*HLTRADEAPI_HHH_*/
+
+
diff --git a/include/HLAPI/HLTradeApi.lib b/include/HLAPI/HLTradeApi.lib
new file mode 100644
index 0000000..4006dd3
Binary files /dev/null and b/include/HLAPI/HLTradeApi.lib differ
diff --git a/include/HLAPI/HLTradeApid.dll b/include/HLAPI/HLTradeApid.dll
new file mode 100644
index 0000000..b9767df
Binary files /dev/null and b/include/HLAPI/HLTradeApid.dll differ
diff --git a/include/HLAPI/HLTradeApid.lib b/include/HLAPI/HLTradeApid.lib
new file mode 100644
index 0000000..afa55c5
Binary files /dev/null and b/include/HLAPI/HLTradeApid.lib differ
diff --git a/include/HLAPI/HLUserApiDefine.h b/include/HLAPI/HLUserApiDefine.h
new file mode 100644
index 0000000..877db35
--- /dev/null
+++ b/include/HLAPI/HLUserApiDefine.h
@@ -0,0 +1,527 @@
+#ifndef HLUSERAPIDEFINE_HHH_
+#define HLUSERAPIDEFINE_HHH_
+
+//errcode
+const int API_ERROR_OK = 0; //OK
+const int API_ERROR_DISCONNECTED = -1; //未连接
+const int API_ERROR_NORESULT = 0xD000; //没有查询结果
+
+#define API_PACKET_FIRST 0x01 //首包标记
+#define API_PACKET_LAST 0x02 //尾包标记
+
+#define API_ERRORMSG_LEN 256
+#define API_APP_LEN 16
+#define API_CLIENT_LEN 16
+#define API_ORDERID_LEN 11
+#define API_ACCOUNT_LEN 16
+#define API_PSW_LEN 16
+#define API_IPADDR 16
+#define API_CLIENTINFO 32
+#define API_DATE_LEN 9 //日期结构 yyyymmdd
+#define API_TIME_LEN 9 //时间结构 hh:mm:ss
+#define API_MARKET_LEN 4
+#define API_SYMBOL_LEN 8
+#define API_SYMBOLNAME_LEN 16
+#define API_SAVE_LEN 32
+#define API_PREFIX_LEN 4
+#define API_MATCHED_SN_LEN 17 //成交编号
+#define API_STOCK_PBU_LEN 9 //交易单元
+#define API_TRADE_COUNT_LEN 11 //证券帐户
+#define API_QUERY_POS_LEN 33 //定为串
+#define API_ORD_TIME_LEN 33 //委托时间
+#define API_ORDER_ID_LEN 11 //合同序号
+
+
+#define API_MAX_BATCH_ORDER_COUNT 15 //批量委托最大数量
+#define API_MAX_DAY_ORDER_RECORDSET_COUNT 100 //当日委托查询返回记录最大数量
+#define API_MAX_AVL_STK_COUNTS 100 //查询可用股份时,每次返回最大股份数量
+
+//交易所
+#define API_EXCH_SZ "SZ" //深圳
+#define API_EXCH_SH "SH" //上海
+#define API_EXCH_CF "CF" //中国金融期货交易所
+#define API_EXCH_SP "SP" //商品期货
+
+typedef char API_MARKETFLAG[API_MARKET_LEN];
+
+//板块标志
+typedef enum
+{
+ SectorSHA = '1', //上海A股
+ SectorSZA = '2', //深圳A股
+ SectorSHB = '3', //上海B股
+ SectorSZB = '4', //深圳B股
+ SectorSBA = '5', //三板A
+ SectorSBB = '6', //三板B
+} SECTORSYMBOL;
+
+//成交状态集合
+typedef enum
+{
+ MatchStatusDone = 0, //不包含撤单记录
+ MatchStatusCancel = 1, //包含撤单记录
+} MATCHSTATUSSET;
+
+//证券业务
+typedef enum
+{
+ ETFSubcribe = 1, //申购
+ ETFRedeem = 2, //赎回
+ StockBuy = 100, //证券买入
+ StockSel = 101, //证券卖出
+
+ Fund_Creation = 102, //基金申购
+ Fund_Redemption = 103, //基金赎回
+ Fund_Merger = 104, //基金合并
+ Fund_Demerger = 105, //基金分拆
+
+} STOCKBIZ;
+
+//报价方式
+typedef enum
+{
+ StockLimit = 100, //订单申报-限价委托(支持深沪市)
+ //StockCancel = 101, //撤单申报
+ StockAction1 = 120, //订单申报-最优成交转价(支持深沪市)
+ StockAction2 = 121, //订单申报-最优成交剩撤(支持深市)
+ StockAction3 = 122, //订单申报-全成交或撤销(支持深市)
+ StockAction4 = 123, //订单申报-本方最优价格(支持深市)
+ StockAction5 = 124, //订单申报-对手最优价格(支持深市)
+ StockAction6 = 125, //订单申报-即时成交剩撤(支持沪市)
+} STOCKBIZACTION;
+
+//委托单类型
+typedef enum
+{
+ OrderLimited = 0, //限价
+ OrderAutoOffer = 1, //自动盘口
+ OrderAskPrice1 = 2, //卖一价
+ OrderBidPrice1 = 3, //买一价
+} ORDERPRICETYPE;
+
+//委托状态
+typedef enum
+{
+ OrderNotSend = 'o', //未报
+ OrderSending = 's', //正报
+ OrderNewComer = 'n', //待报
+ OrderSended = 'a', //已报
+ OrderToBeDel = '3', //已报待撤
+ OrderPartCToBeDel = '4', //部成待撤
+ OrderPartDeleted = 'b', //部成部撤
+ OrderToBeDelete = 'f', //场外撤单
+ OrderPartCDeleted = 'p', //部成
+ OrderCompleted = 'c', //全成
+ OrderUseless = 'e', //错单
+ OrderBeDeleted = 'd', //全撤
+ OrderConfirmed = 'D', //已确认
+ OrderDenied = 'E', //已否决
+ OrderCanceling = 'Z', //正在撤单
+ LogoicOrderAbandoned= 'L', //逻辑单作废
+} ORDERSTATUS;
+
+//推送标志
+typedef enum
+{
+ MatchPushDeal = 0, //成交推送
+ MatchPushCancel = 1, //撤单推送
+ MatchPushOrderFailed = 2, //委托失败推送
+ MatchPushCancelFailed = 4, //撤单失败推送
+} MATCHPUSHFLAG;
+
+//委托有效标志
+typedef enum
+{
+ OrderFlagInvalid = 0, //无效
+ OrderFlagValid = 1, //有效
+} ORDERVALIDFLAG;
+
+//撤单标志
+typedef enum
+{
+ FlagNormal = 'F', //正常
+ FlagCanceled = 'T', //撤单
+} ISWITHDRAW;
+
+//币种
+typedef enum
+{
+ CurrencyRMB = 1, //人民币
+ CurrencyUSD = 2, //美元
+ CurrencyHK = 3, //港币
+} CURRENCYTYPE;
+
+//资金状态
+typedef enum
+{
+ FundStatusNormal = 0, //正常
+ FundStatusCancel = 9, //销户
+} FUNDSTATUS;
+
+//ETF申赎标志
+typedef enum
+{
+ ETFSubcribeFlag = 1, //申购
+ ETFRedeemFlag = 2, //赎回
+} ETFSUBSCRIBEFLAG;
+
+
+//委托数据
+typedef struct
+{
+ char chSecurityCode[API_SYMBOL_LEN]; //证券代码
+ double dOrderPrice; //委托价
+ ORDERPRICETYPE eOrderPriceType; //委托价方式
+ int nOrderQty; //委托股数
+ STOCKBIZ eStockBiz; //证券业务
+ STOCKBIZACTION eStockBizAction; //报价方式
+} ORDERDATA;
+
+
+//证券数据
+struct HLApiSecurityCode
+{
+ int nType; //证券类型
+ char chSecurityCode[API_SYMBOL_LEN]; //证券代码
+ char chSymbol[API_SYMBOLNAME_LEN]; //证券名称
+};
+
+//ETF股票数据
+struct ETFItemData
+{
+ char chSecurityCode[API_SYMBOL_LEN]; //股票代码
+ char chSymbol[API_SYMBOLNAME_LEN]; //股票名称
+ SECTORSYMBOL eSectorSymbol; //板块标志
+ int nNum; //股票数量
+ int nFlag; //现金替代标志
+ double dRatio; //溢价比例
+ double dReplaceAmount; //替代金额
+};
+
+///响应信息
+struct CHLRspInfoData
+{
+ int ErrorID;
+ char ErrorMsg[API_ERRORMSG_LEN];
+};
+
+//用户登录请求
+struct HLApiReqUserLoginData
+{
+ char chApplication[API_APP_LEN]; //应用类型
+ char chClientID[API_CLIENT_LEN]; //客户号
+ char chPassword[API_PSW_LEN]; //密码
+ char chDynPassword[API_PSW_LEN]; //动态密码
+ char chCurIP[API_IPADDR]; //IP
+ int nUserType; //客户类型
+ char chClientInfo[API_CLIENTINFO]; //客户端信息
+};
+
+//用户登录响应
+struct HLApiRspUserLoginData
+{
+ char chTradingDay[API_DATE_LEN]; //交易日
+ char chLoginTime[API_TIME_LEN]; //登录时间
+ char chClientID[API_CLIENT_LEN]; //客户号
+ int nSessionID; //session id
+ char chSvrInfo[API_CLIENTINFO]; //服务端信息
+ int nMarkets; //市场个数
+ API_MARKETFLAG* chMarketFlag; //市场标志(SZ;SH;HK;CF)
+ int* nDynDate; //动态数据日期
+};
+
+//市场索引请求
+struct HLApiReqCodeTable
+{
+ char chMarket[API_MARKET_LEN]; //市场标志(SZ;SH;HK;CF)
+};
+
+//市场索引请求应答
+struct HLApiRspCodeTable
+{
+ API_MARKETFLAG chMarketFlag; //市场标志(SZ;SH;HK;CF)
+ int nDate; //数据日期
+ int nCount; //数据总数(-1:未授权)
+ HLApiSecurityCode* pSecurityCode; //数据
+};
+
+//当日ETF清单请求
+struct HLApiReqETFList
+{
+ char chSecurityCode[API_SYMBOL_LEN]; //证券代码
+};
+
+//ETF清单请求响应
+struct HLApiRspETFList
+{
+ char chSecurityCode[API_SYMBOL_LEN]; //ETF代码
+ char chSymbol[API_SYMBOLNAME_LEN]; //ETF名称
+ char szFundid[API_SYMBOL_LEN]; //一级市场代码
+ SECTORSYMBOL eSectorSymbol; //板块标志
+ int nCreationRedemptionUnit; //最小申购赎回单位
+ double dMaxCashRatio; //现金替代比例上限
+ int nCreationRedemption; //基金当天申购赎回状态(1,0)
+ double dEstimateCashComponent; //T日预估现金余额
+ int nTradingDay; //T日日期
+ double dCashComponent; //T-1日现金差额(单位:元)
+ double dNAVperCU; //T-1日最小申购、赎回单位资产净值(单位:元)
+ ETFItemData* pETFItemData; //成份股数组指针
+ int nItemDataSize; //成份股数量
+};
+
+//行情订阅请求
+struct HLApiReqMarketData
+{
+ int nType; //命令类型(0订阅 1退订)
+ char chMarket[API_MARKET_LEN]; //市场标志(SZ;SH;HK;CF)
+ char chSecurityCode[API_SYMBOL_LEN]; //股票代码(空则为全市场行情)
+};
+
+//行情订阅请求应答
+struct HLApiRspMarketData
+{
+ int nResult; //命令结果(0成功 1失败)
+ int nType; //命令类型(0订阅 1退订)
+ char chMarket[API_MARKET_LEN]; //市场标志(SZ;SH;HK;CF)
+ char chSecurityCode[API_SYMBOL_LEN]; //股票代码(空则为全市场行情)
+};
+
+//行情信息
+struct HLApiMarketData
+{
+ char chMarket[API_MARKET_LEN]; //市场标志(SZ;SH;HK;CF)
+ char chSymbol[API_SYMBOL_LEN]; //股票代码
+ int nTime; //时间(HHMMSSmmm)
+ int nStatus; //状态
+ double dPreClose; //前收盘价
+ double dOpen; //开盘价
+ double dHigh; //最高价
+ double dLow; //最低价
+ double dMatch; //最新价
+ double dAskPrice[10]; //申卖价
+ unsigned int nAskVol[10]; //申卖量
+ double dBidPrice[10]; //申买价
+ unsigned int nBidVol[10]; //申买量
+ unsigned int nNumTrades; //成交笔数
+ long long iVolume; //成交总量
+ long long iTurnover; //成交总金额
+ long long nTotalBidVol; //委托买入总量
+ long long nTotalAskVol; //委托卖出总量
+ double dHighLimited; //涨停价
+ double dLowLimited; //跌停价
+};
+
+//用户委托请求
+struct HLApiCmdOrder
+{
+ char chClientID[API_CLIENT_LEN]; //客户号
+ char chAccountNO[API_ACCOUNT_LEN]; //资金账户
+ //int nOrderBsn; //委托批号(0则系统生成)
+ ORDERDATA stOrderData; //委托数据
+ int nSaveInt1; //客户保留字段1
+ int nSaveInt2; //客户保留字段2
+ char chSaveString[API_SAVE_LEN]; //客户保留字段3
+};
+
+//用户委托请求应答
+struct HLApiRspOrder
+{
+ char chClientID[API_CLIENT_LEN]; //客户号
+ char chAccountNO[API_ACCOUNT_LEN]; //资金账户
+ char chSecurityCode[API_SYMBOL_LEN]; //证券代码
+ char chSecurityName[API_SYMBOLNAME_LEN];//证券名称
+ char chOrderID[API_ORDER_ID_LEN]; //合同序号
+ ORDERSTATUS eOrderStatus; //委托状态
+ STOCKBIZ eStockBiz; //证券业务
+ double dOrderPrice; //委托价格
+ int nOrderQty; //委托数量
+ double dMatchedPrice; //已成均价
+ int nMatchedQty; //已成数量
+ char chOrderTime[API_ORD_TIME_LEN]; //委托时间
+ int nOrderDay; //委托日期
+ int nSaveInt1; //客户保留字段1
+ int nSaveInt2; //客户保留字段2
+ char chSaveString[API_SAVE_LEN]; //客户保留字段3
+};
+
+//用户撤单请求
+struct HLApiCmdCancelOrder
+{
+ char chOrderID[API_ORDERID_LEN]; //合同序号
+ char chClientID[API_CLIENT_LEN]; //客户号
+ char chAccountNO[API_ACCOUNT_LEN]; //资金账户
+};
+
+//用户撤单请求应答
+typedef struct HLApiCmdCancelOrder HLApiRspCancelOrder;
+
+//用户批量委托请求
+struct HLApiCmdBatchOrder
+{
+ char chClientID[API_CLIENT_LEN]; //客户号
+ char chAccountNO[API_ACCOUNT_LEN]; //资金账户
+ int nOrderCount; //委托数,最大个数API_MAX_BATCH_ORDER_COUNT
+ ORDERDATA stOrderData[API_MAX_BATCH_ORDER_COUNT]; //委托数据
+ int nSaveInt1; //客户保留字段1
+ int nSaveInt2; //客户保留字段2
+ char chSaveString[API_SAVE_LEN]; //客户保留字段3
+};
+
+//ETF申赎请求
+struct HLApiCmdETFSubscribe
+{
+ char chClientID[API_CLIENT_LEN]; //客户号
+ char chAccountNO[API_ACCOUNT_LEN]; //资金账户
+ ETFSUBSCRIBEFLAG eSubscribeFlag; //申赎标志
+ char chSecurityCode[API_SYMBOL_LEN]; //ETF代码
+ int nSubscribeQty; //申赎份额
+};
+
+//ETF申赎请求应答
+struct HLApiRspETFSubscribe
+{
+ char chClientID[API_CLIENT_LEN]; //客户号
+ char chAccountNO[API_ACCOUNT_LEN]; //资金账户
+ ETFSUBSCRIBEFLAG eSubscribeFlag; //申赎标志
+ char chSecurityCode[API_SYMBOL_LEN]; //ETF代码
+ int nSubscribeQty; //申赎份额
+ char chOrderID[API_ORDERID_LEN]; //合同序号
+};
+
+//成交、撤单、废单通知推送
+struct HLApiRtnMatchInfo
+{
+ char chMatchedSN[API_MATCHED_SN_LEN]; //成交编号
+ SECTORSYMBOL eSectorSymbol; //板块标志
+ char chSecurityCode[API_SYMBOL_LEN]; //证券代码
+ char chSecurityName[API_SYMBOLNAME_LEN];//证券名称
+ char chClientID[API_CLIENT_LEN]; //客户号
+ char chAccountNO[API_ACCOUNT_LEN]; //资金账户
+ char chOrderID[API_ORDER_ID_LEN]; //合同序号
+ int nMatchedQty; //成交或撤单数量
+ double dMatchedPrice; //成交或撤单均价
+ int nMatchedDate; //成交或撤单日期
+ char chMatchedTime[API_ORD_TIME_LEN]; //成交或撤单时间
+ MATCHPUSHFLAG eMatchPushFlag; //推送类型标志
+ STOCKBIZ eStockBiz; //证券业务(成交查询时有效)
+};
+
+typedef struct HLApiRspOrder HLApiRtnOrderInfo;
+
+typedef struct HLApiRspAvlStocksInfoQry HLApiRtnAvlStockInfo;
+
+typedef struct HLApiRspMoneyInfoQry HLApiRtnMoneyInfo;
+
+//委托查询请求
+struct HLApiCmdOrderQry
+{
+ char chClientID[API_CLIENT_LEN]; //客户号
+ char chAccountNO[API_ACCOUNT_LEN]; //资金账户
+ char chBeginDate[API_DATE_LEN]; //起始日期(空为查询所有)
+ char chEndDate[API_DATE_LEN]; //终止日期(空为查询所有)
+ char chOrderID[API_ORDERID_LEN]; //合同序号(空为查询所有)
+ char chSecurityCode[API_SYMBOL_LEN]; //证券代码(空为查询所有)
+ STOCKBIZ eStockBiz; //证券业务(0为查询所有)
+ double dOrderPrice; //委托价(0为查询所有)
+ int nOrderQty; //委托股数(0为查询所有)
+};
+
+//委托查询请求应答
+typedef struct HLApiRspOrder HLApiRspOrderQry;
+
+//可用资金查询
+struct HLApiCmdMoneyInfoQry
+{
+ char chClientID[API_CLIENT_LEN]; //客户号
+ char chAccountNO[API_ACCOUNT_LEN]; //资金账户
+ CURRENCYTYPE eCurrencyType; //币种
+};
+
+//可用资金查询应答
+struct HLApiRspMoneyInfoQry
+{
+ char chClientID[API_CLIENT_LEN]; //客户号
+ char chAccountNO[API_ACCOUNT_LEN]; //资金账户
+ CURRENCYTYPE eCurrencyType; //币种
+ //unsigned short nIntOrg; //内部机构
+ //double dMarketValue; //资产总值
+ //double dFundValue; //资金资产
+ //double dStkValue; //市值
+ //double dFundLoan; //融资总金额
+ //double dFundPreBln; //资金昨日余额
+ double dFundBln; //资金余额
+ double dFundAvl; //可用资金
+ double dFundWithDraw; //可取资金
+ //double dFundUnFrz; //资金解冻金额
+ //double dFundTradeFrz; //资金交易冻结金额
+ //double dFundTradeUnFrz; //资金交易解冻金额
+ //double dFundTradeInTransit; //资金交易在途金额
+ //double FundTradeInBln; //资金交易轧差金额
+ //FUNDSTATUS nFundStatus; //资金状态(正常、销户)
+};
+
+//可用股份查询
+struct HLApiCmdAvlStocksInfoQry
+{
+ char chClientID[API_CLIENT_LEN]; //客户号
+ char chAccountNO[API_ACCOUNT_LEN]; //资金账户
+ char chSecurityCode[API_SYMBOL_LEN]; //证券代码(空为查询所有)
+};
+
+//可用股份查询应答
+struct HLApiRspAvlStocksInfoQry
+{
+ char chClientID[API_CLIENT_LEN]; //客户号
+ char chAccountNO[API_ACCOUNT_LEN]; //资金账户
+ SECTORSYMBOL eSectorSymbol; //板块标志
+ char chSecurityCode[API_SYMBOL_LEN]; //证券代码
+ char chSecurityName[API_SYMBOLNAME_LEN];//证券名称
+ int nStockBln; //证券余额(含当日成交,既拥股数)
+ int nStockAvlValue; //可用余额
+ int nStockPreBln; //昨日库存
+ double dStkValue; //市值
+ double dProPrice; //成本价
+ int nStockSR; //可申赎数量
+ int nStockAskFrn; //卖出冻结
+ int nStockBidFrn; //买入冻结
+};
+
+//当日成交查询
+struct HLApiCmdTodayDealQry
+{
+ char chClientID[API_CLIENT_LEN]; //客户号
+ char chAccountNO[API_ACCOUNT_LEN]; //资金账户
+ char chSecurityCode[API_SYMBOL_LEN]; //证券代码
+ MATCHSTATUSSET eMatchStatus; //成交状态集合
+};
+
+//当日成交查询应答
+typedef struct HLApiRtnMatchInfo HLApiRspTodayDealQry;
+
+
+//分级基金成分信息查询
+struct HLApiCmdStruFundInfoQry
+{
+ char chFundCode[API_SYMBOL_LEN]; //母基金代码,空串""则查询整个清单
+};
+
+
+//分级基金成分信息查询_应答
+struct HLApiRspStruFundInfoQry
+{
+ char chFundCode[API_SYMBOL_LEN]; //母基金代码
+ char chFundName[API_SYMBOLNAME_LEN]; //母基金名称
+ char chFundACode[API_SYMBOL_LEN]; //分级A代码
+ char chFundAName[API_SYMBOLNAME_LEN]; //分级A名称
+ char chFundBCode[API_SYMBOL_LEN]; //分级B代码
+ char chFundBName[API_SYMBOLNAME_LEN]; //分级B名称
+ int nFundAShare; //分级A比例(0,100), 默认:50
+ int nFundBShare; //分级B比例(0,100), 默认:50
+};
+
+
+
+#endif /*HLUSERAPIDEFINE_HHH_*/
+
+
+
diff --git a/include/HLAPI/Qubit_HL_Quote.h b/include/HLAPI/Qubit_HL_Quote.h
new file mode 100644
index 0000000..e11e71e
--- /dev/null
+++ b/include/HLAPI/Qubit_HL_Quote.h
@@ -0,0 +1,123 @@
+// Qubit_HL_Quote.h : Qubit_HL_Quote DLL 的主头文件
+//
+
+#pragma once
+
+
+
+// CQubit_HL_QuoteApp
+// 有关此类实现的信息,请参阅 Qubit_HL_Quote.cpp
+//
+
+#pragma once
+
+#include "../include/ApiStruct.h"
+#include "../include/HLAPI/HLQuoteApi.h"
+
+
+#pragma comment(lib, "../include/HLAPI/HLQuoteApi.lib")
+#pragma comment(lib, "../lib/QuantBox_Queue_x86.lib")
+
+#include
+#include
+#include
+#include
+#include