初步完成vn.ctp封装,完成md的测试,td的测试只进行了初步
This commit is contained in:
parent
36fc5b0d19
commit
5ece1a7f36
158
vn.ctp/ctpapi/ThostFtdcMdApi.h
Normal file
158
vn.ctp/ctpapi/ThostFtdcMdApi.h
Normal file
@ -0,0 +1,158 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///@system 新一代交易所系统
|
||||
///@company 上海期货信息技术有限公司
|
||||
///@file ThostFtdcMdApi.h
|
||||
///@brief 定义了客户端接口
|
||||
///@history
|
||||
///20060106 赵鸿昊 创建该文件
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(THOST_FTDCMDAPI_H)
|
||||
#define THOST_FTDCMDAPI_H
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include "ThostFtdcUserApiStruct.h"
|
||||
|
||||
#if defined(ISLIB) && defined(WIN32)
|
||||
#ifdef LIB_MD_API_EXPORT
|
||||
#define MD_API_EXPORT __declspec(dllexport)
|
||||
#else
|
||||
#define MD_API_EXPORT __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define MD_API_EXPORT
|
||||
#endif
|
||||
|
||||
class CThostFtdcMdSpi
|
||||
{
|
||||
public:
|
||||
///当客户端与交易后台建立起通信连接时(还未登录前),该方法被调用。
|
||||
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) {};
|
||||
};
|
||||
|
||||
class MD_API_EXPORT CThostFtdcMdApi
|
||||
{
|
||||
public:
|
||||
///创建MdApi
|
||||
///@param pszFlowPath 存贮订阅信息文件的目录,默认为当前目录
|
||||
///@return 创建出的UserApi
|
||||
///modify for udp marketdata
|
||||
static CThostFtdcMdApi *CreateFtdcMdApi(const char *pszFlowPath = "", const bool bIsUsingUdp=false, const bool bIsMulticast=false);
|
||||
|
||||
///删除接口对象本身
|
||||
///@remark 不再使用本接口对象时,调用该函数删除接口对象
|
||||
virtual void Release() = 0;
|
||||
|
||||
///初始化
|
||||
///@remark 初始化运行环境,只有调用后,接口才开始工作
|
||||
virtual void Init() = 0;
|
||||
|
||||
///等待接口线程结束运行
|
||||
///@return 线程退出代码
|
||||
virtual int Join() = 0;
|
||||
|
||||
///获取当前交易日
|
||||
///@retrun 获取到的交易日
|
||||
///@remark 只有登录成功后,才能得到正确的交易日
|
||||
virtual const char *GetTradingDay() = 0;
|
||||
|
||||
///注册前置机网络地址
|
||||
///@param pszFrontAddress:前置机网络地址。
|
||||
///@remark 网络地址的格式为:“protocol://ipaddress:port”,如:”tcp://127.0.0.1:17001”。
|
||||
///@remark “tcp”代表传输协议,“127.0.0.1”代表服务器地址。”17001”代表服务器端口号。
|
||||
virtual void RegisterFront(char *pszFrontAddress) = 0;
|
||||
|
||||
///注册名字服务器网络地址
|
||||
///@param pszNsAddress:名字服务器网络地址。
|
||||
///@remark 网络地址的格式为:“protocol://ipaddress:port”,如:”tcp://127.0.0.1:12001”。
|
||||
///@remark “tcp”代表传输协议,“127.0.0.1”代表服务器地址。”12001”代表服务器端口号。
|
||||
///@remark RegisterNameServer优先于RegisterFront
|
||||
virtual void RegisterNameServer(char *pszNsAddress) = 0;
|
||||
|
||||
///注册名字服务器用户信息
|
||||
///@param pFensUserInfo:用户信息。
|
||||
virtual void RegisterFensUserInfo(CThostFtdcFensUserInfoField * pFensUserInfo) = 0;
|
||||
|
||||
///注册回调接口
|
||||
///@param pSpi 派生自回调接口类的实例
|
||||
virtual void RegisterSpi(CThostFtdcMdSpi *pSpi) = 0;
|
||||
|
||||
///订阅行情。
|
||||
///@param ppInstrumentID 合约ID
|
||||
///@param nCount 要订阅/退订行情的合约个数
|
||||
///@remark
|
||||
virtual int SubscribeMarketData(char *ppInstrumentID[], int nCount) = 0;
|
||||
|
||||
///退订行情。
|
||||
///@param ppInstrumentID 合约ID
|
||||
///@param nCount 要订阅/退订行情的合约个数
|
||||
///@remark
|
||||
virtual int UnSubscribeMarketData(char *ppInstrumentID[], int nCount) = 0;
|
||||
|
||||
///订阅询价。
|
||||
///@param ppInstrumentID 合约ID
|
||||
///@param nCount 要订阅/退订行情的合约个数
|
||||
///@remark
|
||||
virtual int SubscribeForQuoteRsp(char *ppInstrumentID[], int nCount) = 0;
|
||||
|
||||
///退订询价。
|
||||
///@param ppInstrumentID 合约ID
|
||||
///@param nCount 要订阅/退订行情的合约个数
|
||||
///@remark
|
||||
virtual int UnSubscribeForQuoteRsp(char *ppInstrumentID[], int nCount) = 0;
|
||||
|
||||
///用户登录请求
|
||||
virtual int ReqUserLogin(CThostFtdcReqUserLoginField *pReqUserLoginField, int nRequestID) = 0;
|
||||
|
||||
|
||||
///登出请求
|
||||
virtual int ReqUserLogout(CThostFtdcUserLogoutField *pUserLogout, int nRequestID) = 0;
|
||||
protected:
|
||||
~CThostFtdcMdApi(){};
|
||||
};
|
||||
|
||||
#endif
|
575
vn.ctp/ctpapi/ThostFtdcTraderApi.h
Normal file
575
vn.ctp/ctpapi/ThostFtdcTraderApi.h
Normal file
@ -0,0 +1,575 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///@system 新一代交易所系统
|
||||
///@company 上海期货信息技术有限公司
|
||||
///@file ThostFtdcTraderApi.h
|
||||
///@brief 定义了客户端接口
|
||||
///@history
|
||||
///20060106 赵鸿昊 创建该文件
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(THOST_FTDCTRADERAPI_H)
|
||||
#define THOST_FTDCTRADERAPI_H
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include "ThostFtdcUserApiStruct.h"
|
||||
|
||||
#if defined(ISLIB) && defined(WIN32)
|
||||
#ifdef LIB_TRADER_API_EXPORT
|
||||
#define TRADER_API_EXPORT __declspec(dllexport)
|
||||
#else
|
||||
#define TRADER_API_EXPORT __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define TRADER_API_EXPORT
|
||||
#endif
|
||||
|
||||
class CThostFtdcTraderSpi
|
||||
{
|
||||
public:
|
||||
///当客户端与交易后台建立起通信连接时(还未登录前),该方法被调用。
|
||||
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 OnRspAuthenticate(CThostFtdcRspAuthenticateField *pRspAuthenticateField, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
|
||||
///登录请求响应
|
||||
virtual void OnRspUserLogin(CThostFtdcRspUserLoginField *pRspUserLogin, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///登出请求响应
|
||||
virtual void OnRspUserLogout(CThostFtdcUserLogoutField *pUserLogout, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///用户口令更新请求响应
|
||||
virtual void OnRspUserPasswordUpdate(CThostFtdcUserPasswordUpdateField *pUserPasswordUpdate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///资金账户口令更新请求响应
|
||||
virtual void OnRspTradingAccountPasswordUpdate(CThostFtdcTradingAccountPasswordUpdateField *pTradingAccountPasswordUpdate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///报单录入请求响应
|
||||
virtual void OnRspOrderInsert(CThostFtdcInputOrderField *pInputOrder, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///预埋单录入请求响应
|
||||
virtual void OnRspParkedOrderInsert(CThostFtdcParkedOrderField *pParkedOrder, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///预埋撤单录入请求响应
|
||||
virtual void OnRspParkedOrderAction(CThostFtdcParkedOrderActionField *pParkedOrderAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///报单操作请求响应
|
||||
virtual void OnRspOrderAction(CThostFtdcInputOrderActionField *pInputOrderAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///查询最大报单数量响应
|
||||
virtual void OnRspQueryMaxOrderVolume(CThostFtdcQueryMaxOrderVolumeField *pQueryMaxOrderVolume, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///投资者结算结果确认响应
|
||||
virtual void OnRspSettlementInfoConfirm(CThostFtdcSettlementInfoConfirmField *pSettlementInfoConfirm, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///删除预埋单响应
|
||||
virtual void OnRspRemoveParkedOrder(CThostFtdcRemoveParkedOrderField *pRemoveParkedOrder, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///删除预埋撤单响应
|
||||
virtual void OnRspRemoveParkedOrderAction(CThostFtdcRemoveParkedOrderActionField *pRemoveParkedOrderAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///执行宣告录入请求响应
|
||||
virtual void OnRspExecOrderInsert(CThostFtdcInputExecOrderField *pInputExecOrder, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///执行宣告操作请求响应
|
||||
virtual void OnRspExecOrderAction(CThostFtdcInputExecOrderActionField *pInputExecOrderAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///询价录入请求响应
|
||||
virtual void OnRspForQuoteInsert(CThostFtdcInputForQuoteField *pInputForQuote, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///报价录入请求响应
|
||||
virtual void OnRspQuoteInsert(CThostFtdcInputQuoteField *pInputQuote, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///报价操作请求响应
|
||||
virtual void OnRspQuoteAction(CThostFtdcInputQuoteActionField *pInputQuoteAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询报单响应
|
||||
virtual void OnRspQryOrder(CThostFtdcOrderField *pOrder, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询成交响应
|
||||
virtual void OnRspQryTrade(CThostFtdcTradeField *pTrade, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询投资者持仓响应
|
||||
virtual void OnRspQryInvestorPosition(CThostFtdcInvestorPositionField *pInvestorPosition, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询资金账户响应
|
||||
virtual void OnRspQryTradingAccount(CThostFtdcTradingAccountField *pTradingAccount, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询投资者响应
|
||||
virtual void OnRspQryInvestor(CThostFtdcInvestorField *pInvestor, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询交易编码响应
|
||||
virtual void OnRspQryTradingCode(CThostFtdcTradingCodeField *pTradingCode, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询合约保证金率响应
|
||||
virtual void OnRspQryInstrumentMarginRate(CThostFtdcInstrumentMarginRateField *pInstrumentMarginRate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询合约手续费率响应
|
||||
virtual void OnRspQryInstrumentCommissionRate(CThostFtdcInstrumentCommissionRateField *pInstrumentCommissionRate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询交易所响应
|
||||
virtual void OnRspQryExchange(CThostFtdcExchangeField *pExchange, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询产品响应
|
||||
virtual void OnRspQryProduct(CThostFtdcProductField *pProduct, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询合约响应
|
||||
virtual void OnRspQryInstrument(CThostFtdcInstrumentField *pInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询行情响应
|
||||
virtual void OnRspQryDepthMarketData(CThostFtdcDepthMarketDataField *pDepthMarketData, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询投资者结算结果响应
|
||||
virtual void OnRspQrySettlementInfo(CThostFtdcSettlementInfoField *pSettlementInfo, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询转帐银行响应
|
||||
virtual void OnRspQryTransferBank(CThostFtdcTransferBankField *pTransferBank, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询投资者持仓明细响应
|
||||
virtual void OnRspQryInvestorPositionDetail(CThostFtdcInvestorPositionDetailField *pInvestorPositionDetail, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询客户通知响应
|
||||
virtual void OnRspQryNotice(CThostFtdcNoticeField *pNotice, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询结算信息确认响应
|
||||
virtual void OnRspQrySettlementInfoConfirm(CThostFtdcSettlementInfoConfirmField *pSettlementInfoConfirm, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询投资者持仓明细响应
|
||||
virtual void OnRspQryInvestorPositionCombineDetail(CThostFtdcInvestorPositionCombineDetailField *pInvestorPositionCombineDetail, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///查询保证金监管系统经纪公司资金账户密钥响应
|
||||
virtual void OnRspQryCFMMCTradingAccountKey(CThostFtdcCFMMCTradingAccountKeyField *pCFMMCTradingAccountKey, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询仓单折抵信息响应
|
||||
virtual void OnRspQryEWarrantOffset(CThostFtdcEWarrantOffsetField *pEWarrantOffset, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询投资者品种/跨品种保证金响应
|
||||
virtual void OnRspQryInvestorProductGroupMargin(CThostFtdcInvestorProductGroupMarginField *pInvestorProductGroupMargin, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询交易所保证金率响应
|
||||
virtual void OnRspQryExchangeMarginRate(CThostFtdcExchangeMarginRateField *pExchangeMarginRate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询交易所调整保证金率响应
|
||||
virtual void OnRspQryExchangeMarginRateAdjust(CThostFtdcExchangeMarginRateAdjustField *pExchangeMarginRateAdjust, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询汇率响应
|
||||
virtual void OnRspQryExchangeRate(CThostFtdcExchangeRateField *pExchangeRate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询二级代理操作员银期权限响应
|
||||
virtual void OnRspQrySecAgentACIDMap(CThostFtdcSecAgentACIDMapField *pSecAgentACIDMap, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询期权交易成本响应
|
||||
virtual void OnRspQryOptionInstrTradeCost(CThostFtdcOptionInstrTradeCostField *pOptionInstrTradeCost, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询期权合约手续费响应
|
||||
virtual void OnRspQryOptionInstrCommRate(CThostFtdcOptionInstrCommRateField *pOptionInstrCommRate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询执行宣告响应
|
||||
virtual void OnRspQryExecOrder(CThostFtdcExecOrderField *pExecOrder, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询询价响应
|
||||
virtual void OnRspQryForQuote(CThostFtdcForQuoteField *pForQuote, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询报价响应
|
||||
virtual void OnRspQryQuote(CThostFtdcQuoteField *pQuote, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询转帐流水响应
|
||||
virtual void OnRspQryTransferSerial(CThostFtdcTransferSerialField *pTransferSerial, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询银期签约关系响应
|
||||
virtual void OnRspQryAccountregister(CThostFtdcAccountregisterField *pAccountregister, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///错误应答
|
||||
virtual void OnRspError(CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///报单通知
|
||||
virtual void OnRtnOrder(CThostFtdcOrderField *pOrder) {};
|
||||
|
||||
///成交通知
|
||||
virtual void OnRtnTrade(CThostFtdcTradeField *pTrade) {};
|
||||
|
||||
///报单录入错误回报
|
||||
virtual void OnErrRtnOrderInsert(CThostFtdcInputOrderField *pInputOrder, CThostFtdcRspInfoField *pRspInfo) {};
|
||||
|
||||
///报单操作错误回报
|
||||
virtual void OnErrRtnOrderAction(CThostFtdcOrderActionField *pOrderAction, CThostFtdcRspInfoField *pRspInfo) {};
|
||||
|
||||
///合约交易状态通知
|
||||
virtual void OnRtnInstrumentStatus(CThostFtdcInstrumentStatusField *pInstrumentStatus) {};
|
||||
|
||||
///交易通知
|
||||
virtual void OnRtnTradingNotice(CThostFtdcTradingNoticeInfoField *pTradingNoticeInfo) {};
|
||||
|
||||
///提示条件单校验错误
|
||||
virtual void OnRtnErrorConditionalOrder(CThostFtdcErrorConditionalOrderField *pErrorConditionalOrder) {};
|
||||
|
||||
///执行宣告通知
|
||||
virtual void OnRtnExecOrder(CThostFtdcExecOrderField *pExecOrder) {};
|
||||
|
||||
///执行宣告录入错误回报
|
||||
virtual void OnErrRtnExecOrderInsert(CThostFtdcInputExecOrderField *pInputExecOrder, CThostFtdcRspInfoField *pRspInfo) {};
|
||||
|
||||
///执行宣告操作错误回报
|
||||
virtual void OnErrRtnExecOrderAction(CThostFtdcExecOrderActionField *pExecOrderAction, CThostFtdcRspInfoField *pRspInfo) {};
|
||||
|
||||
///询价录入错误回报
|
||||
virtual void OnErrRtnForQuoteInsert(CThostFtdcInputForQuoteField *pInputForQuote, CThostFtdcRspInfoField *pRspInfo) {};
|
||||
|
||||
///报价通知
|
||||
virtual void OnRtnQuote(CThostFtdcQuoteField *pQuote) {};
|
||||
|
||||
///报价录入错误回报
|
||||
virtual void OnErrRtnQuoteInsert(CThostFtdcInputQuoteField *pInputQuote, CThostFtdcRspInfoField *pRspInfo) {};
|
||||
|
||||
///报价操作错误回报
|
||||
virtual void OnErrRtnQuoteAction(CThostFtdcQuoteActionField *pQuoteAction, CThostFtdcRspInfoField *pRspInfo) {};
|
||||
|
||||
///询价通知
|
||||
virtual void OnRtnForQuoteRsp(CThostFtdcForQuoteRspField *pForQuoteRsp) {};
|
||||
|
||||
///请求查询签约银行响应
|
||||
virtual void OnRspQryContractBank(CThostFtdcContractBankField *pContractBank, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询预埋单响应
|
||||
virtual void OnRspQryParkedOrder(CThostFtdcParkedOrderField *pParkedOrder, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询预埋撤单响应
|
||||
virtual void OnRspQryParkedOrderAction(CThostFtdcParkedOrderActionField *pParkedOrderAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询交易通知响应
|
||||
virtual void OnRspQryTradingNotice(CThostFtdcTradingNoticeField *pTradingNotice, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询经纪公司交易参数响应
|
||||
virtual void OnRspQryBrokerTradingParams(CThostFtdcBrokerTradingParamsField *pBrokerTradingParams, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询经纪公司交易算法响应
|
||||
virtual void OnRspQryBrokerTradingAlgos(CThostFtdcBrokerTradingAlgosField *pBrokerTradingAlgos, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///银行发起银行资金转期货通知
|
||||
virtual void OnRtnFromBankToFutureByBank(CThostFtdcRspTransferField *pRspTransfer) {};
|
||||
|
||||
///银行发起期货资金转银行通知
|
||||
virtual void OnRtnFromFutureToBankByBank(CThostFtdcRspTransferField *pRspTransfer) {};
|
||||
|
||||
///银行发起冲正银行转期货通知
|
||||
virtual void OnRtnRepealFromBankToFutureByBank(CThostFtdcRspRepealField *pRspRepeal) {};
|
||||
|
||||
///银行发起冲正期货转银行通知
|
||||
virtual void OnRtnRepealFromFutureToBankByBank(CThostFtdcRspRepealField *pRspRepeal) {};
|
||||
|
||||
///期货发起银行资金转期货通知
|
||||
virtual void OnRtnFromBankToFutureByFuture(CThostFtdcRspTransferField *pRspTransfer) {};
|
||||
|
||||
///期货发起期货资金转银行通知
|
||||
virtual void OnRtnFromFutureToBankByFuture(CThostFtdcRspTransferField *pRspTransfer) {};
|
||||
|
||||
///系统运行时期货端手工发起冲正银行转期货请求,银行处理完毕后报盘发回的通知
|
||||
virtual void OnRtnRepealFromBankToFutureByFutureManual(CThostFtdcRspRepealField *pRspRepeal) {};
|
||||
|
||||
///系统运行时期货端手工发起冲正期货转银行请求,银行处理完毕后报盘发回的通知
|
||||
virtual void OnRtnRepealFromFutureToBankByFutureManual(CThostFtdcRspRepealField *pRspRepeal) {};
|
||||
|
||||
///期货发起查询银行余额通知
|
||||
virtual void OnRtnQueryBankBalanceByFuture(CThostFtdcNotifyQueryAccountField *pNotifyQueryAccount) {};
|
||||
|
||||
///期货发起银行资金转期货错误回报
|
||||
virtual void OnErrRtnBankToFutureByFuture(CThostFtdcReqTransferField *pReqTransfer, CThostFtdcRspInfoField *pRspInfo) {};
|
||||
|
||||
///期货发起期货资金转银行错误回报
|
||||
virtual void OnErrRtnFutureToBankByFuture(CThostFtdcReqTransferField *pReqTransfer, CThostFtdcRspInfoField *pRspInfo) {};
|
||||
|
||||
///系统运行时期货端手工发起冲正银行转期货错误回报
|
||||
virtual void OnErrRtnRepealBankToFutureByFutureManual(CThostFtdcReqRepealField *pReqRepeal, CThostFtdcRspInfoField *pRspInfo) {};
|
||||
|
||||
///系统运行时期货端手工发起冲正期货转银行错误回报
|
||||
virtual void OnErrRtnRepealFutureToBankByFutureManual(CThostFtdcReqRepealField *pReqRepeal, CThostFtdcRspInfoField *pRspInfo) {};
|
||||
|
||||
///期货发起查询银行余额错误回报
|
||||
virtual void OnErrRtnQueryBankBalanceByFuture(CThostFtdcReqQueryAccountField *pReqQueryAccount, CThostFtdcRspInfoField *pRspInfo) {};
|
||||
|
||||
///期货发起冲正银行转期货请求,银行处理完毕后报盘发回的通知
|
||||
virtual void OnRtnRepealFromBankToFutureByFuture(CThostFtdcRspRepealField *pRspRepeal) {};
|
||||
|
||||
///期货发起冲正期货转银行请求,银行处理完毕后报盘发回的通知
|
||||
virtual void OnRtnRepealFromFutureToBankByFuture(CThostFtdcRspRepealField *pRspRepeal) {};
|
||||
|
||||
///期货发起银行资金转期货应答
|
||||
virtual void OnRspFromBankToFutureByFuture(CThostFtdcReqTransferField *pReqTransfer, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///期货发起期货资金转银行应答
|
||||
virtual void OnRspFromFutureToBankByFuture(CThostFtdcReqTransferField *pReqTransfer, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///期货发起查询银行余额应答
|
||||
virtual void OnRspQueryBankAccountMoneyByFuture(CThostFtdcReqQueryAccountField *pReqQueryAccount, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///银行发起银期开户通知
|
||||
virtual void OnRtnOpenAccountByBank(CThostFtdcOpenAccountField *pOpenAccount) {};
|
||||
|
||||
///银行发起银期销户通知
|
||||
virtual void OnRtnCancelAccountByBank(CThostFtdcCancelAccountField *pCancelAccount) {};
|
||||
|
||||
///银行发起变更银行账号通知
|
||||
virtual void OnRtnChangeAccountByBank(CThostFtdcChangeAccountField *pChangeAccount) {};
|
||||
};
|
||||
|
||||
class TRADER_API_EXPORT CThostFtdcTraderApi
|
||||
{
|
||||
public:
|
||||
///创建TraderApi
|
||||
///@param pszFlowPath 存贮订阅信息文件的目录,默认为当前目录
|
||||
///@return 创建出的UserApi
|
||||
static CThostFtdcTraderApi *CreateFtdcTraderApi(const char *pszFlowPath = "");
|
||||
|
||||
///删除接口对象本身
|
||||
///@remark 不再使用本接口对象时,调用该函数删除接口对象
|
||||
virtual void Release() = 0;
|
||||
|
||||
///初始化
|
||||
///@remark 初始化运行环境,只有调用后,接口才开始工作
|
||||
virtual void Init() = 0;
|
||||
|
||||
///等待接口线程结束运行
|
||||
///@return 线程退出代码
|
||||
virtual int Join() = 0;
|
||||
|
||||
///获取当前交易日
|
||||
///@retrun 获取到的交易日
|
||||
///@remark 只有登录成功后,才能得到正确的交易日
|
||||
virtual const char *GetTradingDay() = 0;
|
||||
|
||||
///注册前置机网络地址
|
||||
///@param pszFrontAddress:前置机网络地址。
|
||||
///@remark 网络地址的格式为:“protocol://ipaddress:port”,如:”tcp://127.0.0.1:17001”。
|
||||
///@remark “tcp”代表传输协议,“127.0.0.1”代表服务器地址。”17001”代表服务器端口号。
|
||||
virtual void RegisterFront(char *pszFrontAddress) = 0;
|
||||
|
||||
///注册名字服务器网络地址
|
||||
///@param pszNsAddress:名字服务器网络地址。
|
||||
///@remark 网络地址的格式为:“protocol://ipaddress:port”,如:”tcp://127.0.0.1:12001”。
|
||||
///@remark “tcp”代表传输协议,“127.0.0.1”代表服务器地址。”12001”代表服务器端口号。
|
||||
///@remark RegisterNameServer优先于RegisterFront
|
||||
virtual void RegisterNameServer(char *pszNsAddress) = 0;
|
||||
|
||||
///注册名字服务器用户信息
|
||||
///@param pFensUserInfo:用户信息。
|
||||
virtual void RegisterFensUserInfo(CThostFtdcFensUserInfoField * pFensUserInfo) = 0;
|
||||
|
||||
///注册回调接口
|
||||
///@param pSpi 派生自回调接口类的实例
|
||||
virtual void RegisterSpi(CThostFtdcTraderSpi *pSpi) = 0;
|
||||
|
||||
///订阅私有流。
|
||||
///@param nResumeType 私有流重传方式
|
||||
/// THOST_TERT_RESTART:从本交易日开始重传
|
||||
/// THOST_TERT_RESUME:从上次收到的续传
|
||||
/// THOST_TERT_QUICK:只传送登录后私有流的内容
|
||||
///@remark 该方法要在Init方法前调用。若不调用则不会收到私有流的数据。
|
||||
virtual void SubscribePrivateTopic(THOST_TE_RESUME_TYPE nResumeType) = 0;
|
||||
|
||||
///订阅公共流。
|
||||
///@param nResumeType 公共流重传方式
|
||||
/// THOST_TERT_RESTART:从本交易日开始重传
|
||||
/// THOST_TERT_RESUME:从上次收到的续传
|
||||
/// THOST_TERT_QUICK:只传送登录后公共流的内容
|
||||
///@remark 该方法要在Init方法前调用。若不调用则不会收到公共流的数据。
|
||||
virtual void SubscribePublicTopic(THOST_TE_RESUME_TYPE nResumeType) = 0;
|
||||
|
||||
///客户端认证请求
|
||||
virtual int ReqAuthenticate(CThostFtdcReqAuthenticateField *pReqAuthenticateField, int nRequestID) = 0;
|
||||
|
||||
///用户登录请求
|
||||
virtual int ReqUserLogin(CThostFtdcReqUserLoginField *pReqUserLoginField, int nRequestID) = 0;
|
||||
|
||||
|
||||
///登出请求
|
||||
virtual int ReqUserLogout(CThostFtdcUserLogoutField *pUserLogout, int nRequestID) = 0;
|
||||
|
||||
///用户口令更新请求
|
||||
virtual int ReqUserPasswordUpdate(CThostFtdcUserPasswordUpdateField *pUserPasswordUpdate, int nRequestID) = 0;
|
||||
|
||||
///资金账户口令更新请求
|
||||
virtual int ReqTradingAccountPasswordUpdate(CThostFtdcTradingAccountPasswordUpdateField *pTradingAccountPasswordUpdate, int nRequestID) = 0;
|
||||
|
||||
///报单录入请求
|
||||
virtual int ReqOrderInsert(CThostFtdcInputOrderField *pInputOrder, int nRequestID) = 0;
|
||||
|
||||
///预埋单录入请求
|
||||
virtual int ReqParkedOrderInsert(CThostFtdcParkedOrderField *pParkedOrder, int nRequestID) = 0;
|
||||
|
||||
///预埋撤单录入请求
|
||||
virtual int ReqParkedOrderAction(CThostFtdcParkedOrderActionField *pParkedOrderAction, int nRequestID) = 0;
|
||||
|
||||
///报单操作请求
|
||||
virtual int ReqOrderAction(CThostFtdcInputOrderActionField *pInputOrderAction, int nRequestID) = 0;
|
||||
|
||||
///查询最大报单数量请求
|
||||
virtual int ReqQueryMaxOrderVolume(CThostFtdcQueryMaxOrderVolumeField *pQueryMaxOrderVolume, int nRequestID) = 0;
|
||||
|
||||
///投资者结算结果确认
|
||||
virtual int ReqSettlementInfoConfirm(CThostFtdcSettlementInfoConfirmField *pSettlementInfoConfirm, int nRequestID) = 0;
|
||||
|
||||
///请求删除预埋单
|
||||
virtual int ReqRemoveParkedOrder(CThostFtdcRemoveParkedOrderField *pRemoveParkedOrder, int nRequestID) = 0;
|
||||
|
||||
///请求删除预埋撤单
|
||||
virtual int ReqRemoveParkedOrderAction(CThostFtdcRemoveParkedOrderActionField *pRemoveParkedOrderAction, int nRequestID) = 0;
|
||||
|
||||
///执行宣告录入请求
|
||||
virtual int ReqExecOrderInsert(CThostFtdcInputExecOrderField *pInputExecOrder, int nRequestID) = 0;
|
||||
|
||||
///执行宣告操作请求
|
||||
virtual int ReqExecOrderAction(CThostFtdcInputExecOrderActionField *pInputExecOrderAction, int nRequestID) = 0;
|
||||
|
||||
///询价录入请求
|
||||
virtual int ReqForQuoteInsert(CThostFtdcInputForQuoteField *pInputForQuote, int nRequestID) = 0;
|
||||
|
||||
///报价录入请求
|
||||
virtual int ReqQuoteInsert(CThostFtdcInputQuoteField *pInputQuote, int nRequestID) = 0;
|
||||
|
||||
///报价操作请求
|
||||
virtual int ReqQuoteAction(CThostFtdcInputQuoteActionField *pInputQuoteAction, int nRequestID) = 0;
|
||||
|
||||
///请求查询报单
|
||||
virtual int ReqQryOrder(CThostFtdcQryOrderField *pQryOrder, int nRequestID) = 0;
|
||||
|
||||
///请求查询成交
|
||||
virtual int ReqQryTrade(CThostFtdcQryTradeField *pQryTrade, int nRequestID) = 0;
|
||||
|
||||
///请求查询投资者持仓
|
||||
virtual int ReqQryInvestorPosition(CThostFtdcQryInvestorPositionField *pQryInvestorPosition, int nRequestID) = 0;
|
||||
|
||||
///请求查询资金账户
|
||||
virtual int ReqQryTradingAccount(CThostFtdcQryTradingAccountField *pQryTradingAccount, int nRequestID) = 0;
|
||||
|
||||
///请求查询投资者
|
||||
virtual int ReqQryInvestor(CThostFtdcQryInvestorField *pQryInvestor, int nRequestID) = 0;
|
||||
|
||||
///请求查询交易编码
|
||||
virtual int ReqQryTradingCode(CThostFtdcQryTradingCodeField *pQryTradingCode, int nRequestID) = 0;
|
||||
|
||||
///请求查询合约保证金率
|
||||
virtual int ReqQryInstrumentMarginRate(CThostFtdcQryInstrumentMarginRateField *pQryInstrumentMarginRate, int nRequestID) = 0;
|
||||
|
||||
///请求查询合约手续费率
|
||||
virtual int ReqQryInstrumentCommissionRate(CThostFtdcQryInstrumentCommissionRateField *pQryInstrumentCommissionRate, int nRequestID) = 0;
|
||||
|
||||
///请求查询交易所
|
||||
virtual int ReqQryExchange(CThostFtdcQryExchangeField *pQryExchange, int nRequestID) = 0;
|
||||
|
||||
///请求查询产品
|
||||
virtual int ReqQryProduct(CThostFtdcQryProductField *pQryProduct, int nRequestID) = 0;
|
||||
|
||||
///请求查询合约
|
||||
virtual int ReqQryInstrument(CThostFtdcQryInstrumentField *pQryInstrument, int nRequestID) = 0;
|
||||
|
||||
///请求查询行情
|
||||
virtual int ReqQryDepthMarketData(CThostFtdcQryDepthMarketDataField *pQryDepthMarketData, int nRequestID) = 0;
|
||||
|
||||
///请求查询投资者结算结果
|
||||
virtual int ReqQrySettlementInfo(CThostFtdcQrySettlementInfoField *pQrySettlementInfo, int nRequestID) = 0;
|
||||
|
||||
///请求查询转帐银行
|
||||
virtual int ReqQryTransferBank(CThostFtdcQryTransferBankField *pQryTransferBank, int nRequestID) = 0;
|
||||
|
||||
///请求查询投资者持仓明细
|
||||
virtual int ReqQryInvestorPositionDetail(CThostFtdcQryInvestorPositionDetailField *pQryInvestorPositionDetail, int nRequestID) = 0;
|
||||
|
||||
///请求查询客户通知
|
||||
virtual int ReqQryNotice(CThostFtdcQryNoticeField *pQryNotice, int nRequestID) = 0;
|
||||
|
||||
///请求查询结算信息确认
|
||||
virtual int ReqQrySettlementInfoConfirm(CThostFtdcQrySettlementInfoConfirmField *pQrySettlementInfoConfirm, int nRequestID) = 0;
|
||||
|
||||
///请求查询投资者持仓明细
|
||||
virtual int ReqQryInvestorPositionCombineDetail(CThostFtdcQryInvestorPositionCombineDetailField *pQryInvestorPositionCombineDetail, int nRequestID) = 0;
|
||||
|
||||
///请求查询保证金监管系统经纪公司资金账户密钥
|
||||
virtual int ReqQryCFMMCTradingAccountKey(CThostFtdcQryCFMMCTradingAccountKeyField *pQryCFMMCTradingAccountKey, int nRequestID) = 0;
|
||||
|
||||
///请求查询仓单折抵信息
|
||||
virtual int ReqQryEWarrantOffset(CThostFtdcQryEWarrantOffsetField *pQryEWarrantOffset, int nRequestID) = 0;
|
||||
|
||||
///请求查询投资者品种/跨品种保证金
|
||||
virtual int ReqQryInvestorProductGroupMargin(CThostFtdcQryInvestorProductGroupMarginField *pQryInvestorProductGroupMargin, int nRequestID) = 0;
|
||||
|
||||
///请求查询交易所保证金率
|
||||
virtual int ReqQryExchangeMarginRate(CThostFtdcQryExchangeMarginRateField *pQryExchangeMarginRate, int nRequestID) = 0;
|
||||
|
||||
///请求查询交易所调整保证金率
|
||||
virtual int ReqQryExchangeMarginRateAdjust(CThostFtdcQryExchangeMarginRateAdjustField *pQryExchangeMarginRateAdjust, int nRequestID) = 0;
|
||||
|
||||
///请求查询汇率
|
||||
virtual int ReqQryExchangeRate(CThostFtdcQryExchangeRateField *pQryExchangeRate, int nRequestID) = 0;
|
||||
|
||||
///请求查询二级代理操作员银期权限
|
||||
virtual int ReqQrySecAgentACIDMap(CThostFtdcQrySecAgentACIDMapField *pQrySecAgentACIDMap, int nRequestID) = 0;
|
||||
|
||||
///请求查询期权交易成本
|
||||
virtual int ReqQryOptionInstrTradeCost(CThostFtdcQryOptionInstrTradeCostField *pQryOptionInstrTradeCost, int nRequestID) = 0;
|
||||
|
||||
///请求查询期权合约手续费
|
||||
virtual int ReqQryOptionInstrCommRate(CThostFtdcQryOptionInstrCommRateField *pQryOptionInstrCommRate, int nRequestID) = 0;
|
||||
|
||||
///请求查询执行宣告
|
||||
virtual int ReqQryExecOrder(CThostFtdcQryExecOrderField *pQryExecOrder, int nRequestID) = 0;
|
||||
|
||||
///请求查询询价
|
||||
virtual int ReqQryForQuote(CThostFtdcQryForQuoteField *pQryForQuote, int nRequestID) = 0;
|
||||
|
||||
///请求查询报价
|
||||
virtual int ReqQryQuote(CThostFtdcQryQuoteField *pQryQuote, int nRequestID) = 0;
|
||||
|
||||
///请求查询转帐流水
|
||||
virtual int ReqQryTransferSerial(CThostFtdcQryTransferSerialField *pQryTransferSerial, int nRequestID) = 0;
|
||||
|
||||
///请求查询银期签约关系
|
||||
virtual int ReqQryAccountregister(CThostFtdcQryAccountregisterField *pQryAccountregister, int nRequestID) = 0;
|
||||
|
||||
///请求查询签约银行
|
||||
virtual int ReqQryContractBank(CThostFtdcQryContractBankField *pQryContractBank, int nRequestID) = 0;
|
||||
|
||||
///请求查询预埋单
|
||||
virtual int ReqQryParkedOrder(CThostFtdcQryParkedOrderField *pQryParkedOrder, int nRequestID) = 0;
|
||||
|
||||
///请求查询预埋撤单
|
||||
virtual int ReqQryParkedOrderAction(CThostFtdcQryParkedOrderActionField *pQryParkedOrderAction, int nRequestID) = 0;
|
||||
|
||||
///请求查询交易通知
|
||||
virtual int ReqQryTradingNotice(CThostFtdcQryTradingNoticeField *pQryTradingNotice, int nRequestID) = 0;
|
||||
|
||||
///请求查询经纪公司交易参数
|
||||
virtual int ReqQryBrokerTradingParams(CThostFtdcQryBrokerTradingParamsField *pQryBrokerTradingParams, int nRequestID) = 0;
|
||||
|
||||
///请求查询经纪公司交易算法
|
||||
virtual int ReqQryBrokerTradingAlgos(CThostFtdcQryBrokerTradingAlgosField *pQryBrokerTradingAlgos, int nRequestID) = 0;
|
||||
|
||||
///期货发起银行资金转期货请求
|
||||
virtual int ReqFromBankToFutureByFuture(CThostFtdcReqTransferField *pReqTransfer, int nRequestID) = 0;
|
||||
|
||||
///期货发起期货资金转银行请求
|
||||
virtual int ReqFromFutureToBankByFuture(CThostFtdcReqTransferField *pReqTransfer, int nRequestID) = 0;
|
||||
|
||||
///期货发起查询银行余额请求
|
||||
virtual int ReqQueryBankAccountMoneyByFuture(CThostFtdcReqQueryAccountField *pReqQueryAccount, int nRequestID) = 0;
|
||||
protected:
|
||||
~CThostFtdcTraderApi(){};
|
||||
};
|
||||
|
||||
#endif
|
6267
vn.ctp/ctpapi/ThostFtdcUserApiDataType.h
Normal file
6267
vn.ctp/ctpapi/ThostFtdcUserApiDataType.h
Normal file
File diff suppressed because it is too large
Load Diff
7430
vn.ctp/ctpapi/ThostFtdcUserApiStruct.h
Normal file
7430
vn.ctp/ctpapi/ThostFtdcUserApiStruct.h
Normal file
File diff suppressed because it is too large
Load Diff
9
vn.ctp/ctpapi/error.dtd
Normal file
9
vn.ctp/ctpapi/error.dtd
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!ELEMENT errors (error*)>
|
||||
<!ELEMENT error EMPTY>
|
||||
<!ATTLIST error
|
||||
id CDATA #REQUIRED
|
||||
value CDATA #REQUIRED
|
||||
prompt CDATA #REQUIRED
|
||||
>
|
||||
|
118
vn.ctp/ctpapi/error.xml
Normal file
118
vn.ctp/ctpapi/error.xml
Normal file
@ -0,0 +1,118 @@
|
||||
<?xml version="1.0" encoding="gb2312"?>
|
||||
<!-- edited with XMLSPY v2004 rel. 4 U (http://www.xmlspy.com) by wangzhaodong (ORiON) -->
|
||||
<!DOCTYPE errors SYSTEM "error.dtd">
|
||||
<errors>
|
||||
<error id="NONE" value="0" prompt="综合交易平台:正确"/>
|
||||
<error id="INVALID_DATA_SYNC_STATUS" value="1" prompt="综合交易平台:不在已同步状态"/>
|
||||
<error id="INCONSISTENT_INFORMATION" value="2" prompt="综合交易平台:会话信息不一致"/>
|
||||
<error id="INVALID_LOGIN" value="3" prompt="综合交易平台:不合法的登录"/>
|
||||
<error id="USER_NOT_ACTIVE" value="4" prompt="综合交易平台:用户不活跃"/>
|
||||
<error id="DUPLICATE_LOGIN" value="5" prompt="综合交易平台:重复的登录"/>
|
||||
<error id="NOT_LOGIN_YET" value="6" prompt="综合交易平台:还没有登录"/>
|
||||
<error id="NOT_INITED" value="7" prompt="综合交易平台:还没有初始化"/>
|
||||
<error id="FRONT_NOT_ACTIVE" value="8" prompt="综合交易平台:前置不活跃"/>
|
||||
<error id="NO_PRIVILEGE" value="9" prompt="综合交易平台:无此权限"/>
|
||||
<error id="CHANGE_OTHER_PASSWORD" value="10" prompt="综合交易平台:修改别人的口令"/>
|
||||
<error id="USER_NOT_FOUND" value="11" prompt="综合交易平台:找不到该用户"/>
|
||||
<error id="BROKER_NOT_FOUND" value="12" prompt="综合交易平台:找不到该经纪公司"/>
|
||||
<error id="INVESTOR_NOT_FOUND" value="13" prompt="综合交易平台:找不到投资者"/>
|
||||
<error id="OLD_PASSWORD_MISMATCH" value="14" prompt="综合交易平台:原口令不匹配"/>
|
||||
<error id="BAD_FIELD" value="15" prompt="综合交易平台:报单字段有误"/>
|
||||
<error id="INSTRUMENT_NOT_FOUND" value="16" prompt="综合交易平台:找不到合约"/>
|
||||
<error id="INSTRUMENT_NOT_TRADING" value="17" prompt="综合交易平台:合约不能交易"/>
|
||||
<error id="NOT_EXCHANGE_PARTICIPANT" value="18" prompt="综合交易平台:经纪公司不是交易所的会员"/>
|
||||
<error id="INVESTOR_NOT_ACTIVE" value="19" prompt="综合交易平台:投资者不活跃"/>
|
||||
<error id="NOT_EXCHANGE_CLIENT" value="20" prompt="综合交易平台:投资者未在交易所开户"/>
|
||||
<error id="NO_VALID_TRADER_AVAILABLE" value="21" prompt="综合交易平台:该交易席位未连接到交易所"/>
|
||||
<error id="DUPLICATE_ORDER_REF" value="22" prompt="综合交易平台:报单错误:不允许重复报单"/>
|
||||
<error id="BAD_ORDER_ACTION_FIELD" value="23" prompt="综合交易平台:错误的报单操作字段"/>
|
||||
<error id="DUPLICATE_ORDER_ACTION_REF" value="24" prompt="综合交易平台:撤单已报送,不允许重复撤单"/>
|
||||
<error id="ORDER_NOT_FOUND" value="25" prompt="综合交易平台:撤单找不到相应报单"/>
|
||||
<error id="INSUITABLE_ORDER_STATUS" value="26" prompt="综合交易平台:报单已全成交或已撤销,不能再撤"/>
|
||||
<error id="UNSUPPORTED_FUNCTION" value="27" prompt="综合交易平台:不支持的功能"/>
|
||||
<error id="NO_TRADING_RIGHT" value="28" prompt="综合交易平台:没有报单交易权限"/>
|
||||
<error id="CLOSE_ONLY" value="29" prompt="综合交易平台:只能平仓"/>
|
||||
<error id="OVER_CLOSE_POSITION" value="30" prompt="综合交易平台:平仓量超过持仓量"/>
|
||||
<error id="INSUFFICIENT_MONEY" value="31" prompt="综合交易平台:资金不足"/>
|
||||
<error id="DUPLICATE_PK" value="32" prompt="综合交易平台:主键重复"/>
|
||||
<error id="CANNOT_FIND_PK" value="33" prompt="综合交易平台:找不到主键"/>
|
||||
<error id="CAN_NOT_INACTIVE_BROKER" value="34" prompt="综合交易平台:设置经纪公司不活跃状态失败"/>
|
||||
<error id="BROKER_SYNCHRONIZING" value="35" prompt="综合交易平台:经纪公司正在同步"/>
|
||||
<error id="BROKER_SYNCHRONIZED" value="36" prompt="综合交易平台:经纪公司已同步"/>
|
||||
<error id="SHORT_SELL" value="37" prompt="综合交易平台:现货交易不能卖空"/>
|
||||
<error id="INVALID_SETTLEMENT_REF" value="38" prompt="综合交易平台:不合法的结算引用"/>
|
||||
<error id="CFFEX_NETWORK_ERROR" value="39" prompt="综合交易平台:交易所网络连接失败"/>
|
||||
<error id="CFFEX_OVER_REQUEST" value="40" prompt="综合交易平台:交易所未处理请求超过许可数"/>
|
||||
<error id="CFFEX_OVER_REQUEST_PER_SECOND" value="41" prompt="综合交易平台:交易所每秒发送请求数超过许可数"/>
|
||||
<error id="SETTLEMENT_INFO_NOT_CONFIRMED" value="42" prompt="综合交易平台:结算结果未确认"/>
|
||||
<error id="DEPOSIT_NOT_FOUND" value="43" prompt="综合交易平台:没有对应的入金记录"/>
|
||||
<error id="EXCHANG_TRADING" value="44" prompt="综合交易平台:交易所已经进入连续交易状态"/>
|
||||
<error id="PARKEDORDER_NOT_FOUND" value="45" prompt="综合交易平台:找不到预埋(撤单)单"/>
|
||||
<error id="PARKEDORDER_HASSENDED" value="46" prompt="综合交易平台:预埋(撤单)单已经发送"/>
|
||||
<error id="PARKEDORDER_HASDELETE" value="47" prompt="综合交易平台:预埋(撤单)单已经删除"/>
|
||||
<error id="INVALID_INVESTORIDORPASSWORD" value="48" prompt="综合交易平台:无效的投资者或者密码"/>
|
||||
<error id="INVALID_LOGIN_IPADDRESS" value="49" prompt="综合交易平台:不合法的登录IP地址"/>
|
||||
<error id="OVER_CLOSETODAY_POSITION" value="50" prompt="综合交易平台:平今仓位不足"/>
|
||||
<error id="OVER_CLOSEYESTERDAY_POSITION" value="51" prompt="综合交易平台:平昨仓位不足"/>
|
||||
<error id="BROKER_NOT_ENOUGH_CONDORDER" value="52" prompt="综合交易平台:经纪公司没有足够可用的条件单数量"/>
|
||||
<error id="INVESTOR_NOT_ENOUGH_CONDORDER" value="53" prompt="综合交易平台:投资者没有足够可用的条件单数量"/>
|
||||
<error id="BROKER_NOT_SUPPORT_CONDORDER" value="54" prompt="综合交易平台:经纪公司不支持条件单"/>
|
||||
<error id="RESEND_ORDER_BROKERINVESTOR_NOTMATCH" value="55" prompt="综合交易平台:重发未知单经济公司/投资者不匹配"/>
|
||||
<error id="SYC_OTP_FAILED" value="56" prompt="综合交易平台:同步动态令牌失败"/>
|
||||
<error id="OTP_MISMATCH" value="57" prompt="综合交易平台:动态令牌校验错误"/>
|
||||
<error id="OTPPARAM_NOT_FOUND" value="58" prompt="综合交易平台:找不到动态令牌配置信息"/>
|
||||
<error id="UNSUPPORTED_OTPTYPE" value="59" prompt="综合交易平台:不支持的动态令牌类型"/>
|
||||
<error id="SINGLEUSERSESSION_EXCEED_LIMIT" value="60" prompt="综合交易平台:用户在线会话超出上限"/>
|
||||
<error id="EXCHANGE_UNSUPPORTED_ARBITRAGE" value="61" prompt="综合交易平台:该交易所不支持套利类型报单"/>
|
||||
<!--转帐系统错误代码 -->
|
||||
<error id="SEND_INSTITUTION_CODE_ERROR" value="1000" prompt="银期转账:发送机构代码错误"/>
|
||||
<error id="NO_GET_PLATFORM_SN" value="1001" prompt="银期转账:取平台流水号错误"/>
|
||||
<error id="ILLEGAL_TRANSFER_BANK" value="1002" prompt="银期转账:不合法的转账银行"/>
|
||||
<error id="ALREADY_OPEN_ACCOUNT" value="1003" prompt="银期转账:已经开户"/>
|
||||
<error id="NOT_OPEN_ACCOUNT" value="1004" prompt="银期转账:未开户"/>
|
||||
<error id="PROCESSING" value="1005" prompt="银期转账:处理中"/>
|
||||
<error id="OVERTIME" value="1006" prompt="银期转账:交易超时"/>
|
||||
<error id="RECORD_NOT_FOUND" value="1007" prompt="银期转账:找不到记录"/>
|
||||
<error id="NO_FOUND_REVERSAL_ORIGINAL_TRANSACTION" value="1008" prompt="银期转账:找不到被冲正的原始交易"/>
|
||||
<error id="CONNECT_HOST_FAILED" value="1009" prompt="银期转账:连接主机失败"/>
|
||||
<error id="SEND_FAILED" value="1010" prompt="银期转账:发送失败"/>
|
||||
<error id="LATE_RESPONSE" value="1011" prompt="银期转账:迟到应答"/>
|
||||
<error id="REVERSAL_BANKID_NOT_MATCH" value="1012" prompt="银期转账:冲正交易银行代码错误"/>
|
||||
<error id="REVERSAL_BANKACCOUNT_NOT_MATCH" value="1013" prompt="银期转账:冲正交易银行账户错误"/>
|
||||
<error id="REVERSAL_BROKERID_NOT_MATCH" value="1014" prompt="银期转账:冲正交易经纪公司代码错误"/>
|
||||
<error id="REVERSAL_ACCOUNTID_NOT_MATCH" value="1015" prompt="银期转账:冲正交易资金账户错误"/>
|
||||
<error id="REVERSAL_AMOUNT_NOT_MATCH" value="1016" prompt="银期转账:冲正交易交易金额错误"/>
|
||||
<error id="DB_OPERATION_FAILED" value="1017" prompt="银期转账:数据库操作错误"/>
|
||||
<error id="SEND_ASP_FAILURE" value="1018" prompt="银期转账:发送到交易系统失败"/>
|
||||
<error id="NOT_SIGNIN" value="1019" prompt="银期转账:没有签到"/>
|
||||
<error id="ALREADY_SIGNIN" value="1020" prompt="银期转账:已经签到"/>
|
||||
<error id="AMOUNT_OR_TIMES_OVER" value="1021" prompt="银期转账:金额或次数超限"/>
|
||||
<error id="NOT_IN_TRANSFER_TIME" value="1022" prompt="银期转账:这一时间段不能转账"/>
|
||||
<error id="BANK_SERVER_ERROR" value="1023" prompt="银行主机错"/>
|
||||
<error id="BANK_SERIAL_IS_REPEALED" value="1024" prompt="银期转账:银行已经冲正"/>
|
||||
<error id="BANK_SERIAL_NOT_EXIST" value="1025" prompt="银期转账:银行流水不存在"/>
|
||||
<error id="NOT_ORGAN_MAP" value="1026" prompt="银期转账:机构没有签约"/>
|
||||
<error id="EXIST_TRANSFER" value="1027" prompt="银期转账:存在转账,不能销户"/>
|
||||
<error id="BANK_FORBID_REVERSAL" value="1028" prompt="银期转账:银行不支持冲正"/>
|
||||
<error id="DUP_BANK_SERIAL" value="1029" prompt="银期转账:重复的银行流水"/>
|
||||
<error id="FBT_SYSTEM_BUSY" value="1030" prompt="银期转账:转账系统忙,稍后再试"/>
|
||||
<error id="MACKEY_SYNCING" value="1031" prompt="银期转账:MAC密钥正在同步"/>
|
||||
<error id="ACCOUNTID_ALREADY_REGISTER" value="1032" prompt="银期转账:资金账户已经登记"/>
|
||||
<error id="BANKACCOUNT_ALREADY_REGISTER" value="1033" prompt="银期转账:银行账户已经登记"/>
|
||||
<error id="DUP_BANK_SERIAL_REDO_OK" value="1034" prompt="银期转账:重复的银行流水,重发成功"/>
|
||||
<!-- add for transfer begin -->
|
||||
<error id="NO_VALID_BANKOFFER_AVAILABLE" value="2000" prompt="综合交易平台:该报盘未连接到银行"/>
|
||||
<error id="PASSWORD_MISMATCH" value="2001" prompt="综合交易平台:资金密码错误"/>
|
||||
<error id="DUPLATION_BANK_SERIAL" value="2004" prompt="综合交易平台:银行流水号重复"/>
|
||||
<error id="DUPLATION_OFFER_SERIAL" value="2005" prompt="综合交易平台:报盘流水号重复"/>
|
||||
<error id="SERIAL_NOT_EXSIT" value="2006" prompt="综合交易平台:被冲正流水不存在(冲正交易)"/>
|
||||
<error id="SERIAL_IS_REPEALED" value="2007" prompt="综合交易平台:原流水已冲正(冲正交易)"/>
|
||||
<error id="SERIAL_MISMATCH" value="2008" prompt="综合交易平台:与原流水信息不符(冲正交易)"/>
|
||||
<error id="IdentifiedCardNo_MISMATCH" value="2009" prompt="综合交易平台:证件号码或类型错误"/>
|
||||
<error id="ACCOUNT_NOT_FUND" value="2011" prompt="综合交易平台:资金账户不存在"/>
|
||||
<error id="ACCOUNT_NOT_ACTIVE" value="2012" prompt="综合交易平台:资金账户已经销户"/>
|
||||
<error id="NOT_ALLOW_REPEAL_BYMANUAL" value="2013" prompt="综合交易平台:该交易不能执行手工冲正"/>
|
||||
<error id="AMOUNT_OUTOFTHEWAY" value="2014" prompt="综合交易平台:转帐金额错误"/>
|
||||
<error id="WAITING_OFFER_RSP" value="999999" prompt="综合交易平台:等待银期报盘处理结果"/>
|
||||
<!-- add for transfer end -->
|
||||
</errors>
|
BIN
vn.ctp/ctpapi/thostmduserapi.dll
Normal file
BIN
vn.ctp/ctpapi/thostmduserapi.dll
Normal file
Binary file not shown.
BIN
vn.ctp/ctpapi/thostmduserapi.lib
Normal file
BIN
vn.ctp/ctpapi/thostmduserapi.lib
Normal file
Binary file not shown.
BIN
vn.ctp/ctpapi/thosttraderapi.dll
Normal file
BIN
vn.ctp/ctpapi/thosttraderapi.dll
Normal file
Binary file not shown.
BIN
vn.ctp/ctpapi/thosttraderapi.lib
Normal file
BIN
vn.ctp/ctpapi/thosttraderapi.lib
Normal file
Binary file not shown.
158
vn.ctp/pyscript/ThostFtdcMdApi.h
Normal file
158
vn.ctp/pyscript/ThostFtdcMdApi.h
Normal file
@ -0,0 +1,158 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///@system 新一代交易所系统
|
||||
///@company 上海期货信息技术有限公司
|
||||
///@file ThostFtdcMdApi.h
|
||||
///@brief 定义了客户端接口
|
||||
///@history
|
||||
///20060106 赵鸿昊 创建该文件
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(THOST_FTDCMDAPI_H)
|
||||
#define THOST_FTDCMDAPI_H
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include "ThostFtdcUserApiStruct.h"
|
||||
|
||||
#if defined(ISLIB) && defined(WIN32)
|
||||
#ifdef LIB_MD_API_EXPORT
|
||||
#define MD_API_EXPORT __declspec(dllexport)
|
||||
#else
|
||||
#define MD_API_EXPORT __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define MD_API_EXPORT
|
||||
#endif
|
||||
|
||||
class CThostFtdcMdSpi
|
||||
{
|
||||
public:
|
||||
///当客户端与交易后台建立起通信连接时(还未登录前),该方法被调用。
|
||||
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) {};
|
||||
};
|
||||
|
||||
class MD_API_EXPORT CThostFtdcMdApi
|
||||
{
|
||||
public:
|
||||
///创建MdApi
|
||||
///@param pszFlowPath 存贮订阅信息文件的目录,默认为当前目录
|
||||
///@return 创建出的UserApi
|
||||
///modify for udp marketdata
|
||||
static CThostFtdcMdApi *CreateFtdcMdApi(const char *pszFlowPath = "", const bool bIsUsingUdp=false, const bool bIsMulticast=false);
|
||||
|
||||
///删除接口对象本身
|
||||
///@remark 不再使用本接口对象时,调用该函数删除接口对象
|
||||
virtual void Release() = 0;
|
||||
|
||||
///初始化
|
||||
///@remark 初始化运行环境,只有调用后,接口才开始工作
|
||||
virtual void Init() = 0;
|
||||
|
||||
///等待接口线程结束运行
|
||||
///@return 线程退出代码
|
||||
virtual int Join() = 0;
|
||||
|
||||
///获取当前交易日
|
||||
///@retrun 获取到的交易日
|
||||
///@remark 只有登录成功后,才能得到正确的交易日
|
||||
virtual const char *GetTradingDay() = 0;
|
||||
|
||||
///注册前置机网络地址
|
||||
///@param pszFrontAddress:前置机网络地址。
|
||||
///@remark 网络地址的格式为:“protocol://ipaddress:port”,如:”tcp://127.0.0.1:17001”。
|
||||
///@remark “tcp”代表传输协议,“127.0.0.1”代表服务器地址。”17001”代表服务器端口号。
|
||||
virtual void RegisterFront(char *pszFrontAddress) = 0;
|
||||
|
||||
///注册名字服务器网络地址
|
||||
///@param pszNsAddress:名字服务器网络地址。
|
||||
///@remark 网络地址的格式为:“protocol://ipaddress:port”,如:”tcp://127.0.0.1:12001”。
|
||||
///@remark “tcp”代表传输协议,“127.0.0.1”代表服务器地址。”12001”代表服务器端口号。
|
||||
///@remark RegisterNameServer优先于RegisterFront
|
||||
virtual void RegisterNameServer(char *pszNsAddress) = 0;
|
||||
|
||||
///注册名字服务器用户信息
|
||||
///@param pFensUserInfo:用户信息。
|
||||
virtual void RegisterFensUserInfo(CThostFtdcFensUserInfoField * pFensUserInfo) = 0;
|
||||
|
||||
///注册回调接口
|
||||
///@param pSpi 派生自回调接口类的实例
|
||||
virtual void RegisterSpi(CThostFtdcMdSpi *pSpi) = 0;
|
||||
|
||||
///订阅行情。
|
||||
///@param ppInstrumentID 合约ID
|
||||
///@param nCount 要订阅/退订行情的合约个数
|
||||
///@remark
|
||||
virtual int SubscribeMarketData(char *ppInstrumentID[], int nCount) = 0;
|
||||
|
||||
///退订行情。
|
||||
///@param ppInstrumentID 合约ID
|
||||
///@param nCount 要订阅/退订行情的合约个数
|
||||
///@remark
|
||||
virtual int UnSubscribeMarketData(char *ppInstrumentID[], int nCount) = 0;
|
||||
|
||||
///订阅询价。
|
||||
///@param ppInstrumentID 合约ID
|
||||
///@param nCount 要订阅/退订行情的合约个数
|
||||
///@remark
|
||||
virtual int SubscribeForQuoteRsp(char *ppInstrumentID[], int nCount) = 0;
|
||||
|
||||
///退订询价。
|
||||
///@param ppInstrumentID 合约ID
|
||||
///@param nCount 要订阅/退订行情的合约个数
|
||||
///@remark
|
||||
virtual int UnSubscribeForQuoteRsp(char *ppInstrumentID[], int nCount) = 0;
|
||||
|
||||
///用户登录请求
|
||||
virtual int ReqUserLogin(CThostFtdcReqUserLoginField *pReqUserLoginField, int nRequestID) = 0;
|
||||
|
||||
|
||||
///登出请求
|
||||
virtual int ReqUserLogout(CThostFtdcUserLogoutField *pUserLogout, int nRequestID) = 0;
|
||||
protected:
|
||||
~CThostFtdcMdApi(){};
|
||||
};
|
||||
|
||||
#endif
|
575
vn.ctp/pyscript/ThostFtdcTraderApi.h
Normal file
575
vn.ctp/pyscript/ThostFtdcTraderApi.h
Normal file
@ -0,0 +1,575 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///@system 新一代交易所系统
|
||||
///@company 上海期货信息技术有限公司
|
||||
///@file ThostFtdcTraderApi.h
|
||||
///@brief 定义了客户端接口
|
||||
///@history
|
||||
///20060106 赵鸿昊 创建该文件
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(THOST_FTDCTRADERAPI_H)
|
||||
#define THOST_FTDCTRADERAPI_H
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include "ThostFtdcUserApiStruct.h"
|
||||
|
||||
#if defined(ISLIB) && defined(WIN32)
|
||||
#ifdef LIB_TRADER_API_EXPORT
|
||||
#define TRADER_API_EXPORT __declspec(dllexport)
|
||||
#else
|
||||
#define TRADER_API_EXPORT __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define TRADER_API_EXPORT
|
||||
#endif
|
||||
|
||||
class CThostFtdcTraderSpi
|
||||
{
|
||||
public:
|
||||
///当客户端与交易后台建立起通信连接时(还未登录前),该方法被调用。
|
||||
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 OnRspAuthenticate(CThostFtdcRspAuthenticateField *pRspAuthenticateField, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
|
||||
///登录请求响应
|
||||
virtual void OnRspUserLogin(CThostFtdcRspUserLoginField *pRspUserLogin, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///登出请求响应
|
||||
virtual void OnRspUserLogout(CThostFtdcUserLogoutField *pUserLogout, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///用户口令更新请求响应
|
||||
virtual void OnRspUserPasswordUpdate(CThostFtdcUserPasswordUpdateField *pUserPasswordUpdate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///资金账户口令更新请求响应
|
||||
virtual void OnRspTradingAccountPasswordUpdate(CThostFtdcTradingAccountPasswordUpdateField *pTradingAccountPasswordUpdate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///报单录入请求响应
|
||||
virtual void OnRspOrderInsert(CThostFtdcInputOrderField *pInputOrder, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///预埋单录入请求响应
|
||||
virtual void OnRspParkedOrderInsert(CThostFtdcParkedOrderField *pParkedOrder, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///预埋撤单录入请求响应
|
||||
virtual void OnRspParkedOrderAction(CThostFtdcParkedOrderActionField *pParkedOrderAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///报单操作请求响应
|
||||
virtual void OnRspOrderAction(CThostFtdcInputOrderActionField *pInputOrderAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///查询最大报单数量响应
|
||||
virtual void OnRspQueryMaxOrderVolume(CThostFtdcQueryMaxOrderVolumeField *pQueryMaxOrderVolume, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///投资者结算结果确认响应
|
||||
virtual void OnRspSettlementInfoConfirm(CThostFtdcSettlementInfoConfirmField *pSettlementInfoConfirm, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///删除预埋单响应
|
||||
virtual void OnRspRemoveParkedOrder(CThostFtdcRemoveParkedOrderField *pRemoveParkedOrder, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///删除预埋撤单响应
|
||||
virtual void OnRspRemoveParkedOrderAction(CThostFtdcRemoveParkedOrderActionField *pRemoveParkedOrderAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///执行宣告录入请求响应
|
||||
virtual void OnRspExecOrderInsert(CThostFtdcInputExecOrderField *pInputExecOrder, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///执行宣告操作请求响应
|
||||
virtual void OnRspExecOrderAction(CThostFtdcInputExecOrderActionField *pInputExecOrderAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///询价录入请求响应
|
||||
virtual void OnRspForQuoteInsert(CThostFtdcInputForQuoteField *pInputForQuote, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///报价录入请求响应
|
||||
virtual void OnRspQuoteInsert(CThostFtdcInputQuoteField *pInputQuote, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///报价操作请求响应
|
||||
virtual void OnRspQuoteAction(CThostFtdcInputQuoteActionField *pInputQuoteAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询报单响应
|
||||
virtual void OnRspQryOrder(CThostFtdcOrderField *pOrder, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询成交响应
|
||||
virtual void OnRspQryTrade(CThostFtdcTradeField *pTrade, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询投资者持仓响应
|
||||
virtual void OnRspQryInvestorPosition(CThostFtdcInvestorPositionField *pInvestorPosition, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询资金账户响应
|
||||
virtual void OnRspQryTradingAccount(CThostFtdcTradingAccountField *pTradingAccount, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询投资者响应
|
||||
virtual void OnRspQryInvestor(CThostFtdcInvestorField *pInvestor, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询交易编码响应
|
||||
virtual void OnRspQryTradingCode(CThostFtdcTradingCodeField *pTradingCode, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询合约保证金率响应
|
||||
virtual void OnRspQryInstrumentMarginRate(CThostFtdcInstrumentMarginRateField *pInstrumentMarginRate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询合约手续费率响应
|
||||
virtual void OnRspQryInstrumentCommissionRate(CThostFtdcInstrumentCommissionRateField *pInstrumentCommissionRate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询交易所响应
|
||||
virtual void OnRspQryExchange(CThostFtdcExchangeField *pExchange, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询产品响应
|
||||
virtual void OnRspQryProduct(CThostFtdcProductField *pProduct, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询合约响应
|
||||
virtual void OnRspQryInstrument(CThostFtdcInstrumentField *pInstrument, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询行情响应
|
||||
virtual void OnRspQryDepthMarketData(CThostFtdcDepthMarketDataField *pDepthMarketData, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询投资者结算结果响应
|
||||
virtual void OnRspQrySettlementInfo(CThostFtdcSettlementInfoField *pSettlementInfo, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询转帐银行响应
|
||||
virtual void OnRspQryTransferBank(CThostFtdcTransferBankField *pTransferBank, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询投资者持仓明细响应
|
||||
virtual void OnRspQryInvestorPositionDetail(CThostFtdcInvestorPositionDetailField *pInvestorPositionDetail, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询客户通知响应
|
||||
virtual void OnRspQryNotice(CThostFtdcNoticeField *pNotice, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询结算信息确认响应
|
||||
virtual void OnRspQrySettlementInfoConfirm(CThostFtdcSettlementInfoConfirmField *pSettlementInfoConfirm, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询投资者持仓明细响应
|
||||
virtual void OnRspQryInvestorPositionCombineDetail(CThostFtdcInvestorPositionCombineDetailField *pInvestorPositionCombineDetail, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///查询保证金监管系统经纪公司资金账户密钥响应
|
||||
virtual void OnRspQryCFMMCTradingAccountKey(CThostFtdcCFMMCTradingAccountKeyField *pCFMMCTradingAccountKey, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询仓单折抵信息响应
|
||||
virtual void OnRspQryEWarrantOffset(CThostFtdcEWarrantOffsetField *pEWarrantOffset, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询投资者品种/跨品种保证金响应
|
||||
virtual void OnRspQryInvestorProductGroupMargin(CThostFtdcInvestorProductGroupMarginField *pInvestorProductGroupMargin, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询交易所保证金率响应
|
||||
virtual void OnRspQryExchangeMarginRate(CThostFtdcExchangeMarginRateField *pExchangeMarginRate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询交易所调整保证金率响应
|
||||
virtual void OnRspQryExchangeMarginRateAdjust(CThostFtdcExchangeMarginRateAdjustField *pExchangeMarginRateAdjust, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询汇率响应
|
||||
virtual void OnRspQryExchangeRate(CThostFtdcExchangeRateField *pExchangeRate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询二级代理操作员银期权限响应
|
||||
virtual void OnRspQrySecAgentACIDMap(CThostFtdcSecAgentACIDMapField *pSecAgentACIDMap, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询期权交易成本响应
|
||||
virtual void OnRspQryOptionInstrTradeCost(CThostFtdcOptionInstrTradeCostField *pOptionInstrTradeCost, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询期权合约手续费响应
|
||||
virtual void OnRspQryOptionInstrCommRate(CThostFtdcOptionInstrCommRateField *pOptionInstrCommRate, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询执行宣告响应
|
||||
virtual void OnRspQryExecOrder(CThostFtdcExecOrderField *pExecOrder, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询询价响应
|
||||
virtual void OnRspQryForQuote(CThostFtdcForQuoteField *pForQuote, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询报价响应
|
||||
virtual void OnRspQryQuote(CThostFtdcQuoteField *pQuote, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询转帐流水响应
|
||||
virtual void OnRspQryTransferSerial(CThostFtdcTransferSerialField *pTransferSerial, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询银期签约关系响应
|
||||
virtual void OnRspQryAccountregister(CThostFtdcAccountregisterField *pAccountregister, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///错误应答
|
||||
virtual void OnRspError(CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///报单通知
|
||||
virtual void OnRtnOrder(CThostFtdcOrderField *pOrder) {};
|
||||
|
||||
///成交通知
|
||||
virtual void OnRtnTrade(CThostFtdcTradeField *pTrade) {};
|
||||
|
||||
///报单录入错误回报
|
||||
virtual void OnErrRtnOrderInsert(CThostFtdcInputOrderField *pInputOrder, CThostFtdcRspInfoField *pRspInfo) {};
|
||||
|
||||
///报单操作错误回报
|
||||
virtual void OnErrRtnOrderAction(CThostFtdcOrderActionField *pOrderAction, CThostFtdcRspInfoField *pRspInfo) {};
|
||||
|
||||
///合约交易状态通知
|
||||
virtual void OnRtnInstrumentStatus(CThostFtdcInstrumentStatusField *pInstrumentStatus) {};
|
||||
|
||||
///交易通知
|
||||
virtual void OnRtnTradingNotice(CThostFtdcTradingNoticeInfoField *pTradingNoticeInfo) {};
|
||||
|
||||
///提示条件单校验错误
|
||||
virtual void OnRtnErrorConditionalOrder(CThostFtdcErrorConditionalOrderField *pErrorConditionalOrder) {};
|
||||
|
||||
///执行宣告通知
|
||||
virtual void OnRtnExecOrder(CThostFtdcExecOrderField *pExecOrder) {};
|
||||
|
||||
///执行宣告录入错误回报
|
||||
virtual void OnErrRtnExecOrderInsert(CThostFtdcInputExecOrderField *pInputExecOrder, CThostFtdcRspInfoField *pRspInfo) {};
|
||||
|
||||
///执行宣告操作错误回报
|
||||
virtual void OnErrRtnExecOrderAction(CThostFtdcExecOrderActionField *pExecOrderAction, CThostFtdcRspInfoField *pRspInfo) {};
|
||||
|
||||
///询价录入错误回报
|
||||
virtual void OnErrRtnForQuoteInsert(CThostFtdcInputForQuoteField *pInputForQuote, CThostFtdcRspInfoField *pRspInfo) {};
|
||||
|
||||
///报价通知
|
||||
virtual void OnRtnQuote(CThostFtdcQuoteField *pQuote) {};
|
||||
|
||||
///报价录入错误回报
|
||||
virtual void OnErrRtnQuoteInsert(CThostFtdcInputQuoteField *pInputQuote, CThostFtdcRspInfoField *pRspInfo) {};
|
||||
|
||||
///报价操作错误回报
|
||||
virtual void OnErrRtnQuoteAction(CThostFtdcQuoteActionField *pQuoteAction, CThostFtdcRspInfoField *pRspInfo) {};
|
||||
|
||||
///询价通知
|
||||
virtual void OnRtnForQuoteRsp(CThostFtdcForQuoteRspField *pForQuoteRsp) {};
|
||||
|
||||
///请求查询签约银行响应
|
||||
virtual void OnRspQryContractBank(CThostFtdcContractBankField *pContractBank, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询预埋单响应
|
||||
virtual void OnRspQryParkedOrder(CThostFtdcParkedOrderField *pParkedOrder, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询预埋撤单响应
|
||||
virtual void OnRspQryParkedOrderAction(CThostFtdcParkedOrderActionField *pParkedOrderAction, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询交易通知响应
|
||||
virtual void OnRspQryTradingNotice(CThostFtdcTradingNoticeField *pTradingNotice, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询经纪公司交易参数响应
|
||||
virtual void OnRspQryBrokerTradingParams(CThostFtdcBrokerTradingParamsField *pBrokerTradingParams, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///请求查询经纪公司交易算法响应
|
||||
virtual void OnRspQryBrokerTradingAlgos(CThostFtdcBrokerTradingAlgosField *pBrokerTradingAlgos, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///银行发起银行资金转期货通知
|
||||
virtual void OnRtnFromBankToFutureByBank(CThostFtdcRspTransferField *pRspTransfer) {};
|
||||
|
||||
///银行发起期货资金转银行通知
|
||||
virtual void OnRtnFromFutureToBankByBank(CThostFtdcRspTransferField *pRspTransfer) {};
|
||||
|
||||
///银行发起冲正银行转期货通知
|
||||
virtual void OnRtnRepealFromBankToFutureByBank(CThostFtdcRspRepealField *pRspRepeal) {};
|
||||
|
||||
///银行发起冲正期货转银行通知
|
||||
virtual void OnRtnRepealFromFutureToBankByBank(CThostFtdcRspRepealField *pRspRepeal) {};
|
||||
|
||||
///期货发起银行资金转期货通知
|
||||
virtual void OnRtnFromBankToFutureByFuture(CThostFtdcRspTransferField *pRspTransfer) {};
|
||||
|
||||
///期货发起期货资金转银行通知
|
||||
virtual void OnRtnFromFutureToBankByFuture(CThostFtdcRspTransferField *pRspTransfer) {};
|
||||
|
||||
///系统运行时期货端手工发起冲正银行转期货请求,银行处理完毕后报盘发回的通知
|
||||
virtual void OnRtnRepealFromBankToFutureByFutureManual(CThostFtdcRspRepealField *pRspRepeal) {};
|
||||
|
||||
///系统运行时期货端手工发起冲正期货转银行请求,银行处理完毕后报盘发回的通知
|
||||
virtual void OnRtnRepealFromFutureToBankByFutureManual(CThostFtdcRspRepealField *pRspRepeal) {};
|
||||
|
||||
///期货发起查询银行余额通知
|
||||
virtual void OnRtnQueryBankBalanceByFuture(CThostFtdcNotifyQueryAccountField *pNotifyQueryAccount) {};
|
||||
|
||||
///期货发起银行资金转期货错误回报
|
||||
virtual void OnErrRtnBankToFutureByFuture(CThostFtdcReqTransferField *pReqTransfer, CThostFtdcRspInfoField *pRspInfo) {};
|
||||
|
||||
///期货发起期货资金转银行错误回报
|
||||
virtual void OnErrRtnFutureToBankByFuture(CThostFtdcReqTransferField *pReqTransfer, CThostFtdcRspInfoField *pRspInfo) {};
|
||||
|
||||
///系统运行时期货端手工发起冲正银行转期货错误回报
|
||||
virtual void OnErrRtnRepealBankToFutureByFutureManual(CThostFtdcReqRepealField *pReqRepeal, CThostFtdcRspInfoField *pRspInfo) {};
|
||||
|
||||
///系统运行时期货端手工发起冲正期货转银行错误回报
|
||||
virtual void OnErrRtnRepealFutureToBankByFutureManual(CThostFtdcReqRepealField *pReqRepeal, CThostFtdcRspInfoField *pRspInfo) {};
|
||||
|
||||
///期货发起查询银行余额错误回报
|
||||
virtual void OnErrRtnQueryBankBalanceByFuture(CThostFtdcReqQueryAccountField *pReqQueryAccount, CThostFtdcRspInfoField *pRspInfo) {};
|
||||
|
||||
///期货发起冲正银行转期货请求,银行处理完毕后报盘发回的通知
|
||||
virtual void OnRtnRepealFromBankToFutureByFuture(CThostFtdcRspRepealField *pRspRepeal) {};
|
||||
|
||||
///期货发起冲正期货转银行请求,银行处理完毕后报盘发回的通知
|
||||
virtual void OnRtnRepealFromFutureToBankByFuture(CThostFtdcRspRepealField *pRspRepeal) {};
|
||||
|
||||
///期货发起银行资金转期货应答
|
||||
virtual void OnRspFromBankToFutureByFuture(CThostFtdcReqTransferField *pReqTransfer, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///期货发起期货资金转银行应答
|
||||
virtual void OnRspFromFutureToBankByFuture(CThostFtdcReqTransferField *pReqTransfer, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///期货发起查询银行余额应答
|
||||
virtual void OnRspQueryBankAccountMoneyByFuture(CThostFtdcReqQueryAccountField *pReqQueryAccount, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///银行发起银期开户通知
|
||||
virtual void OnRtnOpenAccountByBank(CThostFtdcOpenAccountField *pOpenAccount) {};
|
||||
|
||||
///银行发起银期销户通知
|
||||
virtual void OnRtnCancelAccountByBank(CThostFtdcCancelAccountField *pCancelAccount) {};
|
||||
|
||||
///银行发起变更银行账号通知
|
||||
virtual void OnRtnChangeAccountByBank(CThostFtdcChangeAccountField *pChangeAccount) {};
|
||||
};
|
||||
|
||||
class TRADER_API_EXPORT CThostFtdcTraderApi
|
||||
{
|
||||
public:
|
||||
///创建TraderApi
|
||||
///@param pszFlowPath 存贮订阅信息文件的目录,默认为当前目录
|
||||
///@return 创建出的UserApi
|
||||
static CThostFtdcTraderApi *CreateFtdcTraderApi(const char *pszFlowPath = "");
|
||||
|
||||
///删除接口对象本身
|
||||
///@remark 不再使用本接口对象时,调用该函数删除接口对象
|
||||
virtual void Release() = 0;
|
||||
|
||||
///初始化
|
||||
///@remark 初始化运行环境,只有调用后,接口才开始工作
|
||||
virtual void Init() = 0;
|
||||
|
||||
///等待接口线程结束运行
|
||||
///@return 线程退出代码
|
||||
virtual int Join() = 0;
|
||||
|
||||
///获取当前交易日
|
||||
///@retrun 获取到的交易日
|
||||
///@remark 只有登录成功后,才能得到正确的交易日
|
||||
virtual const char *GetTradingDay() = 0;
|
||||
|
||||
///注册前置机网络地址
|
||||
///@param pszFrontAddress:前置机网络地址。
|
||||
///@remark 网络地址的格式为:“protocol://ipaddress:port”,如:”tcp://127.0.0.1:17001”。
|
||||
///@remark “tcp”代表传输协议,“127.0.0.1”代表服务器地址。”17001”代表服务器端口号。
|
||||
virtual void RegisterFront(char *pszFrontAddress) = 0;
|
||||
|
||||
///注册名字服务器网络地址
|
||||
///@param pszNsAddress:名字服务器网络地址。
|
||||
///@remark 网络地址的格式为:“protocol://ipaddress:port”,如:”tcp://127.0.0.1:12001”。
|
||||
///@remark “tcp”代表传输协议,“127.0.0.1”代表服务器地址。”12001”代表服务器端口号。
|
||||
///@remark RegisterNameServer优先于RegisterFront
|
||||
virtual void RegisterNameServer(char *pszNsAddress) = 0;
|
||||
|
||||
///注册名字服务器用户信息
|
||||
///@param pFensUserInfo:用户信息。
|
||||
virtual void RegisterFensUserInfo(CThostFtdcFensUserInfoField * pFensUserInfo) = 0;
|
||||
|
||||
///注册回调接口
|
||||
///@param pSpi 派生自回调接口类的实例
|
||||
virtual void RegisterSpi(CThostFtdcTraderSpi *pSpi) = 0;
|
||||
|
||||
///订阅私有流。
|
||||
///@param nResumeType 私有流重传方式
|
||||
/// THOST_TERT_RESTART:从本交易日开始重传
|
||||
/// THOST_TERT_RESUME:从上次收到的续传
|
||||
/// THOST_TERT_QUICK:只传送登录后私有流的内容
|
||||
///@remark 该方法要在Init方法前调用。若不调用则不会收到私有流的数据。
|
||||
virtual void SubscribePrivateTopic(THOST_TE_RESUME_TYPE nResumeType) = 0;
|
||||
|
||||
///订阅公共流。
|
||||
///@param nResumeType 公共流重传方式
|
||||
/// THOST_TERT_RESTART:从本交易日开始重传
|
||||
/// THOST_TERT_RESUME:从上次收到的续传
|
||||
/// THOST_TERT_QUICK:只传送登录后公共流的内容
|
||||
///@remark 该方法要在Init方法前调用。若不调用则不会收到公共流的数据。
|
||||
virtual void SubscribePublicTopic(THOST_TE_RESUME_TYPE nResumeType) = 0;
|
||||
|
||||
///客户端认证请求
|
||||
virtual int ReqAuthenticate(CThostFtdcReqAuthenticateField *pReqAuthenticateField, int nRequestID) = 0;
|
||||
|
||||
///用户登录请求
|
||||
virtual int ReqUserLogin(CThostFtdcReqUserLoginField *pReqUserLoginField, int nRequestID) = 0;
|
||||
|
||||
|
||||
///登出请求
|
||||
virtual int ReqUserLogout(CThostFtdcUserLogoutField *pUserLogout, int nRequestID) = 0;
|
||||
|
||||
///用户口令更新请求
|
||||
virtual int ReqUserPasswordUpdate(CThostFtdcUserPasswordUpdateField *pUserPasswordUpdate, int nRequestID) = 0;
|
||||
|
||||
///资金账户口令更新请求
|
||||
virtual int ReqTradingAccountPasswordUpdate(CThostFtdcTradingAccountPasswordUpdateField *pTradingAccountPasswordUpdate, int nRequestID) = 0;
|
||||
|
||||
///报单录入请求
|
||||
virtual int ReqOrderInsert(CThostFtdcInputOrderField *pInputOrder, int nRequestID) = 0;
|
||||
|
||||
///预埋单录入请求
|
||||
virtual int ReqParkedOrderInsert(CThostFtdcParkedOrderField *pParkedOrder, int nRequestID) = 0;
|
||||
|
||||
///预埋撤单录入请求
|
||||
virtual int ReqParkedOrderAction(CThostFtdcParkedOrderActionField *pParkedOrderAction, int nRequestID) = 0;
|
||||
|
||||
///报单操作请求
|
||||
virtual int ReqOrderAction(CThostFtdcInputOrderActionField *pInputOrderAction, int nRequestID) = 0;
|
||||
|
||||
///查询最大报单数量请求
|
||||
virtual int ReqQueryMaxOrderVolume(CThostFtdcQueryMaxOrderVolumeField *pQueryMaxOrderVolume, int nRequestID) = 0;
|
||||
|
||||
///投资者结算结果确认
|
||||
virtual int ReqSettlementInfoConfirm(CThostFtdcSettlementInfoConfirmField *pSettlementInfoConfirm, int nRequestID) = 0;
|
||||
|
||||
///请求删除预埋单
|
||||
virtual int ReqRemoveParkedOrder(CThostFtdcRemoveParkedOrderField *pRemoveParkedOrder, int nRequestID) = 0;
|
||||
|
||||
///请求删除预埋撤单
|
||||
virtual int ReqRemoveParkedOrderAction(CThostFtdcRemoveParkedOrderActionField *pRemoveParkedOrderAction, int nRequestID) = 0;
|
||||
|
||||
///执行宣告录入请求
|
||||
virtual int ReqExecOrderInsert(CThostFtdcInputExecOrderField *pInputExecOrder, int nRequestID) = 0;
|
||||
|
||||
///执行宣告操作请求
|
||||
virtual int ReqExecOrderAction(CThostFtdcInputExecOrderActionField *pInputExecOrderAction, int nRequestID) = 0;
|
||||
|
||||
///询价录入请求
|
||||
virtual int ReqForQuoteInsert(CThostFtdcInputForQuoteField *pInputForQuote, int nRequestID) = 0;
|
||||
|
||||
///报价录入请求
|
||||
virtual int ReqQuoteInsert(CThostFtdcInputQuoteField *pInputQuote, int nRequestID) = 0;
|
||||
|
||||
///报价操作请求
|
||||
virtual int ReqQuoteAction(CThostFtdcInputQuoteActionField *pInputQuoteAction, int nRequestID) = 0;
|
||||
|
||||
///请求查询报单
|
||||
virtual int ReqQryOrder(CThostFtdcQryOrderField *pQryOrder, int nRequestID) = 0;
|
||||
|
||||
///请求查询成交
|
||||
virtual int ReqQryTrade(CThostFtdcQryTradeField *pQryTrade, int nRequestID) = 0;
|
||||
|
||||
///请求查询投资者持仓
|
||||
virtual int ReqQryInvestorPosition(CThostFtdcQryInvestorPositionField *pQryInvestorPosition, int nRequestID) = 0;
|
||||
|
||||
///请求查询资金账户
|
||||
virtual int ReqQryTradingAccount(CThostFtdcQryTradingAccountField *pQryTradingAccount, int nRequestID) = 0;
|
||||
|
||||
///请求查询投资者
|
||||
virtual int ReqQryInvestor(CThostFtdcQryInvestorField *pQryInvestor, int nRequestID) = 0;
|
||||
|
||||
///请求查询交易编码
|
||||
virtual int ReqQryTradingCode(CThostFtdcQryTradingCodeField *pQryTradingCode, int nRequestID) = 0;
|
||||
|
||||
///请求查询合约保证金率
|
||||
virtual int ReqQryInstrumentMarginRate(CThostFtdcQryInstrumentMarginRateField *pQryInstrumentMarginRate, int nRequestID) = 0;
|
||||
|
||||
///请求查询合约手续费率
|
||||
virtual int ReqQryInstrumentCommissionRate(CThostFtdcQryInstrumentCommissionRateField *pQryInstrumentCommissionRate, int nRequestID) = 0;
|
||||
|
||||
///请求查询交易所
|
||||
virtual int ReqQryExchange(CThostFtdcQryExchangeField *pQryExchange, int nRequestID) = 0;
|
||||
|
||||
///请求查询产品
|
||||
virtual int ReqQryProduct(CThostFtdcQryProductField *pQryProduct, int nRequestID) = 0;
|
||||
|
||||
///请求查询合约
|
||||
virtual int ReqQryInstrument(CThostFtdcQryInstrumentField *pQryInstrument, int nRequestID) = 0;
|
||||
|
||||
///请求查询行情
|
||||
virtual int ReqQryDepthMarketData(CThostFtdcQryDepthMarketDataField *pQryDepthMarketData, int nRequestID) = 0;
|
||||
|
||||
///请求查询投资者结算结果
|
||||
virtual int ReqQrySettlementInfo(CThostFtdcQrySettlementInfoField *pQrySettlementInfo, int nRequestID) = 0;
|
||||
|
||||
///请求查询转帐银行
|
||||
virtual int ReqQryTransferBank(CThostFtdcQryTransferBankField *pQryTransferBank, int nRequestID) = 0;
|
||||
|
||||
///请求查询投资者持仓明细
|
||||
virtual int ReqQryInvestorPositionDetail(CThostFtdcQryInvestorPositionDetailField *pQryInvestorPositionDetail, int nRequestID) = 0;
|
||||
|
||||
///请求查询客户通知
|
||||
virtual int ReqQryNotice(CThostFtdcQryNoticeField *pQryNotice, int nRequestID) = 0;
|
||||
|
||||
///请求查询结算信息确认
|
||||
virtual int ReqQrySettlementInfoConfirm(CThostFtdcQrySettlementInfoConfirmField *pQrySettlementInfoConfirm, int nRequestID) = 0;
|
||||
|
||||
///请求查询投资者持仓明细
|
||||
virtual int ReqQryInvestorPositionCombineDetail(CThostFtdcQryInvestorPositionCombineDetailField *pQryInvestorPositionCombineDetail, int nRequestID) = 0;
|
||||
|
||||
///请求查询保证金监管系统经纪公司资金账户密钥
|
||||
virtual int ReqQryCFMMCTradingAccountKey(CThostFtdcQryCFMMCTradingAccountKeyField *pQryCFMMCTradingAccountKey, int nRequestID) = 0;
|
||||
|
||||
///请求查询仓单折抵信息
|
||||
virtual int ReqQryEWarrantOffset(CThostFtdcQryEWarrantOffsetField *pQryEWarrantOffset, int nRequestID) = 0;
|
||||
|
||||
///请求查询投资者品种/跨品种保证金
|
||||
virtual int ReqQryInvestorProductGroupMargin(CThostFtdcQryInvestorProductGroupMarginField *pQryInvestorProductGroupMargin, int nRequestID) = 0;
|
||||
|
||||
///请求查询交易所保证金率
|
||||
virtual int ReqQryExchangeMarginRate(CThostFtdcQryExchangeMarginRateField *pQryExchangeMarginRate, int nRequestID) = 0;
|
||||
|
||||
///请求查询交易所调整保证金率
|
||||
virtual int ReqQryExchangeMarginRateAdjust(CThostFtdcQryExchangeMarginRateAdjustField *pQryExchangeMarginRateAdjust, int nRequestID) = 0;
|
||||
|
||||
///请求查询汇率
|
||||
virtual int ReqQryExchangeRate(CThostFtdcQryExchangeRateField *pQryExchangeRate, int nRequestID) = 0;
|
||||
|
||||
///请求查询二级代理操作员银期权限
|
||||
virtual int ReqQrySecAgentACIDMap(CThostFtdcQrySecAgentACIDMapField *pQrySecAgentACIDMap, int nRequestID) = 0;
|
||||
|
||||
///请求查询期权交易成本
|
||||
virtual int ReqQryOptionInstrTradeCost(CThostFtdcQryOptionInstrTradeCostField *pQryOptionInstrTradeCost, int nRequestID) = 0;
|
||||
|
||||
///请求查询期权合约手续费
|
||||
virtual int ReqQryOptionInstrCommRate(CThostFtdcQryOptionInstrCommRateField *pQryOptionInstrCommRate, int nRequestID) = 0;
|
||||
|
||||
///请求查询执行宣告
|
||||
virtual int ReqQryExecOrder(CThostFtdcQryExecOrderField *pQryExecOrder, int nRequestID) = 0;
|
||||
|
||||
///请求查询询价
|
||||
virtual int ReqQryForQuote(CThostFtdcQryForQuoteField *pQryForQuote, int nRequestID) = 0;
|
||||
|
||||
///请求查询报价
|
||||
virtual int ReqQryQuote(CThostFtdcQryQuoteField *pQryQuote, int nRequestID) = 0;
|
||||
|
||||
///请求查询转帐流水
|
||||
virtual int ReqQryTransferSerial(CThostFtdcQryTransferSerialField *pQryTransferSerial, int nRequestID) = 0;
|
||||
|
||||
///请求查询银期签约关系
|
||||
virtual int ReqQryAccountregister(CThostFtdcQryAccountregisterField *pQryAccountregister, int nRequestID) = 0;
|
||||
|
||||
///请求查询签约银行
|
||||
virtual int ReqQryContractBank(CThostFtdcQryContractBankField *pQryContractBank, int nRequestID) = 0;
|
||||
|
||||
///请求查询预埋单
|
||||
virtual int ReqQryParkedOrder(CThostFtdcQryParkedOrderField *pQryParkedOrder, int nRequestID) = 0;
|
||||
|
||||
///请求查询预埋撤单
|
||||
virtual int ReqQryParkedOrderAction(CThostFtdcQryParkedOrderActionField *pQryParkedOrderAction, int nRequestID) = 0;
|
||||
|
||||
///请求查询交易通知
|
||||
virtual int ReqQryTradingNotice(CThostFtdcQryTradingNoticeField *pQryTradingNotice, int nRequestID) = 0;
|
||||
|
||||
///请求查询经纪公司交易参数
|
||||
virtual int ReqQryBrokerTradingParams(CThostFtdcQryBrokerTradingParamsField *pQryBrokerTradingParams, int nRequestID) = 0;
|
||||
|
||||
///请求查询经纪公司交易算法
|
||||
virtual int ReqQryBrokerTradingAlgos(CThostFtdcQryBrokerTradingAlgosField *pQryBrokerTradingAlgos, int nRequestID) = 0;
|
||||
|
||||
///期货发起银行资金转期货请求
|
||||
virtual int ReqFromBankToFutureByFuture(CThostFtdcReqTransferField *pReqTransfer, int nRequestID) = 0;
|
||||
|
||||
///期货发起期货资金转银行请求
|
||||
virtual int ReqFromFutureToBankByFuture(CThostFtdcReqTransferField *pReqTransfer, int nRequestID) = 0;
|
||||
|
||||
///期货发起查询银行余额请求
|
||||
virtual int ReqQueryBankAccountMoneyByFuture(CThostFtdcReqQueryAccountField *pReqQueryAccount, int nRequestID) = 0;
|
||||
protected:
|
||||
~CThostFtdcTraderApi(){};
|
||||
};
|
||||
|
||||
#endif
|
6267
vn.ctp/pyscript/ThostFtdcUserApiDataType.h
Normal file
6267
vn.ctp/pyscript/ThostFtdcUserApiDataType.h
Normal file
File diff suppressed because it is too large
Load Diff
7430
vn.ctp/pyscript/ThostFtdcUserApiStruct.h
Normal file
7430
vn.ctp/pyscript/ThostFtdcUserApiStruct.h
Normal file
File diff suppressed because it is too large
Load Diff
6263
vn.ctp/pyscript/ctp_data_type.py
Normal file
6263
vn.ctp/pyscript/ctp_data_type.py
Normal file
File diff suppressed because it is too large
Load Diff
12
vn.ctp/pyscript/ctp_md_define.cpp
Normal file
12
vn.ctp/pyscript/ctp_md_define.cpp
Normal file
@ -0,0 +1,12 @@
|
||||
#define ONFRONTCONNECTED 1
|
||||
#define ONFRONTDISCONNECTED 2
|
||||
#define ONHEARTBEATWARNING 3
|
||||
#define ONRSPUSERLOGIN 4
|
||||
#define ONRSPUSERLOGOUT 5
|
||||
#define ONRSPERROR 6
|
||||
#define ONRSPSUBMARKETDATA 7
|
||||
#define ONRSPUNSUBMARKETDATA 8
|
||||
#define ONRSPSUBFORQUOTERSP 9
|
||||
#define ONRSPUNSUBFORQUOTERSP 10
|
||||
#define ONRTNDEPTHMARKETDATA 11
|
||||
#define ONRTNFORQUOTERSP 12
|
28
vn.ctp/pyscript/ctp_md_function.cpp
Normal file
28
vn.ctp/pyscript/ctp_md_function.cpp
Normal file
@ -0,0 +1,28 @@
|
||||
ReqUserLogin
|
||||
{
|
||||
CThostFtdcReqUserLoginField myreq = CThostFtdcReqUserLoginField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "MacAddress", myreq.MacAddress);
|
||||
getChar(req, "UserProductInfo", myreq.UserProductInfo);
|
||||
getChar(req, "UserID", myreq.UserID);
|
||||
getChar(req, "TradingDay", myreq.TradingDay);
|
||||
getChar(req, "InterfaceProductInfo", myreq.InterfaceProductInfo);
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
getChar(req, "ClientIPAddress", myreq.ClientIPAddress);
|
||||
getChar(req, "OneTimePassword", myreq.OneTimePassword);
|
||||
getChar(req, "ProtocolInfo", myreq.ProtocolInfo);
|
||||
getChar(req, "Password", myreq.Password);
|
||||
int i = this->api->ReqUserLogin(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
ReqUserLogout
|
||||
{
|
||||
CThostFtdcUserLogoutField myreq = CThostFtdcUserLogoutField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "UserID", myreq.UserID);
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
int i = this->api->ReqUserLogout(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
187
vn.ctp/pyscript/ctp_md_process.cpp
Normal file
187
vn.ctp/pyscript/ctp_md_process.cpp
Normal file
@ -0,0 +1,187 @@
|
||||
void MdApi::processFrontConnected(Task task)
|
||||
{
|
||||
this->onFrontConnected();
|
||||
};
|
||||
|
||||
void MdApi::processFrontDisconnected(Task task)
|
||||
{
|
||||
this->onFrontDisconnected(task.task_id);
|
||||
};
|
||||
|
||||
void MdApi::processHeartBeatWarning(Task task)
|
||||
{
|
||||
this->onHeartBeatWarning(task.task_id);
|
||||
};
|
||||
|
||||
void MdApi::processRspUserLogin(Task task)
|
||||
{
|
||||
CThostFtdcRspUserLoginField task_data = any_cast<CThostFtdcRspUserLoginField>(task.task_data);
|
||||
dict data;
|
||||
data["CZCETime"] = task_data.CZCETime;
|
||||
data["SHFETime"] = task_data.SHFETime;
|
||||
data["MaxOrderRef"] = task_data.MaxOrderRef;
|
||||
data["INETime"] = task_data.INETime;
|
||||
data["UserID"] = task_data.UserID;
|
||||
data["TradingDay"] = task_data.TradingDay;
|
||||
data["SessionID"] = task_data.SessionID;
|
||||
data["SystemName"] = task_data.SystemName;
|
||||
data["FrontID"] = task_data.FrontID;
|
||||
data["FFEXTime"] = task_data.FFEXTime;
|
||||
data["BrokerID"] = task_data.BrokerID;
|
||||
data["DCETime"] = task_data.DCETime;
|
||||
data["LoginTime"] = task_data.LoginTime;
|
||||
|
||||
CThostFtdcRspInfoField task_error = any_cast<CThostFtdcRspInfoField>(task.task_error);
|
||||
dict error;
|
||||
error["ErrorMsg"] = task_error.ErrorMsg;
|
||||
error["ErrorID"] = task_error.ErrorID;
|
||||
|
||||
this->onRspUserLogin(data, error, task.task_id, task.task_last);
|
||||
};
|
||||
|
||||
void MdApi::processRspUserLogout(Task task)
|
||||
{
|
||||
CThostFtdcUserLogoutField task_data = any_cast<CThostFtdcUserLogoutField>(task.task_data);
|
||||
dict data;
|
||||
data["UserID"] = task_data.UserID;
|
||||
data["BrokerID"] = task_data.BrokerID;
|
||||
|
||||
CThostFtdcRspInfoField task_error = any_cast<CThostFtdcRspInfoField>(task.task_error);
|
||||
dict error;
|
||||
error["ErrorMsg"] = task_error.ErrorMsg;
|
||||
error["ErrorID"] = task_error.ErrorID;
|
||||
|
||||
this->onRspUserLogout(data, error, task.task_id, task.task_last);
|
||||
};
|
||||
|
||||
void MdApi::processRspError(Task task)
|
||||
{
|
||||
CThostFtdcRspInfoField task_error = any_cast<CThostFtdcRspInfoField>(task.task_error);
|
||||
dict error;
|
||||
error["ErrorMsg"] = task_error.ErrorMsg;
|
||||
error["ErrorID"] = task_error.ErrorID;
|
||||
|
||||
this->onRspError(error, task.task_id, task.task_last);
|
||||
};
|
||||
|
||||
void MdApi::processRspSubMarketData(Task task)
|
||||
{
|
||||
CThostFtdcSpecificInstrumentField task_data = any_cast<CThostFtdcSpecificInstrumentField>(task.task_data);
|
||||
dict data;
|
||||
data["InstrumentID"] = task_data.InstrumentID;
|
||||
|
||||
CThostFtdcRspInfoField task_error = any_cast<CThostFtdcRspInfoField>(task.task_error);
|
||||
dict error;
|
||||
error["ErrorMsg"] = task_error.ErrorMsg;
|
||||
error["ErrorID"] = task_error.ErrorID;
|
||||
|
||||
this->onRspSubMarketData(data, error, task.task_id, task.task_last);
|
||||
};
|
||||
|
||||
void MdApi::processRspUnSubMarketData(Task task)
|
||||
{
|
||||
CThostFtdcSpecificInstrumentField task_data = any_cast<CThostFtdcSpecificInstrumentField>(task.task_data);
|
||||
dict data;
|
||||
data["InstrumentID"] = task_data.InstrumentID;
|
||||
|
||||
CThostFtdcRspInfoField task_error = any_cast<CThostFtdcRspInfoField>(task.task_error);
|
||||
dict error;
|
||||
error["ErrorMsg"] = task_error.ErrorMsg;
|
||||
error["ErrorID"] = task_error.ErrorID;
|
||||
|
||||
this->onRspUnSubMarketData(data, error, task.task_id, task.task_last);
|
||||
};
|
||||
|
||||
void MdApi::processRspSubForQuoteRsp(Task task)
|
||||
{
|
||||
CThostFtdcSpecificInstrumentField task_data = any_cast<CThostFtdcSpecificInstrumentField>(task.task_data);
|
||||
dict data;
|
||||
data["InstrumentID"] = task_data.InstrumentID;
|
||||
|
||||
CThostFtdcRspInfoField task_error = any_cast<CThostFtdcRspInfoField>(task.task_error);
|
||||
dict error;
|
||||
error["ErrorMsg"] = task_error.ErrorMsg;
|
||||
error["ErrorID"] = task_error.ErrorID;
|
||||
|
||||
this->onRspSubForQuoteRsp(data, error, task.task_id, task.task_last);
|
||||
};
|
||||
|
||||
void MdApi::processRspUnSubForQuoteRsp(Task task)
|
||||
{
|
||||
CThostFtdcSpecificInstrumentField task_data = any_cast<CThostFtdcSpecificInstrumentField>(task.task_data);
|
||||
dict data;
|
||||
data["InstrumentID"] = task_data.InstrumentID;
|
||||
|
||||
CThostFtdcRspInfoField task_error = any_cast<CThostFtdcRspInfoField>(task.task_error);
|
||||
dict error;
|
||||
error["ErrorMsg"] = task_error.ErrorMsg;
|
||||
error["ErrorID"] = task_error.ErrorID;
|
||||
|
||||
this->onRspUnSubForQuoteRsp(data, error, task.task_id, task.task_last);
|
||||
};
|
||||
|
||||
void MdApi::processRtnDepthMarketData(Task task)
|
||||
{
|
||||
CThostFtdcDepthMarketDataField task_data = any_cast<CThostFtdcDepthMarketDataField>(task.task_data);
|
||||
dict data;
|
||||
data["HighestPrice"] = task_data.HighestPrice;
|
||||
data["BidPrice5"] = task_data.BidPrice5;
|
||||
data["BidPrice4"] = task_data.BidPrice4;
|
||||
data["BidPrice1"] = task_data.BidPrice1;
|
||||
data["BidPrice3"] = task_data.BidPrice3;
|
||||
data["BidPrice2"] = task_data.BidPrice2;
|
||||
data["LowerLimitPrice"] = task_data.LowerLimitPrice;
|
||||
data["OpenPrice"] = task_data.OpenPrice;
|
||||
data["AskPrice5"] = task_data.AskPrice5;
|
||||
data["AskPrice4"] = task_data.AskPrice4;
|
||||
data["AskPrice3"] = task_data.AskPrice3;
|
||||
data["PreClosePrice"] = task_data.PreClosePrice;
|
||||
data["AskPrice1"] = task_data.AskPrice1;
|
||||
data["PreSettlementPrice"] = task_data.PreSettlementPrice;
|
||||
data["AskVolume1"] = task_data.AskVolume1;
|
||||
data["UpdateTime"] = task_data.UpdateTime;
|
||||
data["UpdateMillisec"] = task_data.UpdateMillisec;
|
||||
data["AveragePrice"] = task_data.AveragePrice;
|
||||
data["BidVolume5"] = task_data.BidVolume5;
|
||||
data["BidVolume4"] = task_data.BidVolume4;
|
||||
data["BidVolume3"] = task_data.BidVolume3;
|
||||
data["BidVolume2"] = task_data.BidVolume2;
|
||||
data["PreOpenInterest"] = task_data.PreOpenInterest;
|
||||
data["AskPrice2"] = task_data.AskPrice2;
|
||||
data["Volume"] = task_data.Volume;
|
||||
data["AskVolume3"] = task_data.AskVolume3;
|
||||
data["AskVolume2"] = task_data.AskVolume2;
|
||||
data["AskVolume5"] = task_data.AskVolume5;
|
||||
data["AskVolume4"] = task_data.AskVolume4;
|
||||
data["UpperLimitPrice"] = task_data.UpperLimitPrice;
|
||||
data["BidVolume1"] = task_data.BidVolume1;
|
||||
data["InstrumentID"] = task_data.InstrumentID;
|
||||
data["ClosePrice"] = task_data.ClosePrice;
|
||||
data["ExchangeID"] = task_data.ExchangeID;
|
||||
data["TradingDay"] = task_data.TradingDay;
|
||||
data["PreDelta"] = task_data.PreDelta;
|
||||
data["OpenInterest"] = task_data.OpenInterest;
|
||||
data["CurrDelta"] = task_data.CurrDelta;
|
||||
data["Turnover"] = task_data.Turnover;
|
||||
data["LastPrice"] = task_data.LastPrice;
|
||||
data["SettlementPrice"] = task_data.SettlementPrice;
|
||||
data["ExchangeInstID"] = task_data.ExchangeInstID;
|
||||
data["LowestPrice"] = task_data.LowestPrice;
|
||||
data["ActionDay"] = task_data.ActionDay;
|
||||
|
||||
this->onRtnDepthMarketData(data);
|
||||
};
|
||||
|
||||
void MdApi::processRtnForQuoteRsp(Task task)
|
||||
{
|
||||
CThostFtdcForQuoteRspField task_data = any_cast<CThostFtdcForQuoteRspField>(task.task_data);
|
||||
dict data;
|
||||
data["InstrumentID"] = task_data.InstrumentID;
|
||||
data["TradingDay"] = task_data.TradingDay;
|
||||
data["ForQuoteTime"] = task_data.ForQuoteTime;
|
||||
data["ForQuoteSysID"] = task_data.ForQuoteSysID;
|
||||
data["ActionDay"] = task_data.ActionDay;
|
||||
|
||||
this->onRtnForQuoteRsp(data);
|
||||
};
|
||||
|
72
vn.ctp/pyscript/ctp_md_switch.cpp
Normal file
72
vn.ctp/pyscript/ctp_md_switch.cpp
Normal file
@ -0,0 +1,72 @@
|
||||
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;
|
||||
}
|
||||
|
178
vn.ctp/pyscript/ctp_md_task.cpp
Normal file
178
vn.ctp/pyscript/ctp_md_task.cpp
Normal file
@ -0,0 +1,178 @@
|
||||
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;
|
||||
task.task_data = *pRspUserLogin;
|
||||
if (pRspInfo)
|
||||
{
|
||||
task.task_error = *pRspInfo;
|
||||
}
|
||||
else
|
||||
{
|
||||
CSecurityFtdcRspInfoField empty_error = CSecurityFtdcRspInfoField();
|
||||
memset(&empty_error, 0, sizeof(empty_error));
|
||||
task.task_error = empty_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;
|
||||
task.task_data = *pUserLogout;
|
||||
if (pRspInfo)
|
||||
{
|
||||
task.task_error = *pRspInfo;
|
||||
}
|
||||
else
|
||||
{
|
||||
CSecurityFtdcRspInfoField empty_error = CSecurityFtdcRspInfoField();
|
||||
memset(&empty_error, 0, sizeof(empty_error));
|
||||
task.task_error = empty_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)
|
||||
{
|
||||
task.task_error = *pRspInfo;
|
||||
}
|
||||
else
|
||||
{
|
||||
CSecurityFtdcRspInfoField empty_error = CSecurityFtdcRspInfoField();
|
||||
memset(&empty_error, 0, sizeof(empty_error));
|
||||
task.task_error = empty_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;
|
||||
task.task_data = *pSpecificInstrument;
|
||||
if (pRspInfo)
|
||||
{
|
||||
task.task_error = *pRspInfo;
|
||||
}
|
||||
else
|
||||
{
|
||||
CSecurityFtdcRspInfoField empty_error = CSecurityFtdcRspInfoField();
|
||||
memset(&empty_error, 0, sizeof(empty_error));
|
||||
task.task_error = empty_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;
|
||||
task.task_data = *pSpecificInstrument;
|
||||
if (pRspInfo)
|
||||
{
|
||||
task.task_error = *pRspInfo;
|
||||
}
|
||||
else
|
||||
{
|
||||
CSecurityFtdcRspInfoField empty_error = CSecurityFtdcRspInfoField();
|
||||
memset(&empty_error, 0, sizeof(empty_error));
|
||||
task.task_error = empty_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;
|
||||
task.task_data = *pSpecificInstrument;
|
||||
if (pRspInfo)
|
||||
{
|
||||
task.task_error = *pRspInfo;
|
||||
}
|
||||
else
|
||||
{
|
||||
CSecurityFtdcRspInfoField empty_error = CSecurityFtdcRspInfoField();
|
||||
memset(&empty_error, 0, sizeof(empty_error));
|
||||
task.task_error = empty_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;
|
||||
task.task_data = *pSpecificInstrument;
|
||||
if (pRspInfo)
|
||||
{
|
||||
task.task_error = *pRspInfo;
|
||||
}
|
||||
else
|
||||
{
|
||||
CSecurityFtdcRspInfoField empty_error = CSecurityFtdcRspInfoField();
|
||||
memset(&empty_error, 0, sizeof(empty_error));
|
||||
task.task_error = empty_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;
|
||||
task.task_data = *pDepthMarketData;
|
||||
this->task_queue.push(task);
|
||||
};
|
||||
|
||||
void MdApi::OnRtnForQuoteRsp(CThostFtdcForQuoteRspField *pForQuoteRsp)
|
||||
{
|
||||
Task task = Task();
|
||||
task.task_name = ONRTNFORQUOTERSP;
|
||||
task.task_data = *pForQuoteRsp;
|
||||
this->task_queue.push(task);
|
||||
};
|
||||
|
7434
vn.ctp/pyscript/ctp_struct.py
Normal file
7434
vn.ctp/pyscript/ctp_struct.py
Normal file
File diff suppressed because it is too large
Load Diff
97
vn.ctp/pyscript/ctp_td_define.cpp
Normal file
97
vn.ctp/pyscript/ctp_td_define.cpp
Normal file
@ -0,0 +1,97 @@
|
||||
#define ONFRONTCONNECTED 1
|
||||
#define ONFRONTDISCONNECTED 2
|
||||
#define ONHEARTBEATWARNING 3
|
||||
#define ONRSPAUTHENTICATE 4
|
||||
#define ONRSPUSERLOGIN 5
|
||||
#define ONRSPUSERLOGOUT 6
|
||||
#define ONRSPUSERPASSWORDUPDATE 7
|
||||
#define ONRSPTRADINGACCOUNTPASSWORDUPDATE 8
|
||||
#define ONRSPORDERINSERT 9
|
||||
#define ONRSPPARKEDORDERINSERT 10
|
||||
#define ONRSPPARKEDORDERACTION 11
|
||||
#define ONRSPORDERACTION 12
|
||||
#define ONRSPQUERYMAXORDERVOLUME 13
|
||||
#define ONRSPSETTLEMENTINFOCONFIRM 14
|
||||
#define ONRSPREMOVEPARKEDORDER 15
|
||||
#define ONRSPREMOVEPARKEDORDERACTION 16
|
||||
#define ONRSPEXECORDERINSERT 17
|
||||
#define ONRSPEXECORDERACTION 18
|
||||
#define ONRSPFORQUOTEINSERT 19
|
||||
#define ONRSPQUOTEINSERT 20
|
||||
#define ONRSPQUOTEACTION 21
|
||||
#define ONRSPQRYORDER 22
|
||||
#define ONRSPQRYTRADE 23
|
||||
#define ONRSPQRYINVESTORPOSITION 24
|
||||
#define ONRSPQRYTRADINGACCOUNT 25
|
||||
#define ONRSPQRYINVESTOR 26
|
||||
#define ONRSPQRYTRADINGCODE 27
|
||||
#define ONRSPQRYINSTRUMENTMARGINRATE 28
|
||||
#define ONRSPQRYINSTRUMENTCOMMISSIONRATE 29
|
||||
#define ONRSPQRYEXCHANGE 30
|
||||
#define ONRSPQRYPRODUCT 31
|
||||
#define ONRSPQRYINSTRUMENT 32
|
||||
#define ONRSPQRYDEPTHMARKETDATA 33
|
||||
#define ONRSPQRYSETTLEMENTINFO 34
|
||||
#define ONRSPQRYTRANSFERBANK 35
|
||||
#define ONRSPQRYINVESTORPOSITIONDETAIL 36
|
||||
#define ONRSPQRYNOTICE 37
|
||||
#define ONRSPQRYSETTLEMENTINFOCONFIRM 38
|
||||
#define ONRSPQRYINVESTORPOSITIONCOMBINEDETAIL 39
|
||||
#define ONRSPQRYCFMMCTRADINGACCOUNTKEY 40
|
||||
#define ONRSPQRYEWARRANTOFFSET 41
|
||||
#define ONRSPQRYINVESTORPRODUCTGROUPMARGIN 42
|
||||
#define ONRSPQRYEXCHANGEMARGINRATE 43
|
||||
#define ONRSPQRYEXCHANGEMARGINRATEADJUST 44
|
||||
#define ONRSPQRYEXCHANGERATE 45
|
||||
#define ONRSPQRYSECAGENTACIDMAP 46
|
||||
#define ONRSPQRYOPTIONINSTRTRADECOST 47
|
||||
#define ONRSPQRYOPTIONINSTRCOMMRATE 48
|
||||
#define ONRSPQRYEXECORDER 49
|
||||
#define ONRSPQRYFORQUOTE 50
|
||||
#define ONRSPQRYQUOTE 51
|
||||
#define ONRSPQRYTRANSFERSERIAL 52
|
||||
#define ONRSPQRYACCOUNTREGISTER 53
|
||||
#define ONRSPERROR 54
|
||||
#define ONRTNORDER 55
|
||||
#define ONRTNTRADE 56
|
||||
#define ONERRRTNORDERINSERT 57
|
||||
#define ONERRRTNORDERACTION 58
|
||||
#define ONRTNINSTRUMENTSTATUS 59
|
||||
#define ONRTNTRADINGNOTICE 60
|
||||
#define ONRTNERRORCONDITIONALORDER 61
|
||||
#define ONRTNEXECORDER 62
|
||||
#define ONERRRTNEXECORDERINSERT 63
|
||||
#define ONERRRTNEXECORDERACTION 64
|
||||
#define ONERRRTNFORQUOTEINSERT 65
|
||||
#define ONRTNQUOTE 66
|
||||
#define ONERRRTNQUOTEINSERT 67
|
||||
#define ONERRRTNQUOTEACTION 68
|
||||
#define ONRTNFORQUOTERSP 69
|
||||
#define ONRSPQRYCONTRACTBANK 70
|
||||
#define ONRSPQRYPARKEDORDER 71
|
||||
#define ONRSPQRYPARKEDORDERACTION 72
|
||||
#define ONRSPQRYTRADINGNOTICE 73
|
||||
#define ONRSPQRYBROKERTRADINGPARAMS 74
|
||||
#define ONRSPQRYBROKERTRADINGALGOS 75
|
||||
#define ONRTNFROMBANKTOFUTUREBYBANK 76
|
||||
#define ONRTNFROMFUTURETOBANKBYBANK 77
|
||||
#define ONRTNREPEALFROMBANKTOFUTUREBYBANK 78
|
||||
#define ONRTNREPEALFROMFUTURETOBANKBYBANK 79
|
||||
#define ONRTNFROMBANKTOFUTUREBYFUTURE 80
|
||||
#define ONRTNFROMFUTURETOBANKBYFUTURE 81
|
||||
#define ONRTNREPEALFROMBANKTOFUTUREBYFUTUREMANUAL 82
|
||||
#define ONRTNREPEALFROMFUTURETOBANKBYFUTUREMANUAL 83
|
||||
#define ONRTNQUERYBANKBALANCEBYFUTURE 84
|
||||
#define ONERRRTNBANKTOFUTUREBYFUTURE 85
|
||||
#define ONERRRTNFUTURETOBANKBYFUTURE 86
|
||||
#define ONERRRTNREPEALBANKTOFUTUREBYFUTUREMANUAL 87
|
||||
#define ONERRRTNREPEALFUTURETOBANKBYFUTUREMANUAL 88
|
||||
#define ONERRRTNQUERYBANKBALANCEBYFUTURE 89
|
||||
#define ONRTNREPEALFROMBANKTOFUTUREBYFUTURE 90
|
||||
#define ONRTNREPEALFROMFUTURETOBANKBYFUTURE 91
|
||||
#define ONRSPFROMBANKTOFUTUREBYFUTURE 92
|
||||
#define ONRSPFROMFUTURETOBANKBYFUTURE 93
|
||||
#define ONRSPQUERYBANKACCOUNTMONEYBYFUTURE 94
|
||||
#define ONRTNOPENACCOUNTBYBANK 95
|
||||
#define ONRTNCANCELACCOUNTBYBANK 96
|
||||
#define ONRTNCHANGEACCOUNTBYBANK 97
|
915
vn.ctp/pyscript/ctp_td_function.cpp
Normal file
915
vn.ctp/pyscript/ctp_td_function.cpp
Normal file
@ -0,0 +1,915 @@
|
||||
int TdApi::reqAuthenticate(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcReqAuthenticateField myreq = CThostFtdcReqAuthenticateField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "UserID", myreq.UserID);
|
||||
getChar(req, "AuthCode", myreq.AuthCode);
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
getChar(req, "UserProductInfo", myreq.UserProductInfo);
|
||||
int i = this->api->ReqAuthenticate(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqUserLogin(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcReqUserLoginField myreq = CThostFtdcReqUserLoginField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "MacAddress", myreq.MacAddress);
|
||||
getChar(req, "UserProductInfo", myreq.UserProductInfo);
|
||||
getChar(req, "UserID", myreq.UserID);
|
||||
getChar(req, "TradingDay", myreq.TradingDay);
|
||||
getChar(req, "InterfaceProductInfo", myreq.InterfaceProductInfo);
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
getChar(req, "ClientIPAddress", myreq.ClientIPAddress);
|
||||
getChar(req, "OneTimePassword", myreq.OneTimePassword);
|
||||
getChar(req, "ProtocolInfo", myreq.ProtocolInfo);
|
||||
getChar(req, "Password", myreq.Password);
|
||||
int i = this->api->ReqUserLogin(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqUserLogout(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcUserLogoutField myreq = CThostFtdcUserLogoutField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "UserID", myreq.UserID);
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
int i = this->api->ReqUserLogout(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqUserPasswordUpdate(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcUserPasswordUpdateField myreq = CThostFtdcUserPasswordUpdateField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "UserID", myreq.UserID);
|
||||
getChar(req, "NewPassword", myreq.NewPassword);
|
||||
getChar(req, "OldPassword", myreq.OldPassword);
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
int i = this->api->ReqUserPasswordUpdate(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqTradingAccountPasswordUpdate(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcTradingAccountPasswordUpdateField myreq = CThostFtdcTradingAccountPasswordUpdateField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "CurrencyID", myreq.CurrencyID);
|
||||
getChar(req, "NewPassword", myreq.NewPassword);
|
||||
getChar(req, "OldPassword", myreq.OldPassword);
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
getChar(req, "AccountID", myreq.AccountID);
|
||||
int i = this->api->ReqTradingAccountPasswordUpdate(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqOrderInsert(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcInputOrderField myreq = CThostFtdcInputOrderField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "ContingentCondition", myreq.ContingentCondition);
|
||||
getChar(req, "CombOffsetFlag", myreq.CombOffsetFlag);
|
||||
getChar(req, "UserID", myreq.UserID);
|
||||
getChar(req, "UserID", myreq.UserID);
|
||||
getInt(req, "UserForceClose", &myreq.UserForceClose);
|
||||
getChar(req, "Direction", myreq.Direction);
|
||||
getInt(req, "IsSwapOrder", &myreq.IsSwapOrder);
|
||||
getInt(req, "VolumeTotalOriginal", &myreq.VolumeTotalOriginal);
|
||||
getChar(req, "OrderPriceType", myreq.OrderPriceType);
|
||||
getChar(req, "TimeCondition", myreq.TimeCondition);
|
||||
getInt(req, "IsAutoSuspend", &myreq.IsAutoSuspend);
|
||||
getInt(req, "IsAutoSuspend", &myreq.IsAutoSuspend);
|
||||
getChar(req, "InstrumentID", myreq.InstrumentID);
|
||||
getInt(req, "MinVolume", &myreq.MinVolume);
|
||||
getChar(req, "ForceCloseReason", myreq.ForceCloseReason);
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
getChar(req, "CombHedgeFlag", myreq.CombHedgeFlag);
|
||||
getChar(req, "GTDDate", myreq.GTDDate);
|
||||
getChar(req, "BusinessUnit", myreq.BusinessUnit);
|
||||
getChar(req, "OrderRef", myreq.OrderRef);
|
||||
getChar(req, "InvestorID", myreq.InvestorID);
|
||||
getChar(req, "VolumeCondition", myreq.VolumeCondition);
|
||||
getInt(req, "RequestID", &myreq.RequestID);
|
||||
int i = this->api->ReqOrderInsert(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqParkedOrderInsert(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcParkedOrderField myreq = CThostFtdcParkedOrderField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "ContingentCondition", myreq.ContingentCondition);
|
||||
getChar(req, "CombOffsetFlag", myreq.CombOffsetFlag);
|
||||
getChar(req, "UserID", myreq.UserID);
|
||||
getChar(req, "UserID", myreq.UserID);
|
||||
getInt(req, "UserForceClose", &myreq.UserForceClose);
|
||||
getChar(req, "Status", myreq.Status);
|
||||
getChar(req, "Direction", myreq.Direction);
|
||||
getInt(req, "IsSwapOrder", &myreq.IsSwapOrder);
|
||||
getChar(req, "UserType", myreq.UserType);
|
||||
getInt(req, "VolumeTotalOriginal", &myreq.VolumeTotalOriginal);
|
||||
getChar(req, "OrderPriceType", myreq.OrderPriceType);
|
||||
getChar(req, "TimeCondition", myreq.TimeCondition);
|
||||
getInt(req, "IsAutoSuspend", &myreq.IsAutoSuspend);
|
||||
getInt(req, "IsAutoSuspend", &myreq.IsAutoSuspend);
|
||||
getChar(req, "InstrumentID", myreq.InstrumentID);
|
||||
getChar(req, "ExchangeID", myreq.ExchangeID);
|
||||
getInt(req, "MinVolume", &myreq.MinVolume);
|
||||
getChar(req, "ForceCloseReason", myreq.ForceCloseReason);
|
||||
getInt(req, "ErrorID", &myreq.ErrorID);
|
||||
getChar(req, "ParkedOrderID", myreq.ParkedOrderID);
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
getChar(req, "CombHedgeFlag", myreq.CombHedgeFlag);
|
||||
getChar(req, "GTDDate", myreq.GTDDate);
|
||||
getChar(req, "BusinessUnit", myreq.BusinessUnit);
|
||||
getChar(req, "ErrorMsg", myreq.ErrorMsg);
|
||||
getChar(req, "OrderRef", myreq.OrderRef);
|
||||
getChar(req, "InvestorID", myreq.InvestorID);
|
||||
getChar(req, "VolumeCondition", myreq.VolumeCondition);
|
||||
getInt(req, "RequestID", &myreq.RequestID);
|
||||
int i = this->api->ReqParkedOrderInsert(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqParkedOrderAction(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcParkedOrderActionField myreq = CThostFtdcParkedOrderActionField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "InstrumentID", myreq.InstrumentID);
|
||||
getChar(req, "Status", myreq.Status);
|
||||
getChar(req, "ExchangeID", myreq.ExchangeID);
|
||||
getChar(req, "ActionFlag", myreq.ActionFlag);
|
||||
getInt(req, "OrderActionRef", &myreq.OrderActionRef);
|
||||
getChar(req, "UserType", myreq.UserType);
|
||||
getChar(req, "ErrorMsg", myreq.ErrorMsg);
|
||||
getChar(req, "UserID", myreq.UserID);
|
||||
getChar(req, "UserID", myreq.UserID);
|
||||
getChar(req, "OrderRef", myreq.OrderRef);
|
||||
getChar(req, "InvestorID", myreq.InvestorID);
|
||||
getInt(req, "SessionID", &myreq.SessionID);
|
||||
getInt(req, "VolumeChange", &myreq.VolumeChange);
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
getInt(req, "RequestID", &myreq.RequestID);
|
||||
getChar(req, "OrderSysID", myreq.OrderSysID);
|
||||
getChar(req, "ParkedOrderActionID", myreq.ParkedOrderActionID);
|
||||
getInt(req, "FrontID", &myreq.FrontID);
|
||||
getInt(req, "ErrorID", &myreq.ErrorID);
|
||||
int i = this->api->ReqParkedOrderAction(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqOrderAction(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcInputOrderActionField myreq = CThostFtdcInputOrderActionField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "InstrumentID", myreq.InstrumentID);
|
||||
getChar(req, "ExchangeID", myreq.ExchangeID);
|
||||
getChar(req, "ActionFlag", myreq.ActionFlag);
|
||||
getInt(req, "OrderActionRef", &myreq.OrderActionRef);
|
||||
getChar(req, "UserID", myreq.UserID);
|
||||
getChar(req, "UserID", myreq.UserID);
|
||||
getChar(req, "OrderRef", myreq.OrderRef);
|
||||
getChar(req, "InvestorID", myreq.InvestorID);
|
||||
getInt(req, "SessionID", &myreq.SessionID);
|
||||
getInt(req, "VolumeChange", &myreq.VolumeChange);
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
getInt(req, "RequestID", &myreq.RequestID);
|
||||
getChar(req, "OrderSysID", myreq.OrderSysID);
|
||||
getInt(req, "FrontID", &myreq.FrontID);
|
||||
int i = this->api->ReqOrderAction(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqQueryMaxOrderVolume(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcQueryMaxOrderVolumeField myreq = CThostFtdcQueryMaxOrderVolumeField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "InstrumentID", myreq.InstrumentID);
|
||||
getChar(req, "Direction", myreq.Direction);
|
||||
getChar(req, "OffsetFlag", myreq.OffsetFlag);
|
||||
getChar(req, "HedgeFlag", myreq.HedgeFlag);
|
||||
getChar(req, "InvestorID", myreq.InvestorID);
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
getInt(req, "MaxVolume", &myreq.MaxVolume);
|
||||
int i = this->api->ReqQueryMaxOrderVolume(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqSettlementInfoConfirm(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcSettlementInfoConfirmField myreq = CThostFtdcSettlementInfoConfirmField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "ConfirmTime", myreq.ConfirmTime);
|
||||
getChar(req, "InvestorID", myreq.InvestorID);
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
getChar(req, "ConfirmDate", myreq.ConfirmDate);
|
||||
int i = this->api->ReqSettlementInfoConfirm(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqRemoveParkedOrder(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcRemoveParkedOrderField myreq = CThostFtdcRemoveParkedOrderField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "InvestorID", myreq.InvestorID);
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
getChar(req, "ParkedOrderID", myreq.ParkedOrderID);
|
||||
int i = this->api->ReqRemoveParkedOrder(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqRemoveParkedOrderAction(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcRemoveParkedOrderActionField myreq = CThostFtdcRemoveParkedOrderActionField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "InvestorID", myreq.InvestorID);
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
getChar(req, "ParkedOrderActionID", myreq.ParkedOrderActionID);
|
||||
int i = this->api->ReqRemoveParkedOrderAction(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqExecOrderInsert(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcInputExecOrderField myreq = CThostFtdcInputExecOrderField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "InstrumentID", myreq.InstrumentID);
|
||||
getChar(req, "ExecOrderRef", myreq.ExecOrderRef);
|
||||
getChar(req, "CloseFlag", myreq.CloseFlag);
|
||||
getChar(req, "OffsetFlag", myreq.OffsetFlag);
|
||||
getChar(req, "PosiDirection", myreq.PosiDirection);
|
||||
getChar(req, "BusinessUnit", myreq.BusinessUnit);
|
||||
getChar(req, "HedgeFlag", myreq.HedgeFlag);
|
||||
getChar(req, "UserID", myreq.UserID);
|
||||
getInt(req, "Volume", &myreq.Volume);
|
||||
getChar(req, "InvestorID", myreq.InvestorID);
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
getInt(req, "RequestID", &myreq.RequestID);
|
||||
getChar(req, "ActionType", myreq.ActionType);
|
||||
getChar(req, "ReservePositionFlag", myreq.ReservePositionFlag);
|
||||
int i = this->api->ReqExecOrderInsert(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqExecOrderAction(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcInputExecOrderActionField myreq = CThostFtdcInputExecOrderActionField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "InstrumentID", myreq.InstrumentID);
|
||||
getChar(req, "ExecOrderSysID", myreq.ExecOrderSysID);
|
||||
getChar(req, "ExchangeID", myreq.ExchangeID);
|
||||
getChar(req, "UserID", myreq.UserID);
|
||||
getChar(req, "ExecOrderRef", myreq.ExecOrderRef);
|
||||
getChar(req, "InvestorID", myreq.InvestorID);
|
||||
getInt(req, "SessionID", &myreq.SessionID);
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
getInt(req, "RequestID", &myreq.RequestID);
|
||||
getChar(req, "ActionFlag", myreq.ActionFlag);
|
||||
getInt(req, "ExecOrderActionRef", &myreq.ExecOrderActionRef);
|
||||
getInt(req, "FrontID", &myreq.FrontID);
|
||||
int i = this->api->ReqExecOrderAction(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqForQuoteInsert(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcInputForQuoteField myreq = CThostFtdcInputForQuoteField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "InstrumentID", myreq.InstrumentID);
|
||||
getChar(req, "InvestorID", myreq.InvestorID);
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
getChar(req, "UserID", myreq.UserID);
|
||||
getChar(req, "ForQuoteRef", myreq.ForQuoteRef);
|
||||
int i = this->api->ReqForQuoteInsert(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqQuoteInsert(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcInputQuoteField myreq = CThostFtdcInputQuoteField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "InstrumentID", myreq.InstrumentID);
|
||||
getChar(req, "AskHedgeFlag", myreq.AskHedgeFlag);
|
||||
getChar(req, "BusinessUnit", myreq.BusinessUnit);
|
||||
getChar(req, "BusinessUnit", myreq.BusinessUnit);
|
||||
getChar(req, "UserID", myreq.UserID);
|
||||
getChar(req, "AskOffsetFlag", myreq.AskOffsetFlag);
|
||||
getInt(req, "BidVolume", &myreq.BidVolume);
|
||||
getInt(req, "AskVolume", &myreq.AskVolume);
|
||||
getChar(req, "InvestorID", myreq.InvestorID);
|
||||
getChar(req, "BidOffsetFlag", myreq.BidOffsetFlag);
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
getInt(req, "RequestID", &myreq.RequestID);
|
||||
getInt(req, "RequestID", &myreq.RequestID);
|
||||
getChar(req, "BidHedgeFlag", myreq.BidHedgeFlag);
|
||||
getChar(req, "QuoteRef", myreq.QuoteRef);
|
||||
int i = this->api->ReqQuoteInsert(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqQuoteAction(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcInputQuoteActionField myreq = CThostFtdcInputQuoteActionField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "InstrumentID", myreq.InstrumentID);
|
||||
getChar(req, "ExchangeID", myreq.ExchangeID);
|
||||
getInt(req, "QuoteActionRef", &myreq.QuoteActionRef);
|
||||
getChar(req, "UserID", myreq.UserID);
|
||||
getChar(req, "InvestorID", myreq.InvestorID);
|
||||
getInt(req, "SessionID", &myreq.SessionID);
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
getInt(req, "RequestID", &myreq.RequestID);
|
||||
getChar(req, "ActionFlag", myreq.ActionFlag);
|
||||
getInt(req, "FrontID", &myreq.FrontID);
|
||||
getChar(req, "QuoteSysID", myreq.QuoteSysID);
|
||||
getChar(req, "QuoteRef", myreq.QuoteRef);
|
||||
int i = this->api->ReqQuoteAction(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqQryOrder(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcQryOrderField myreq = CThostFtdcQryOrderField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "InstrumentID", myreq.InstrumentID);
|
||||
getChar(req, "ExchangeID", myreq.ExchangeID);
|
||||
getChar(req, "InsertTimeStart", myreq.InsertTimeStart);
|
||||
getChar(req, "InvestorID", myreq.InvestorID);
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
getChar(req, "OrderSysID", myreq.OrderSysID);
|
||||
getChar(req, "InsertTimeEnd", myreq.InsertTimeEnd);
|
||||
int i = this->api->ReqQryOrder(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqQryTrade(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcQryTradeField myreq = CThostFtdcQryTradeField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "InstrumentID", myreq.InstrumentID);
|
||||
getChar(req, "TradeTimeStart", myreq.TradeTimeStart);
|
||||
getChar(req, "ExchangeID", myreq.ExchangeID);
|
||||
getChar(req, "TradeID", myreq.TradeID);
|
||||
getChar(req, "InvestorID", myreq.InvestorID);
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
getChar(req, "TradeTimeEnd", myreq.TradeTimeEnd);
|
||||
int i = this->api->ReqQryTrade(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqQryInvestorPosition(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcQryInvestorPositionField myreq = CThostFtdcQryInvestorPositionField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "InstrumentID", myreq.InstrumentID);
|
||||
getChar(req, "InvestorID", myreq.InvestorID);
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
int i = this->api->ReqQryInvestorPosition(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqQryTradingAccount(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcQryTradingAccountField myreq = CThostFtdcQryTradingAccountField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "CurrencyID", myreq.CurrencyID);
|
||||
getChar(req, "InvestorID", myreq.InvestorID);
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
int i = this->api->ReqQryTradingAccount(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqQryInvestor(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcQryInvestorField myreq = CThostFtdcQryInvestorField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "InvestorID", myreq.InvestorID);
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
int i = this->api->ReqQryInvestor(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqQryTradingCode(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcQryTradingCodeField myreq = CThostFtdcQryTradingCodeField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "InvestorID", myreq.InvestorID);
|
||||
getChar(req, "ExchangeID", myreq.ExchangeID);
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
getChar(req, "ClientIDType", myreq.ClientIDType);
|
||||
getChar(req, "ClientID", myreq.ClientID);
|
||||
int i = this->api->ReqQryTradingCode(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqQryInstrumentMarginRate(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcQryInstrumentMarginRateField myreq = CThostFtdcQryInstrumentMarginRateField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "InstrumentID", myreq.InstrumentID);
|
||||
getChar(req, "InvestorID", myreq.InvestorID);
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
getChar(req, "HedgeFlag", myreq.HedgeFlag);
|
||||
int i = this->api->ReqQryInstrumentMarginRate(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqQryInstrumentCommissionRate(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcQryInstrumentCommissionRateField myreq = CThostFtdcQryInstrumentCommissionRateField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "InstrumentID", myreq.InstrumentID);
|
||||
getChar(req, "InvestorID", myreq.InvestorID);
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
int i = this->api->ReqQryInstrumentCommissionRate(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqQryExchange(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcQryExchangeField myreq = CThostFtdcQryExchangeField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "ExchangeID", myreq.ExchangeID);
|
||||
int i = this->api->ReqQryExchange(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqQryProduct(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcQryProductField myreq = CThostFtdcQryProductField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "ProductClass", myreq.ProductClass);
|
||||
getChar(req, "ProductID", myreq.ProductID);
|
||||
int i = this->api->ReqQryProduct(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqQryInstrument(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcQryInstrumentField myreq = CThostFtdcQryInstrumentField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "InstrumentID", myreq.InstrumentID);
|
||||
getChar(req, "ExchangeID", myreq.ExchangeID);
|
||||
getChar(req, "ExchangeInstID", myreq.ExchangeInstID);
|
||||
getChar(req, "ProductID", myreq.ProductID);
|
||||
int i = this->api->ReqQryInstrument(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqQryDepthMarketData(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcQryDepthMarketDataField myreq = CThostFtdcQryDepthMarketDataField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "InstrumentID", myreq.InstrumentID);
|
||||
int i = this->api->ReqQryDepthMarketData(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqQrySettlementInfo(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcQrySettlementInfoField myreq = CThostFtdcQrySettlementInfoField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "InvestorID", myreq.InvestorID);
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
getChar(req, "TradingDay", myreq.TradingDay);
|
||||
int i = this->api->ReqQrySettlementInfo(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqQryTransferBank(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcQryTransferBankField myreq = CThostFtdcQryTransferBankField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "BankBrchID", myreq.BankBrchID);
|
||||
getChar(req, "BankID", myreq.BankID);
|
||||
int i = this->api->ReqQryTransferBank(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqQryInvestorPositionDetail(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcQryInvestorPositionDetailField myreq = CThostFtdcQryInvestorPositionDetailField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "InstrumentID", myreq.InstrumentID);
|
||||
getChar(req, "InvestorID", myreq.InvestorID);
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
int i = this->api->ReqQryInvestorPositionDetail(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqQryNotice(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcQryNoticeField myreq = CThostFtdcQryNoticeField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
int i = this->api->ReqQryNotice(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqQrySettlementInfoConfirm(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcQrySettlementInfoConfirmField myreq = CThostFtdcQrySettlementInfoConfirmField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "InvestorID", myreq.InvestorID);
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
int i = this->api->ReqQrySettlementInfoConfirm(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqQryInvestorPositionCombineDetail(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcQryInvestorPositionCombineDetailField myreq = CThostFtdcQryInvestorPositionCombineDetailField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "InvestorID", myreq.InvestorID);
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
getChar(req, "CombInstrumentID", myreq.CombInstrumentID);
|
||||
int i = this->api->ReqQryInvestorPositionCombineDetail(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqQryCFMMCTradingAccountKey(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcQryCFMMCTradingAccountKeyField myreq = CThostFtdcQryCFMMCTradingAccountKeyField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "InvestorID", myreq.InvestorID);
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
int i = this->api->ReqQryCFMMCTradingAccountKey(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqQryEWarrantOffset(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcQryEWarrantOffsetField myreq = CThostFtdcQryEWarrantOffsetField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "InstrumentID", myreq.InstrumentID);
|
||||
getChar(req, "InvestorID", myreq.InvestorID);
|
||||
getChar(req, "ExchangeID", myreq.ExchangeID);
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
int i = this->api->ReqQryEWarrantOffset(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqQryInvestorProductGroupMargin(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcQryInvestorProductGroupMarginField myreq = CThostFtdcQryInvestorProductGroupMarginField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "InvestorID", myreq.InvestorID);
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
getChar(req, "HedgeFlag", myreq.HedgeFlag);
|
||||
getChar(req, "ProductGroupID", myreq.ProductGroupID);
|
||||
int i = this->api->ReqQryInvestorProductGroupMargin(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqQryExchangeMarginRate(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcQryExchangeMarginRateField myreq = CThostFtdcQryExchangeMarginRateField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "InstrumentID", myreq.InstrumentID);
|
||||
getChar(req, "HedgeFlag", myreq.HedgeFlag);
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
int i = this->api->ReqQryExchangeMarginRate(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqQryExchangeMarginRateAdjust(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcQryExchangeMarginRateAdjustField myreq = CThostFtdcQryExchangeMarginRateAdjustField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "InstrumentID", myreq.InstrumentID);
|
||||
getChar(req, "HedgeFlag", myreq.HedgeFlag);
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
int i = this->api->ReqQryExchangeMarginRateAdjust(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqQryExchangeRate(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcQryExchangeRateField myreq = CThostFtdcQryExchangeRateField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "FromCurrencyID", myreq.FromCurrencyID);
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
getChar(req, "ToCurrencyID", myreq.ToCurrencyID);
|
||||
int i = this->api->ReqQryExchangeRate(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqQrySecAgentACIDMap(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcQrySecAgentACIDMapField myreq = CThostFtdcQrySecAgentACIDMapField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "CurrencyID", myreq.CurrencyID);
|
||||
getChar(req, "UserID", myreq.UserID);
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
getChar(req, "AccountID", myreq.AccountID);
|
||||
int i = this->api->ReqQrySecAgentACIDMap(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqQryOptionInstrTradeCost(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcQryOptionInstrTradeCostField myreq = CThostFtdcQryOptionInstrTradeCostField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "InstrumentID", myreq.InstrumentID);
|
||||
getChar(req, "InstrumentID", myreq.InstrumentID);
|
||||
getChar(req, "InstrumentID", myreq.InstrumentID);
|
||||
getChar(req, "HedgeFlag", myreq.HedgeFlag);
|
||||
getChar(req, "InvestorID", myreq.InvestorID);
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
int i = this->api->ReqQryOptionInstrTradeCost(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqQryOptionInstrCommRate(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcQryOptionInstrCommRateField myreq = CThostFtdcQryOptionInstrCommRateField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "InstrumentID", myreq.InstrumentID);
|
||||
getChar(req, "InvestorID", myreq.InvestorID);
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
int i = this->api->ReqQryOptionInstrCommRate(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqQryExecOrder(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcQryExecOrderField myreq = CThostFtdcQryExecOrderField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "InstrumentID", myreq.InstrumentID);
|
||||
getChar(req, "ExecOrderSysID", myreq.ExecOrderSysID);
|
||||
getChar(req, "ExchangeID", myreq.ExchangeID);
|
||||
getChar(req, "InsertTimeStart", myreq.InsertTimeStart);
|
||||
getChar(req, "InvestorID", myreq.InvestorID);
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
getChar(req, "InsertTimeEnd", myreq.InsertTimeEnd);
|
||||
int i = this->api->ReqQryExecOrder(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqQryForQuote(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcQryForQuoteField myreq = CThostFtdcQryForQuoteField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "InstrumentID", myreq.InstrumentID);
|
||||
getChar(req, "ExchangeID", myreq.ExchangeID);
|
||||
getChar(req, "InsertTimeStart", myreq.InsertTimeStart);
|
||||
getChar(req, "InvestorID", myreq.InvestorID);
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
getChar(req, "InsertTimeEnd", myreq.InsertTimeEnd);
|
||||
int i = this->api->ReqQryForQuote(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqQryQuote(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcQryQuoteField myreq = CThostFtdcQryQuoteField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "InstrumentID", myreq.InstrumentID);
|
||||
getChar(req, "ExchangeID", myreq.ExchangeID);
|
||||
getChar(req, "InsertTimeStart", myreq.InsertTimeStart);
|
||||
getChar(req, "InvestorID", myreq.InvestorID);
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
getChar(req, "QuoteSysID", myreq.QuoteSysID);
|
||||
getChar(req, "InsertTimeEnd", myreq.InsertTimeEnd);
|
||||
int i = this->api->ReqQryQuote(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqQryTransferSerial(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcQryTransferSerialField myreq = CThostFtdcQryTransferSerialField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "CurrencyID", myreq.CurrencyID);
|
||||
getChar(req, "BankID", myreq.BankID);
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
getChar(req, "AccountID", myreq.AccountID);
|
||||
int i = this->api->ReqQryTransferSerial(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqQryAccountregister(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcQryAccountregisterField myreq = CThostFtdcQryAccountregisterField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "CurrencyID", myreq.CurrencyID);
|
||||
getChar(req, "BankID", myreq.BankID);
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
getChar(req, "BankBranchID", myreq.BankBranchID);
|
||||
getChar(req, "AccountID", myreq.AccountID);
|
||||
int i = this->api->ReqQryAccountregister(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqQryContractBank(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcQryContractBankField myreq = CThostFtdcQryContractBankField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
getChar(req, "BankBrchID", myreq.BankBrchID);
|
||||
getChar(req, "BankID", myreq.BankID);
|
||||
int i = this->api->ReqQryContractBank(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqQryParkedOrder(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcQryParkedOrderField myreq = CThostFtdcQryParkedOrderField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "InstrumentID", myreq.InstrumentID);
|
||||
getChar(req, "InvestorID", myreq.InvestorID);
|
||||
getChar(req, "ExchangeID", myreq.ExchangeID);
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
int i = this->api->ReqQryParkedOrder(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqQryParkedOrderAction(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcQryParkedOrderActionField myreq = CThostFtdcQryParkedOrderActionField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "InstrumentID", myreq.InstrumentID);
|
||||
getChar(req, "InvestorID", myreq.InvestorID);
|
||||
getChar(req, "ExchangeID", myreq.ExchangeID);
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
int i = this->api->ReqQryParkedOrderAction(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqQryTradingNotice(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcQryTradingNoticeField myreq = CThostFtdcQryTradingNoticeField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "InvestorID", myreq.InvestorID);
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
int i = this->api->ReqQryTradingNotice(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqQryBrokerTradingParams(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcQryBrokerTradingParamsField myreq = CThostFtdcQryBrokerTradingParamsField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "CurrencyID", myreq.CurrencyID);
|
||||
getChar(req, "InvestorID", myreq.InvestorID);
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
int i = this->api->ReqQryBrokerTradingParams(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqQryBrokerTradingAlgos(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcQryBrokerTradingAlgosField myreq = CThostFtdcQryBrokerTradingAlgosField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "InstrumentID", myreq.InstrumentID);
|
||||
getChar(req, "ExchangeID", myreq.ExchangeID);
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
int i = this->api->ReqQryBrokerTradingAlgos(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqFromBankToFutureByFuture(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcReqTransferField myreq = CThostFtdcReqTransferField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "BrokerBranchID", myreq.BrokerBranchID);
|
||||
getChar(req, "UserID", myreq.UserID);
|
||||
getChar(req, "BankPassWord", myreq.BankPassWord);
|
||||
getChar(req, "TradeTime", myreq.TradeTime);
|
||||
getChar(req, "VerifyCertNoFlag", myreq.VerifyCertNoFlag);
|
||||
getInt(req, "TID", &myreq.TID);
|
||||
getChar(req, "AccountID", myreq.AccountID);
|
||||
getChar(req, "BankAccount", myreq.BankAccount);
|
||||
getInt(req, "InstallID", &myreq.InstallID);
|
||||
getChar(req, "CustomerName", myreq.CustomerName);
|
||||
getChar(req, "TradeCode", myreq.TradeCode);
|
||||
getChar(req, "BankBranchID", myreq.BankBranchID);
|
||||
getInt(req, "SessionID", &myreq.SessionID);
|
||||
getChar(req, "BankID", myreq.BankID);
|
||||
getChar(req, "Password", myreq.Password);
|
||||
getChar(req, "BankPwdFlag", myreq.BankPwdFlag);
|
||||
getInt(req, "RequestID", &myreq.RequestID);
|
||||
getChar(req, "CustType", myreq.CustType);
|
||||
getChar(req, "IdentifiedCardNo", myreq.IdentifiedCardNo);
|
||||
getChar(req, "FeePayFlag", myreq.FeePayFlag);
|
||||
getChar(req, "BankSerial", myreq.BankSerial);
|
||||
getChar(req, "OperNo", myreq.OperNo);
|
||||
getChar(req, "TradingDay", myreq.TradingDay);
|
||||
getChar(req, "BankSecuAcc", myreq.BankSecuAcc);
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
getChar(req, "DeviceID", myreq.DeviceID);
|
||||
getChar(req, "TransferStatus", myreq.TransferStatus);
|
||||
getChar(req, "IdCardType", myreq.IdCardType);
|
||||
getInt(req, "PlateSerial", &myreq.PlateSerial);
|
||||
getInt(req, "PlateSerial", &myreq.PlateSerial);
|
||||
getChar(req, "TradeDate", myreq.TradeDate);
|
||||
getChar(req, "CurrencyID", myreq.CurrencyID);
|
||||
getChar(req, "CurrencyID", myreq.CurrencyID);
|
||||
getChar(req, "BankAccType", myreq.BankAccType);
|
||||
getChar(req, "LastFragment", myreq.LastFragment);
|
||||
getInt(req, "FutureSerial", &myreq.FutureSerial);
|
||||
getChar(req, "BankSecuAccType", myreq.BankSecuAccType);
|
||||
getChar(req, "BrokerIDByBank", myreq.BrokerIDByBank);
|
||||
getChar(req, "SecuPwdFlag", myreq.SecuPwdFlag);
|
||||
getChar(req, "Message", myreq.Message);
|
||||
getChar(req, "Message", myreq.Message);
|
||||
getChar(req, "Message", myreq.Message);
|
||||
getChar(req, "Digest", myreq.Digest);
|
||||
int i = this->api->ReqFromBankToFutureByFuture(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqFromFutureToBankByFuture(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcReqTransferField myreq = CThostFtdcReqTransferField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "BrokerBranchID", myreq.BrokerBranchID);
|
||||
getChar(req, "UserID", myreq.UserID);
|
||||
getChar(req, "BankPassWord", myreq.BankPassWord);
|
||||
getChar(req, "TradeTime", myreq.TradeTime);
|
||||
getChar(req, "VerifyCertNoFlag", myreq.VerifyCertNoFlag);
|
||||
getInt(req, "TID", &myreq.TID);
|
||||
getChar(req, "AccountID", myreq.AccountID);
|
||||
getChar(req, "BankAccount", myreq.BankAccount);
|
||||
getInt(req, "InstallID", &myreq.InstallID);
|
||||
getChar(req, "CustomerName", myreq.CustomerName);
|
||||
getChar(req, "TradeCode", myreq.TradeCode);
|
||||
getChar(req, "BankBranchID", myreq.BankBranchID);
|
||||
getInt(req, "SessionID", &myreq.SessionID);
|
||||
getChar(req, "BankID", myreq.BankID);
|
||||
getChar(req, "Password", myreq.Password);
|
||||
getChar(req, "BankPwdFlag", myreq.BankPwdFlag);
|
||||
getInt(req, "RequestID", &myreq.RequestID);
|
||||
getChar(req, "CustType", myreq.CustType);
|
||||
getChar(req, "IdentifiedCardNo", myreq.IdentifiedCardNo);
|
||||
getChar(req, "FeePayFlag", myreq.FeePayFlag);
|
||||
getChar(req, "BankSerial", myreq.BankSerial);
|
||||
getChar(req, "OperNo", myreq.OperNo);
|
||||
getChar(req, "TradingDay", myreq.TradingDay);
|
||||
getChar(req, "BankSecuAcc", myreq.BankSecuAcc);
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
getChar(req, "DeviceID", myreq.DeviceID);
|
||||
getChar(req, "TransferStatus", myreq.TransferStatus);
|
||||
getChar(req, "IdCardType", myreq.IdCardType);
|
||||
getInt(req, "PlateSerial", &myreq.PlateSerial);
|
||||
getInt(req, "PlateSerial", &myreq.PlateSerial);
|
||||
getChar(req, "TradeDate", myreq.TradeDate);
|
||||
getChar(req, "CurrencyID", myreq.CurrencyID);
|
||||
getChar(req, "CurrencyID", myreq.CurrencyID);
|
||||
getChar(req, "BankAccType", myreq.BankAccType);
|
||||
getChar(req, "LastFragment", myreq.LastFragment);
|
||||
getInt(req, "FutureSerial", &myreq.FutureSerial);
|
||||
getChar(req, "BankSecuAccType", myreq.BankSecuAccType);
|
||||
getChar(req, "BrokerIDByBank", myreq.BrokerIDByBank);
|
||||
getChar(req, "SecuPwdFlag", myreq.SecuPwdFlag);
|
||||
getChar(req, "Message", myreq.Message);
|
||||
getChar(req, "Message", myreq.Message);
|
||||
getChar(req, "Message", myreq.Message);
|
||||
getChar(req, "Digest", myreq.Digest);
|
||||
int i = this->api->ReqFromFutureToBankByFuture(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqQueryBankAccountMoneyByFuture(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcReqQueryAccountField myreq = CThostFtdcReqQueryAccountField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "BrokerBranchID", myreq.BrokerBranchID);
|
||||
getChar(req, "UserID", myreq.UserID);
|
||||
getChar(req, "BankPassWord", myreq.BankPassWord);
|
||||
getChar(req, "TradeTime", myreq.TradeTime);
|
||||
getChar(req, "VerifyCertNoFlag", myreq.VerifyCertNoFlag);
|
||||
getInt(req, "TID", &myreq.TID);
|
||||
getChar(req, "AccountID", myreq.AccountID);
|
||||
getChar(req, "BankAccount", myreq.BankAccount);
|
||||
getInt(req, "InstallID", &myreq.InstallID);
|
||||
getChar(req, "CustomerName", myreq.CustomerName);
|
||||
getChar(req, "TradeCode", myreq.TradeCode);
|
||||
getChar(req, "BankBranchID", myreq.BankBranchID);
|
||||
getInt(req, "SessionID", &myreq.SessionID);
|
||||
getChar(req, "BankID", myreq.BankID);
|
||||
getChar(req, "Password", myreq.Password);
|
||||
getChar(req, "BankPwdFlag", myreq.BankPwdFlag);
|
||||
getInt(req, "RequestID", &myreq.RequestID);
|
||||
getChar(req, "CustType", myreq.CustType);
|
||||
getChar(req, "IdentifiedCardNo", myreq.IdentifiedCardNo);
|
||||
getChar(req, "BankSerial", myreq.BankSerial);
|
||||
getChar(req, "OperNo", myreq.OperNo);
|
||||
getChar(req, "TradingDay", myreq.TradingDay);
|
||||
getChar(req, "BankSecuAcc", myreq.BankSecuAcc);
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
getChar(req, "DeviceID", myreq.DeviceID);
|
||||
getChar(req, "IdCardType", myreq.IdCardType);
|
||||
getInt(req, "PlateSerial", &myreq.PlateSerial);
|
||||
getChar(req, "TradeDate", myreq.TradeDate);
|
||||
getChar(req, "CurrencyID", myreq.CurrencyID);
|
||||
getChar(req, "BankAccType", myreq.BankAccType);
|
||||
getChar(req, "LastFragment", myreq.LastFragment);
|
||||
getInt(req, "FutureSerial", &myreq.FutureSerial);
|
||||
getChar(req, "BankSecuAccType", myreq.BankSecuAccType);
|
||||
getChar(req, "BrokerIDByBank", myreq.BrokerIDByBank);
|
||||
getChar(req, "SecuPwdFlag", myreq.SecuPwdFlag);
|
||||
getChar(req, "Digest", myreq.Digest);
|
||||
int i = this->api->ReqQueryBankAccountMoneyByFuture(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
118
vn.ctp/pyscript/ctp_td_header_function.h
Normal file
118
vn.ctp/pyscript/ctp_td_header_function.h
Normal file
@ -0,0 +1,118 @@
|
||||
int reqAuthenticate(dict req, int nRequestID);
|
||||
|
||||
int reqUserLogin(dict req, int nRequestID);
|
||||
|
||||
int reqUserLogout(dict req, int nRequestID);
|
||||
|
||||
int reqUserPasswordUpdate(dict req, int nRequestID);
|
||||
|
||||
int reqTradingAccountPasswordUpdate(dict req, int nRequestID);
|
||||
|
||||
int reqOrderInsert(dict req, int nRequestID);
|
||||
|
||||
int reqParkedOrderInsert(dict req, int nRequestID);
|
||||
|
||||
int reqParkedOrderAction(dict req, int nRequestID);
|
||||
|
||||
int reqOrderAction(dict req, int nRequestID);
|
||||
|
||||
int reqQueryMaxOrderVolume(dict req, int nRequestID);
|
||||
|
||||
int reqSettlementInfoConfirm(dict req, int nRequestID);
|
||||
|
||||
int reqRemoveParkedOrder(dict req, int nRequestID);
|
||||
|
||||
int reqRemoveParkedOrderAction(dict req, int nRequestID);
|
||||
|
||||
int reqExecOrderInsert(dict req, int nRequestID);
|
||||
|
||||
int reqExecOrderAction(dict req, int nRequestID);
|
||||
|
||||
int reqForQuoteInsert(dict req, int nRequestID);
|
||||
|
||||
int reqQuoteInsert(dict req, int nRequestID);
|
||||
|
||||
int reqQuoteAction(dict req, int nRequestID);
|
||||
|
||||
int reqQryOrder(dict req, int nRequestID);
|
||||
|
||||
int reqQryTrade(dict req, int nRequestID);
|
||||
|
||||
int reqQryInvestorPosition(dict req, int nRequestID);
|
||||
|
||||
int reqQryTradingAccount(dict req, int nRequestID);
|
||||
|
||||
int reqQryInvestor(dict req, int nRequestID);
|
||||
|
||||
int reqQryTradingCode(dict req, int nRequestID);
|
||||
|
||||
int reqQryInstrumentMarginRate(dict req, int nRequestID);
|
||||
|
||||
int reqQryInstrumentCommissionRate(dict req, int nRequestID);
|
||||
|
||||
int reqQryExchange(dict req, int nRequestID);
|
||||
|
||||
int reqQryProduct(dict req, int nRequestID);
|
||||
|
||||
int reqQryInstrument(dict req, int nRequestID);
|
||||
|
||||
int reqQryDepthMarketData(dict req, int nRequestID);
|
||||
|
||||
int reqQrySettlementInfo(dict req, int nRequestID);
|
||||
|
||||
int reqQryTransferBank(dict req, int nRequestID);
|
||||
|
||||
int reqQryInvestorPositionDetail(dict req, int nRequestID);
|
||||
|
||||
int reqQryNotice(dict req, int nRequestID);
|
||||
|
||||
int reqQrySettlementInfoConfirm(dict req, int nRequestID);
|
||||
|
||||
int reqQryInvestorPositionCombineDetail(dict req, int nRequestID);
|
||||
|
||||
int reqQryCFMMCTradingAccountKey(dict req, int nRequestID);
|
||||
|
||||
int reqQryEWarrantOffset(dict req, int nRequestID);
|
||||
|
||||
int reqQryInvestorProductGroupMargin(dict req, int nRequestID);
|
||||
|
||||
int reqQryExchangeMarginRate(dict req, int nRequestID);
|
||||
|
||||
int reqQryExchangeMarginRateAdjust(dict req, int nRequestID);
|
||||
|
||||
int reqQryExchangeRate(dict req, int nRequestID);
|
||||
|
||||
int reqQrySecAgentACIDMap(dict req, int nRequestID);
|
||||
|
||||
int reqQryOptionInstrTradeCost(dict req, int nRequestID);
|
||||
|
||||
int reqQryOptionInstrCommRate(dict req, int nRequestID);
|
||||
|
||||
int reqQryExecOrder(dict req, int nRequestID);
|
||||
|
||||
int reqQryForQuote(dict req, int nRequestID);
|
||||
|
||||
int reqQryQuote(dict req, int nRequestID);
|
||||
|
||||
int reqQryTransferSerial(dict req, int nRequestID);
|
||||
|
||||
int reqQryAccountregister(dict req, int nRequestID);
|
||||
|
||||
int reqQryContractBank(dict req, int nRequestID);
|
||||
|
||||
int reqQryParkedOrder(dict req, int nRequestID);
|
||||
|
||||
int reqQryParkedOrderAction(dict req, int nRequestID);
|
||||
|
||||
int reqQryTradingNotice(dict req, int nRequestID);
|
||||
|
||||
int reqQryBrokerTradingParams(dict req, int nRequestID);
|
||||
|
||||
int reqQryBrokerTradingAlgos(dict req, int nRequestID);
|
||||
|
||||
int reqFromBankToFutureByFuture(dict req, int nRequestID);
|
||||
|
||||
int reqFromFutureToBankByFuture(dict req, int nRequestID);
|
||||
|
||||
int reqQueryBankAccountMoneyByFuture(dict req, int nRequestID);
|
||||
|
191
vn.ctp/pyscript/ctp_td_header_on.h
Normal file
191
vn.ctp/pyscript/ctp_td_header_on.h
Normal file
@ -0,0 +1,191 @@
|
||||
|
||||
|
||||
|
||||
virtual void onRspAuthenticate(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspUserLogin(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspUserLogout(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspUserPasswordUpdate(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspTradingAccountPasswordUpdate(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspOrderInsert(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspParkedOrderInsert(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspParkedOrderAction(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspOrderAction(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspQueryMaxOrderVolume(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspSettlementInfoConfirm(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspRemoveParkedOrder(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspRemoveParkedOrderAction(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspExecOrderInsert(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspExecOrderAction(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspForQuoteInsert(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspQuoteInsert(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspQuoteAction(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspQryOrder(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspQryTrade(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspQryInvestorPosition(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspQryTradingAccount(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspQryInvestor(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspQryTradingCode(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspQryInstrumentMarginRate(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspQryInstrumentCommissionRate(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspQryExchange(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspQryProduct(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspQryInstrument(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspQryDepthMarketData(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspQrySettlementInfo(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspQryTransferBank(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspQryInvestorPositionDetail(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspQryNotice(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspQrySettlementInfoConfirm(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspQryInvestorPositionCombineDetail(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspQryCFMMCTradingAccountKey(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspQryEWarrantOffset(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspQryInvestorProductGroupMargin(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspQryExchangeMarginRate(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspQryExchangeMarginRateAdjust(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspQryExchangeRate(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspQrySecAgentACIDMap(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspQryOptionInstrTradeCost(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspQryOptionInstrCommRate(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspQryExecOrder(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspQryForQuote(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspQryQuote(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspQryTransferSerial(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspQryAccountregister(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspError(dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRtnOrder(dict data) {};
|
||||
|
||||
virtual void onRtnTrade(dict data) {};
|
||||
|
||||
virtual void onErrRtnOrderInsert(dict data, dict error) {};
|
||||
|
||||
virtual void onErrRtnOrderAction(dict data, dict error) {};
|
||||
|
||||
virtual void onRtnInstrumentStatus(dict data) {};
|
||||
|
||||
virtual void onRtnTradingNotice(dict data) {};
|
||||
|
||||
virtual void onRtnErrorConditionalOrder(dict data) {};
|
||||
|
||||
virtual void onRtnExecOrder(dict data) {};
|
||||
|
||||
virtual void onErrRtnExecOrderInsert(dict data, dict error) {};
|
||||
|
||||
virtual void onErrRtnExecOrderAction(dict data, dict error) {};
|
||||
|
||||
virtual void onErrRtnForQuoteInsert(dict data, dict error) {};
|
||||
|
||||
virtual void onRtnQuote(dict data) {};
|
||||
|
||||
virtual void onErrRtnQuoteInsert(dict data, dict error) {};
|
||||
|
||||
virtual void onErrRtnQuoteAction(dict data, dict error) {};
|
||||
|
||||
virtual void onRtnForQuoteRsp(dict data) {};
|
||||
|
||||
virtual void onRspQryContractBank(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspQryParkedOrder(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspQryParkedOrderAction(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspQryTradingNotice(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspQryBrokerTradingParams(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspQryBrokerTradingAlgos(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRtnFromBankToFutureByBank(dict data) {};
|
||||
|
||||
virtual void onRtnFromFutureToBankByBank(dict data) {};
|
||||
|
||||
virtual void onRtnRepealFromBankToFutureByBank(dict data) {};
|
||||
|
||||
virtual void onRtnRepealFromFutureToBankByBank(dict data) {};
|
||||
|
||||
virtual void onRtnFromBankToFutureByFuture(dict data) {};
|
||||
|
||||
virtual void onRtnFromFutureToBankByFuture(dict data) {};
|
||||
|
||||
virtual void onRtnRepealFromBankToFutureByFutureManual(dict data) {};
|
||||
|
||||
virtual void onRtnRepealFromFutureToBankByFutureManual(dict data) {};
|
||||
|
||||
virtual void onRtnQueryBankBalanceByFuture(dict data) {};
|
||||
|
||||
virtual void onErrRtnBankToFutureByFuture(dict data, dict error) {};
|
||||
|
||||
virtual void onErrRtnFutureToBankByFuture(dict data, dict error) {};
|
||||
|
||||
virtual void onErrRtnRepealBankToFutureByFutureManual(dict data, dict error) {};
|
||||
|
||||
virtual void onErrRtnRepealFutureToBankByFutureManual(dict data, dict error) {};
|
||||
|
||||
virtual void onErrRtnQueryBankBalanceByFuture(dict data, dict error) {};
|
||||
|
||||
virtual void onRtnRepealFromBankToFutureByFuture(dict data) {};
|
||||
|
||||
virtual void onRtnRepealFromFutureToBankByFuture(dict data) {};
|
||||
|
||||
virtual void onRspFromBankToFutureByFuture(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspFromFutureToBankByFuture(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspQueryBankAccountMoneyByFuture(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRtnOpenAccountByBank(dict data) {};
|
||||
|
||||
virtual void onRtnCancelAccountByBank(dict data) {};
|
||||
|
||||
virtual void onRtnChangeAccountByBank(dict data) {};
|
||||
|
194
vn.ctp/pyscript/ctp_td_header_process.h
Normal file
194
vn.ctp/pyscript/ctp_td_header_process.h
Normal file
@ -0,0 +1,194 @@
|
||||
void processFrontConnected(Task task);
|
||||
|
||||
void processFrontDisconnected(Task task);
|
||||
|
||||
void processHeartBeatWarning(Task task);
|
||||
|
||||
void processRspAuthenticate(Task task);
|
||||
|
||||
void processRspUserLogin(Task task);
|
||||
|
||||
void processRspUserLogout(Task task);
|
||||
|
||||
void processRspUserPasswordUpdate(Task task);
|
||||
|
||||
void processRspTradingAccountPasswordUpdate(Task task);
|
||||
|
||||
void processRspOrderInsert(Task task);
|
||||
|
||||
void processRspParkedOrderInsert(Task task);
|
||||
|
||||
void processRspParkedOrderAction(Task task);
|
||||
|
||||
void processRspOrderAction(Task task);
|
||||
|
||||
void processRspQueryMaxOrderVolume(Task task);
|
||||
|
||||
void processRspSettlementInfoConfirm(Task task);
|
||||
|
||||
void processRspRemoveParkedOrder(Task task);
|
||||
|
||||
void processRspRemoveParkedOrderAction(Task task);
|
||||
|
||||
void processRspExecOrderInsert(Task task);
|
||||
|
||||
void processRspExecOrderAction(Task task);
|
||||
|
||||
void processRspForQuoteInsert(Task task);
|
||||
|
||||
void processRspQuoteInsert(Task task);
|
||||
|
||||
void processRspQuoteAction(Task task);
|
||||
|
||||
void processRspQryOrder(Task task);
|
||||
|
||||
void processRspQryTrade(Task task);
|
||||
|
||||
void processRspQryInvestorPosition(Task task);
|
||||
|
||||
void processRspQryTradingAccount(Task task);
|
||||
|
||||
void processRspQryInvestor(Task task);
|
||||
|
||||
void processRspQryTradingCode(Task task);
|
||||
|
||||
void processRspQryInstrumentMarginRate(Task task);
|
||||
|
||||
void processRspQryInstrumentCommissionRate(Task task);
|
||||
|
||||
void processRspQryExchange(Task task);
|
||||
|
||||
void processRspQryProduct(Task task);
|
||||
|
||||
void processRspQryInstrument(Task task);
|
||||
|
||||
void processRspQryDepthMarketData(Task task);
|
||||
|
||||
void processRspQrySettlementInfo(Task task);
|
||||
|
||||
void processRspQryTransferBank(Task task);
|
||||
|
||||
void processRspQryInvestorPositionDetail(Task task);
|
||||
|
||||
void processRspQryNotice(Task task);
|
||||
|
||||
void processRspQrySettlementInfoConfirm(Task task);
|
||||
|
||||
void processRspQryInvestorPositionCombineDetail(Task task);
|
||||
|
||||
void processRspQryCFMMCTradingAccountKey(Task task);
|
||||
|
||||
void processRspQryEWarrantOffset(Task task);
|
||||
|
||||
void processRspQryInvestorProductGroupMargin(Task task);
|
||||
|
||||
void processRspQryExchangeMarginRate(Task task);
|
||||
|
||||
void processRspQryExchangeMarginRateAdjust(Task task);
|
||||
|
||||
void processRspQryExchangeRate(Task task);
|
||||
|
||||
void processRspQrySecAgentACIDMap(Task task);
|
||||
|
||||
void processRspQryOptionInstrTradeCost(Task task);
|
||||
|
||||
void processRspQryOptionInstrCommRate(Task task);
|
||||
|
||||
void processRspQryExecOrder(Task task);
|
||||
|
||||
void processRspQryForQuote(Task task);
|
||||
|
||||
void processRspQryQuote(Task task);
|
||||
|
||||
void processRspQryTransferSerial(Task task);
|
||||
|
||||
void processRspQryAccountregister(Task task);
|
||||
|
||||
void processRspError(Task task);
|
||||
|
||||
void processRtnOrder(Task task);
|
||||
|
||||
void processRtnTrade(Task task);
|
||||
|
||||
void processErrRtnOrderInsert(Task task);
|
||||
|
||||
void processErrRtnOrderAction(Task task);
|
||||
|
||||
void processRtnInstrumentStatus(Task task);
|
||||
|
||||
void processRtnTradingNotice(Task task);
|
||||
|
||||
void processRtnErrorConditionalOrder(Task task);
|
||||
|
||||
void processRtnExecOrder(Task task);
|
||||
|
||||
void processErrRtnExecOrderInsert(Task task);
|
||||
|
||||
void processErrRtnExecOrderAction(Task task);
|
||||
|
||||
void processErrRtnForQuoteInsert(Task task);
|
||||
|
||||
void processRtnQuote(Task task);
|
||||
|
||||
void processErrRtnQuoteInsert(Task task);
|
||||
|
||||
void processErrRtnQuoteAction(Task task);
|
||||
|
||||
void processRtnForQuoteRsp(Task task);
|
||||
|
||||
void processRspQryContractBank(Task task);
|
||||
|
||||
void processRspQryParkedOrder(Task task);
|
||||
|
||||
void processRspQryParkedOrderAction(Task task);
|
||||
|
||||
void processRspQryTradingNotice(Task task);
|
||||
|
||||
void processRspQryBrokerTradingParams(Task task);
|
||||
|
||||
void processRspQryBrokerTradingAlgos(Task task);
|
||||
|
||||
void processRtnFromBankToFutureByBank(Task task);
|
||||
|
||||
void processRtnFromFutureToBankByBank(Task task);
|
||||
|
||||
void processRtnRepealFromBankToFutureByBank(Task task);
|
||||
|
||||
void processRtnRepealFromFutureToBankByBank(Task task);
|
||||
|
||||
void processRtnFromBankToFutureByFuture(Task task);
|
||||
|
||||
void processRtnFromFutureToBankByFuture(Task task);
|
||||
|
||||
void processRtnRepealFromBankToFutureByFutureManual(Task task);
|
||||
|
||||
void processRtnRepealFromFutureToBankByFutureManual(Task task);
|
||||
|
||||
void processRtnQueryBankBalanceByFuture(Task task);
|
||||
|
||||
void processErrRtnBankToFutureByFuture(Task task);
|
||||
|
||||
void processErrRtnFutureToBankByFuture(Task task);
|
||||
|
||||
void processErrRtnRepealBankToFutureByFutureManual(Task task);
|
||||
|
||||
void processErrRtnRepealFutureToBankByFutureManual(Task task);
|
||||
|
||||
void processErrRtnQueryBankBalanceByFuture(Task task);
|
||||
|
||||
void processRtnRepealFromBankToFutureByFuture(Task task);
|
||||
|
||||
void processRtnRepealFromFutureToBankByFuture(Task task);
|
||||
|
||||
void processRspFromBankToFutureByFuture(Task task);
|
||||
|
||||
void processRspFromFutureToBankByFuture(Task task);
|
||||
|
||||
void processRspQueryBankAccountMoneyByFuture(Task task);
|
||||
|
||||
void processRtnOpenAccountByBank(Task task);
|
||||
|
||||
void processRtnCancelAccountByBank(Task task);
|
||||
|
||||
void processRtnChangeAccountByBank(Task task);
|
||||
|
3380
vn.ctp/pyscript/ctp_td_process.cpp
Normal file
3380
vn.ctp/pyscript/ctp_td_process.cpp
Normal file
File diff suppressed because it is too large
Load Diff
582
vn.ctp/pyscript/ctp_td_switch.cpp
Normal file
582
vn.ctp/pyscript/ctp_td_switch.cpp
Normal file
@ -0,0 +1,582 @@
|
||||
case ONFRONTCONNECTED:
|
||||
{
|
||||
this->processFrontConnected(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONFRONTDISCONNECTED:
|
||||
{
|
||||
this->processFrontDisconnected(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONHEARTBEATWARNING:
|
||||
{
|
||||
this->processHeartBeatWarning(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPAUTHENTICATE:
|
||||
{
|
||||
this->processRspAuthenticate(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPUSERLOGIN:
|
||||
{
|
||||
this->processRspUserLogin(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPUSERLOGOUT:
|
||||
{
|
||||
this->processRspUserLogout(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPUSERPASSWORDUPDATE:
|
||||
{
|
||||
this->processRspUserPasswordUpdate(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPTRADINGACCOUNTPASSWORDUPDATE:
|
||||
{
|
||||
this->processRspTradingAccountPasswordUpdate(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPORDERINSERT:
|
||||
{
|
||||
this->processRspOrderInsert(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPPARKEDORDERINSERT:
|
||||
{
|
||||
this->processRspParkedOrderInsert(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPPARKEDORDERACTION:
|
||||
{
|
||||
this->processRspParkedOrderAction(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPORDERACTION:
|
||||
{
|
||||
this->processRspOrderAction(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPQUERYMAXORDERVOLUME:
|
||||
{
|
||||
this->processRspQueryMaxOrderVolume(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPSETTLEMENTINFOCONFIRM:
|
||||
{
|
||||
this->processRspSettlementInfoConfirm(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPREMOVEPARKEDORDER:
|
||||
{
|
||||
this->processRspRemoveParkedOrder(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPREMOVEPARKEDORDERACTION:
|
||||
{
|
||||
this->processRspRemoveParkedOrderAction(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPEXECORDERINSERT:
|
||||
{
|
||||
this->processRspExecOrderInsert(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPEXECORDERACTION:
|
||||
{
|
||||
this->processRspExecOrderAction(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPFORQUOTEINSERT:
|
||||
{
|
||||
this->processRspForQuoteInsert(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPQUOTEINSERT:
|
||||
{
|
||||
this->processRspQuoteInsert(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPQUOTEACTION:
|
||||
{
|
||||
this->processRspQuoteAction(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPQRYORDER:
|
||||
{
|
||||
this->processRspQryOrder(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPQRYTRADE:
|
||||
{
|
||||
this->processRspQryTrade(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPQRYINVESTORPOSITION:
|
||||
{
|
||||
this->processRspQryInvestorPosition(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPQRYTRADINGACCOUNT:
|
||||
{
|
||||
this->processRspQryTradingAccount(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPQRYINVESTOR:
|
||||
{
|
||||
this->processRspQryInvestor(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPQRYTRADINGCODE:
|
||||
{
|
||||
this->processRspQryTradingCode(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPQRYINSTRUMENTMARGINRATE:
|
||||
{
|
||||
this->processRspQryInstrumentMarginRate(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPQRYINSTRUMENTCOMMISSIONRATE:
|
||||
{
|
||||
this->processRspQryInstrumentCommissionRate(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPQRYEXCHANGE:
|
||||
{
|
||||
this->processRspQryExchange(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPQRYPRODUCT:
|
||||
{
|
||||
this->processRspQryProduct(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPQRYINSTRUMENT:
|
||||
{
|
||||
this->processRspQryInstrument(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPQRYDEPTHMARKETDATA:
|
||||
{
|
||||
this->processRspQryDepthMarketData(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPQRYSETTLEMENTINFO:
|
||||
{
|
||||
this->processRspQrySettlementInfo(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPQRYTRANSFERBANK:
|
||||
{
|
||||
this->processRspQryTransferBank(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPQRYINVESTORPOSITIONDETAIL:
|
||||
{
|
||||
this->processRspQryInvestorPositionDetail(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPQRYNOTICE:
|
||||
{
|
||||
this->processRspQryNotice(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPQRYSETTLEMENTINFOCONFIRM:
|
||||
{
|
||||
this->processRspQrySettlementInfoConfirm(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPQRYINVESTORPOSITIONCOMBINEDETAIL:
|
||||
{
|
||||
this->processRspQryInvestorPositionCombineDetail(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPQRYCFMMCTRADINGACCOUNTKEY:
|
||||
{
|
||||
this->processRspQryCFMMCTradingAccountKey(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPQRYEWARRANTOFFSET:
|
||||
{
|
||||
this->processRspQryEWarrantOffset(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPQRYINVESTORPRODUCTGROUPMARGIN:
|
||||
{
|
||||
this->processRspQryInvestorProductGroupMargin(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPQRYEXCHANGEMARGINRATE:
|
||||
{
|
||||
this->processRspQryExchangeMarginRate(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPQRYEXCHANGEMARGINRATEADJUST:
|
||||
{
|
||||
this->processRspQryExchangeMarginRateAdjust(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPQRYEXCHANGERATE:
|
||||
{
|
||||
this->processRspQryExchangeRate(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPQRYSECAGENTACIDMAP:
|
||||
{
|
||||
this->processRspQrySecAgentACIDMap(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPQRYOPTIONINSTRTRADECOST:
|
||||
{
|
||||
this->processRspQryOptionInstrTradeCost(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPQRYOPTIONINSTRCOMMRATE:
|
||||
{
|
||||
this->processRspQryOptionInstrCommRate(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPQRYEXECORDER:
|
||||
{
|
||||
this->processRspQryExecOrder(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPQRYFORQUOTE:
|
||||
{
|
||||
this->processRspQryForQuote(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPQRYQUOTE:
|
||||
{
|
||||
this->processRspQryQuote(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPQRYTRANSFERSERIAL:
|
||||
{
|
||||
this->processRspQryTransferSerial(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPQRYACCOUNTREGISTER:
|
||||
{
|
||||
this->processRspQryAccountregister(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPERROR:
|
||||
{
|
||||
this->processRspError(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRTNORDER:
|
||||
{
|
||||
this->processRtnOrder(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRTNTRADE:
|
||||
{
|
||||
this->processRtnTrade(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONERRRTNORDERINSERT:
|
||||
{
|
||||
this->processErrRtnOrderInsert(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONERRRTNORDERACTION:
|
||||
{
|
||||
this->processErrRtnOrderAction(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRTNINSTRUMENTSTATUS:
|
||||
{
|
||||
this->processRtnInstrumentStatus(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRTNTRADINGNOTICE:
|
||||
{
|
||||
this->processRtnTradingNotice(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRTNERRORCONDITIONALORDER:
|
||||
{
|
||||
this->processRtnErrorConditionalOrder(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRTNEXECORDER:
|
||||
{
|
||||
this->processRtnExecOrder(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONERRRTNEXECORDERINSERT:
|
||||
{
|
||||
this->processErrRtnExecOrderInsert(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONERRRTNEXECORDERACTION:
|
||||
{
|
||||
this->processErrRtnExecOrderAction(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONERRRTNFORQUOTEINSERT:
|
||||
{
|
||||
this->processErrRtnForQuoteInsert(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRTNQUOTE:
|
||||
{
|
||||
this->processRtnQuote(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONERRRTNQUOTEINSERT:
|
||||
{
|
||||
this->processErrRtnQuoteInsert(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONERRRTNQUOTEACTION:
|
||||
{
|
||||
this->processErrRtnQuoteAction(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRTNFORQUOTERSP:
|
||||
{
|
||||
this->processRtnForQuoteRsp(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPQRYCONTRACTBANK:
|
||||
{
|
||||
this->processRspQryContractBank(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPQRYPARKEDORDER:
|
||||
{
|
||||
this->processRspQryParkedOrder(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPQRYPARKEDORDERACTION:
|
||||
{
|
||||
this->processRspQryParkedOrderAction(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPQRYTRADINGNOTICE:
|
||||
{
|
||||
this->processRspQryTradingNotice(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPQRYBROKERTRADINGPARAMS:
|
||||
{
|
||||
this->processRspQryBrokerTradingParams(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPQRYBROKERTRADINGALGOS:
|
||||
{
|
||||
this->processRspQryBrokerTradingAlgos(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRTNFROMBANKTOFUTUREBYBANK:
|
||||
{
|
||||
this->processRtnFromBankToFutureByBank(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRTNFROMFUTURETOBANKBYBANK:
|
||||
{
|
||||
this->processRtnFromFutureToBankByBank(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRTNREPEALFROMBANKTOFUTUREBYBANK:
|
||||
{
|
||||
this->processRtnRepealFromBankToFutureByBank(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRTNREPEALFROMFUTURETOBANKBYBANK:
|
||||
{
|
||||
this->processRtnRepealFromFutureToBankByBank(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRTNFROMBANKTOFUTUREBYFUTURE:
|
||||
{
|
||||
this->processRtnFromBankToFutureByFuture(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRTNFROMFUTURETOBANKBYFUTURE:
|
||||
{
|
||||
this->processRtnFromFutureToBankByFuture(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRTNREPEALFROMBANKTOFUTUREBYFUTUREMANUAL:
|
||||
{
|
||||
this->processRtnRepealFromBankToFutureByFutureManual(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRTNREPEALFROMFUTURETOBANKBYFUTUREMANUAL:
|
||||
{
|
||||
this->processRtnRepealFromFutureToBankByFutureManual(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRTNQUERYBANKBALANCEBYFUTURE:
|
||||
{
|
||||
this->processRtnQueryBankBalanceByFuture(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONERRRTNBANKTOFUTUREBYFUTURE:
|
||||
{
|
||||
this->processErrRtnBankToFutureByFuture(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONERRRTNFUTURETOBANKBYFUTURE:
|
||||
{
|
||||
this->processErrRtnFutureToBankByFuture(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONERRRTNREPEALBANKTOFUTUREBYFUTUREMANUAL:
|
||||
{
|
||||
this->processErrRtnRepealBankToFutureByFutureManual(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONERRRTNREPEALFUTURETOBANKBYFUTUREMANUAL:
|
||||
{
|
||||
this->processErrRtnRepealFutureToBankByFutureManual(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONERRRTNQUERYBANKBALANCEBYFUTURE:
|
||||
{
|
||||
this->processErrRtnQueryBankBalanceByFuture(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRTNREPEALFROMBANKTOFUTUREBYFUTURE:
|
||||
{
|
||||
this->processRtnRepealFromBankToFutureByFuture(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRTNREPEALFROMFUTURETOBANKBYFUTURE:
|
||||
{
|
||||
this->processRtnRepealFromFutureToBankByFuture(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPFROMBANKTOFUTUREBYFUTURE:
|
||||
{
|
||||
this->processRspFromBankToFutureByFuture(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPFROMFUTURETOBANKBYFUTURE:
|
||||
{
|
||||
this->processRspFromFutureToBankByFuture(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPQUERYBANKACCOUNTMONEYBYFUTURE:
|
||||
{
|
||||
this->processRspQueryBankAccountMoneyByFuture(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRTNOPENACCOUNTBYBANK:
|
||||
{
|
||||
this->processRtnOpenAccountByBank(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRTNCANCELACCOUNTBYBANK:
|
||||
{
|
||||
this->processRtnCancelAccountByBank(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRTNCHANGEACCOUNTBYBANK:
|
||||
{
|
||||
this->processRtnChangeAccountByBank(task);
|
||||
break;
|
||||
}
|
||||
|
2616
vn.ctp/pyscript/ctp_td_task.cpp
Normal file
2616
vn.ctp/pyscript/ctp_td_task.cpp
Normal file
File diff suppressed because it is too large
Load Diff
1316
vn.ctp/pyscript/ctp_td_wrap.cpp
Normal file
1316
vn.ctp/pyscript/ctp_td_wrap.cpp
Normal file
File diff suppressed because it is too large
Load Diff
98
vn.ctp/pyscript/generate_data_type.py
Normal file
98
vn.ctp/pyscript/generate_data_type.py
Normal file
@ -0,0 +1,98 @@
|
||||
# encoding: UTF-8
|
||||
|
||||
__author__ = 'CHENXY'
|
||||
|
||||
# C++和python类型的映射字典
|
||||
type_dict = {
|
||||
'int': 'int',
|
||||
'char': 'string',
|
||||
'double': 'float',
|
||||
'short': 'int'
|
||||
}
|
||||
|
||||
|
||||
def process_line(line):
|
||||
"""处理每行"""
|
||||
if '///' in line: # 注释
|
||||
py_line = process_comment(line)
|
||||
elif 'typedef' in line: # 类型申明
|
||||
py_line = process_typedef(line)
|
||||
elif '#define' in line: # 定义常量
|
||||
py_line = process_define(line)
|
||||
elif line == '\n': # 空行
|
||||
py_line = line
|
||||
else:
|
||||
py_line = ''
|
||||
|
||||
return py_line
|
||||
|
||||
|
||||
def process_comment(line):
|
||||
"""处理注释"""
|
||||
# if line[3] == '/':
|
||||
# py_line = ''
|
||||
# else:
|
||||
# py_line = '#' + line[3:]
|
||||
py_line = '#' + line[3:]
|
||||
return py_line
|
||||
|
||||
|
||||
def process_typedef(line):
|
||||
"""处理类型申明"""
|
||||
content = line.split(' ')
|
||||
type_ = type_dict[content[1]]
|
||||
|
||||
keyword = content[2]
|
||||
if '[' in keyword:
|
||||
i = keyword.index('[')
|
||||
keyword = keyword[:i]
|
||||
else:
|
||||
keyword = keyword.replace(';\n', '') # 删除行末分号
|
||||
|
||||
py_line = 'typedefDict["%s"] = "%s"\n' % (keyword, type_)
|
||||
|
||||
return py_line
|
||||
|
||||
|
||||
def process_define(line):
|
||||
"""处理定义常量"""
|
||||
content = line.split(' ')
|
||||
constant = content[1]
|
||||
|
||||
if len(content)>2:
|
||||
value = content[-1]
|
||||
py_line = 'defineDict["%s"] = %s' % (constant, value)
|
||||
else:
|
||||
py_line = ''
|
||||
|
||||
return py_line
|
||||
|
||||
|
||||
def main():
|
||||
"""主函数"""
|
||||
try:
|
||||
fcpp = open('ThostFtdcUserApiDataType.h','r')
|
||||
fpy = open('ctp_data_type.py', 'w')
|
||||
|
||||
fpy.write('# encoding: UTF-8\n')
|
||||
fpy.write('\n')
|
||||
fpy.write('defineDict = {}\n')
|
||||
fpy.write('typedefDict = {}\n')
|
||||
fpy.write('\n')
|
||||
|
||||
for line in fcpp:
|
||||
py_line = process_line(line)
|
||||
if py_line:
|
||||
fpy.write(py_line.decode('gbk').encode('utf-8'))
|
||||
|
||||
fcpp.close()
|
||||
fpy.close()
|
||||
|
||||
print u'data_type.py生成过程完成'
|
||||
except:
|
||||
print u'data_type.py生成过程出错'
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
207
vn.ctp/pyscript/generate_md_functions.py
Normal file
207
vn.ctp/pyscript/generate_md_functions.py
Normal file
@ -0,0 +1,207 @@
|
||||
# encoding: UTF-8
|
||||
|
||||
__author__ = 'CHENXY'
|
||||
|
||||
from string import join
|
||||
from ctp_struct import structDict
|
||||
|
||||
|
||||
|
||||
def processCallBack(line):
|
||||
orignalLine = line
|
||||
line = line.replace('\tvirtual void ', '') # 删除行首的无效内容
|
||||
line = line.replace('{};\n', '') # 删除行尾的无效内容
|
||||
|
||||
content = line.split('(')
|
||||
cbName = content[0] # 回调函数名称
|
||||
|
||||
cbArgs = content[1] # 回调函数参数
|
||||
if cbArgs[-1] == ' ':
|
||||
cbArgs = cbArgs.replace(') ', '')
|
||||
else:
|
||||
cbArgs = cbArgs.replace(')', '')
|
||||
|
||||
cbArgsList = cbArgs.split(', ') # 将每个参数转化为列表
|
||||
|
||||
cbArgsTypeList = []
|
||||
cbArgsValueList = []
|
||||
|
||||
for arg in cbArgsList: # 开始处理参数
|
||||
content = arg.split(' ')
|
||||
if len(content) > 1:
|
||||
cbArgsTypeList.append(content[0]) # 参数类型列表
|
||||
cbArgsValueList.append(content[1]) # 参数数据列表
|
||||
|
||||
createTask(cbName, cbArgsTypeList, cbArgsValueList, orignalLine)
|
||||
createProcess(cbName, cbArgsTypeList, cbArgsValueList)
|
||||
|
||||
|
||||
def createTask(cbName, cbArgsTypeList, cbArgsValueList, orignalLine):
|
||||
# 从回调函数生成任务对象,并放入队列
|
||||
funcline = orignalLine.replace('\tvirtual void ', 'void ' + apiName + '::')
|
||||
funcline = funcline.replace('{};', '')
|
||||
|
||||
ftask.write(funcline)
|
||||
ftask.write('{\n')
|
||||
ftask.write("\tTask task = Task();\n")
|
||||
|
||||
ftask.write("\ttask.task_name = " + cbName.upper() + ";\n")
|
||||
|
||||
# define常量
|
||||
global define_count
|
||||
fdefine.write("#define " + cbName.upper() + ' ' + str(define_count) + '\n')
|
||||
define_count = define_count + 1
|
||||
|
||||
# switch段代码
|
||||
fswitch.write("case " + cbName.upper() + ':\n')
|
||||
fswitch.write("{\n")
|
||||
fswitch.write("\tthis->" + cbName.replace('On', 'process') + '(task);\n')
|
||||
fswitch.write("\tbreak;\n")
|
||||
fswitch.write("}\n")
|
||||
fswitch.write("\n")
|
||||
|
||||
for i, type_ in enumerate(cbArgsTypeList):
|
||||
if type_ == 'int':
|
||||
ftask.write("\ttask.task_id = " + cbArgsValueList[i] + ";\n")
|
||||
elif type_ == 'bool':
|
||||
ftask.write("\ttask.task_last = " + cbArgsValueList[i] + ";\n")
|
||||
elif 'RspInfoField' in type_:
|
||||
ftask.write("\tif (pRspInfo)\n")
|
||||
ftask.write("\t{\n")
|
||||
ftask.write("\t\ttask.task_error = " + cbArgsValueList[i] + ";\n")
|
||||
ftask.write("\t}\n")
|
||||
ftask.write("\telse\n")
|
||||
ftask.write("\t{\n")
|
||||
ftask.write("\t\tCSecurityFtdcRspInfoField empty_error = CSecurityFtdcRspInfoField();\n")
|
||||
ftask.write("\t\tmemset(&empty_error, 0, sizeof(empty_error));\n")
|
||||
ftask.write("\t\ttask.task_error = empty_error;\n")
|
||||
ftask.write("\t}\n")
|
||||
else:
|
||||
ftask.write("\ttask.task_data = " + cbArgsValueList[i] + ";\n")
|
||||
|
||||
ftask.write("\tthis->task_queue.push(task);\n")
|
||||
ftask.write("};\n")
|
||||
ftask.write("\n")
|
||||
|
||||
|
||||
def createProcess(cbName, cbArgsTypeList, cbArgsValueList):
|
||||
# 从队列中提取任务,并转化为python字典
|
||||
fprocess.write("void " + apiName + '::' + cbName.replace('On', 'process') + '(Task task)' + "\n")
|
||||
fprocess.write("{\n")
|
||||
|
||||
onArgsList = []
|
||||
|
||||
for i, type_ in enumerate(cbArgsTypeList):
|
||||
if 'RspInfoField' in type_:
|
||||
fprocess.write("\t"+ type_ + ' task_error = any_cast<' + type_ + '>(task.task_error);\n')
|
||||
fprocess.write("\t"+ "dict error;\n")
|
||||
|
||||
struct = structDict[type_]
|
||||
for key in struct.keys():
|
||||
fprocess.write("\t"+ 'error["' + key + '"] = task_error.' + key + ';\n')
|
||||
|
||||
fprocess.write("\n")
|
||||
|
||||
onArgsList.append('error')
|
||||
|
||||
elif type_ in structDict:
|
||||
fprocess.write("\t"+ type_ + ' task_data = any_cast<' + type_ + '>(task.task_data);\n')
|
||||
fprocess.write("\t"+ "dict data;\n")
|
||||
|
||||
struct = structDict[type_]
|
||||
for key in struct.keys():
|
||||
fprocess.write("\t"+ 'data["' + key + '"] = task_data.' + key + ';\n')
|
||||
|
||||
fprocess.write("\n")
|
||||
|
||||
onArgsList.append('data')
|
||||
|
||||
elif type_ == 'bool':
|
||||
onArgsList.append('task.task_last')
|
||||
|
||||
elif type_ == 'int':
|
||||
onArgsList.append('task.task_id')
|
||||
|
||||
onArgs = join(onArgsList, ', ')
|
||||
fprocess.write('\tthis->' + cbName.replace('On', 'on') + '(' + onArgs +');\n')
|
||||
|
||||
fprocess.write("};\n")
|
||||
fprocess.write("\n")
|
||||
|
||||
|
||||
def processFunction(line):
|
||||
line = line.replace('\tvirtual int ', '') # 删除行首的无效内容
|
||||
line = line.replace(') = 0;\n', '') # 删除行尾的无效内容
|
||||
|
||||
content = line.split('(')
|
||||
fcName = content[0] # 回调函数名称
|
||||
|
||||
fcArgs = content[1] # 回调函数参数
|
||||
fcArgs = fcArgs.replace(')', '')
|
||||
|
||||
fcArgsList = fcArgs.split(', ') # 将每个参数转化为列表
|
||||
|
||||
fcArgsTypeList = []
|
||||
fcArgsValueList = []
|
||||
|
||||
for arg in fcArgsList: # 开始处理参数
|
||||
content = arg.split(' ')
|
||||
if len(content) > 1:
|
||||
fcArgsTypeList.append(content[0]) # 参数类型列表
|
||||
fcArgsValueList.append(content[1]) # 参数数据列表
|
||||
|
||||
if len(fcArgsTypeList)>0 and fcArgsTypeList[0] in structDict:
|
||||
createFunction(fcName, fcArgsTypeList, fcArgsValueList)
|
||||
|
||||
|
||||
def createFunction(fcName, fcArgsTypeList, fcArgsValueList):
|
||||
type_ = fcArgsTypeList[0]
|
||||
struct = structDict[type_]
|
||||
|
||||
ffunction.write(fcName + '\n')
|
||||
ffunction.write('{\n')
|
||||
ffunction.write('\t' + type_ +' myreq = ' + type_ + '();\n')
|
||||
ffunction.write('\tmemset(&myreq, 0, sizeof(myreq));\n')
|
||||
|
||||
for key, value in struct.items():
|
||||
if value == 'string':
|
||||
line = '\tgetChar(req, "' + key + '", myreq.' + key + ');\n'
|
||||
elif value == 'int':
|
||||
line = '\tgetInt(req, "' + key + '", &myreq.' + key + ');\n'
|
||||
elif value == 'double':
|
||||
line = '\tgetDouble(req, "' + key + '", &myreq.' + key + ');\n'
|
||||
ffunction.write(line)
|
||||
|
||||
ffunction.write('\tint i = this->api->' + fcName + '(&myreq, nRequestID);\n')
|
||||
ffunction.write('\treturn i;\n')
|
||||
|
||||
ffunction.write('};\n')
|
||||
ffunction.write('\n')
|
||||
|
||||
|
||||
|
||||
|
||||
#########################################################
|
||||
apiName = 'MdApi'
|
||||
|
||||
fcpp = open('ThostFtdcMdApi.h', 'r')
|
||||
ftask = open('ctp_md_task.cpp', 'w')
|
||||
fprocess = open('ctp_md_process.cpp', 'w')
|
||||
ffunction = open('ctp_md_function.cpp', 'w')
|
||||
fdefine = open('ctp_md_define.cpp', 'w')
|
||||
fswitch = open('ctp_md_switch.cpp', 'w')
|
||||
|
||||
define_count = 1
|
||||
|
||||
for line in fcpp:
|
||||
if "\tvirtual void On" in line:
|
||||
processCallBack(line)
|
||||
elif "\tvirtual int" in line:
|
||||
processFunction(line)
|
||||
|
||||
fcpp.close()
|
||||
ftask.close()
|
||||
fprocess.close()
|
||||
ffunction.close()
|
||||
fswitch.close()
|
||||
fdefine.close()
|
56
vn.ctp/pyscript/generate_struct.py
Normal file
56
vn.ctp/pyscript/generate_struct.py
Normal file
@ -0,0 +1,56 @@
|
||||
# encoding: UTF-8
|
||||
|
||||
__author__ = 'CHENXY'
|
||||
|
||||
from ctp_data_type import *
|
||||
|
||||
def main():
|
||||
"""主函数"""
|
||||
fcpp = open('ThostFtdcUserApiStruct.h', 'r')
|
||||
fpy = open('ctp_struct.py', 'w')
|
||||
|
||||
fpy.write('# encoding: UTF-8\n')
|
||||
fpy.write('\n')
|
||||
fpy.write('structDict = {}\n')
|
||||
fpy.write('\n')
|
||||
|
||||
for line in fcpp:
|
||||
# 结构体申明注释
|
||||
if '///' in line and '\t' not in line:
|
||||
py_line = '#' + line[3:]
|
||||
|
||||
# 结构体变量注释
|
||||
elif '\t///' in line:
|
||||
py_line = '#' + line[4:]
|
||||
|
||||
# 结构体申明
|
||||
elif 'struct' in line:
|
||||
content = line.split(' ')
|
||||
name = content[1].replace('\n','')
|
||||
py_line = '%s = {}\n' % name
|
||||
|
||||
# 结构体变量
|
||||
elif '\t' in line and '///' not in line:
|
||||
content = line.split('\t')
|
||||
typedef = content[1]
|
||||
type_ = typedefDict[typedef]
|
||||
variable = content[2].replace(';\n', "")
|
||||
py_line = '%s["%s"] = "%s"\n' % (name, variable, type_)
|
||||
|
||||
# 结构体结束
|
||||
elif '}' in line:
|
||||
py_line = "structDict['%s'] = %s\n\n" % (name, name)
|
||||
|
||||
# 结构体开始
|
||||
elif '{' in line:
|
||||
py_line = ''
|
||||
|
||||
# 其他
|
||||
else:
|
||||
py_line = '\n'
|
||||
|
||||
fpy.write(py_line.decode('gbk').encode('utf-8'))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
291
vn.ctp/pyscript/generate_td_functions.py
Normal file
291
vn.ctp/pyscript/generate_td_functions.py
Normal file
@ -0,0 +1,291 @@
|
||||
# encoding: UTF-8
|
||||
|
||||
__author__ = 'CHENXY'
|
||||
|
||||
from string import join
|
||||
from ctp_struct import structDict
|
||||
|
||||
|
||||
|
||||
def processCallBack(line):
|
||||
orignalLine = line
|
||||
line = line.replace('\tvirtual void ', '') # 删除行首的无效内容
|
||||
line = line.replace('{};\n', '') # 删除行尾的无效内容
|
||||
|
||||
content = line.split('(')
|
||||
cbName = content[0] # 回调函数名称
|
||||
|
||||
cbArgs = content[1] # 回调函数参数
|
||||
if cbArgs[-1] == ' ':
|
||||
cbArgs = cbArgs.replace(') ', '')
|
||||
else:
|
||||
cbArgs = cbArgs.replace(')', '')
|
||||
|
||||
cbArgsList = cbArgs.split(', ') # 将每个参数转化为列表
|
||||
|
||||
cbArgsTypeList = []
|
||||
cbArgsValueList = []
|
||||
|
||||
for arg in cbArgsList: # 开始处理参数
|
||||
content = arg.split(' ')
|
||||
if len(content) > 1:
|
||||
cbArgsTypeList.append(content[0]) # 参数类型列表
|
||||
cbArgsValueList.append(content[1]) # 参数数据列表
|
||||
|
||||
createTask(cbName, cbArgsTypeList, cbArgsValueList, orignalLine)
|
||||
createProcess(cbName, cbArgsTypeList, cbArgsValueList)
|
||||
|
||||
# 生成.h文件中的process部分
|
||||
process_line = 'void process' + cbName[2:] + '(Task task);\n'
|
||||
fheaderprocess.write(process_line)
|
||||
fheaderprocess.write('\n')
|
||||
|
||||
# 生成.h文件中的on部分
|
||||
if 'OnRspError' in cbName:
|
||||
on_line = 'virtual void on' + cbName[2:] + '(dict error, int id, bool last) {};\n'
|
||||
elif 'OnRsp' in cbName:
|
||||
on_line = 'virtual void on' + cbName[2:] + '(dict data, dict error, int id, bool last) {};\n'
|
||||
elif 'OnRtn' in cbName:
|
||||
on_line = 'virtual void on' + cbName[2:] + '(dict data) {};\n'
|
||||
elif 'OnErrRtn' in cbName:
|
||||
on_line = 'virtual void on' + cbName[2:] + '(dict data, dict error) {};\n'
|
||||
else:
|
||||
on_line = ''
|
||||
fheaderon.write(on_line)
|
||||
fheaderon.write('\n')
|
||||
|
||||
# 生成封装部分
|
||||
createWrap(cbName)
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def createWrap(cbName):
|
||||
"""在Python封装段代码中进行处理"""
|
||||
# 生成.h文件中的on部分
|
||||
if 'OnRspError' in cbName:
|
||||
on_line = 'virtual void on' + cbName[2:] + '(dict error, int id, bool last)\n'
|
||||
override_line = '("on' + cbName[2:] + '")(error, id, last);\n'
|
||||
elif 'OnRsp' in cbName:
|
||||
on_line = 'virtual void on' + cbName[2:] + '(dict data, dict error, int id, bool last)\n'
|
||||
override_line = '("on' + cbName[2:] + '")(data, error, id, last);\n'
|
||||
elif 'OnRtn' in cbName:
|
||||
on_line = 'virtual void on' + cbName[2:] + '(dict data)\n'
|
||||
override_line = '("on' + cbName[2:] + '")(data);\n'
|
||||
elif 'OnErrRtn' in cbName:
|
||||
on_line = 'virtual void on' + cbName[2:] + '(dict data, dict error)\n'
|
||||
override_line = '("on' + cbName[2:] + '")(data, error);\n'
|
||||
else:
|
||||
on_line = ''
|
||||
|
||||
if on_line is not '':
|
||||
fwrap.write(on_line)
|
||||
fwrap.write('{\n')
|
||||
fwrap.write('\t PyLock lock;\n')
|
||||
fwrap.write('\n')
|
||||
fwrap.write('\ttry\n')
|
||||
fwrap.write('\t{\n')
|
||||
fwrap.write('\t\tthis->get_override'+override_line)
|
||||
fwrap.write('\t}\n')
|
||||
fwrap.write('\tcatch (error_already_set const &)\n')
|
||||
fwrap.write('\t{\n')
|
||||
fwrap.write('\t\tPyErr_Print();\n')
|
||||
fwrap.write('\t}\n')
|
||||
fwrap.write('};\n')
|
||||
fwrap.write('\n')
|
||||
|
||||
|
||||
|
||||
def createTask(cbName, cbArgsTypeList, cbArgsValueList, orignalLine):
|
||||
# 从回调函数生成任务对象,并放入队列
|
||||
funcline = orignalLine.replace('\tvirtual void ', 'void ' + apiName + '::')
|
||||
funcline = funcline.replace('{};', '')
|
||||
|
||||
ftask.write(funcline)
|
||||
ftask.write('{\n')
|
||||
ftask.write("\tTask task = Task();\n")
|
||||
|
||||
ftask.write("\ttask.task_name = " + cbName.upper() + ";\n")
|
||||
|
||||
# define常量
|
||||
global define_count
|
||||
fdefine.write("#define " + cbName.upper() + ' ' + str(define_count) + '\n')
|
||||
define_count = define_count + 1
|
||||
|
||||
# switch段代码
|
||||
fswitch.write("case " + cbName.upper() + ':\n')
|
||||
fswitch.write("{\n")
|
||||
fswitch.write("\tthis->" + cbName.replace('On', 'process') + '(task);\n')
|
||||
fswitch.write("\tbreak;\n")
|
||||
fswitch.write("}\n")
|
||||
fswitch.write("\n")
|
||||
|
||||
for i, type_ in enumerate(cbArgsTypeList):
|
||||
if type_ == 'int':
|
||||
ftask.write("\ttask.task_id = " + cbArgsValueList[i] + ";\n")
|
||||
elif type_ == 'bool':
|
||||
ftask.write("\ttask.task_last = " + cbArgsValueList[i] + ";\n")
|
||||
elif 'RspInfoField' in type_:
|
||||
ftask.write("\n")
|
||||
ftask.write("\tif (pRspInfo)\n")
|
||||
ftask.write("\t{\n")
|
||||
ftask.write("\t\ttask.task_error = " + cbArgsValueList[i] + ";\n")
|
||||
ftask.write("\t}\n")
|
||||
ftask.write("\telse\n")
|
||||
ftask.write("\t{\n")
|
||||
ftask.write("\t\tCThostFtdcRspInfoField empty_error = CThostFtdcRspInfoField();\n")
|
||||
ftask.write("\t\tmemset(&empty_error, 0, sizeof(empty_error));\n")
|
||||
ftask.write("\t\ttask.task_error = empty_error;\n")
|
||||
ftask.write("\t}\n")
|
||||
else:
|
||||
ftask.write("\n")
|
||||
ftask.write("\tif (" + cbArgsValueList[i][1:] + ")\n")
|
||||
ftask.write("\t{\n")
|
||||
ftask.write("\t\ttask.task_data = " + cbArgsValueList[i] + ";\n")
|
||||
ftask.write("\t}\n")
|
||||
ftask.write("\telse\n")
|
||||
ftask.write("\t{\n")
|
||||
ftask.write("\t\t" + type_ + " empty_data = " + type_ + "();\n")
|
||||
ftask.write("\t\tmemset(&empty_data, 0, sizeof(empty_data));\n")
|
||||
ftask.write("\t\ttask.task_data = empty_data;\n")
|
||||
ftask.write("\t}\n")
|
||||
|
||||
ftask.write("\tthis->task_queue.push(task);\n")
|
||||
ftask.write("};\n")
|
||||
ftask.write("\n")
|
||||
|
||||
|
||||
def createProcess(cbName, cbArgsTypeList, cbArgsValueList):
|
||||
# 从队列中提取任务,并转化为python字典
|
||||
fprocess.write("void " + apiName + '::' + cbName.replace('On', 'process') + '(Task task)' + "\n")
|
||||
fprocess.write("{\n")
|
||||
|
||||
onArgsList = []
|
||||
|
||||
for i, type_ in enumerate(cbArgsTypeList):
|
||||
if 'RspInfoField' in type_:
|
||||
fprocess.write("\t"+ type_ + ' task_error = any_cast<' + type_ + '>(task.task_error);\n')
|
||||
fprocess.write("\t"+ "dict error;\n")
|
||||
|
||||
struct = structDict[type_]
|
||||
for key in struct.keys():
|
||||
fprocess.write("\t"+ 'error["' + key + '"] = task_error.' + key + ';\n')
|
||||
|
||||
fprocess.write("\n")
|
||||
|
||||
onArgsList.append('error')
|
||||
|
||||
elif type_ in structDict:
|
||||
fprocess.write("\t"+ type_ + ' task_data = any_cast<' + type_ + '>(task.task_data);\n')
|
||||
fprocess.write("\t"+ "dict data;\n")
|
||||
|
||||
struct = structDict[type_]
|
||||
for key in struct.keys():
|
||||
fprocess.write("\t"+ 'data["' + key + '"] = task_data.' + key + ';\n')
|
||||
|
||||
fprocess.write("\n")
|
||||
|
||||
onArgsList.append('data')
|
||||
|
||||
elif type_ == 'bool':
|
||||
onArgsList.append('task.task_last')
|
||||
|
||||
elif type_ == 'int':
|
||||
onArgsList.append('task.task_id')
|
||||
|
||||
onArgs = join(onArgsList, ', ')
|
||||
fprocess.write('\tthis->' + cbName.replace('On', 'on') + '(' + onArgs +');\n')
|
||||
|
||||
fprocess.write("};\n")
|
||||
fprocess.write("\n")
|
||||
|
||||
|
||||
def processFunction(line):
|
||||
line = line.replace('\tvirtual int ', '') # 删除行首的无效内容
|
||||
line = line.replace(') = 0;\n', '') # 删除行尾的无效内容
|
||||
|
||||
content = line.split('(')
|
||||
fcName = content[0] # 回调函数名称
|
||||
|
||||
fcArgs = content[1] # 回调函数参数
|
||||
fcArgs = fcArgs.replace(')', '')
|
||||
|
||||
fcArgsList = fcArgs.split(', ') # 将每个参数转化为列表
|
||||
|
||||
fcArgsTypeList = []
|
||||
fcArgsValueList = []
|
||||
|
||||
for arg in fcArgsList: # 开始处理参数
|
||||
content = arg.split(' ')
|
||||
if len(content) > 1:
|
||||
fcArgsTypeList.append(content[0]) # 参数类型列表
|
||||
fcArgsValueList.append(content[1]) # 参数数据列表
|
||||
|
||||
if len(fcArgsTypeList)>0 and fcArgsTypeList[0] in structDict:
|
||||
createFunction(fcName, fcArgsTypeList, fcArgsValueList)
|
||||
|
||||
# 生成.h文件中的主动函数部分
|
||||
if 'Req' in fcName:
|
||||
req_line = 'int req' + fcName[3:] + '(dict req, int nRequestID);\n'
|
||||
fheaderfunction.write(req_line)
|
||||
fheaderfunction.write('\n')
|
||||
|
||||
|
||||
def createFunction(fcName, fcArgsTypeList, fcArgsValueList):
|
||||
type_ = fcArgsTypeList[0]
|
||||
struct = structDict[type_]
|
||||
|
||||
ffunction.write('int TdApi::req' + fcName[3:] + '(dict req, int nRequestID)\n')
|
||||
ffunction.write('{\n')
|
||||
ffunction.write('\t' + type_ +' myreq = ' + type_ + '();\n')
|
||||
ffunction.write('\tmemset(&myreq, 0, sizeof(myreq));\n')
|
||||
|
||||
for key, value in struct.items():
|
||||
if value == 'string':
|
||||
line = '\tgetChar(req, "' + key + '", myreq.' + key + ');\n'
|
||||
elif value == 'int':
|
||||
line = '\tgetInt(req, "' + key + '", &myreq.' + key + ');\n'
|
||||
elif value == 'double':
|
||||
line = '\tgetDouble(req, "' + key + '", &myreq.' + key + ');\n'
|
||||
ffunction.write(line)
|
||||
|
||||
ffunction.write('\tint i = this->api->' + fcName + '(&myreq, nRequestID);\n')
|
||||
ffunction.write('\treturn i;\n')
|
||||
|
||||
ffunction.write('};\n')
|
||||
ffunction.write('\n')
|
||||
|
||||
|
||||
|
||||
|
||||
#########################################################
|
||||
apiName = 'TdApi'
|
||||
|
||||
fcpp = open('ThostFtdcTraderApi.h', 'r')
|
||||
ftask = open('ctp_td_task.cpp', 'w')
|
||||
fprocess = open('ctp_td_process.cpp', 'w')
|
||||
ffunction = open('ctp_td_function.cpp', 'w')
|
||||
fdefine = open('ctp_td_define.cpp', 'w')
|
||||
fswitch = open('ctp_td_switch.cpp', 'w')
|
||||
fheaderprocess = open('ctp_td_header_process.h', 'w')
|
||||
fheaderon = open('ctp_td_header_on.h', 'w')
|
||||
fheaderfunction = open('ctp_td_header_function.h', 'w')
|
||||
fwrap = open('ctp_td_wrap.cpp', 'w')
|
||||
|
||||
define_count = 1
|
||||
|
||||
for line in fcpp:
|
||||
if "\tvirtual void On" in line:
|
||||
processCallBack(line)
|
||||
elif "\tvirtual int" in line:
|
||||
processFunction(line)
|
||||
|
||||
fcpp.close()
|
||||
ftask.close()
|
||||
fprocess.close()
|
||||
ffunction.close()
|
||||
fswitch.close()
|
||||
fdefine.close()
|
||||
fheaderprocess.close()
|
||||
fheaderon.close()
|
||||
fheaderfunction.close()
|
||||
fwrap.close()
|
177
vn.ctp/vnctpmd/test/mdtest.py
Normal file
177
vn.ctp/vnctpmd/test/mdtest.py
Normal file
@ -0,0 +1,177 @@
|
||||
# encoding: UTF-8
|
||||
|
||||
import sys
|
||||
from time import sleep
|
||||
|
||||
from PyQt4 import QtGui
|
||||
|
||||
from vnctpmd import *
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def print_dict(d):
|
||||
"""按照键值打印一个字典"""
|
||||
for key,value in d.items():
|
||||
print key + ':' + str(value)
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def simple_log(func):
|
||||
"""简单装饰器用于输出函数名"""
|
||||
def wrapper(*args, **kw):
|
||||
print ""
|
||||
print str(func.__name__)
|
||||
return func(*args, **kw)
|
||||
return wrapper
|
||||
|
||||
|
||||
########################################################################
|
||||
class TestMdApi(MdApi):
|
||||
"""测试用实例"""
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def __init__(self):
|
||||
"""Constructor"""
|
||||
super(TestMdApi, self).__init__()
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@simple_log
|
||||
def onFrontConnected(self):
|
||||
"""服务器连接"""
|
||||
pass
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@simple_log
|
||||
def onFrontDisconnected(self, n):
|
||||
"""服务器断开"""
|
||||
print n
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@simple_log
|
||||
def onHeartBeatWarning(self, n):
|
||||
"""心跳报警"""
|
||||
print n
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@simple_log
|
||||
def onRspError(self, error, n, last):
|
||||
"""错误"""
|
||||
print_dict(error)
|
||||
|
||||
@simple_log
|
||||
#----------------------------------------------------------------------
|
||||
def onRspUserLogin(self, data, error, n, last):
|
||||
"""登陆回报"""
|
||||
print_dict(data)
|
||||
print_dict(error)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@simple_log
|
||||
def onRspUserLogout(self, data, error, n, last):
|
||||
"""登出回报"""
|
||||
print_dict(data)
|
||||
print_dict(error)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@simple_log
|
||||
def onRspSubMarketData(self, data, error, n, last):
|
||||
"""订阅合约回报"""
|
||||
print_dict(data)
|
||||
print_dict(error)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@simple_log
|
||||
def onRspUnSubMarketData(self, data, error, n, last):
|
||||
"""退订合约回报"""
|
||||
print_dict(data)
|
||||
print_dict(error)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@simple_log
|
||||
def onRtnDepthMarketData(self, data):
|
||||
"""行情推送"""
|
||||
print_dict(data)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@simple_log
|
||||
def onRspSubForQuoteRsp(self, data, error, n, last):
|
||||
"""订阅合约回报"""
|
||||
print_dict(data)
|
||||
print_dict(error)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@simple_log
|
||||
def onRspUnSubForQuoteRsp(self, data, error, n, last):
|
||||
"""退订合约回报"""
|
||||
print_dict(data)
|
||||
print_dict(error)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@simple_log
|
||||
def onRtnForQuoteRsp(self, data):
|
||||
"""行情推送"""
|
||||
print_dict(data)
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def main():
|
||||
"""主测试函数,出现堵塞时可以考虑使用sleep"""
|
||||
reqid = 0
|
||||
|
||||
# 创建Qt应用对象,用于事件循环
|
||||
app = QtGui.QApplication(sys.argv)
|
||||
|
||||
# 创建API对象
|
||||
api = TestMdApi()
|
||||
|
||||
# 在C++环境中创建MdApi对象,传入参数是希望用来保存.con文件的地址
|
||||
api.createFtdcMdApi('')
|
||||
|
||||
# 注册前置机地址
|
||||
api.registerFront("tcp://qqfz-md1.ctp.shcifco.com:32313")
|
||||
|
||||
# 初始化api,连接前置机
|
||||
api.init()
|
||||
sleep(0.5)
|
||||
|
||||
# 登陆
|
||||
loginReq = {} # 创建一个空字典
|
||||
loginReq['UserID'] = '' # 参数作为字典键值的方式传入
|
||||
loginReq['Password'] = '' # 键名和C++中的结构体成员名对应
|
||||
loginReq['BrokerID'] = ''
|
||||
reqid = reqid + 1 # 请求数必须保持唯一性
|
||||
i = api.reqUserLogin(loginReq, 1)
|
||||
sleep(0.5)
|
||||
|
||||
## 登出,测试出错(无此功能)
|
||||
#reqid = reqid + 1
|
||||
#i = api.reqUserLogout({}, 1)
|
||||
#sleep(0.5)
|
||||
|
||||
## 安全退出,测试通过
|
||||
#i = api.exit()
|
||||
|
||||
## 获取交易日,目前输出为空
|
||||
#day = api.getTradingDay()
|
||||
#print 'Trading Day is:' + str(day)
|
||||
#sleep(0.5)
|
||||
|
||||
## 订阅合约,测试通过
|
||||
#i = api.subscribeMarketData('IF1505')
|
||||
|
||||
## 退订合约,测试通过
|
||||
#i = api.unSubscribeMarketData('IF1505')
|
||||
|
||||
# 订阅询价,测试通过
|
||||
i = api.subscribeForQuoteRsp('IO1504-C-3900')
|
||||
|
||||
# 退订询价,测试通过
|
||||
i = api.unSubscribeForQuoteRsp('IO1504-C-3900')
|
||||
|
||||
# 连续运行,用于输出行情
|
||||
app.exec_()
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
BIN
vn.ctp/vnctpmd/test/thostmduserapi.dll
Normal file
BIN
vn.ctp/vnctpmd/test/thostmduserapi.dll
Normal file
Binary file not shown.
BIN
vn.ctp/vnctpmd/test/vnctpmd.pyd
Normal file
BIN
vn.ctp/vnctpmd/test/vnctpmd.pyd
Normal file
Binary file not shown.
32
vn.ctp/vnctpmd/vnctpmd/ReadMe.txt
Normal file
32
vn.ctp/vnctpmd/vnctpmd/ReadMe.txt
Normal file
@ -0,0 +1,32 @@
|
||||
========================================================================
|
||||
动态链接库:vnctpmd 项目概述
|
||||
========================================================================
|
||||
|
||||
应用程序向导已为您创建了此 vnctpmd DLL。
|
||||
|
||||
本文件概要介绍组成 vnctpmd 应用程序的每个文件的内容。
|
||||
|
||||
|
||||
vnctpmd.vcxproj
|
||||
这是使用应用程序向导生成的 VC++ 项目的主项目文件,其中包含生成该文件的 Visual C++ 的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。
|
||||
|
||||
vnctpmd.vcxproj.filters
|
||||
这是使用“应用程序向导”生成的 VC++ 项目筛选器文件。它包含有关项目文件与筛选器之间的关联信息。在 IDE 中,通过这种关联,在特定节点下以分组形式显示具有相似扩展名的文件。例如,“.cpp”文件与“源文件”筛选器关联。
|
||||
|
||||
vnctpmd.cpp
|
||||
这是主 DLL 源文件。
|
||||
|
||||
此 DLL 在创建时不导出任何符号。因此,生成时不会产生 .lib 文件。如果希望此项目成为其他某个项目的项目依赖项,则需要添加代码以从 DLL 导出某些符号,以便产生一个导出库,或者,也可以在项目“属性页”对话框中的“链接器”文件夹中,将“常规”属性页上的“忽略输入库”属性设置为“是”。
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
其他标准文件:
|
||||
|
||||
StdAfx.h, StdAfx.cpp
|
||||
这些文件用于生成名为 vnctpmd.pch 的预编译头 (PCH) 文件和名为 StdAfx.obj 的预编译类型文件。
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
其他注释:
|
||||
|
||||
应用程序向导使用“TODO:”注释来指示应添加或自定义的源代码部分。
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
19
vn.ctp/vnctpmd/vnctpmd/dllmain.cpp
Normal file
19
vn.ctp/vnctpmd/vnctpmd/dllmain.cpp
Normal file
@ -0,0 +1,19 @@
|
||||
// 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;
|
||||
}
|
||||
|
8
vn.ctp/vnctpmd/vnctpmd/stdafx.cpp
Normal file
8
vn.ctp/vnctpmd/vnctpmd/stdafx.cpp
Normal file
@ -0,0 +1,8 @@
|
||||
// stdafx.cpp : 只包括标准包含文件的源文件
|
||||
// vnctpmd.pch 将作为预编译头
|
||||
// stdafx.obj 将包含预编译类型信息
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
// TODO: 在 STDAFX.H 中
|
||||
// 引用任何所需的附加头文件,而不是在此文件中引用
|
16
vn.ctp/vnctpmd/vnctpmd/stdafx.h
Normal file
16
vn.ctp/vnctpmd/vnctpmd/stdafx.h
Normal file
@ -0,0 +1,16 @@
|
||||
// stdafx.h : 标准系统包含文件的包含文件,
|
||||
// 或是经常使用但不常更改的
|
||||
// 特定于项目的包含文件
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "targetver.h"
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN // 从 Windows 头文件中排除极少使用的信息
|
||||
// Windows 头文件:
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
|
||||
// TODO: 在此处引用程序需要的其他头文件
|
8
vn.ctp/vnctpmd/vnctpmd/targetver.h
Normal file
8
vn.ctp/vnctpmd/vnctpmd/targetver.h
Normal file
@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
// 包括 SDKDDKVer.h 将定义可用的最高版本的 Windows 平台。
|
||||
|
||||
// 如果要为以前的 Windows 平台生成应用程序,请包括 WinSDKVer.h,并将
|
||||
// WIN32_WINNT 宏设置为要支持的平台,然后再包括 SDKDDKVer.h。
|
||||
|
||||
#include <SDKDDKVer.h>
|
833
vn.ctp/vnctpmd/vnctpmd/vnctpmd.cpp
Normal file
833
vn.ctp/vnctpmd/vnctpmd/vnctpmd.cpp
Normal file
@ -0,0 +1,833 @@
|
||||
// vnctpmd.cpp : 定义 DLL 应用程序的导出函数。
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "vnctpmd.h"
|
||||
|
||||
///-------------------------------------------------------------------------------------
|
||||
///从Python对象到C++类型转换用的函数
|
||||
///-------------------------------------------------------------------------------------
|
||||
|
||||
void getInt(dict d, string key, int *value)
|
||||
{
|
||||
if (d.has_key(key)) //检查字典中是否存在该键值
|
||||
{
|
||||
object o = d[key]; //获取该键值
|
||||
extract<int> x(o); //创建提取器
|
||||
if (x.check()) //如果可以提取
|
||||
{
|
||||
*value = x(); //对目标整数指针赋值
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void getDouble(dict d, string key, double *value)
|
||||
{
|
||||
if (d.has_key(key))
|
||||
{
|
||||
object o = d[key];
|
||||
extract<double> x(o);
|
||||
if (x.check())
|
||||
{
|
||||
*value = x();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void getChar(dict d, string key, char *value)
|
||||
{
|
||||
if (d.has_key(key))
|
||||
{
|
||||
object o = d[key];
|
||||
extract<string> x(o);
|
||||
if (x.check())
|
||||
{
|
||||
string s = x();
|
||||
const char *buffer = s.c_str();
|
||||
//对字符串指针赋值必须使用strcpy_s, vs2013使用strcpy编译通不过
|
||||
//+1应该是因为C++字符串的结尾符号?不是特别确定,不加这个1会出错
|
||||
strcpy_s(value, strlen(buffer) + 1, buffer);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
///-------------------------------------------------------------------------------------
|
||||
///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;
|
||||
task.task_data = *pRspUserLogin;
|
||||
if (pRspInfo)
|
||||
{
|
||||
task.task_error = *pRspInfo;
|
||||
}
|
||||
else
|
||||
{
|
||||
CThostFtdcRspInfoField empty_error = CThostFtdcRspInfoField();
|
||||
memset(&empty_error, 0, sizeof(empty_error));
|
||||
task.task_error = empty_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;
|
||||
task.task_data = *pUserLogout;
|
||||
if (pRspInfo)
|
||||
{
|
||||
task.task_error = *pRspInfo;
|
||||
}
|
||||
else
|
||||
{
|
||||
CThostFtdcRspInfoField empty_error = CThostFtdcRspInfoField();
|
||||
memset(&empty_error, 0, sizeof(empty_error));
|
||||
task.task_error = empty_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)
|
||||
{
|
||||
task.task_error = *pRspInfo;
|
||||
}
|
||||
else
|
||||
{
|
||||
CThostFtdcRspInfoField empty_error = CThostFtdcRspInfoField();
|
||||
memset(&empty_error, 0, sizeof(empty_error));
|
||||
task.task_error = empty_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;
|
||||
task.task_data = *pSpecificInstrument;
|
||||
if (pRspInfo)
|
||||
{
|
||||
task.task_error = *pRspInfo;
|
||||
}
|
||||
else
|
||||
{
|
||||
CThostFtdcRspInfoField empty_error = CThostFtdcRspInfoField();
|
||||
memset(&empty_error, 0, sizeof(empty_error));
|
||||
task.task_error = empty_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;
|
||||
task.task_data = *pSpecificInstrument;
|
||||
if (pRspInfo)
|
||||
{
|
||||
task.task_error = *pRspInfo;
|
||||
}
|
||||
else
|
||||
{
|
||||
CThostFtdcRspInfoField empty_error = CThostFtdcRspInfoField();
|
||||
memset(&empty_error, 0, sizeof(empty_error));
|
||||
task.task_error = empty_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;
|
||||
task.task_data = *pSpecificInstrument;
|
||||
if (pRspInfo)
|
||||
{
|
||||
task.task_error = *pRspInfo;
|
||||
}
|
||||
else
|
||||
{
|
||||
CThostFtdcRspInfoField empty_error = CThostFtdcRspInfoField();
|
||||
memset(&empty_error, 0, sizeof(empty_error));
|
||||
task.task_error = empty_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;
|
||||
task.task_data = *pSpecificInstrument;
|
||||
if (pRspInfo)
|
||||
{
|
||||
task.task_error = *pRspInfo;
|
||||
}
|
||||
else
|
||||
{
|
||||
CThostFtdcRspInfoField empty_error = CThostFtdcRspInfoField();
|
||||
memset(&empty_error, 0, sizeof(empty_error));
|
||||
task.task_error = empty_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;
|
||||
task.task_data = *pDepthMarketData;
|
||||
this->task_queue.push(task);
|
||||
};
|
||||
|
||||
void MdApi::OnRtnForQuoteRsp(CThostFtdcForQuoteRspField *pForQuoteRsp)
|
||||
{
|
||||
Task task = Task();
|
||||
task.task_name = ONRTNFORQUOTERSP;
|
||||
task.task_data = *pForQuoteRsp;
|
||||
this->task_queue.push(task);
|
||||
};
|
||||
|
||||
|
||||
|
||||
///-------------------------------------------------------------------------------------
|
||||
///工作线程从队列中取出数据,转化为python对象后,进行推送
|
||||
///-------------------------------------------------------------------------------------
|
||||
|
||||
void MdApi::processTask()
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
Task task = this->task_queue.wait_and_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;
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
void MdApi::processFrontConnected(Task task)
|
||||
{
|
||||
this->onFrontConnected();
|
||||
};
|
||||
|
||||
void MdApi::processFrontDisconnected(Task task)
|
||||
{
|
||||
this->onFrontDisconnected(task.task_id);
|
||||
};
|
||||
|
||||
void MdApi::processHeartBeatWarning(Task task)
|
||||
{
|
||||
this->onHeartBeatWarning(task.task_id);
|
||||
};
|
||||
|
||||
void MdApi::processRspUserLogin(Task task)
|
||||
{
|
||||
CThostFtdcRspUserLoginField task_data = any_cast<CThostFtdcRspUserLoginField>(task.task_data);
|
||||
dict data;
|
||||
data["CZCETime"] = task_data.CZCETime;
|
||||
data["SHFETime"] = task_data.SHFETime;
|
||||
data["MaxOrderRef"] = task_data.MaxOrderRef;
|
||||
data["INETime"] = task_data.INETime;
|
||||
data["UserID"] = task_data.UserID;
|
||||
data["TradingDay"] = task_data.TradingDay;
|
||||
data["SessionID"] = task_data.SessionID;
|
||||
data["SystemName"] = task_data.SystemName;
|
||||
data["FrontID"] = task_data.FrontID;
|
||||
data["FFEXTime"] = task_data.FFEXTime;
|
||||
data["BrokerID"] = task_data.BrokerID;
|
||||
data["DCETime"] = task_data.DCETime;
|
||||
data["LoginTime"] = task_data.LoginTime;
|
||||
|
||||
CThostFtdcRspInfoField task_error = any_cast<CThostFtdcRspInfoField>(task.task_error);
|
||||
dict error;
|
||||
error["ErrorMsg"] = task_error.ErrorMsg;
|
||||
error["ErrorID"] = task_error.ErrorID;
|
||||
|
||||
this->onRspUserLogin(data, error, task.task_id, task.task_last);
|
||||
};
|
||||
|
||||
void MdApi::processRspUserLogout(Task task)
|
||||
{
|
||||
CThostFtdcUserLogoutField task_data = any_cast<CThostFtdcUserLogoutField>(task.task_data);
|
||||
dict data;
|
||||
data["UserID"] = task_data.UserID;
|
||||
data["BrokerID"] = task_data.BrokerID;
|
||||
|
||||
CThostFtdcRspInfoField task_error = any_cast<CThostFtdcRspInfoField>(task.task_error);
|
||||
dict error;
|
||||
error["ErrorMsg"] = task_error.ErrorMsg;
|
||||
error["ErrorID"] = task_error.ErrorID;
|
||||
|
||||
this->onRspUserLogout(data, error, task.task_id, task.task_last);
|
||||
};
|
||||
|
||||
void MdApi::processRspError(Task task)
|
||||
{
|
||||
CThostFtdcRspInfoField task_error = any_cast<CThostFtdcRspInfoField>(task.task_error);
|
||||
dict error;
|
||||
error["ErrorMsg"] = task_error.ErrorMsg;
|
||||
error["ErrorID"] = task_error.ErrorID;
|
||||
|
||||
this->onRspError(error, task.task_id, task.task_last);
|
||||
};
|
||||
|
||||
void MdApi::processRspSubMarketData(Task task)
|
||||
{
|
||||
CThostFtdcSpecificInstrumentField task_data = any_cast<CThostFtdcSpecificInstrumentField>(task.task_data);
|
||||
dict data;
|
||||
data["InstrumentID"] = task_data.InstrumentID;
|
||||
|
||||
CThostFtdcRspInfoField task_error = any_cast<CThostFtdcRspInfoField>(task.task_error);
|
||||
dict error;
|
||||
error["ErrorMsg"] = task_error.ErrorMsg;
|
||||
error["ErrorID"] = task_error.ErrorID;
|
||||
|
||||
this->onRspSubMarketData(data, error, task.task_id, task.task_last);
|
||||
};
|
||||
|
||||
void MdApi::processRspUnSubMarketData(Task task)
|
||||
{
|
||||
CThostFtdcSpecificInstrumentField task_data = any_cast<CThostFtdcSpecificInstrumentField>(task.task_data);
|
||||
dict data;
|
||||
data["InstrumentID"] = task_data.InstrumentID;
|
||||
|
||||
CThostFtdcRspInfoField task_error = any_cast<CThostFtdcRspInfoField>(task.task_error);
|
||||
dict error;
|
||||
error["ErrorMsg"] = task_error.ErrorMsg;
|
||||
error["ErrorID"] = task_error.ErrorID;
|
||||
|
||||
this->onRspUnSubMarketData(data, error, task.task_id, task.task_last);
|
||||
};
|
||||
|
||||
void MdApi::processRspSubForQuoteRsp(Task task)
|
||||
{
|
||||
CThostFtdcSpecificInstrumentField task_data = any_cast<CThostFtdcSpecificInstrumentField>(task.task_data);
|
||||
dict data;
|
||||
data["InstrumentID"] = task_data.InstrumentID;
|
||||
|
||||
CThostFtdcRspInfoField task_error = any_cast<CThostFtdcRspInfoField>(task.task_error);
|
||||
dict error;
|
||||
error["ErrorMsg"] = task_error.ErrorMsg;
|
||||
error["ErrorID"] = task_error.ErrorID;
|
||||
|
||||
this->onRspSubForQuoteRsp(data, error, task.task_id, task.task_last);
|
||||
};
|
||||
|
||||
void MdApi::processRspUnSubForQuoteRsp(Task task)
|
||||
{
|
||||
CThostFtdcSpecificInstrumentField task_data = any_cast<CThostFtdcSpecificInstrumentField>(task.task_data);
|
||||
dict data;
|
||||
data["InstrumentID"] = task_data.InstrumentID;
|
||||
|
||||
CThostFtdcRspInfoField task_error = any_cast<CThostFtdcRspInfoField>(task.task_error);
|
||||
dict error;
|
||||
error["ErrorMsg"] = task_error.ErrorMsg;
|
||||
error["ErrorID"] = task_error.ErrorID;
|
||||
|
||||
this->onRspUnSubForQuoteRsp(data, error, task.task_id, task.task_last);
|
||||
};
|
||||
|
||||
void MdApi::processRtnDepthMarketData(Task task)
|
||||
{
|
||||
CThostFtdcDepthMarketDataField task_data = any_cast<CThostFtdcDepthMarketDataField>(task.task_data);
|
||||
dict data;
|
||||
data["HighestPrice"] = task_data.HighestPrice;
|
||||
data["BidPrice5"] = task_data.BidPrice5;
|
||||
data["BidPrice4"] = task_data.BidPrice4;
|
||||
data["BidPrice1"] = task_data.BidPrice1;
|
||||
data["BidPrice3"] = task_data.BidPrice3;
|
||||
data["BidPrice2"] = task_data.BidPrice2;
|
||||
data["LowerLimitPrice"] = task_data.LowerLimitPrice;
|
||||
data["OpenPrice"] = task_data.OpenPrice;
|
||||
data["AskPrice5"] = task_data.AskPrice5;
|
||||
data["AskPrice4"] = task_data.AskPrice4;
|
||||
data["AskPrice3"] = task_data.AskPrice3;
|
||||
data["PreClosePrice"] = task_data.PreClosePrice;
|
||||
data["AskPrice1"] = task_data.AskPrice1;
|
||||
data["PreSettlementPrice"] = task_data.PreSettlementPrice;
|
||||
data["AskVolume1"] = task_data.AskVolume1;
|
||||
data["UpdateTime"] = task_data.UpdateTime;
|
||||
data["UpdateMillisec"] = task_data.UpdateMillisec;
|
||||
data["AveragePrice"] = task_data.AveragePrice;
|
||||
data["BidVolume5"] = task_data.BidVolume5;
|
||||
data["BidVolume4"] = task_data.BidVolume4;
|
||||
data["BidVolume3"] = task_data.BidVolume3;
|
||||
data["BidVolume2"] = task_data.BidVolume2;
|
||||
data["PreOpenInterest"] = task_data.PreOpenInterest;
|
||||
data["AskPrice2"] = task_data.AskPrice2;
|
||||
data["Volume"] = task_data.Volume;
|
||||
data["AskVolume3"] = task_data.AskVolume3;
|
||||
data["AskVolume2"] = task_data.AskVolume2;
|
||||
data["AskVolume5"] = task_data.AskVolume5;
|
||||
data["AskVolume4"] = task_data.AskVolume4;
|
||||
data["UpperLimitPrice"] = task_data.UpperLimitPrice;
|
||||
data["BidVolume1"] = task_data.BidVolume1;
|
||||
data["InstrumentID"] = task_data.InstrumentID;
|
||||
data["ClosePrice"] = task_data.ClosePrice;
|
||||
data["ExchangeID"] = task_data.ExchangeID;
|
||||
data["TradingDay"] = task_data.TradingDay;
|
||||
data["PreDelta"] = task_data.PreDelta;
|
||||
data["OpenInterest"] = task_data.OpenInterest;
|
||||
data["CurrDelta"] = task_data.CurrDelta;
|
||||
data["Turnover"] = task_data.Turnover;
|
||||
data["LastPrice"] = task_data.LastPrice;
|
||||
data["SettlementPrice"] = task_data.SettlementPrice;
|
||||
data["ExchangeInstID"] = task_data.ExchangeInstID;
|
||||
data["LowestPrice"] = task_data.LowestPrice;
|
||||
data["ActionDay"] = task_data.ActionDay;
|
||||
|
||||
this->onRtnDepthMarketData(data);
|
||||
};
|
||||
|
||||
void MdApi::processRtnForQuoteRsp(Task task)
|
||||
{
|
||||
CThostFtdcForQuoteRspField task_data = any_cast<CThostFtdcForQuoteRspField>(task.task_data);
|
||||
dict data;
|
||||
data["InstrumentID"] = task_data.InstrumentID;
|
||||
data["TradingDay"] = task_data.TradingDay;
|
||||
data["ForQuoteTime"] = task_data.ForQuoteTime;
|
||||
data["ForQuoteSysID"] = task_data.ForQuoteSysID;
|
||||
data["ActionDay"] = task_data.ActionDay;
|
||||
|
||||
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->api->Init();
|
||||
};
|
||||
|
||||
int MdApi::join()
|
||||
{
|
||||
int i = this->api->Join();
|
||||
return i;
|
||||
};
|
||||
|
||||
int MdApi::exit()
|
||||
{
|
||||
//该函数在原生API里没有,用于安全退出API用,原生的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(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcReqUserLoginField myreq = CThostFtdcReqUserLoginField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "MacAddress", myreq.MacAddress);
|
||||
getChar(req, "UserProductInfo", myreq.UserProductInfo);
|
||||
getChar(req, "UserID", myreq.UserID);
|
||||
getChar(req, "TradingDay", myreq.TradingDay);
|
||||
getChar(req, "InterfaceProductInfo", myreq.InterfaceProductInfo);
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
getChar(req, "ClientIPAddress", myreq.ClientIPAddress);
|
||||
getChar(req, "OneTimePassword", myreq.OneTimePassword);
|
||||
getChar(req, "ProtocolInfo", myreq.ProtocolInfo);
|
||||
getChar(req, "Password", myreq.Password);
|
||||
int i = this->api->ReqUserLogin(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int MdApi::reqUserLogout(dict req, int nRequestID)
|
||||
{
|
||||
CThostFtdcUserLogoutField myreq = CThostFtdcUserLogoutField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "UserID", myreq.UserID);
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
int i = this->api->ReqUserLogout(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
|
||||
|
||||
///-------------------------------------------------------------------------------------
|
||||
///Boost.Python封装
|
||||
///-------------------------------------------------------------------------------------
|
||||
|
||||
struct MdApiWrap : MdApi, wrapper < MdApi >
|
||||
{
|
||||
virtual void onFrontConnected()
|
||||
{
|
||||
//在向python环境中调用回调函数推送数据前,需要先获取全局锁GIL,防止解释器崩溃
|
||||
PyLock lock;
|
||||
|
||||
//以下的try...catch...可以实现捕捉python环境中错误的功能,防止C++直接出现原因未知的崩溃
|
||||
try
|
||||
{
|
||||
this->get_override("onFrontConnected")();
|
||||
}
|
||||
catch (error_already_set const &)
|
||||
{
|
||||
PyErr_Print();
|
||||
}
|
||||
};
|
||||
|
||||
virtual void onFrontDisconnected(int i)
|
||||
{
|
||||
PyLock lock;
|
||||
|
||||
try
|
||||
{
|
||||
this->get_override("onFrontDisconnected")(i);
|
||||
}
|
||||
catch (error_already_set const &)
|
||||
{
|
||||
PyErr_Print();
|
||||
}
|
||||
};
|
||||
|
||||
virtual void onHeartBeatWarning(int i)
|
||||
{
|
||||
PyLock lock;
|
||||
|
||||
try
|
||||
{
|
||||
this->get_override("onHeartBeatWarning")(i);
|
||||
}
|
||||
catch (error_already_set const &)
|
||||
{
|
||||
PyErr_Print();
|
||||
}
|
||||
};
|
||||
|
||||
virtual void onRspError(dict data, int id, bool last)
|
||||
{
|
||||
PyLock lock;
|
||||
|
||||
try
|
||||
{
|
||||
this->get_override("onRspError")(data, id, last);
|
||||
}
|
||||
catch (error_already_set const &)
|
||||
{
|
||||
PyErr_Print();
|
||||
}
|
||||
};
|
||||
|
||||
virtual void onRspUserLogin(dict data, dict error, int id, bool last)
|
||||
{
|
||||
PyLock lock;
|
||||
|
||||
try
|
||||
{
|
||||
this->get_override("onRspUserLogin")(data, error, id, last);
|
||||
}
|
||||
catch (error_already_set const &)
|
||||
{
|
||||
PyErr_Print();
|
||||
}
|
||||
};
|
||||
|
||||
virtual void onRspUserLogout(dict data, dict error, int id, bool last)
|
||||
{
|
||||
PyLock lock;
|
||||
|
||||
try
|
||||
{
|
||||
this->get_override("onRspUserLogout")(data, error, id, last);
|
||||
}
|
||||
catch (error_already_set const &)
|
||||
{
|
||||
PyErr_Print();
|
||||
}
|
||||
};
|
||||
|
||||
virtual void onRspSubMarketData(dict data, dict error, int id, bool last)
|
||||
{
|
||||
PyLock lock;
|
||||
|
||||
try
|
||||
{
|
||||
this->get_override("onRspSubMarketData")(data, error, id, last);
|
||||
}
|
||||
catch (error_already_set const &)
|
||||
{
|
||||
PyErr_Print();
|
||||
}
|
||||
};
|
||||
|
||||
virtual void onRspUnSubMarketData(dict data, dict error, int id, bool last)
|
||||
{
|
||||
PyLock lock;
|
||||
|
||||
try
|
||||
{
|
||||
this->get_override("onRspUnSubMarketData")(data, error, id, last);
|
||||
}
|
||||
catch (error_already_set const &)
|
||||
{
|
||||
PyErr_Print();
|
||||
}
|
||||
};
|
||||
|
||||
virtual void onRspSubForQuoteRsp(dict data, dict error, int id, bool last)
|
||||
{
|
||||
PyLock lock;
|
||||
|
||||
try
|
||||
{
|
||||
this->get_override("onRspSubForQuoteRsp")(data, error, id, last);
|
||||
}
|
||||
catch (error_already_set const &)
|
||||
{
|
||||
PyErr_Print();
|
||||
}
|
||||
};
|
||||
|
||||
virtual void onRspUnSubForQuoteRsp(dict data, dict error, int id, bool last)
|
||||
{
|
||||
PyLock lock;
|
||||
|
||||
try
|
||||
{
|
||||
this->get_override("onRspUnSubForQuoteRsp")(data, error, id, last);
|
||||
}
|
||||
catch (error_already_set const &)
|
||||
{
|
||||
PyErr_Print();
|
||||
}
|
||||
};
|
||||
|
||||
virtual void onRtnDepthMarketData(dict data)
|
||||
{
|
||||
PyLock lock;
|
||||
|
||||
try
|
||||
{
|
||||
this->get_override("onRtnDepthMarketData")(data);
|
||||
}
|
||||
catch (error_already_set const &)
|
||||
{
|
||||
PyErr_Print();
|
||||
}
|
||||
};
|
||||
|
||||
virtual void onRtnForQuoteRsp(dict data)
|
||||
{
|
||||
PyLock lock;
|
||||
|
||||
try
|
||||
{
|
||||
this->get_override("onRtnForQuoteRsp")(data);
|
||||
}
|
||||
catch (error_already_set const &)
|
||||
{
|
||||
PyErr_Print();
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
BOOST_PYTHON_MODULE(vnctpmd)
|
||||
{
|
||||
PyEval_InitThreads(); //导入时运行,保证先创建GIL
|
||||
|
||||
class_<MdApiWrap, boost::noncopyable>("MdApi")
|
||||
.def("createFtdcMdApi", &MdApiWrap::createFtdcMdApi)
|
||||
.def("release", &MdApiWrap::release)
|
||||
.def("init", &MdApiWrap::init)
|
||||
.def("join", &MdApiWrap::join)
|
||||
.def("exit", &MdApiWrap::exit)
|
||||
.def("getTradingDay", &MdApiWrap::getTradingDay)
|
||||
.def("registerFront", &MdApiWrap::registerFront)
|
||||
.def("subscribeMarketData", &MdApiWrap::subscribeMarketData)
|
||||
.def("unSubscribeMarketData", &MdApiWrap::unSubscribeMarketData)
|
||||
.def("subscribeForQuoteRsp", &MdApiWrap::subscribeForQuoteRsp)
|
||||
.def("unSubscribeForQuoteRsp", &MdApiWrap::unSubscribeForQuoteRsp)
|
||||
.def("reqUserLogin", &MdApiWrap::reqUserLogin)
|
||||
.def("reqUserLogout", &MdApiWrap::reqUserLogout)
|
||||
|
||||
.def("onFrontConnected", pure_virtual(&MdApiWrap::onFrontConnected))
|
||||
.def("onFrontDisconnected", pure_virtual(&MdApiWrap::onFrontDisconnected))
|
||||
.def("onHeartBeatWarning", pure_virtual(&MdApiWrap::onHeartBeatWarning))
|
||||
.def("onRspError", pure_virtual(&MdApiWrap::onRspError))
|
||||
.def("onRspUserLogin", pure_virtual(&MdApiWrap::onRspUserLogin))
|
||||
.def("onRspUserLogout", pure_virtual(&MdApiWrap::onRspUserLogout))
|
||||
.def("onRspSubMarketData", pure_virtual(&MdApiWrap::onRspSubMarketData))
|
||||
.def("onRspUnSubMarketData", pure_virtual(&MdApiWrap::onRspUnSubMarketData))
|
||||
.def("onRtnDepthMarketData", pure_virtual(&MdApiWrap::onRtnDepthMarketData))
|
||||
.def("onRspSubForQuoteRsp", pure_virtual(&MdApiWrap::onRspSubForQuoteRsp))
|
||||
.def("onRspUnSubForQuoteRsp", pure_virtual(&MdApiWrap::onRspUnSubForQuoteRsp))
|
||||
.def("onRtnForQuoteRsp", pure_virtual(&MdApiWrap::onRtnForQuoteRsp))
|
||||
;
|
||||
};
|
301
vn.ctp/vnctpmd/vnctpmd/vnctpmd.h
Normal file
301
vn.ctp/vnctpmd/vnctpmd/vnctpmd.h
Normal file
@ -0,0 +1,301 @@
|
||||
//说明部分
|
||||
|
||||
//系统
|
||||
#include "stdafx.h"
|
||||
#include <string>
|
||||
#include <queue>
|
||||
|
||||
//Boost
|
||||
#define BOOST_PYTHON_STATIC_LIB
|
||||
#include <boost/python/module.hpp> //python封装
|
||||
#include <boost/python/def.hpp> //python封装
|
||||
#include <boost/python/dict.hpp> //python封装
|
||||
#include <boost/python/object.hpp> //python封装
|
||||
#include <boost/python.hpp> //python封装
|
||||
#include <boost/thread.hpp> //任务队列的线程功能
|
||||
#include <boost/bind.hpp> //任务队列的线程功能
|
||||
#include <boost/any.hpp> //任务队列的任务实现
|
||||
|
||||
//API
|
||||
#include "ThostFtdcMdApi.h"
|
||||
|
||||
//命名空间
|
||||
using namespace std;
|
||||
using namespace boost::python;
|
||||
using namespace boost;
|
||||
|
||||
//常量
|
||||
#define ONFRONTCONNECTED 1
|
||||
#define ONFRONTDISCONNECTED 2
|
||||
#define ONHEARTBEATWARNING 3
|
||||
#define ONRSPUSERLOGIN 4
|
||||
#define ONRSPUSERLOGOUT 5
|
||||
#define ONRSPERROR 6
|
||||
#define ONRSPSUBMARKETDATA 7
|
||||
#define ONRSPUNSUBMARKETDATA 8
|
||||
#define ONRSPSUBFORQUOTERSP 9
|
||||
#define ONRSPUNSUBFORQUOTERSP 10
|
||||
#define ONRTNDEPTHMARKETDATA 11
|
||||
#define ONRTNFORQUOTERSP 12
|
||||
|
||||
|
||||
|
||||
///-------------------------------------------------------------------------------------
|
||||
///API中的部分组件
|
||||
///-------------------------------------------------------------------------------------
|
||||
|
||||
//GIL全局锁简化获取用,
|
||||
//用于帮助C++线程获得GIL锁,从而防止python崩溃
|
||||
class PyLock
|
||||
{
|
||||
private:
|
||||
PyGILState_STATE gil_state;
|
||||
|
||||
public:
|
||||
//在某个函数方法中创建该对象时,获得GIL锁
|
||||
PyLock()
|
||||
{
|
||||
gil_state = PyGILState_Ensure();
|
||||
}
|
||||
|
||||
//在某个函数完成后销毁该对象时,解放GIL锁
|
||||
~PyLock()
|
||||
{
|
||||
PyGILState_Release(gil_state);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//任务结构体
|
||||
struct Task
|
||||
{
|
||||
int task_name; //回调函数名称对应的常量
|
||||
any task_data; //数据结构体
|
||||
any task_error; //错误结构体
|
||||
int task_id; //请求id
|
||||
bool task_last; //是否为最后返回
|
||||
};
|
||||
|
||||
|
||||
///线程安全的队列
|
||||
template<typename Data>
|
||||
|
||||
class ConcurrentQueue
|
||||
{
|
||||
private:
|
||||
queue<Data> the_queue; //标准库队列
|
||||
mutable mutex the_mutex; //boost互斥锁
|
||||
condition_variable the_condition_variable; //boost条件变量
|
||||
|
||||
public:
|
||||
|
||||
//存入新的任务
|
||||
void push(Data const& data)
|
||||
{
|
||||
mutex::scoped_lock lock(the_mutex); //获取互斥锁
|
||||
the_queue.push(data); //向队列中存入数据
|
||||
lock.unlock(); //释放锁
|
||||
the_condition_variable.notify_one(); //通知正在阻塞等待的线程
|
||||
}
|
||||
|
||||
//检查队列是否为空
|
||||
bool empty() const
|
||||
{
|
||||
mutex::scoped_lock lock(the_mutex);
|
||||
return the_queue.empty();
|
||||
}
|
||||
|
||||
//取出
|
||||
Data wait_and_pop()
|
||||
{
|
||||
mutex::scoped_lock lock(the_mutex);
|
||||
|
||||
while (the_queue.empty()) //当队列为空时
|
||||
{
|
||||
the_condition_variable.wait(lock); //等待条件变量通知
|
||||
}
|
||||
|
||||
Data popped_value = the_queue.front(); //获取队列中的最后一个任务
|
||||
the_queue.pop(); //删除该任务
|
||||
return popped_value; //返回该任务
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
//从字典中获取某个建值对应的整数,并赋值到请求结构体对象的值上
|
||||
void getInt(dict d, string key, int* value);
|
||||
|
||||
|
||||
//从字典中获取某个建值对应的浮点数,并赋值到请求结构体对象的值上
|
||||
void getDouble(dict d, string key, double* value);
|
||||
|
||||
|
||||
//从字典中获取某个建值对应的字符串,并赋值到请求结构体对象的值上
|
||||
void getChar(dict d, string key, char* value);
|
||||
|
||||
|
||||
|
||||
///-------------------------------------------------------------------------------------
|
||||
///C++ SPI的回调函数方法实现
|
||||
///-------------------------------------------------------------------------------------
|
||||
|
||||
//API的继承实现
|
||||
class MdApi : public CThostFtdcMdSpi
|
||||
{
|
||||
private:
|
||||
CThostFtdcMdApi* api; //API对象
|
||||
thread *task_thread; //工作线程指针(向python中推送数据)
|
||||
ConcurrentQueue<Task> task_queue; //任务队列
|
||||
|
||||
public:
|
||||
MdApi()
|
||||
{
|
||||
function0<void> f = boost::bind(&MdApi::processTask, this);
|
||||
thread t(f);
|
||||
this->task_thread = &t;
|
||||
};
|
||||
|
||||
~MdApi()
|
||||
{
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
//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 i){};
|
||||
|
||||
virtual void onHeartBeatWarning(int i){};
|
||||
|
||||
virtual void onRspUserLogin(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspUserLogout(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspError(dict data, int id, bool last) {};
|
||||
|
||||
virtual void onRspSubMarketData(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspUnSubMarketData(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspSubForQuoteRsp(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspUnSubForQuoteRsp(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRtnDepthMarketData(dict data) {};
|
||||
|
||||
virtual void onRtnForQuoteRsp(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(dict req, int nRequestID);
|
||||
|
||||
int reqUserLogout(dict req, int nRequestID);
|
||||
};
|
163
vn.ctp/vnctptd/test/tdtest.py
Normal file
163
vn.ctp/vnctptd/test/tdtest.py
Normal file
@ -0,0 +1,163 @@
|
||||
# encoding: UTF-8
|
||||
|
||||
import sys
|
||||
from time import sleep
|
||||
|
||||
from PyQt4 import QtGui
|
||||
|
||||
from vnctptd import *
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def print_dict(d):
|
||||
"""按照键值打印一个字典"""
|
||||
for key,value in d.items():
|
||||
print key + ':' + str(value)
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def simple_log(func):
|
||||
"""简单装饰器用于输出函数名"""
|
||||
def wrapper(*args, **kw):
|
||||
print ""
|
||||
print str(func.__name__)
|
||||
return func(*args, **kw)
|
||||
return wrapper
|
||||
|
||||
|
||||
########################################################################
|
||||
class TestTdApi(TdApi):
|
||||
"""测试用实例"""
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def __init__(self):
|
||||
"""Constructor"""
|
||||
super(TestTdApi, self).__init__()
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@simple_log
|
||||
def onFrontConnected(self):
|
||||
"""服务器连接"""
|
||||
pass
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@simple_log
|
||||
def onFrontDisconnected(self, n):
|
||||
"""服务器断开"""
|
||||
print n
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@simple_log
|
||||
def onHeartBeatWarning(self, n):
|
||||
"""心跳报警"""
|
||||
print n
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@simple_log
|
||||
def onRspError(self, error, n, last):
|
||||
"""错误"""
|
||||
print_dict(error)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@simple_log
|
||||
def onRspUserLogin(self, data, error, n, last):
|
||||
"""登陆回报"""
|
||||
print_dict(data)
|
||||
print_dict(error)
|
||||
self.brokerID = data['BrokerID']
|
||||
self.userID = data['UserID']
|
||||
self.frontID = data['FrontID']
|
||||
self.sessionID = data['SessionID']
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@simple_log
|
||||
def onRspUserLogout(self, data, error, n, last):
|
||||
"""登出回报"""
|
||||
print_dict(data)
|
||||
print_dict(error)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@simple_log
|
||||
def onRspQrySettlementInfo(self, data, error, n, last):
|
||||
"""查询结算信息回报"""
|
||||
print_dict(data)
|
||||
print_dict(error)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@simple_log
|
||||
def onRspSettlementInfoConfirm(self, data, error, n, last):
|
||||
"""确认结算信息回报"""
|
||||
print_dict(data)
|
||||
print_dict(error)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@simple_log
|
||||
def onRspQryInstrument(self, data, error, n, last):
|
||||
"""查询合约回报"""
|
||||
print_dict(data)
|
||||
print_dict(error)
|
||||
print n
|
||||
print last
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def main():
|
||||
"""主测试函数,出现堵塞时可以考虑使用sleep"""
|
||||
reqid = 0
|
||||
|
||||
# 创建Qt应用对象,用于事件循环
|
||||
app = QtGui.QApplication(sys.argv)
|
||||
|
||||
# 创建API对象,测试通过
|
||||
api = TestTdApi()
|
||||
|
||||
# 在C++环境中创建MdApi对象,传入参数是希望用来保存.con文件的地址,测试通过
|
||||
api.createFtdcTraderApi('')
|
||||
|
||||
# 设置数据流重传方式,测试通过
|
||||
api.subscribePrivateTopic(1)
|
||||
api.subscribePublicTopic(1)
|
||||
|
||||
# 注册前置机地址,测试通过
|
||||
api.registerFront("tcp://qqfz-front1.ctp.shcifco.com:32305")
|
||||
|
||||
# 初始化api,连接前置机,测试通过
|
||||
api.init()
|
||||
sleep(0.5)
|
||||
|
||||
# 登陆,测试通过
|
||||
loginReq = {} # 创建一个空字典
|
||||
loginReq['UserID'] = '' # 参数作为字典键值的方式传入
|
||||
loginReq['Password'] = '' # 键名和C++中的结构体成员名对应
|
||||
loginReq['BrokerID'] = ''
|
||||
reqid = reqid + 1 # 请求数必须保持唯一性
|
||||
i = api.reqUserLogin(loginReq, reqid)
|
||||
sleep(0.5)
|
||||
|
||||
## 查询合约, 测试通过
|
||||
#reqid = reqid + 1
|
||||
#i = api.reqQryInstrument({}, reqid)
|
||||
|
||||
## 查询结算, 测试通过
|
||||
#req = {}
|
||||
#req['BrokerID'] = api.brokerID
|
||||
#req['InvestorID'] = api.userID
|
||||
#reqid = reqid + 1
|
||||
#i = api.reqQrySettlementInfo(req, reqid)
|
||||
#sleep(0.5)
|
||||
|
||||
## 确认结算, 测试通过
|
||||
#req = {}
|
||||
#req['BrokerID'] = api.brokerID
|
||||
#req['InvestorID'] = api.userID
|
||||
#reqid = reqid + 1
|
||||
#i = api.reqSettlementInfoConfirm(req, reqid)
|
||||
#sleep(0.5)
|
||||
|
||||
|
||||
# 连续运行
|
||||
app.exec_()
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
BIN
vn.ctp/vnctptd/test/thosttraderapi.dll
Normal file
BIN
vn.ctp/vnctptd/test/thosttraderapi.dll
Normal file
Binary file not shown.
BIN
vn.ctp/vnctptd/test/vnctptd.pyd
Normal file
BIN
vn.ctp/vnctptd/test/vnctptd.pyd
Normal file
Binary file not shown.
32
vn.ctp/vnctptd/vnctptd/ReadMe.txt
Normal file
32
vn.ctp/vnctptd/vnctptd/ReadMe.txt
Normal file
@ -0,0 +1,32 @@
|
||||
========================================================================
|
||||
动态链接库:vnctptd 项目概述
|
||||
========================================================================
|
||||
|
||||
应用程序向导已为您创建了此 vnctptd DLL。
|
||||
|
||||
本文件概要介绍组成 vnctptd 应用程序的每个文件的内容。
|
||||
|
||||
|
||||
vnctptd.vcxproj
|
||||
这是使用应用程序向导生成的 VC++ 项目的主项目文件,其中包含生成该文件的 Visual C++ 的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。
|
||||
|
||||
vnctptd.vcxproj.filters
|
||||
这是使用“应用程序向导”生成的 VC++ 项目筛选器文件。它包含有关项目文件与筛选器之间的关联信息。在 IDE 中,通过这种关联,在特定节点下以分组形式显示具有相似扩展名的文件。例如,“.cpp”文件与“源文件”筛选器关联。
|
||||
|
||||
vnctptd.cpp
|
||||
这是主 DLL 源文件。
|
||||
|
||||
此 DLL 在创建时不导出任何符号。因此,生成时不会产生 .lib 文件。如果希望此项目成为其他某个项目的项目依赖项,则需要添加代码以从 DLL 导出某些符号,以便产生一个导出库,或者,也可以在项目“属性页”对话框中的“链接器”文件夹中,将“常规”属性页上的“忽略输入库”属性设置为“是”。
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
其他标准文件:
|
||||
|
||||
StdAfx.h, StdAfx.cpp
|
||||
这些文件用于生成名为 vnctptd.pch 的预编译头 (PCH) 文件和名为 StdAfx.obj 的预编译类型文件。
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
其他注释:
|
||||
|
||||
应用程序向导使用“TODO:”注释来指示应添加或自定义的源代码部分。
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
19
vn.ctp/vnctptd/vnctptd/dllmain.cpp
Normal file
19
vn.ctp/vnctptd/vnctptd/dllmain.cpp
Normal file
@ -0,0 +1,19 @@
|
||||
// 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;
|
||||
}
|
||||
|
8
vn.ctp/vnctptd/vnctptd/stdafx.cpp
Normal file
8
vn.ctp/vnctptd/vnctptd/stdafx.cpp
Normal file
@ -0,0 +1,8 @@
|
||||
// stdafx.cpp : 只包括标准包含文件的源文件
|
||||
// vnctptd.pch 将作为预编译头
|
||||
// stdafx.obj 将包含预编译类型信息
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
// TODO: 在 STDAFX.H 中
|
||||
// 引用任何所需的附加头文件,而不是在此文件中引用
|
16
vn.ctp/vnctptd/vnctptd/stdafx.h
Normal file
16
vn.ctp/vnctptd/vnctptd/stdafx.h
Normal file
@ -0,0 +1,16 @@
|
||||
// stdafx.h : 标准系统包含文件的包含文件,
|
||||
// 或是经常使用但不常更改的
|
||||
// 特定于项目的包含文件
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "targetver.h"
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN // 从 Windows 头文件中排除极少使用的信息
|
||||
// Windows 头文件:
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
|
||||
// TODO: 在此处引用程序需要的其他头文件
|
8
vn.ctp/vnctptd/vnctptd/targetver.h
Normal file
8
vn.ctp/vnctptd/vnctptd/targetver.h
Normal file
@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
// 包括 SDKDDKVer.h 将定义可用的最高版本的 Windows 平台。
|
||||
|
||||
// 如果要为以前的 Windows 平台生成应用程序,请包括 WinSDKVer.h,并将
|
||||
// WIN32_WINNT 宏设置为要支持的平台,然后再包括 SDKDDKVer.h。
|
||||
|
||||
#include <SDKDDKVer.h>
|
9220
vn.ctp/vnctptd/vnctptd/vnctptd.cpp
Normal file
9220
vn.ctp/vnctptd/vnctptd/vnctptd.cpp
Normal file
File diff suppressed because it is too large
Load Diff
1101
vn.ctp/vnctptd/vnctptd/vnctptd.h
Normal file
1101
vn.ctp/vnctptd/vnctptd/vnctptd.h
Normal file
File diff suppressed because it is too large
Load Diff
@ -398,6 +398,7 @@ public:
|
||||
|
||||
void processErrRtnFundInterTransfer(Task task);
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
//data:回调函数的数据字典
|
||||
//error:回调函数的错误字典
|
||||
|
Loading…
Reference in New Issue
Block a user