[Del] dulpicate vnctp code

This commit is contained in:
vn.py 2019-07-16 11:11:33 +08:00
parent 87f2f8141e
commit 07b51393dd
20 changed files with 0 additions and 14453 deletions

View File

@ -1,146 +0,0 @@
#include <string>
#include <queue>
#include <thread>
#include <mutex>
#include <iostream>
#include <codecvt>
#include <condition_variable>
#include <locale>
#include "pybind11/pybind11.h"
using namespace std;
using namespace pybind11;
//任务结构体
struct Task
{
int task_name; //回调函数名称对应的常量
void *task_data; //数据指针
void *task_error; //错误指针
int task_id; //请求id
bool task_last; //是否为最后返回
};
class TerminatedError : std::exception
{};
class TaskQueue
{
private:
queue<Task> queue_; //标准库队列
mutex mutex_; //互斥锁
condition_variable cond_; //条件变量
bool _terminate = false;
public:
//存入新的任务
void push(const Task &task)
{
unique_lock<mutex > mlock(mutex_);
queue_.push(task); //向队列中存入数据
mlock.unlock(); //释放锁
cond_.notify_one(); //通知正在阻塞等待的线程
}
//取出老的任务
Task pop()
{
unique_lock<mutex> mlock(mutex_);
cond_.wait(mlock, [&]() {
return !queue_.empty() || _terminate;
}); //等待条件变量通知
if (_terminate)
throw TerminatedError();
Task task = queue_.front(); //获取队列中的最后一个任务
queue_.pop(); //删除该任务
return task; //返回该任务
}
void terminate()
{
_terminate = true;
cond_.notify_all(); //通知正在阻塞等待的线程
}
};
//从字典中获取某个建值对应的整数,并赋值到请求结构体对象的值上
void getInt(const dict &d, const char *key, int *value)
{
if (d.contains(key)) //检查字典中是否存在该键值
{
object o = d[key]; //获取该键值
*value = o.cast<int>();
}
};
//从字典中获取某个建值对应的浮点数,并赋值到请求结构体对象的值上
void getDouble(const dict &d, const char *key, double *value)
{
if (d.contains(key))
{
object o = d[key];
*value = o.cast<double>();
}
};
//从字典中获取某个建值对应的字符,并赋值到请求结构体对象的值上
void getChar(const dict &d, const char *key, char *value)
{
if (d.contains(key))
{
object o = d[key];
*value = o.cast<char>();
}
};
template <size_t size>
using string_literal = char[size];
//从字典中获取某个建值对应的字符串,并赋值到请求结构体对象的值上
template <size_t size>
void getString(const pybind11::dict &d, const char *key, string_literal<size> &value)
{
if (d.contains(key))
{
object o = d[key];
string s = o.cast<string>();
const char *buf = s.c_str();
strcpy(value, buf);
}
};
//将GBK编码的字符串转换为UTF8
inline string toUtf(const string &gb2312)
{
#ifdef _MSC_VER
const static locale loc("zh-CN");
#else
const static locale loc("zh_CN.GB18030");
#endif
vector<wchar_t> wstr(gb2312.size());
wchar_t* wstrEnd = nullptr;
const char* gbEnd = nullptr;
mbstate_t state = {};
int res = use_facet<codecvt<wchar_t, char, mbstate_t> >
(loc).in(state,
gb2312.data(), gb2312.data() + gb2312.size(), gbEnd,
wstr.data(), wstr.data() + wstr.size(), wstrEnd);
if (codecvt_base::ok == res)
{
wstring_convert<codecvt_utf8<wchar_t>> cutf8;
return cutf8.to_bytes(wstring(wstr.data(), wstrEnd));
}
return string();
}

View File

@ -1,41 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.329
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vnctptd", "vnctptd\vnctptd.vcxproj", "{016732E6-5789-4F7C-9A1C-C46A249080CF}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vnctpmd", "vnctpmd\vnctpmd.vcxproj", "{F00054FF-282F-4826-848E-D58BFB9E9D9F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{016732E6-5789-4F7C-9A1C-C46A249080CF}.Debug|x64.ActiveCfg = Debug|x64
{016732E6-5789-4F7C-9A1C-C46A249080CF}.Debug|x64.Build.0 = Debug|x64
{016732E6-5789-4F7C-9A1C-C46A249080CF}.Debug|x86.ActiveCfg = Debug|Win32
{016732E6-5789-4F7C-9A1C-C46A249080CF}.Debug|x86.Build.0 = Debug|Win32
{016732E6-5789-4F7C-9A1C-C46A249080CF}.Release|x64.ActiveCfg = Release|x64
{016732E6-5789-4F7C-9A1C-C46A249080CF}.Release|x64.Build.0 = Release|x64
{016732E6-5789-4F7C-9A1C-C46A249080CF}.Release|x86.ActiveCfg = Release|Win32
{016732E6-5789-4F7C-9A1C-C46A249080CF}.Release|x86.Build.0 = Release|Win32
{F00054FF-282F-4826-848E-D58BFB9E9D9F}.Debug|x64.ActiveCfg = Debug|x64
{F00054FF-282F-4826-848E-D58BFB9E9D9F}.Debug|x64.Build.0 = Debug|x64
{F00054FF-282F-4826-848E-D58BFB9E9D9F}.Debug|x86.ActiveCfg = Debug|Win32
{F00054FF-282F-4826-848E-D58BFB9E9D9F}.Debug|x86.Build.0 = Debug|Win32
{F00054FF-282F-4826-848E-D58BFB9E9D9F}.Release|x64.ActiveCfg = Release|x64
{F00054FF-282F-4826-848E-D58BFB9E9D9F}.Release|x64.Build.0 = Release|x64
{F00054FF-282F-4826-848E-D58BFB9E9D9F}.Release|x86.ActiveCfg = Release|Win32
{F00054FF-282F-4826-848E-D58BFB9E9D9F}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C24EA8F8-8E45-4556-A1D8-AF8DEE29D09F}
EndGlobalSection
EndGlobal

View File

@ -1,19 +0,0 @@
// dllmain.cpp : 定义 DLL 应用程序的入口点。
#include "stdafx.h"
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;
}

View File

@ -1 +0,0 @@
#include "stdafx.h"

View File

@ -1,17 +0,0 @@
// stdafx.h: 标准系统包含文件的包含文件,
// 或是经常使用但不常更改的
// 项目特定的包含文件
//
#pragma once
#include "targetver.h"
#define WIN32_LEAN_AND_MEAN // 从 Windows 头文件中排除极少使用的内容
// Windows 头文件
#include <windows.h>
// 在此处引用程序需要的其他标头

View File

@ -1,8 +0,0 @@
#pragma once
// 包括 SDKDDKVer.h 将定义可用的最高版本的 Windows 平台。
// 如果要为以前的 Windows 平台生成应用程序,请包括 WinSDKVer.h
// 将 _WIN32_WINNT 宏设置为要支持的平台,然后再包括 SDKDDKVer.h。
#include <SDKDDKVer.h>

View File

@ -1,842 +0,0 @@
// vnctpmd.cpp : 定义 DLL 应用程序的导出函数。
//
#include "vnctpmd.h"
///-------------------------------------------------------------------------------------
///C++的回调函数将数据保存到队列中
///-------------------------------------------------------------------------------------
void MdApi::OnFrontConnected()
{
Task task = Task();
task.task_name = ONFRONTCONNECTED;
this->task_queue.push(task);
};
void MdApi::OnFrontDisconnected(int nReason)
{
Task task = Task();
task.task_name = ONFRONTDISCONNECTED;
task.task_id = nReason;
this->task_queue.push(task);
};
void MdApi::OnHeartBeatWarning(int nTimeLapse)
{
Task task = Task();
task.task_name = ONHEARTBEATWARNING;
task.task_id = nTimeLapse;
this->task_queue.push(task);
};
void MdApi::OnRspUserLogin(CThostFtdcRspUserLoginField *pRspUserLogin, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast)
{
Task task = Task();
task.task_name = ONRSPUSERLOGIN;
if (pRspUserLogin)
{
CThostFtdcRspUserLoginField *task_data = new CThostFtdcRspUserLoginField();
*task_data = *pRspUserLogin;
task.task_data = task_data;
}
if (pRspInfo)
{
CThostFtdcRspInfoField *task_error = new CThostFtdcRspInfoField();
*task_error = *pRspInfo;
task.task_error = task_error;
}
task.task_id = nRequestID;
task.task_last = bIsLast;
this->task_queue.push(task);
};
void MdApi::OnRspUserLogout(CThostFtdcUserLogoutField *pUserLogout, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast)
{
Task task = Task();
task.task_name = ONRSPUSERLOGOUT;
if (pUserLogout)
{
CThostFtdcUserLogoutField *task_data = new CThostFtdcUserLogoutField();
*task_data = *pUserLogout;
task.task_data = task_data;
}
if (pRspInfo)
{
CThostFtdcRspInfoField *task_error = new CThostFtdcRspInfoField();
*task_error = *pRspInfo;
task.task_error = task_error;
}
task.task_id = nRequestID;
task.task_last = bIsLast;
this->task_queue.push(task);
};
void MdApi::OnRspError(CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast)
{
Task task = Task();
task.task_name = ONRSPERROR;
if (pRspInfo)
{
CThostFtdcRspInfoField *task_error = new CThostFtdcRspInfoField();
*task_error = *pRspInfo;
task.task_error = task_error;
}
task.task_id = nRequestID;
task.task_last = bIsLast;
this->task_queue.push(task);
};
void MdApi::OnRspSubMarketData(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast)
{
Task task = Task();
task.task_name = ONRSPSUBMARKETDATA;
if (pSpecificInstrument)
{
CThostFtdcSpecificInstrumentField *task_data = new CThostFtdcSpecificInstrumentField();
*task_data = *pSpecificInstrument;
task.task_data = task_data;
}
if (pRspInfo)
{
CThostFtdcRspInfoField *task_error = new CThostFtdcRspInfoField();
*task_error = *pRspInfo;
task.task_error = task_error;
}
task.task_id = nRequestID;
task.task_last = bIsLast;
this->task_queue.push(task);
};
void MdApi::OnRspUnSubMarketData(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast)
{
Task task = Task();
task.task_name = ONRSPUNSUBMARKETDATA;
if (pSpecificInstrument)
{
CThostFtdcSpecificInstrumentField *task_data = new CThostFtdcSpecificInstrumentField();
*task_data = *pSpecificInstrument;
task.task_data = task_data;
}
if (pRspInfo)
{
CThostFtdcRspInfoField *task_error = new CThostFtdcRspInfoField();
*task_error = *pRspInfo;
task.task_error = task_error;
}
task.task_id = nRequestID;
task.task_last = bIsLast;
this->task_queue.push(task);
};
void MdApi::OnRspSubForQuoteRsp(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast)
{
Task task = Task();
task.task_name = ONRSPSUBFORQUOTERSP;
if (pSpecificInstrument)
{
CThostFtdcSpecificInstrumentField *task_data = new CThostFtdcSpecificInstrumentField();
*task_data = *pSpecificInstrument;
task.task_data = task_data;
}
if (pRspInfo)
{
CThostFtdcRspInfoField *task_error = new CThostFtdcRspInfoField();
*task_error = *pRspInfo;
task.task_error = task_error;
}
task.task_id = nRequestID;
task.task_last = bIsLast;
this->task_queue.push(task);
};
void MdApi::OnRspUnSubForQuoteRsp(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast)
{
Task task = Task();
task.task_name = ONRSPUNSUBFORQUOTERSP;
if (pSpecificInstrument)
{
CThostFtdcSpecificInstrumentField *task_data = new CThostFtdcSpecificInstrumentField();
*task_data = *pSpecificInstrument;
task.task_data = task_data;
}
if (pRspInfo)
{
CThostFtdcRspInfoField *task_error = new CThostFtdcRspInfoField();
*task_error = *pRspInfo;
task.task_error = task_error;
}
task.task_id = nRequestID;
task.task_last = bIsLast;
this->task_queue.push(task);
};
void MdApi::OnRtnDepthMarketData(CThostFtdcDepthMarketDataField *pDepthMarketData)
{
Task task = Task();
task.task_name = ONRTNDEPTHMARKETDATA;
if (pDepthMarketData)
{
CThostFtdcDepthMarketDataField *task_data = new CThostFtdcDepthMarketDataField();
*task_data = *pDepthMarketData;
task.task_data = task_data;
}
this->task_queue.push(task);
};
void MdApi::OnRtnForQuoteRsp(CThostFtdcForQuoteRspField *pForQuoteRsp)
{
Task task = Task();
task.task_name = ONRTNFORQUOTERSP;
if (pForQuoteRsp)
{
CThostFtdcForQuoteRspField *task_data = new CThostFtdcForQuoteRspField();
*task_data = *pForQuoteRsp;
task.task_data = task_data;
}
this->task_queue.push(task);
};
///-------------------------------------------------------------------------------------
///工作线程从队列中取出数据转化为python对象后进行推送
///-------------------------------------------------------------------------------------
void MdApi::processTask()
{
try
{
while (this->active)
{
Task task = this->task_queue.pop();
switch (task.task_name)
{
case ONFRONTCONNECTED:
{
this->processFrontConnected(&task);
break;
}
case ONFRONTDISCONNECTED:
{
this->processFrontDisconnected(&task);
break;
}
case ONHEARTBEATWARNING:
{
this->processHeartBeatWarning(&task);
break;
}
case ONRSPUSERLOGIN:
{
this->processRspUserLogin(&task);
break;
}
case ONRSPUSERLOGOUT:
{
this->processRspUserLogout(&task);
break;
}
case ONRSPERROR:
{
this->processRspError(&task);
break;
}
case ONRSPSUBMARKETDATA:
{
this->processRspSubMarketData(&task);
break;
}
case ONRSPUNSUBMARKETDATA:
{
this->processRspUnSubMarketData(&task);
break;
}
case ONRSPSUBFORQUOTERSP:
{
this->processRspSubForQuoteRsp(&task);
break;
}
case ONRSPUNSUBFORQUOTERSP:
{
this->processRspUnSubForQuoteRsp(&task);
break;
}
case ONRTNDEPTHMARKETDATA:
{
this->processRtnDepthMarketData(&task);
break;
}
case ONRTNFORQUOTERSP:
{
this->processRtnForQuoteRsp(&task);
break;
}
};
}
}
catch (const TerminatedError&)
{
}
};
void MdApi::processFrontConnected(Task *task)
{
gil_scoped_acquire acquire;
this->onFrontConnected();
};
void MdApi::processFrontDisconnected(Task *task)
{
gil_scoped_acquire acquire;
this->onFrontDisconnected(task->task_id);
};
void MdApi::processHeartBeatWarning(Task *task)
{
gil_scoped_acquire acquire;
this->onHeartBeatWarning(task->task_id);
};
void MdApi::processRspUserLogin(Task *task)
{
gil_scoped_acquire acquire;
dict data;
if (task->task_data)
{
CThostFtdcRspUserLoginField *task_data = (CThostFtdcRspUserLoginField*)task->task_data;
data["TradingDay"] = toUtf(task_data->TradingDay);
data["LoginTime"] = toUtf(task_data->LoginTime);
data["BrokerID"] = toUtf(task_data->BrokerID);
data["UserID"] = toUtf(task_data->UserID);
data["SystemName"] = toUtf(task_data->SystemName);
data["FrontID"] = task_data->FrontID;
data["SessionID"] = task_data->SessionID;
data["MaxOrderRef"] = toUtf(task_data->MaxOrderRef);
data["SHFETime"] = toUtf(task_data->SHFETime);
data["DCETime"] = toUtf(task_data->DCETime);
data["CZCETime"] = toUtf(task_data->CZCETime);
data["FFEXTime"] = toUtf(task_data->FFEXTime);
data["INETime"] = toUtf(task_data->INETime);
delete task->task_data;
}
dict error;
if (task->task_error)
{
CThostFtdcRspInfoField *task_error = (CThostFtdcRspInfoField*)task->task_error;
error["ErrorID"] = task_error->ErrorID;
error["ErrorMsg"] = toUtf(task_error->ErrorMsg);
delete task->task_error;
}
this->onRspUserLogin(data, error, task->task_id, task->task_last);
};
void MdApi::processRspUserLogout(Task *task)
{
gil_scoped_acquire acquire;
dict data;
if (task->task_data)
{
CThostFtdcUserLogoutField *task_data = (CThostFtdcUserLogoutField*)task->task_data;
data["BrokerID"] = toUtf(task_data->BrokerID);
data["UserID"] = toUtf(task_data->UserID);
delete task->task_data;
}
dict error;
if (task->task_error)
{
CThostFtdcRspInfoField *task_error = (CThostFtdcRspInfoField*)task->task_error;
error["ErrorID"] = task_error->ErrorID;
error["ErrorMsg"] = toUtf(task_error->ErrorMsg);
delete task->task_error;
}
this->onRspUserLogout(data, error, task->task_id, task->task_last);
};
void MdApi::processRspError(Task *task)
{
gil_scoped_acquire acquire;
dict error;
if (task->task_error)
{
CThostFtdcRspInfoField *task_error = (CThostFtdcRspInfoField*)task->task_error;
error["ErrorID"] = task_error->ErrorID;
error["ErrorMsg"] = toUtf(task_error->ErrorMsg);
delete task->task_error;
}
this->onRspError(error, task->task_id, task->task_last);
};
void MdApi::processRspSubMarketData(Task *task)
{
gil_scoped_acquire acquire;
dict data;
if (task->task_data)
{
CThostFtdcSpecificInstrumentField *task_data = (CThostFtdcSpecificInstrumentField*)task->task_data;
data["InstrumentID"] = toUtf(task_data->InstrumentID);
delete task->task_data;
}
dict error;
if (task->task_error)
{
CThostFtdcRspInfoField *task_error = (CThostFtdcRspInfoField*)task->task_error;
error["ErrorID"] = task_error->ErrorID;
error["ErrorMsg"] = toUtf(task_error->ErrorMsg);
delete task->task_error;
}
this->onRspSubMarketData(data, error, task->task_id, task->task_last);
};
void MdApi::processRspUnSubMarketData(Task *task)
{
gil_scoped_acquire acquire;
dict data;
if (task->task_data)
{
CThostFtdcSpecificInstrumentField *task_data = (CThostFtdcSpecificInstrumentField*)task->task_data;
data["InstrumentID"] = toUtf(task_data->InstrumentID);
delete task->task_data;
}
dict error;
if (task->task_error)
{
CThostFtdcRspInfoField *task_error = (CThostFtdcRspInfoField*)task->task_error;
error["ErrorID"] = task_error->ErrorID;
error["ErrorMsg"] = toUtf(task_error->ErrorMsg);
delete task->task_error;
}
this->onRspUnSubMarketData(data, error, task->task_id, task->task_last);
};
void MdApi::processRspSubForQuoteRsp(Task *task)
{
gil_scoped_acquire acquire;
dict data;
if (task->task_data)
{
CThostFtdcSpecificInstrumentField *task_data = (CThostFtdcSpecificInstrumentField*)task->task_data;
data["InstrumentID"] = toUtf(task_data->InstrumentID);
delete task->task_data;
}
dict error;
if (task->task_error)
{
CThostFtdcRspInfoField *task_error = (CThostFtdcRspInfoField*)task->task_error;
error["ErrorID"] = task_error->ErrorID;
error["ErrorMsg"] = toUtf(task_error->ErrorMsg);
delete task->task_error;
}
this->onRspSubForQuoteRsp(data, error, task->task_id, task->task_last);
};
void MdApi::processRspUnSubForQuoteRsp(Task *task)
{
gil_scoped_acquire acquire;
dict data;
if (task->task_data)
{
CThostFtdcSpecificInstrumentField *task_data = (CThostFtdcSpecificInstrumentField*)task->task_data;
data["InstrumentID"] = toUtf(task_data->InstrumentID);
delete task->task_data;
}
dict error;
if (task->task_error)
{
CThostFtdcRspInfoField *task_error = (CThostFtdcRspInfoField*)task->task_error;
error["ErrorID"] = task_error->ErrorID;
error["ErrorMsg"] = toUtf(task_error->ErrorMsg);
delete task->task_error;
}
this->onRspUnSubForQuoteRsp(data, error, task->task_id, task->task_last);
};
void MdApi::processRtnDepthMarketData(Task *task)
{
gil_scoped_acquire acquire;
dict data;
if (task->task_data)
{
CThostFtdcDepthMarketDataField *task_data = (CThostFtdcDepthMarketDataField*)task->task_data;
data["TradingDay"] = toUtf(task_data->TradingDay);
data["InstrumentID"] = toUtf(task_data->InstrumentID);
data["ExchangeID"] = toUtf(task_data->ExchangeID);
data["ExchangeInstID"] = toUtf(task_data->ExchangeInstID);
data["LastPrice"] = task_data->LastPrice;
data["PreSettlementPrice"] = task_data->PreSettlementPrice;
data["PreClosePrice"] = task_data->PreClosePrice;
data["PreOpenInterest"] = task_data->PreOpenInterest;
data["OpenPrice"] = task_data->OpenPrice;
data["HighestPrice"] = task_data->HighestPrice;
data["LowestPrice"] = task_data->LowestPrice;
data["Volume"] = task_data->Volume;
data["Turnover"] = task_data->Turnover;
data["OpenInterest"] = task_data->OpenInterest;
data["ClosePrice"] = task_data->ClosePrice;
data["SettlementPrice"] = task_data->SettlementPrice;
data["UpperLimitPrice"] = task_data->UpperLimitPrice;
data["LowerLimitPrice"] = task_data->LowerLimitPrice;
data["PreDelta"] = task_data->PreDelta;
data["CurrDelta"] = task_data->CurrDelta;
data["UpdateTime"] = toUtf(task_data->UpdateTime);
data["UpdateMillisec"] = task_data->UpdateMillisec;
data["BidPrice1"] = task_data->BidPrice1;
data["BidVolume1"] = task_data->BidVolume1;
data["AskPrice1"] = task_data->AskPrice1;
data["AskVolume1"] = task_data->AskVolume1;
data["BidPrice2"] = task_data->BidPrice2;
data["BidVolume2"] = task_data->BidVolume2;
data["AskPrice2"] = task_data->AskPrice2;
data["AskVolume2"] = task_data->AskVolume2;
data["BidPrice3"] = task_data->BidPrice3;
data["BidVolume3"] = task_data->BidVolume3;
data["AskPrice3"] = task_data->AskPrice3;
data["AskVolume3"] = task_data->AskVolume3;
data["BidPrice4"] = task_data->BidPrice4;
data["BidVolume4"] = task_data->BidVolume4;
data["AskPrice4"] = task_data->AskPrice4;
data["AskVolume4"] = task_data->AskVolume4;
data["BidPrice5"] = task_data->BidPrice5;
data["BidVolume5"] = task_data->BidVolume5;
data["AskPrice5"] = task_data->AskPrice5;
data["AskVolume5"] = task_data->AskVolume5;
data["AveragePrice"] = task_data->AveragePrice;
data["ActionDay"] = toUtf(task_data->ActionDay);
delete task->task_data;
}
this->onRtnDepthMarketData(data);
};
void MdApi::processRtnForQuoteRsp(Task *task)
{
gil_scoped_acquire acquire;
dict data;
if (task->task_data)
{
CThostFtdcForQuoteRspField *task_data = (CThostFtdcForQuoteRspField*)task->task_data;
data["TradingDay"] = toUtf(task_data->TradingDay);
data["InstrumentID"] = toUtf(task_data->InstrumentID);
data["ForQuoteSysID"] = toUtf(task_data->ForQuoteSysID);
data["ForQuoteTime"] = toUtf(task_data->ForQuoteTime);
data["ActionDay"] = toUtf(task_data->ActionDay);
data["ExchangeID"] = toUtf(task_data->ExchangeID);
delete task->task_data;
}
this->onRtnForQuoteRsp(data);
};
///-------------------------------------------------------------------------------------
///主动函数
///-------------------------------------------------------------------------------------
void MdApi::createFtdcMdApi(string pszFlowPath)
{
this->api = CThostFtdcMdApi::CreateFtdcMdApi(pszFlowPath.c_str());
this->api->RegisterSpi(this);
};
void MdApi::release()
{
this->api->Release();
};
void MdApi::init()
{
this->active = true;
this->task_thread = thread(&MdApi::processTask, this);
this->api->Init();
};
int MdApi::join()
{
int i = this->api->Join();
return i;
};
int MdApi::exit()
{
this->active = false;
this->task_queue.terminate();
this->task_thread.join();
this->api->RegisterSpi(NULL);
this->api->Release();
this->api = NULL;
return 1;
};
string MdApi::getTradingDay()
{
string day = this->api->GetTradingDay();
return day;
};
void MdApi::registerFront(string pszFrontAddress)
{
this->api->RegisterFront((char*)pszFrontAddress.c_str());
};
int MdApi::subscribeMarketData(string instrumentID)
{
char* buffer = (char*) instrumentID.c_str();
char* myreq[1] = { buffer };
int i = this->api->SubscribeMarketData(myreq, 1);
return i;
};
int MdApi::unSubscribeMarketData(string instrumentID)
{
char* buffer = (char*)instrumentID.c_str();
char* myreq[1] = { buffer };;
int i = this->api->UnSubscribeMarketData(myreq, 1);
return i;
};
int MdApi::subscribeForQuoteRsp(string instrumentID)
{
char* buffer = (char*)instrumentID.c_str();
char* myreq[1] = { buffer };
int i = this->api->SubscribeForQuoteRsp(myreq, 1);
return i;
};
int MdApi::unSubscribeForQuoteRsp(string instrumentID)
{
char* buffer = (char*)instrumentID.c_str();
char* myreq[1] = { buffer };;
int i = this->api->UnSubscribeForQuoteRsp(myreq, 1);
return i;
};
int MdApi::reqUserLogin(const dict &req, int reqid)
{
CThostFtdcReqUserLoginField myreq = CThostFtdcReqUserLoginField();
memset(&myreq, 0, sizeof(myreq));
getString(req, "TradingDay", myreq.TradingDay);
getString(req, "BrokerID", myreq.BrokerID);
getString(req, "UserID", myreq.UserID);
getString(req, "Password", myreq.Password);
getString(req, "UserProductInfo", myreq.UserProductInfo);
getString(req, "InterfaceProductInfo", myreq.InterfaceProductInfo);
getString(req, "ProtocolInfo", myreq.ProtocolInfo);
getString(req, "MacAddress", myreq.MacAddress);
getString(req, "OneTimePassword", myreq.OneTimePassword);
getString(req, "ClientIPAddress", myreq.ClientIPAddress);
getString(req, "LoginRemark", myreq.LoginRemark);
int i = this->api->ReqUserLogin(&myreq, reqid);
return i;
};
int MdApi::reqUserLogout(const dict &req, int reqid)
{
CThostFtdcUserLogoutField myreq = CThostFtdcUserLogoutField();
memset(&myreq, 0, sizeof(myreq));
getString(req, "BrokerID", myreq.BrokerID);
getString(req, "UserID", myreq.UserID);
int i = this->api->ReqUserLogout(&myreq, reqid);
return i;
};
///-------------------------------------------------------------------------------------
///Boost.Python封装
///-------------------------------------------------------------------------------------
class PyMdApi: public MdApi
{
public:
using MdApi::MdApi;
void onFrontConnected() override
{
try
{
PYBIND11_OVERLOAD(void, MdApi, onFrontConnected);
}
catch (const error_already_set &e)
{
cout << e.what() << endl;
}
};
void onFrontDisconnected(int reqid) override
{
try
{
PYBIND11_OVERLOAD(void, MdApi, onFrontDisconnected, reqid);
}
catch (const error_already_set &e)
{
cout << e.what() << endl;
}
};
void onHeartBeatWarning(int reqid) override
{
try
{
PYBIND11_OVERLOAD(void, MdApi, onHeartBeatWarning, reqid);
}
catch (const error_already_set &e)
{
cout << e.what() << endl;
}
};
void onRspUserLogin(const dict &data, const dict &error, int reqid, bool last) override
{
try
{
PYBIND11_OVERLOAD(void, MdApi, onRspUserLogin, data, error, reqid, last);
}
catch (const error_already_set &e)
{
cout << e.what() << endl;
}
};
void onRspUserLogout(const dict &data, const dict &error, int reqid, bool last) override
{
try
{
PYBIND11_OVERLOAD(void, MdApi, onRspUserLogout, data, error, reqid, last);
}
catch (const error_already_set &e)
{
cout << e.what() << endl;
}
};
void onRspError(const dict &error, int reqid, bool last) override
{
try
{
PYBIND11_OVERLOAD(void, MdApi, onRspError, error, reqid, last);
}
catch (const error_already_set &e)
{
cout << e.what() << endl;
}
};
void onRspSubMarketData(const dict &data, const dict &error, int reqid, bool last) override
{
try
{
PYBIND11_OVERLOAD(void, MdApi, onRspSubMarketData, data, error, reqid, last);
}
catch (const error_already_set &e)
{
cout << e.what() << endl;
}
};
void onRspUnSubMarketData(const dict &data, const dict &error, int reqid, bool last) override
{
try
{
PYBIND11_OVERLOAD(void, MdApi, onRspUnSubMarketData, data, error, reqid, last);
}
catch (const error_already_set &e)
{
cout << e.what() << endl;
}
};
void onRspSubForQuoteRsp(const dict &data, const dict &error, int reqid, bool last) override
{
try
{
PYBIND11_OVERLOAD(void, MdApi, onRspSubForQuoteRsp, data, error, reqid, last);
}
catch (const error_already_set &e)
{
cout << e.what() << endl;
}
};
void onRspUnSubForQuoteRsp(const dict &data, const dict &error, int reqid, bool last) override
{
try
{
PYBIND11_OVERLOAD(void, MdApi, onRspUnSubForQuoteRsp, data, error, reqid, last);
}
catch (const error_already_set &e)
{
cout << e.what() << endl;
}
};
void onRtnDepthMarketData(const dict &data) override
{
try
{
PYBIND11_OVERLOAD(void, MdApi, onRtnDepthMarketData, data);
}
catch (const error_already_set &e)
{
cout << e.what() << endl;
}
};
void onRtnForQuoteRsp(const dict &data) override
{
try
{
PYBIND11_OVERLOAD(void, MdApi, onRtnForQuoteRsp, data);
}
catch (const error_already_set &e)
{
cout << e.what() << endl;
}
};
};
PYBIND11_MODULE(vnctpmd, m)
{
class_<MdApi, PyMdApi> mdapi(m, "MdApi", module_local());
mdapi
.def(init<>())
.def("createFtdcMdApi", &MdApi::createFtdcMdApi)
.def("release", &MdApi::release)
.def("init", &MdApi::init)
.def("join", &MdApi::join)
.def("exit", &MdApi::exit)
.def("getTradingDay", &MdApi::getTradingDay)
.def("registerFront", &MdApi::registerFront)
.def("subscribeMarketData", &MdApi::subscribeMarketData)
.def("unSubscribeMarketData", &MdApi::unSubscribeMarketData)
.def("subscribeForQuoteRsp", &MdApi::subscribeForQuoteRsp)
.def("unSubscribeForQuoteRsp", &MdApi::unSubscribeForQuoteRsp)
.def("reqUserLogin", &MdApi::reqUserLogin)
.def("reqUserLogout", &MdApi::reqUserLogout)
.def("onFrontConnected", &MdApi::onFrontConnected)
.def("onFrontDisconnected", &MdApi::onFrontDisconnected)
.def("onHeartBeatWarning", &MdApi::onHeartBeatWarning)
.def("onRspUserLogin", &MdApi::onRspUserLogin)
.def("onRspUserLogout", &MdApi::onRspUserLogout)
.def("onRspError", &MdApi::onRspError)
.def("onRspSubMarketData", &MdApi::onRspSubMarketData)
.def("onRspUnSubMarketData", &MdApi::onRspUnSubMarketData)
.def("onRspSubForQuoteRsp", &MdApi::onRspSubForQuoteRsp)
.def("onRspUnSubForQuoteRsp", &MdApi::onRspUnSubForQuoteRsp)
.def("onRtnDepthMarketData", &MdApi::onRtnDepthMarketData)
.def("onRtnForQuoteRsp", &MdApi::onRtnForQuoteRsp)
;
}

View File

@ -1,194 +0,0 @@
//系统
#ifdef WIN32
#include "stdafx.h"
#endif
#include "vnctp.h"
#include "pybind11/pybind11.h"
#include "ctp/ThostFtdcMdApi.h"
using namespace pybind11;
//常量
#define ONFRONTCONNECTED 0
#define ONFRONTDISCONNECTED 1
#define ONHEARTBEATWARNING 2
#define ONRSPUSERLOGIN 3
#define ONRSPUSERLOGOUT 4
#define ONRSPERROR 5
#define ONRSPSUBMARKETDATA 6
#define ONRSPUNSUBMARKETDATA 7
#define ONRSPSUBFORQUOTERSP 8
#define ONRSPUNSUBFORQUOTERSP 9
#define ONRTNDEPTHMARKETDATA 10
#define ONRTNFORQUOTERSP 11
///-------------------------------------------------------------------------------------
///C++ SPI的回调函数方法实现
///-------------------------------------------------------------------------------------
//API的继承实现
class MdApi : public CThostFtdcMdSpi
{
private:
CThostFtdcMdApi* api; //API对象
thread task_thread; //工作线程指针向python中推送数据
TaskQueue task_queue; //任务队列
bool active = false; //工作状态
public:
MdApi()
{
};
~MdApi()
{
if (this->active)
{
this->exit();
}
};
//-------------------------------------------------------------------------------------
//API回调函数
//-------------------------------------------------------------------------------------
///当客户端与交易后台建立起通信连接时(还未登录前),该方法被调用。
virtual void OnFrontConnected() ;
///当客户端与交易后台通信连接断开时该方法被调用。当发生这个情况后API会自动重新连接客户端可不做处理。
///@param nReason 错误原因
/// 0x1001 网络读失败
/// 0x1002 网络写失败
/// 0x2001 接收心跳超时
/// 0x2002 发送心跳失败
/// 0x2003 收到错误报文
virtual void OnFrontDisconnected(int nReason) ;
///心跳超时警告。当长时间未收到报文时,该方法被调用。
///@param nTimeLapse 距离上次接收报文的时间
virtual void OnHeartBeatWarning(int nTimeLapse) ;
///登录请求响应
virtual void OnRspUserLogin(CThostFtdcRspUserLoginField *pRspUserLogin, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) ;
///登出请求响应
virtual void OnRspUserLogout(CThostFtdcUserLogoutField *pUserLogout, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) ;
///错误应答
virtual void OnRspError(CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) ;
///订阅行情应答
virtual void OnRspSubMarketData(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) ;
///取消订阅行情应答
virtual void OnRspUnSubMarketData(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) ;
///订阅询价应答
virtual void OnRspSubForQuoteRsp(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) ;
///取消订阅询价应答
virtual void OnRspUnSubForQuoteRsp(CThostFtdcSpecificInstrumentField *pSpecificInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) ;
///深度行情通知
virtual void OnRtnDepthMarketData(CThostFtdcDepthMarketDataField *pDepthMarketData) ;
///询价通知
virtual void OnRtnForQuoteRsp(CThostFtdcForQuoteRspField *pForQuoteRsp) ;
//-------------------------------------------------------------------------------------
//task任务
//-------------------------------------------------------------------------------------
void processTask();
void processFrontConnected(Task *task);
void processFrontDisconnected(Task *task);
void processHeartBeatWarning(Task *task);
void processRspUserLogin(Task *task);
void processRspUserLogout(Task *task);
void processRspError(Task *task);
void processRspSubMarketData(Task *task);
void processRspUnSubMarketData(Task *task);
void processRspSubForQuoteRsp(Task *task);
void processRspUnSubForQuoteRsp(Task *task);
void processRtnDepthMarketData(Task *task);
void processRtnForQuoteRsp(Task *task);
//-------------------------------------------------------------------------------------
//data回调函数的数据字典
//error回调函数的错误字典
//id请求id
//last是否为最后返回
//i整数
//-------------------------------------------------------------------------------------
virtual void onFrontConnected() {};
virtual void onFrontDisconnected(int reqid) {};
virtual void onHeartBeatWarning(int reqid) {};
virtual void onRspUserLogin(const dict &data, const dict &error, int reqid, bool last) {};
virtual void onRspUserLogout(const dict &data, const dict &error, int reqid, bool last) {};
virtual void onRspError(const dict &error, int reqid, bool last) {};
virtual void onRspSubMarketData(const dict &data, const dict &error, int reqid, bool last) {};
virtual void onRspUnSubMarketData(const dict &data, const dict &error, int reqid, bool last) {};
virtual void onRspSubForQuoteRsp(const dict &data, const dict &error, int reqid, bool last) {};
virtual void onRspUnSubForQuoteRsp(const dict &data, const dict &error, int reqid, bool last) {};
virtual void onRtnDepthMarketData(const dict &data) {};
virtual void onRtnForQuoteRsp(const dict &data) {};
//-------------------------------------------------------------------------------------
//req:主动函数的请求字典
//-------------------------------------------------------------------------------------
void createFtdcMdApi(string pszFlowPath = "");
void release();
void init();
int join();
int exit();
string getTradingDay();
void registerFront(string pszFrontAddress);
int subscribeMarketData(string instrumentID);
int unSubscribeMarketData(string instrumentID);
int subscribeForQuoteRsp(string instrumentID);
int unSubscribeForQuoteRsp(string instrumentID);
int reqUserLogin(const dict &req, int reqid);
int reqUserLogout(const dict &req, int reqid);
};

View File

@ -1,200 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{F00054FF-282F-4826-848E-D58BFB9E9D9F}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>vnctpmd</RootNamespace>
<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>C:\Python37\include;$(SolutionDir);$(SolutionDir)..\include;$(SolutionDir)..\include\ctp;$(IncludePath)</IncludePath>
<LibraryPath>C:\Python37\libs;$(SolutionDir)..\libs;$(LibraryPath)</LibraryPath>
<TargetExt>.pyd</TargetExt>
<OutDir>$(SolutionDir)..\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>C:\Python37\include;$(SolutionDir);$(SolutionDir)..\include;$(SolutionDir)..\include\ctp;$(IncludePath)</IncludePath>
<LibraryPath>C:\Python37\libs;$(SolutionDir)..\libs;$(LibraryPath)</LibraryPath>
<TargetExt>.pyd</TargetExt>
<OutDir>$(SolutionDir)..\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<TargetExt>.pyd</TargetExt>
<IncludePath>C:\Python37\include;$(SolutionDir);$(SolutionDir)..\include;$(SolutionDir)..\include\ctp;$(IncludePath)</IncludePath>
<ReferencePath>C:\GitHub\vnpy\vnpy\api\ctp\ctpapi;$(ReferencePath)</ReferencePath>
<LibraryPath>C:\Python37\libs;$(SolutionDir)..\libs;$(LibraryPath)</LibraryPath>
<OutDir>$(SolutionDir)..\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>C:\Miniconda3\include;$(SolutionDir);$(SolutionDir)..\include;$(SolutionDir)..\include\ctp;$(IncludePath)</IncludePath>
<ReferencePath>$(ReferencePath)</ReferencePath>
<TargetExt>.pyd</TargetExt>
<LibraryPath>C:\Miniconda3\libs;$(SolutionDir)..\libs;$(LibraryPath)</LibraryPath>
<OutDir>$(SolutionDir)..\</OutDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NOMINMAX;_CRT_SECURE_NO_WARNINGS;NOMINMAX;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;VNCTPMD_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<ForcedIncludeFiles>stdafx.h</ForcedIncludeFiles>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NOMINMAX;_CRT_SECURE_NO_WARNINGS;NOMINMAX;_CRT_SECURE_NO_WARNINGS;_DEBUG;VNCTPMD_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<ForcedIncludeFiles>stdafx.h</ForcedIncludeFiles>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NOMINMAX;_CRT_SECURE_NO_WARNINGS;NOMINMAX;_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;VNCTPMD_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<ForcedIncludeFiles>stdafx.h</ForcedIncludeFiles>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NOMINMAX;_CRT_SECURE_NO_WARNINGS;NDEBUG;VNCTPMD_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>
</AdditionalIncludeDirectories>
<ForcedIncludeFiles>stdafx.h</ForcedIncludeFiles>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>C:\GitHub\vnpy\vnpy\api\ctp\libs;C:\Miniconda3\libs;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>thostmduserapi_se.lib;thosttraderapi_se.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\..\include\ctp\ThostFtdcMdApi.h" />
<ClInclude Include="..\..\include\ctp\ThostFtdcTraderApi.h" />
<ClInclude Include="..\..\include\ctp\ThostFtdcUserApiDataType.h" />
<ClInclude Include="..\..\include\ctp\ThostFtdcUserApiStruct.h" />
<ClInclude Include="..\vnctp.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
<ClInclude Include="vnctpmd.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="vnctpmd.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -1,54 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="源文件">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="头文件">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="资源文件">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="targetver.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="vnctpmd.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="..\..\include\ctp\ThostFtdcMdApi.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="..\..\include\ctp\ThostFtdcTraderApi.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="..\..\include\ctp\ThostFtdcUserApiDataType.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="..\..\include\ctp\ThostFtdcUserApiStruct.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="..\vnctp.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="vnctpmd.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="dllmain.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
</Project>

View File

@ -1,19 +0,0 @@
// dllmain.cpp : 定义 DLL 应用程序的入口点。
#include "stdafx.h"
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;
}

View File

@ -1 +0,0 @@
#include "stdafx.h"

View File

@ -1,16 +0,0 @@
// stdafx.h: 标准系统包含文件的包含文件,
// 或是经常使用但不常更改的
// 项目特定的包含文件
//
#pragma once
#include "targetver.h"
#define WIN32_LEAN_AND_MEAN // 从 Windows 头文件中排除极少使用的内容
// Windows 头文件
#include <windows.h>
// 在此处引用程序需要的其他标头

View File

@ -1,8 +0,0 @@
#pragma once
// 包括 SDKDDKVer.h 将定义可用的最高版本的 Windows 平台。
// 如果要为以前的 Windows 平台生成应用程序,请包括 WinSDKVer.h
// 将 _WIN32_WINNT 宏设置为要支持的平台,然后再包括 SDKDDKVer.h。
#include <SDKDDKVer.h>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,198 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{016732E6-5789-4F7C-9A1C-C46A249080CF}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>vnctptd</RootNamespace>
<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>C:\Python37\include;$(SolutionDir);$(SolutionDir)..\include;$(SolutionDir)..\include\ctp;$(IncludePath)</IncludePath>
<LibraryPath>C:\Python37\libs;$(SolutionDir)..\libs;$(LibraryPath)</LibraryPath>
<TargetExt>.pyd</TargetExt>
<OutDir>$(SolutionDir)..\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>C:\Python37\include;$(SolutionDir);$(SolutionDir)..\include;$(SolutionDir)..\include\ctp;$(IncludePath)</IncludePath>
<LibraryPath>C:\Python37\libs;$(SolutionDir)..\libs;$(LibraryPath)</LibraryPath>
<TargetExt>.pyd</TargetExt>
<OutDir>$(SolutionDir)..\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>C:\Python37\include;$(SolutionDir);$(SolutionDir)..\include;$(SolutionDir)..\include\ctp;$(IncludePath)</IncludePath>
<LibraryPath>C:\Python37\libs;$(SolutionDir)..\libs;$(LibraryPath)</LibraryPath>
<TargetExt>.pyd</TargetExt>
<OutDir>$(SolutionDir)..\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<TargetExt>.pyd</TargetExt>
<IncludePath>C:\Miniconda3\include;$(SolutionDir);$(SolutionDir)..\include;$(SolutionDir)..\include\ctp;$(IncludePath)</IncludePath>
<LibraryPath>C:\Miniconda3\libs;$(SolutionDir)..\libs;$(LibraryPath)</LibraryPath>
<OutDir>$(SolutionDir)..\</OutDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NOMINMAX;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;VNCTPTD_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<ForcedIncludeFiles>stdafx.h</ForcedIncludeFiles>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NOMINMAX;_CRT_SECURE_NO_WARNINGS;_DEBUG;VNCTPTD_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<ForcedIncludeFiles>stdafx.h</ForcedIncludeFiles>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NOMINMAX;_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;VNCTPTD_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<ForcedIncludeFiles>stdafx.h</ForcedIncludeFiles>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NOMINMAX;_CRT_SECURE_NO_WARNINGS;NDEBUG;VNCTPTD_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>
</AdditionalIncludeDirectories>
<ForcedIncludeFiles>stdafx.h</ForcedIncludeFiles>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>C:\Miniconda3\libs;C:\GitHub\vnpy\vnpy\api\ctp\libs;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>thostmduserapi_se.lib;thosttraderapi_se.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\..\include\ctp\ThostFtdcMdApi.h" />
<ClInclude Include="..\..\include\ctp\ThostFtdcTraderApi.h" />
<ClInclude Include="..\..\include\ctp\ThostFtdcUserApiDataType.h" />
<ClInclude Include="..\..\include\ctp\ThostFtdcUserApiStruct.h" />
<ClInclude Include="..\vnctp.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
<ClInclude Include="vnctptd.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="vnctptd.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -1,54 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="源文件">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="头文件">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="资源文件">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="targetver.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="vnctptd.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="..\..\include\ctp\ThostFtdcMdApi.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="..\..\include\ctp\ThostFtdcTraderApi.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="..\..\include\ctp\ThostFtdcUserApiDataType.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="..\..\include\ctp\ThostFtdcUserApiStruct.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="..\vnctp.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="vnctptd.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="dllmain.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
</Project>

View File

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
</Project>