添加对LTS柜台L2行情API的支持
This commit is contained in:
parent
b6cd04bcb4
commit
fffdc06d92
BIN
vn.lts/ltsl2/L2mduserapi.dll
Normal file
BIN
vn.lts/ltsl2/L2mduserapi.dll
Normal file
Binary file not shown.
BIN
vn.lts/ltsl2/L2mduserapi.lib
Normal file
BIN
vn.lts/ltsl2/L2mduserapi.lib
Normal file
Binary file not shown.
BIN
vn.lts/ltsl2/L2mduserapi.so
Normal file
BIN
vn.lts/ltsl2/L2mduserapi.so
Normal file
Binary file not shown.
9
vn.lts/ltsl2/LTS_ns.h
Normal file
9
vn.lts/ltsl2/LTS_ns.h
Normal file
@ -0,0 +1,9 @@
|
||||
#ifndef _LTS_NAMESPACE_H
|
||||
#define _LTS_NAMESPACE_H
|
||||
|
||||
#define _LTS_NS_ _LTS_
|
||||
#define _LTS_NS_BEGIN_ namespace _LTS_{
|
||||
#define _LTS_NS_END_ }
|
||||
#define _USING_LTS_NS_ using namespace _LTS_;
|
||||
|
||||
#endif
|
150
vn.lts/ltsl2/SecurityFtdcL2MDUserApi.h
Normal file
150
vn.lts/ltsl2/SecurityFtdcL2MDUserApi.h
Normal file
@ -0,0 +1,150 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///@company shanghai liber information Technology Co.,Ltd
|
||||
///@file SecurityFtdcL2MDUserApi.h
|
||||
///@brief 定义客户端接口
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(SECURITY_L2MD_FTDCUSERAPI_H)
|
||||
#define SECURITY_L2MD_FTDCUSERAPI_H
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include "SecurityFtdcL2MDUserApiStruct.h"
|
||||
|
||||
_LTS_NS_BEGIN_
|
||||
#if defined(L2MD_USERAPI_IS_LIB) && defined(WINDOWS)
|
||||
#ifdef LIB_L2MD_USER_API_EXPORT
|
||||
#define L2MD_USER_API_EXPORT __declspec(dllexport)
|
||||
#else
|
||||
#define L2MD_USER_API_EXPORT __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define L2MD_USER_API_EXPORT
|
||||
#endif
|
||||
|
||||
class CSecurityFtdcL2MDUserSpi
|
||||
{
|
||||
public:
|
||||
///当客户端与交易后台建立起通信连接时(还未登录前),该方法被调用。
|
||||
virtual void OnFrontConnected(){};
|
||||
|
||||
///当客户端与交易后台通信连接断开时,该方法被调用。当发生这个情况后,API会自动重新连接,客户端可不做处理。
|
||||
///@param nReason 错误原因
|
||||
/// 0x1001 网络读失败
|
||||
/// 0x1002 网络写失败
|
||||
/// 0x2001 接收心跳超时
|
||||
/// 0x2002 发送心跳失败
|
||||
/// 0x2003 收到错误报文
|
||||
virtual void OnFrontDisconnected(int nReason){};
|
||||
|
||||
///心跳超时警告
|
||||
virtual void OnHeartBeatWarning(int nTimeLapse){};
|
||||
|
||||
///错误应答
|
||||
virtual void OnRspError(CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///登录请求响应
|
||||
virtual void OnRspUserLogin(CSecurityFtdcUserLoginField *pUserLogin, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///登出请求响应
|
||||
virtual void OnRspUserLogout(CSecurityFtdcUserLogoutField *pUserLogout, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///订阅Level2行情应答
|
||||
virtual void OnRspSubL2MarketData(CSecurityFtdcSpecificInstrumentField *pSpecificInstrument, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///取消订阅Level2行情应答
|
||||
virtual void OnRspUnSubL2MarketData(CSecurityFtdcSpecificInstrumentField *pSpecificInstrument, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///订阅Level2指数行情应答
|
||||
virtual void OnRspSubL2Index(CSecurityFtdcSpecificInstrumentField *pSpecificInstrument, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///取消订阅Level2指数行情应答
|
||||
virtual void OnRspUnSubL2Index(CSecurityFtdcSpecificInstrumentField *pSpecificInstrument, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///Level2行情通知
|
||||
virtual void OnRtnL2MarketData(CSecurityFtdcL2MarketDataField *pL2MarketData) {};
|
||||
|
||||
///Level2指数行情通知
|
||||
virtual void OnRtnL2Index(CSecurityFtdcL2IndexField *pL2Index) {};
|
||||
|
||||
///订阅逐笔委托及成交应答
|
||||
virtual void OnRspSubL2OrderAndTrade(CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///取消订阅逐笔委托及成交应答
|
||||
virtual void OnRspUnSubL2OrderAndTrade(CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///Level2委托通知
|
||||
virtual void OnRtnL2Order(CSecurityFtdcL2OrderField *pL2Order) {};
|
||||
|
||||
///Level2成交通知
|
||||
virtual void OnRtnL2Trade(CSecurityFtdcL2TradeField *pL2Trade) {};
|
||||
|
||||
///通知清理SSE买卖一队列中数量为0的报单
|
||||
virtual void OnNtfCheckOrderList(TSecurityFtdcInstrumentIDType InstrumentID, TSecurityFtdcFunctionCodeType FunctionCode) {};
|
||||
};
|
||||
|
||||
#ifndef WINDOWS
|
||||
#if __GNUC__ >= 4
|
||||
#pragma GCC visibility push(default)
|
||||
#endif
|
||||
#endif
|
||||
class L2MD_USER_API_EXPORT CSecurityFtdcL2MDUserApi
|
||||
{
|
||||
public:
|
||||
///创建UserApi
|
||||
static CSecurityFtdcL2MDUserApi *CreateFtdcL2MDUserApi(const bool bIsMulticast=false);
|
||||
|
||||
///删除接口对象本身
|
||||
///@remark 不再使用本接口对象时,调用该函数删除接口对象
|
||||
virtual void Release() = 0;
|
||||
|
||||
///初始化
|
||||
///@remark 初始化运行环境,只有调用后,接口才开始工作
|
||||
virtual void Init() = 0;
|
||||
|
||||
///等待接口线程结束运行
|
||||
virtual int Join() = 0;
|
||||
|
||||
///获取当前交易日
|
||||
///@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 pSpi 派生自回调接口类的实例
|
||||
virtual void RegisterSpi(CSecurityFtdcL2MDUserSpi *pSpi) = 0;
|
||||
|
||||
virtual int SubscribeL2MarketData(char *ppInstrumentID[], int nCount, char* pExchageID) = 0;
|
||||
|
||||
virtual int UnSubscribeL2MarketData(char *ppInstrumentID[], int nCount, char* pExchageID) = 0;
|
||||
|
||||
virtual int SubscribeL2Index(char *ppInstrumentID[], int nCount, char* pExchageID) = 0;
|
||||
|
||||
virtual int UnSubscribeL2Index(char *ppInstrumentID[], int nCount, char* pExchageID) = 0;
|
||||
|
||||
virtual int SubscribeL2OrderAndTrade() = 0;
|
||||
|
||||
virtual int UnSubscribeL2OrderAndTrade() = 0;
|
||||
|
||||
///登录请求
|
||||
virtual int ReqUserLogin(CSecurityFtdcUserLoginField *pUserLogin, int nRequestID) = 0;
|
||||
|
||||
///登出请求
|
||||
virtual int ReqUserLogout(CSecurityFtdcUserLogoutField *pUserLogout, int nRequestID) = 0;
|
||||
protected:
|
||||
~CSecurityFtdcL2MDUserApi(){};
|
||||
};
|
||||
#ifndef WINDOWS
|
||||
#if __GNUC__ >= 4
|
||||
#pragma GCC visibility pop
|
||||
#endif
|
||||
#endif
|
||||
_LTS_NS_END_
|
||||
#endif
|
213
vn.lts/ltsl2/SecurityFtdcL2MDUserApiDataType.h
Normal file
213
vn.lts/ltsl2/SecurityFtdcL2MDUserApiDataType.h
Normal file
@ -0,0 +1,213 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///@company shanghai liber information Technology Co.,Ltd
|
||||
///@file SecurityFtdcL2MDUserApiDataType.h
|
||||
///@brief 定义业务数据类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef SECURITY_L2MD_FTDCDATATYPE_H
|
||||
#define SECURITY_L2MD_FTDCDATATYPE_H
|
||||
|
||||
#include "LTS_ns.h"
|
||||
|
||||
_LTS_NS_BEGIN_
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcErrorIDType是一个错误代码类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef int TSecurityFtdcErrorIDType;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcErrorMsgType是一个错误信息类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef char TSecurityFtdcErrorMsgType[81];
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcBrokerIDType是一个经纪公司代码类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef char TSecurityFtdcBrokerIDType[11];
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcUserIDType是一个用户代码类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef char TSecurityFtdcUserIDType[16];
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcUserNameType是一个用户名称类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef char TSecurityFtdcUserNameType[81];
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcPasswordType是一个密码类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef char TSecurityFtdcPasswordType[41];
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcExchangeIDType是一个交易所代码类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef char TSecurityFtdcExchangeIDType[9];
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcInstrumentIDType是一个合约代码类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef char TSecurityFtdcInstrumentIDType[31];
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcDateType是一个日期类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef char TSecurityFtdcDateType[9];
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcTimeType是一个时间类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef char TSecurityFtdcTimeType[9];
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcPriceType是一个价格类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef double TSecurityFtdcPriceType;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcVolumeType是一个数量类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef int TSecurityFtdcVolumeType;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcLargeVolumeType是一个大额数量类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef double TSecurityFtdcLargeVolumeType;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcRatioType是一个比率类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef double TSecurityFtdcRatioType;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcMoneyType是一个资金类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef double TSecurityFtdcMoneyType;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcPriceLevelType是一个价格深度类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef int TSecurityFtdcPriceLevelType;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcBoolType是一个布尔型类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef int TSecurityFtdcBoolType;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcIndexType是一个指数类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef double TSecurityFtdcIndexType;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcDataLevelType是一个行情数据等级类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///全量行情
|
||||
#define SECURITY_FTDC_DL_FULL '0'
|
||||
///L10行情
|
||||
#define SECURITY_FTDC_DL_L10 '1'
|
||||
///L5行情
|
||||
#define SECURITY_FTDC_DL_L5 '2'
|
||||
|
||||
typedef char TSecurityFtdcDataLevelType;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcIPAddressType是一个IP地址类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef char TSecurityFtdcIPAddressType[16];
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcIPPortType是一个IP端口类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef int TSecurityFtdcIPPortType;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcBeginStringType是一个step起始串类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef char TSecurityFtdcBeginStringType[17];
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcBodyLengthType是一个消息体长度类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef int TSecurityFtdcBodyLengthType;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcMsgTypeType是一个消息类型类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef char TSecurityFtdcMsgTypeType[9];
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcSenderCompIDType是一个发送方代码类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef char TSecurityFtdcSenderCompIDType[33];
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcTargetCompIDType是一个接收方代码类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef char TSecurityFtdcTargetCompIDType[33];
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcMsgSeqNumType是一个头消息序号标签34类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef int TSecurityFtdcMsgSeqNumType;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcSendingTimeType是一个发送时间类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef char TSecurityFtdcSendingTimeType[21];
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcMessageEncodingType是一个消息中Encoded域的字符编码类型类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef char TSecurityFtdcMessageEncodingType[21];
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcCheckSumType是一个校验和类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef int TSecurityFtdcCheckSumType;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcEncryptMethodType是一个加密方法类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef char TSecurityFtdcEncryptMethodType[9];
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcHeartBtIntType是一个心跳间隔类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef int TSecurityFtdcHeartBtIntType;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcInterfaceVersionType是一个行情数据接口版本号类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef char TSecurityFtdcInterfaceVersionType[9];
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcMsgSeqIDType是一个消息序号标签10072类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef int TSecurityFtdcMsgSeqIDType;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcGroupIDType是一个组号类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef int TSecurityFtdcGroupIDType;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcGroupNoType是一个组序类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef int TSecurityFtdcGroupNoType;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcOrderKindType是一个报单类型类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef char TSecurityFtdcOrderKindType[2];
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcFunctionCodeType是一个功能码类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef char TSecurityFtdcFunctionCodeType[2];
|
||||
|
||||
_LTS_NS_END_
|
||||
|
||||
#endif
|
786
vn.lts/ltsl2/SecurityFtdcL2MDUserApiStruct.h
Normal file
786
vn.lts/ltsl2/SecurityFtdcL2MDUserApiStruct.h
Normal file
@ -0,0 +1,786 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///@company shanghai liber information Technology Co.,Ltd
|
||||
///@file SecurityFtdcL2MDUserApiStruct.h
|
||||
///@brief 定义业务数据结构
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(SECURITY_L2MD_FTDCSTRUCT_H)
|
||||
#define SECURITY_L2MD_FTDCSTRUCT_H
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include "SecurityFtdcL2MDUserApiDataType.h"
|
||||
|
||||
_LTS_NS_BEGIN_
|
||||
|
||||
///响应信息
|
||||
struct CSecurityFtdcRspInfoField
|
||||
{
|
||||
///错误代码
|
||||
TSecurityFtdcErrorIDType ErrorID;
|
||||
///错误信息
|
||||
TSecurityFtdcErrorMsgType ErrorMsg;
|
||||
};
|
||||
|
||||
///用户登录信息
|
||||
struct CSecurityFtdcUserLoginField
|
||||
{
|
||||
///交易日
|
||||
TSecurityFtdcDateType TradingDay;
|
||||
///经纪公司代码
|
||||
TSecurityFtdcBrokerIDType BrokerID;
|
||||
///用户代码
|
||||
TSecurityFtdcUserIDType UserID;
|
||||
///密码
|
||||
TSecurityFtdcPasswordType Password;
|
||||
///行情数据等级
|
||||
TSecurityFtdcDataLevelType DataLevel;
|
||||
};
|
||||
|
||||
///用户登出信息
|
||||
struct CSecurityFtdcUserLogoutField
|
||||
{
|
||||
///经纪公司代码
|
||||
TSecurityFtdcBrokerIDType BrokerID;
|
||||
///用户代码
|
||||
TSecurityFtdcUserIDType UserID;
|
||||
};
|
||||
|
||||
///指定的合约
|
||||
struct CSecurityFtdcSpecificInstrumentField
|
||||
{
|
||||
///合约代码
|
||||
TSecurityFtdcInstrumentIDType InstrumentID;
|
||||
///交易所代码
|
||||
TSecurityFtdcExchangeIDType ExchangeID;
|
||||
};
|
||||
|
||||
///Level2行情
|
||||
struct CSecurityFtdcL2MarketDataField
|
||||
{
|
||||
///交易日
|
||||
TSecurityFtdcDateType TradingDay;
|
||||
///时间戳
|
||||
TSecurityFtdcTimeType TimeStamp;
|
||||
///交易所代码
|
||||
TSecurityFtdcExchangeIDType ExchangeID;
|
||||
///合约代码
|
||||
TSecurityFtdcInstrumentIDType InstrumentID;
|
||||
///昨收盘价
|
||||
TSecurityFtdcPriceType PreClosePrice;
|
||||
///今开盘价
|
||||
TSecurityFtdcPriceType OpenPrice;
|
||||
///收盘价
|
||||
TSecurityFtdcPriceType ClosePrice;
|
||||
///净值估值
|
||||
TSecurityFtdcPriceType IOPV;
|
||||
///到期收益率
|
||||
TSecurityFtdcRatioType YieldToMaturity;
|
||||
///最高价
|
||||
TSecurityFtdcPriceType HighPrice;
|
||||
///最低价
|
||||
TSecurityFtdcPriceType LowPrice;
|
||||
///最新价
|
||||
TSecurityFtdcPriceType LastPrice;
|
||||
///成交笔数
|
||||
TSecurityFtdcVolumeType TradeCount;
|
||||
///成交总量
|
||||
TSecurityFtdcLargeVolumeType TotalTradeVolume;
|
||||
///成交总金额
|
||||
TSecurityFtdcMoneyType TotalTradeValue;
|
||||
///委托买入总量
|
||||
TSecurityFtdcLargeVolumeType TotalBidVolume;
|
||||
///加权平均委买价
|
||||
TSecurityFtdcPriceType WeightedAvgBidPrice;
|
||||
///债券加权平均委买价
|
||||
TSecurityFtdcPriceType AltWeightedAvgBidPrice;
|
||||
///委托卖出总量
|
||||
TSecurityFtdcLargeVolumeType TotalOfferVolume;
|
||||
///加权平均委卖价
|
||||
TSecurityFtdcPriceType WeightedAvgOfferPrice;
|
||||
///债券加权平均委卖价格
|
||||
TSecurityFtdcPriceType AltWeightedAvgOfferPrice;
|
||||
///买价深度
|
||||
TSecurityFtdcPriceLevelType BidPriceLevel;
|
||||
///卖价深度
|
||||
TSecurityFtdcPriceLevelType OfferPriceLevel;
|
||||
///申买价一
|
||||
TSecurityFtdcPriceType BidPrice1;
|
||||
///申买量一
|
||||
TSecurityFtdcVolumeType BidVolume1;
|
||||
///实际买总委托笔数一
|
||||
TSecurityFtdcVolumeType BidCount1;
|
||||
///申买价二
|
||||
TSecurityFtdcPriceType BidPrice2;
|
||||
///申买量二
|
||||
TSecurityFtdcVolumeType BidVolume2;
|
||||
///实际买总委托笔数二
|
||||
TSecurityFtdcVolumeType BidCount2;
|
||||
///申买价三
|
||||
TSecurityFtdcPriceType BidPrice3;
|
||||
///申买量三
|
||||
TSecurityFtdcVolumeType BidVolume3;
|
||||
///实际买总委托笔数三
|
||||
TSecurityFtdcVolumeType BidCount3;
|
||||
///申买价四
|
||||
TSecurityFtdcPriceType BidPrice4;
|
||||
///申买量四
|
||||
TSecurityFtdcVolumeType BidVolume4;
|
||||
///实际买总委托笔数四
|
||||
TSecurityFtdcVolumeType BidCount4;
|
||||
///申买价五
|
||||
TSecurityFtdcPriceType BidPrice5;
|
||||
///申买量五
|
||||
TSecurityFtdcVolumeType BidVolume5;
|
||||
///实际买总委托笔数五
|
||||
TSecurityFtdcVolumeType BidCount5;
|
||||
///申买价六
|
||||
TSecurityFtdcPriceType BidPrice6;
|
||||
///申买量六
|
||||
TSecurityFtdcVolumeType BidVolume6;
|
||||
///实际买总委托笔数六
|
||||
TSecurityFtdcVolumeType BidCount6;
|
||||
///申买价七
|
||||
TSecurityFtdcPriceType BidPrice7;
|
||||
///申买量七
|
||||
TSecurityFtdcVolumeType BidVolume7;
|
||||
///实际买总委托笔数七
|
||||
TSecurityFtdcVolumeType BidCount7;
|
||||
///申买价八
|
||||
TSecurityFtdcPriceType BidPrice8;
|
||||
///申买量八
|
||||
TSecurityFtdcVolumeType BidVolume8;
|
||||
///实际买总委托笔数八
|
||||
TSecurityFtdcVolumeType BidCount8;
|
||||
///申买价九
|
||||
TSecurityFtdcPriceType BidPrice9;
|
||||
///申买量九
|
||||
TSecurityFtdcVolumeType BidVolume9;
|
||||
///实际买总委托笔数九
|
||||
TSecurityFtdcVolumeType BidCount9;
|
||||
///申买价十
|
||||
TSecurityFtdcPriceType BidPriceA;
|
||||
///申买量十
|
||||
TSecurityFtdcVolumeType BidVolumeA;
|
||||
///实际买总委托笔数十
|
||||
TSecurityFtdcVolumeType BidCountA;
|
||||
///申卖价一
|
||||
TSecurityFtdcPriceType OfferPrice1;
|
||||
///申卖量一
|
||||
TSecurityFtdcVolumeType OfferVolume1;
|
||||
///实际卖总委托笔数一
|
||||
TSecurityFtdcVolumeType OfferCount1;
|
||||
///申卖价二
|
||||
TSecurityFtdcPriceType OfferPrice2;
|
||||
///申卖量二
|
||||
TSecurityFtdcVolumeType OfferVolume2;
|
||||
///实际卖总委托笔数二
|
||||
TSecurityFtdcVolumeType OfferCount2;
|
||||
///申卖价三
|
||||
TSecurityFtdcPriceType OfferPrice3;
|
||||
///申卖量三
|
||||
TSecurityFtdcVolumeType OfferVolume3;
|
||||
///实际卖总委托笔数三
|
||||
TSecurityFtdcVolumeType OfferCount3;
|
||||
///申卖价四
|
||||
TSecurityFtdcPriceType OfferPrice4;
|
||||
///申卖量四
|
||||
TSecurityFtdcVolumeType OfferVolume4;
|
||||
///实际卖总委托笔数四
|
||||
TSecurityFtdcVolumeType OfferCount4;
|
||||
///申卖价五
|
||||
TSecurityFtdcPriceType OfferPrice5;
|
||||
///申卖量五
|
||||
TSecurityFtdcVolumeType OfferVolume5;
|
||||
///实际卖总委托笔数五
|
||||
TSecurityFtdcVolumeType OfferCount5;
|
||||
///申卖价六
|
||||
TSecurityFtdcPriceType OfferPrice6;
|
||||
///申卖量六
|
||||
TSecurityFtdcVolumeType OfferVolume6;
|
||||
///实际卖总委托笔数六
|
||||
TSecurityFtdcVolumeType OfferCount6;
|
||||
///申卖价七
|
||||
TSecurityFtdcPriceType OfferPrice7;
|
||||
///申卖量七
|
||||
TSecurityFtdcVolumeType OfferVolume7;
|
||||
///实际卖总委托笔数七
|
||||
TSecurityFtdcVolumeType OfferCount7;
|
||||
///申卖价八
|
||||
TSecurityFtdcPriceType OfferPrice8;
|
||||
///申卖量八
|
||||
TSecurityFtdcVolumeType OfferVolume8;
|
||||
///实际卖总委托笔数八
|
||||
TSecurityFtdcVolumeType OfferCount8;
|
||||
///申卖价九
|
||||
TSecurityFtdcPriceType OfferPrice9;
|
||||
///申卖量九
|
||||
TSecurityFtdcVolumeType OfferVolume9;
|
||||
///实际卖总委托笔数九
|
||||
TSecurityFtdcVolumeType OfferCount9;
|
||||
///申卖价十
|
||||
TSecurityFtdcPriceType OfferPriceA;
|
||||
///申卖量十
|
||||
TSecurityFtdcVolumeType OfferVolumeA;
|
||||
///实际卖总委托笔数十
|
||||
TSecurityFtdcVolumeType OfferCountA;
|
||||
};
|
||||
|
||||
///Level2行情更新时间属性
|
||||
struct CSecurityFtdcL2UpdateTimeField
|
||||
{
|
||||
///交易日
|
||||
TSecurityFtdcDateType TradingDay;
|
||||
///时间戳
|
||||
TSecurityFtdcTimeType TimeStamp;
|
||||
///交易所代码
|
||||
TSecurityFtdcExchangeIDType ExchangeID;
|
||||
///合约代码
|
||||
TSecurityFtdcInstrumentIDType InstrumentID;
|
||||
};
|
||||
|
||||
///Level2行情静态属性
|
||||
struct CSecurityFtdcL2StaticField
|
||||
{
|
||||
///昨收盘价
|
||||
TSecurityFtdcPriceType PreClosePrice;
|
||||
///今开盘价
|
||||
TSecurityFtdcPriceType OpenPrice;
|
||||
///收盘价
|
||||
TSecurityFtdcPriceType ClosePrice;
|
||||
///净值估值
|
||||
TSecurityFtdcPriceType IOPV;
|
||||
///到期收益率
|
||||
TSecurityFtdcRatioType YieldToMaturity;
|
||||
};
|
||||
|
||||
///Level2行情价格区间属性
|
||||
struct CSecurityFtdcL2PriceIntervalField
|
||||
{
|
||||
///最高价
|
||||
TSecurityFtdcPriceType HighPrice;
|
||||
///最低价
|
||||
TSecurityFtdcPriceType LowPrice;
|
||||
};
|
||||
|
||||
///Level2行情基本信息
|
||||
struct CSecurityFtdcL2BaseField
|
||||
{
|
||||
///最新价
|
||||
TSecurityFtdcPriceType LastPrice;
|
||||
};
|
||||
|
||||
///Level2成交信息
|
||||
struct CSecurityFtdcL2TradedField
|
||||
{
|
||||
///成交笔数
|
||||
TSecurityFtdcVolumeType TradeCount;
|
||||
///成交总量
|
||||
TSecurityFtdcLargeVolumeType TotalTradeVolume;
|
||||
///成交总金额
|
||||
TSecurityFtdcMoneyType TotalTradeValue;
|
||||
};
|
||||
|
||||
///Level2行情数据属性
|
||||
struct CSecurityFtdcL2DataLevelField
|
||||
{
|
||||
///价格
|
||||
TSecurityFtdcPriceType Price;
|
||||
///数量
|
||||
TSecurityFtdcVolumeType Volume;
|
||||
///实际总委托笔数
|
||||
TSecurityFtdcVolumeType Count;
|
||||
};
|
||||
|
||||
///Level2委买信息
|
||||
struct CSecurityFtdcL2BidOrderField
|
||||
{
|
||||
///委托买入总量
|
||||
TSecurityFtdcLargeVolumeType TotalBidVolume;
|
||||
///加权平均委买价
|
||||
TSecurityFtdcPriceType WeightedAvgBidPrice;
|
||||
///债券加权平均委买价
|
||||
TSecurityFtdcPriceType AltWeightedAvgBidPrice;
|
||||
};
|
||||
|
||||
///Level2委卖信息
|
||||
struct CSecurityFtdcL2OfferOrderField
|
||||
{
|
||||
///委托卖出总量
|
||||
TSecurityFtdcLargeVolumeType TotalOfferVolume;
|
||||
///加权平均委卖价
|
||||
TSecurityFtdcPriceType WeightedAvgOfferPrice;
|
||||
///债券加权平均委卖价格
|
||||
TSecurityFtdcPriceType AltWeightedAvgOfferPrice;
|
||||
};
|
||||
|
||||
///Level2价格深度属性
|
||||
struct CSecurityFtdcL2PriceLevelField
|
||||
{
|
||||
///买价深度
|
||||
TSecurityFtdcPriceLevelType BidPriceLevel;
|
||||
///卖价深度
|
||||
TSecurityFtdcPriceLevelType OfferPriceLevel;
|
||||
};
|
||||
|
||||
///Level2行情申买一属性
|
||||
struct CSecurityFtdcL2Bid1Field
|
||||
{
|
||||
///申买价一
|
||||
TSecurityFtdcPriceType BidPrice1;
|
||||
///申买量一
|
||||
TSecurityFtdcVolumeType BidVolume1;
|
||||
///实际买总委托笔数一
|
||||
TSecurityFtdcVolumeType BidCount1;
|
||||
};
|
||||
|
||||
///Level2行情申卖一属性
|
||||
struct CSecurityFtdcL2Offer1Field
|
||||
{
|
||||
///申卖价一
|
||||
TSecurityFtdcPriceType OfferPrice1;
|
||||
///申卖量一
|
||||
TSecurityFtdcVolumeType OfferVolume1;
|
||||
///实际卖总委托笔数一
|
||||
TSecurityFtdcVolumeType OfferCount1;
|
||||
};
|
||||
|
||||
///Level2行情申买二属性
|
||||
struct CSecurityFtdcL2Bid2Field
|
||||
{
|
||||
///申买价二
|
||||
TSecurityFtdcPriceType BidPrice2;
|
||||
///申买量二
|
||||
TSecurityFtdcVolumeType BidVolume2;
|
||||
///实际买总委托笔数二
|
||||
TSecurityFtdcVolumeType BidCount2;
|
||||
};
|
||||
|
||||
///Level2行情申卖二属性
|
||||
struct CSecurityFtdcL2Offer2Field
|
||||
{
|
||||
///申卖价二
|
||||
TSecurityFtdcPriceType OfferPrice2;
|
||||
///申卖量二
|
||||
TSecurityFtdcVolumeType OfferVolume2;
|
||||
///实际卖总委托笔数二
|
||||
TSecurityFtdcVolumeType OfferCount2;
|
||||
};
|
||||
|
||||
///Level2行情申买三属性
|
||||
struct CSecurityFtdcL2Bid3Field
|
||||
{
|
||||
///申买价三
|
||||
TSecurityFtdcPriceType BidPrice3;
|
||||
///申买量三
|
||||
TSecurityFtdcVolumeType BidVolume3;
|
||||
///实际买总委托笔数三
|
||||
TSecurityFtdcVolumeType BidCount3;
|
||||
};
|
||||
|
||||
///Level2行情申卖三属性
|
||||
struct CSecurityFtdcL2Offer3Field
|
||||
{
|
||||
///申卖价三
|
||||
TSecurityFtdcPriceType OfferPrice3;
|
||||
///申卖量三
|
||||
TSecurityFtdcVolumeType OfferVolume3;
|
||||
///实际卖总委托笔数三
|
||||
TSecurityFtdcVolumeType OfferCount3;
|
||||
};
|
||||
|
||||
///Level2行情申买四属性
|
||||
struct CSecurityFtdcL2Bid4Field
|
||||
{
|
||||
///申买价四
|
||||
TSecurityFtdcPriceType BidPrice4;
|
||||
///申买量四
|
||||
TSecurityFtdcVolumeType BidVolume4;
|
||||
///实际买总委托笔数四
|
||||
TSecurityFtdcVolumeType BidCount4;
|
||||
};
|
||||
|
||||
///Level2行情申卖四属性
|
||||
struct CSecurityFtdcL2Offer4Field
|
||||
{
|
||||
///申卖价四
|
||||
TSecurityFtdcPriceType OfferPrice4;
|
||||
///申卖量四
|
||||
TSecurityFtdcVolumeType OfferVolume4;
|
||||
///实际卖总委托笔数四
|
||||
TSecurityFtdcVolumeType OfferCount4;
|
||||
};
|
||||
|
||||
///Level2行情申买五属性
|
||||
struct CSecurityFtdcL2Bid5Field
|
||||
{
|
||||
///申买价五
|
||||
TSecurityFtdcPriceType BidPrice5;
|
||||
///申买量五
|
||||
TSecurityFtdcVolumeType BidVolume5;
|
||||
///实际买总委托笔数五
|
||||
TSecurityFtdcVolumeType BidCount5;
|
||||
};
|
||||
|
||||
///Level2行情申卖五属性
|
||||
struct CSecurityFtdcL2Offer5Field
|
||||
{
|
||||
///申卖价五
|
||||
TSecurityFtdcPriceType OfferPrice5;
|
||||
///申卖量五
|
||||
TSecurityFtdcVolumeType OfferVolume5;
|
||||
///实际卖总委托笔数五
|
||||
TSecurityFtdcVolumeType OfferCount5;
|
||||
};
|
||||
|
||||
///Level2行情申买六属性
|
||||
struct CSecurityFtdcL2Bid6Field
|
||||
{
|
||||
///申买价六
|
||||
TSecurityFtdcPriceType BidPrice6;
|
||||
///申买量六
|
||||
TSecurityFtdcVolumeType BidVolume6;
|
||||
///实际买总委托笔数六
|
||||
TSecurityFtdcVolumeType BidCount6;
|
||||
};
|
||||
|
||||
///Level2行情申卖六属性
|
||||
struct CSecurityFtdcL2Offer6Field
|
||||
{
|
||||
///申卖价六
|
||||
TSecurityFtdcPriceType OfferPrice6;
|
||||
///申卖量六
|
||||
TSecurityFtdcVolumeType OfferVolume6;
|
||||
///实际卖总委托笔数六
|
||||
TSecurityFtdcVolumeType OfferCount6;
|
||||
};
|
||||
|
||||
///Level2行情申买七属性
|
||||
struct CSecurityFtdcL2Bid7Field
|
||||
{
|
||||
///申买价七
|
||||
TSecurityFtdcPriceType BidPrice7;
|
||||
///申买量七
|
||||
TSecurityFtdcVolumeType BidVolume7;
|
||||
///实际买总委托笔数七
|
||||
TSecurityFtdcVolumeType BidCount7;
|
||||
};
|
||||
|
||||
///Level2行情申卖七属性
|
||||
struct CSecurityFtdcL2Offer7Field
|
||||
{
|
||||
///申卖价七
|
||||
TSecurityFtdcPriceType OfferPrice7;
|
||||
///申卖量七
|
||||
TSecurityFtdcVolumeType OfferVolume7;
|
||||
///实际卖总委托笔数七
|
||||
TSecurityFtdcVolumeType OfferCount7;
|
||||
};
|
||||
|
||||
///Level2行情申买八属性
|
||||
struct CSecurityFtdcL2Bid8Field
|
||||
{
|
||||
///申买价八
|
||||
TSecurityFtdcPriceType BidPrice8;
|
||||
///申买量八
|
||||
TSecurityFtdcVolumeType BidVolume8;
|
||||
///实际买总委托笔数八
|
||||
TSecurityFtdcVolumeType BidCount8;
|
||||
};
|
||||
|
||||
///Level2行情申卖八属性
|
||||
struct CSecurityFtdcL2Offer8Field
|
||||
{
|
||||
///申卖价八
|
||||
TSecurityFtdcPriceType OfferPrice8;
|
||||
///申卖量八
|
||||
TSecurityFtdcVolumeType OfferVolume8;
|
||||
///实际卖总委托笔数八
|
||||
TSecurityFtdcVolumeType OfferCount8;
|
||||
};
|
||||
|
||||
///Level2行情申买九属性
|
||||
struct CSecurityFtdcL2Bid9Field
|
||||
{
|
||||
///申买价九
|
||||
TSecurityFtdcPriceType BidPrice9;
|
||||
///申买量九
|
||||
TSecurityFtdcVolumeType BidVolume9;
|
||||
///实际买总委托笔数九
|
||||
TSecurityFtdcVolumeType BidCount9;
|
||||
};
|
||||
|
||||
///Level2行情申卖九属性
|
||||
struct CSecurityFtdcL2Offer9Field
|
||||
{
|
||||
///申卖价九
|
||||
TSecurityFtdcPriceType OfferPrice9;
|
||||
///申卖量九
|
||||
TSecurityFtdcVolumeType OfferVolume9;
|
||||
///实际卖总委托笔数九
|
||||
TSecurityFtdcVolumeType OfferCount9;
|
||||
};
|
||||
|
||||
///Level2行情申买十属性
|
||||
struct CSecurityFtdcL2BidAField
|
||||
{
|
||||
///申买价十
|
||||
TSecurityFtdcPriceType BidPriceA;
|
||||
///申买量十
|
||||
TSecurityFtdcVolumeType BidVolumeA;
|
||||
///实际买总委托笔数十
|
||||
TSecurityFtdcVolumeType BidCountA;
|
||||
};
|
||||
|
||||
///Level2行情申卖十属性
|
||||
struct CSecurityFtdcL2OfferAField
|
||||
{
|
||||
///申卖价十
|
||||
TSecurityFtdcPriceType OfferPriceA;
|
||||
///申卖量十
|
||||
TSecurityFtdcVolumeType OfferVolumeA;
|
||||
///实际卖总委托笔数十
|
||||
TSecurityFtdcVolumeType OfferCountA;
|
||||
};
|
||||
|
||||
///Level2行情申买属性
|
||||
struct CSecurityFtdcL2BidField
|
||||
{
|
||||
///申买价一
|
||||
TSecurityFtdcPriceType BidPrice1;
|
||||
///申买量一
|
||||
TSecurityFtdcVolumeType BidVolume1;
|
||||
///实际买总委托笔数一
|
||||
TSecurityFtdcVolumeType BidCount1;
|
||||
///申买价二
|
||||
TSecurityFtdcPriceType BidPrice2;
|
||||
///申买量二
|
||||
TSecurityFtdcVolumeType BidVolume2;
|
||||
///实际买总委托笔数二
|
||||
TSecurityFtdcVolumeType BidCount2;
|
||||
///申买价三
|
||||
TSecurityFtdcPriceType BidPrice3;
|
||||
///申买量三
|
||||
TSecurityFtdcVolumeType BidVolume3;
|
||||
///实际买总委托笔数三
|
||||
TSecurityFtdcVolumeType BidCount3;
|
||||
///申买价四
|
||||
TSecurityFtdcPriceType BidPrice4;
|
||||
///申买量四
|
||||
TSecurityFtdcVolumeType BidVolume4;
|
||||
///实际买总委托笔数四
|
||||
TSecurityFtdcVolumeType BidCount4;
|
||||
///申买价五
|
||||
TSecurityFtdcPriceType BidPrice5;
|
||||
///申买量五
|
||||
TSecurityFtdcVolumeType BidVolume5;
|
||||
///实际买总委托笔数五
|
||||
TSecurityFtdcVolumeType BidCount5;
|
||||
///申买价六
|
||||
TSecurityFtdcPriceType BidPrice6;
|
||||
///申买量六
|
||||
TSecurityFtdcVolumeType BidVolume6;
|
||||
///实际买总委托笔数六
|
||||
TSecurityFtdcVolumeType BidCount6;
|
||||
///申买价七
|
||||
TSecurityFtdcPriceType BidPrice7;
|
||||
///申买量七
|
||||
TSecurityFtdcVolumeType BidVolume7;
|
||||
///实际买总委托笔数七
|
||||
TSecurityFtdcVolumeType BidCount7;
|
||||
///申买价八
|
||||
TSecurityFtdcPriceType BidPrice8;
|
||||
///申买量八
|
||||
TSecurityFtdcVolumeType BidVolume8;
|
||||
///实际买总委托笔数八
|
||||
TSecurityFtdcVolumeType BidCount8;
|
||||
///申买价九
|
||||
TSecurityFtdcPriceType BidPrice9;
|
||||
///申买量九
|
||||
TSecurityFtdcVolumeType BidVolume9;
|
||||
///实际买总委托笔数九
|
||||
TSecurityFtdcVolumeType BidCount9;
|
||||
///申买价十
|
||||
TSecurityFtdcPriceType BidPriceA;
|
||||
///申买量十
|
||||
TSecurityFtdcVolumeType BidVolumeA;
|
||||
///实际买总委托笔数十
|
||||
TSecurityFtdcVolumeType BidCountA;
|
||||
};
|
||||
|
||||
///Level2行情申卖属性
|
||||
struct CSecurityFtdcL2OfferField
|
||||
{
|
||||
///申卖价一
|
||||
TSecurityFtdcPriceType OfferPrice1;
|
||||
///申卖量一
|
||||
TSecurityFtdcVolumeType OfferVolume1;
|
||||
///实际卖总委托笔数一
|
||||
TSecurityFtdcVolumeType OfferCount1;
|
||||
///申卖价二
|
||||
TSecurityFtdcPriceType OfferPrice2;
|
||||
///申卖量二
|
||||
TSecurityFtdcVolumeType OfferVolume2;
|
||||
///实际卖总委托笔数二
|
||||
TSecurityFtdcVolumeType OfferCount2;
|
||||
///申卖价三
|
||||
TSecurityFtdcPriceType OfferPrice3;
|
||||
///申卖量三
|
||||
TSecurityFtdcVolumeType OfferVolume3;
|
||||
///实际卖总委托笔数三
|
||||
TSecurityFtdcVolumeType OfferCount3;
|
||||
///申卖价四
|
||||
TSecurityFtdcPriceType OfferPrice4;
|
||||
///申卖量四
|
||||
TSecurityFtdcVolumeType OfferVolume4;
|
||||
///实际卖总委托笔数四
|
||||
TSecurityFtdcVolumeType OfferCount4;
|
||||
///申卖价五
|
||||
TSecurityFtdcPriceType OfferPrice5;
|
||||
///申卖量五
|
||||
TSecurityFtdcVolumeType OfferVolume5;
|
||||
///实际卖总委托笔数五
|
||||
TSecurityFtdcVolumeType OfferCount5;
|
||||
///申卖价六
|
||||
TSecurityFtdcPriceType OfferPrice6;
|
||||
///申卖量六
|
||||
TSecurityFtdcVolumeType OfferVolume6;
|
||||
///实际卖总委托笔数六
|
||||
TSecurityFtdcVolumeType OfferCount6;
|
||||
///申卖价七
|
||||
TSecurityFtdcPriceType OfferPrice7;
|
||||
///申卖量七
|
||||
TSecurityFtdcVolumeType OfferVolume7;
|
||||
///实际卖总委托笔数七
|
||||
TSecurityFtdcVolumeType OfferCount7;
|
||||
///申卖价八
|
||||
TSecurityFtdcPriceType OfferPrice8;
|
||||
///申卖量八
|
||||
TSecurityFtdcVolumeType OfferVolume8;
|
||||
///实际卖总委托笔数八
|
||||
TSecurityFtdcVolumeType OfferCount8;
|
||||
///申卖价九
|
||||
TSecurityFtdcPriceType OfferPrice9;
|
||||
///申卖量九
|
||||
TSecurityFtdcVolumeType OfferVolume9;
|
||||
///实际卖总委托笔数九
|
||||
TSecurityFtdcVolumeType OfferCount9;
|
||||
///申卖价十
|
||||
TSecurityFtdcPriceType OfferPriceA;
|
||||
///申卖量十
|
||||
TSecurityFtdcVolumeType OfferVolumeA;
|
||||
///实际卖总委托笔数十
|
||||
TSecurityFtdcVolumeType OfferCountA;
|
||||
};
|
||||
|
||||
///Level2指数行情
|
||||
struct CSecurityFtdcL2IndexField
|
||||
{
|
||||
///交易日
|
||||
TSecurityFtdcDateType TradingDay;
|
||||
///行情时间(秒)
|
||||
TSecurityFtdcTimeType TimeStamp;
|
||||
///交易所代码
|
||||
TSecurityFtdcExchangeIDType ExchangeID;
|
||||
///指数代码
|
||||
TSecurityFtdcInstrumentIDType InstrumentID;
|
||||
///前收盘指数
|
||||
TSecurityFtdcIndexType PreCloseIndex;
|
||||
///今开盘指数
|
||||
TSecurityFtdcIndexType OpenIndex;
|
||||
///今日收盘指数
|
||||
TSecurityFtdcIndexType CloseIndex;
|
||||
///最高指数
|
||||
TSecurityFtdcIndexType HighIndex;
|
||||
///最低指数
|
||||
TSecurityFtdcIndexType LowIndex;
|
||||
///最新指数
|
||||
TSecurityFtdcIndexType LastIndex;
|
||||
///参与计算相应指数的成交金额(元)
|
||||
TSecurityFtdcMoneyType TurnOver;
|
||||
///参与计算相应指数的交易数量(手)
|
||||
TSecurityFtdcLargeVolumeType TotalVolume;
|
||||
};
|
||||
|
||||
///Level2行情用户信息
|
||||
struct CSecurityFtdcL2UserInfoField
|
||||
{
|
||||
///经纪公司代码
|
||||
TSecurityFtdcBrokerIDType BrokerID;
|
||||
///用户代码
|
||||
TSecurityFtdcUserIDType UserID;
|
||||
///用户名称
|
||||
TSecurityFtdcUserNameType UserName;
|
||||
///密码
|
||||
TSecurityFtdcPasswordType Password;
|
||||
///行情数据等级
|
||||
TSecurityFtdcDataLevelType DataLevel;
|
||||
};
|
||||
|
||||
///UDP组播组信息
|
||||
struct CSecurityFtdcMulticastGroupInfoField
|
||||
{
|
||||
///组播组IP地址
|
||||
TSecurityFtdcIPAddressType GroupIP;
|
||||
///组播组IP端口
|
||||
TSecurityFtdcIPPortType GroupPort;
|
||||
///源地址
|
||||
TSecurityFtdcIPAddressType SourceIP;
|
||||
};
|
||||
|
||||
///Level2逐笔委托
|
||||
struct CSecurityFtdcL2OrderField
|
||||
{
|
||||
///委托组
|
||||
TSecurityFtdcGroupIDType OrderGroupID;
|
||||
///委托序号
|
||||
TSecurityFtdcGroupNoType OrderIndex;
|
||||
///委托时间(秒)
|
||||
TSecurityFtdcTimeType OrderTime;
|
||||
///交易所代码
|
||||
TSecurityFtdcExchangeIDType ExchangeID;
|
||||
///合约代码
|
||||
TSecurityFtdcInstrumentIDType InstrumentID;
|
||||
///委托价格
|
||||
TSecurityFtdcPriceType Price;
|
||||
///委托数量
|
||||
TSecurityFtdcVolumeType Volume;
|
||||
///报单类型
|
||||
TSecurityFtdcOrderKindType OrderKind;
|
||||
///功能码
|
||||
TSecurityFtdcFunctionCodeType FunctionCode;
|
||||
};
|
||||
|
||||
///Level2逐笔成交
|
||||
struct CSecurityFtdcL2TradeField
|
||||
{
|
||||
///成交组
|
||||
TSecurityFtdcGroupIDType TradeGroupID;
|
||||
///成交序号
|
||||
TSecurityFtdcGroupNoType TradeIndex;
|
||||
///买方委托序号
|
||||
TSecurityFtdcGroupNoType BuyIndex;
|
||||
///卖方委托序号
|
||||
TSecurityFtdcGroupNoType SellIndex;
|
||||
///成交时间(秒)
|
||||
TSecurityFtdcTimeType TradeTime;
|
||||
///交易所代码
|
||||
TSecurityFtdcExchangeIDType ExchangeID;
|
||||
///合约代码
|
||||
TSecurityFtdcInstrumentIDType InstrumentID;
|
||||
///成交价格
|
||||
TSecurityFtdcPriceType Price;
|
||||
///成交数量
|
||||
TSecurityFtdcVolumeType Volume;
|
||||
///报单类型
|
||||
TSecurityFtdcOrderKindType OrderKind;
|
||||
///功能码
|
||||
TSecurityFtdcFunctionCodeType FunctionCode;
|
||||
};
|
||||
|
||||
|
||||
_LTS_NS_END_
|
||||
|
||||
#endif
|
150
vn.lts/pyscript/l2/SecurityFtdcL2MDUserApi.h
Normal file
150
vn.lts/pyscript/l2/SecurityFtdcL2MDUserApi.h
Normal file
@ -0,0 +1,150 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///@company shanghai liber information Technology Co.,Ltd
|
||||
///@file SecurityFtdcL2MDUserApi.h
|
||||
///@brief 定义客户端接口
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(SECURITY_L2MD_FTDCUSERAPI_H)
|
||||
#define SECURITY_L2MD_FTDCUSERAPI_H
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include "SecurityFtdcL2MDUserApiStruct.h"
|
||||
|
||||
_LTS_NS_BEGIN_
|
||||
#if defined(L2MD_USERAPI_IS_LIB) && defined(WINDOWS)
|
||||
#ifdef LIB_L2MD_USER_API_EXPORT
|
||||
#define L2MD_USER_API_EXPORT __declspec(dllexport)
|
||||
#else
|
||||
#define L2MD_USER_API_EXPORT __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define L2MD_USER_API_EXPORT
|
||||
#endif
|
||||
|
||||
class CSecurityFtdcL2MDUserSpi
|
||||
{
|
||||
public:
|
||||
///当客户端与交易后台建立起通信连接时(还未登录前),该方法被调用。
|
||||
virtual void OnFrontConnected(){};
|
||||
|
||||
///当客户端与交易后台通信连接断开时,该方法被调用。当发生这个情况后,API会自动重新连接,客户端可不做处理。
|
||||
///@param nReason 错误原因
|
||||
/// 0x1001 网络读失败
|
||||
/// 0x1002 网络写失败
|
||||
/// 0x2001 接收心跳超时
|
||||
/// 0x2002 发送心跳失败
|
||||
/// 0x2003 收到错误报文
|
||||
virtual void OnFrontDisconnected(int nReason){};
|
||||
|
||||
///心跳超时警告
|
||||
virtual void OnHeartBeatWarning(int nTimeLapse){};
|
||||
|
||||
///错误应答
|
||||
virtual void OnRspError(CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///登录请求响应
|
||||
virtual void OnRspUserLogin(CSecurityFtdcUserLoginField *pUserLogin, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///登出请求响应
|
||||
virtual void OnRspUserLogout(CSecurityFtdcUserLogoutField *pUserLogout, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///订阅Level2行情应答
|
||||
virtual void OnRspSubL2MarketData(CSecurityFtdcSpecificInstrumentField *pSpecificInstrument, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///取消订阅Level2行情应答
|
||||
virtual void OnRspUnSubL2MarketData(CSecurityFtdcSpecificInstrumentField *pSpecificInstrument, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///订阅Level2指数行情应答
|
||||
virtual void OnRspSubL2Index(CSecurityFtdcSpecificInstrumentField *pSpecificInstrument, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///取消订阅Level2指数行情应答
|
||||
virtual void OnRspUnSubL2Index(CSecurityFtdcSpecificInstrumentField *pSpecificInstrument, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///Level2行情通知
|
||||
virtual void OnRtnL2MarketData(CSecurityFtdcL2MarketDataField *pL2MarketData) {};
|
||||
|
||||
///Level2指数行情通知
|
||||
virtual void OnRtnL2Index(CSecurityFtdcL2IndexField *pL2Index) {};
|
||||
|
||||
///订阅逐笔委托及成交应答
|
||||
virtual void OnRspSubL2OrderAndTrade(CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///取消订阅逐笔委托及成交应答
|
||||
virtual void OnRspUnSubL2OrderAndTrade(CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||||
|
||||
///Level2委托通知
|
||||
virtual void OnRtnL2Order(CSecurityFtdcL2OrderField *pL2Order) {};
|
||||
|
||||
///Level2成交通知
|
||||
virtual void OnRtnL2Trade(CSecurityFtdcL2TradeField *pL2Trade) {};
|
||||
|
||||
///通知清理SSE买卖一队列中数量为0的报单
|
||||
virtual void OnNtfCheckOrderList(TSecurityFtdcInstrumentIDType InstrumentID, TSecurityFtdcFunctionCodeType FunctionCode) {};
|
||||
};
|
||||
|
||||
#ifndef WINDOWS
|
||||
#if __GNUC__ >= 4
|
||||
#pragma GCC visibility push(default)
|
||||
#endif
|
||||
#endif
|
||||
class L2MD_USER_API_EXPORT CSecurityFtdcL2MDUserApi
|
||||
{
|
||||
public:
|
||||
///创建UserApi
|
||||
static CSecurityFtdcL2MDUserApi *CreateFtdcL2MDUserApi(const bool bIsMulticast=false);
|
||||
|
||||
///删除接口对象本身
|
||||
///@remark 不再使用本接口对象时,调用该函数删除接口对象
|
||||
virtual void Release() = 0;
|
||||
|
||||
///初始化
|
||||
///@remark 初始化运行环境,只有调用后,接口才开始工作
|
||||
virtual void Init() = 0;
|
||||
|
||||
///等待接口线程结束运行
|
||||
virtual int Join() = 0;
|
||||
|
||||
///获取当前交易日
|
||||
///@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 pSpi 派生自回调接口类的实例
|
||||
virtual void RegisterSpi(CSecurityFtdcL2MDUserSpi *pSpi) = 0;
|
||||
|
||||
virtual int SubscribeL2MarketData(char *ppInstrumentID[], int nCount, char* pExchageID) = 0;
|
||||
|
||||
virtual int UnSubscribeL2MarketData(char *ppInstrumentID[], int nCount, char* pExchageID) = 0;
|
||||
|
||||
virtual int SubscribeL2Index(char *ppInstrumentID[], int nCount, char* pExchageID) = 0;
|
||||
|
||||
virtual int UnSubscribeL2Index(char *ppInstrumentID[], int nCount, char* pExchageID) = 0;
|
||||
|
||||
virtual int SubscribeL2OrderAndTrade() = 0;
|
||||
|
||||
virtual int UnSubscribeL2OrderAndTrade() = 0;
|
||||
|
||||
///登录请求
|
||||
virtual int ReqUserLogin(CSecurityFtdcUserLoginField *pUserLogin, int nRequestID) = 0;
|
||||
|
||||
///登出请求
|
||||
virtual int ReqUserLogout(CSecurityFtdcUserLogoutField *pUserLogout, int nRequestID) = 0;
|
||||
protected:
|
||||
~CSecurityFtdcL2MDUserApi(){};
|
||||
};
|
||||
#ifndef WINDOWS
|
||||
#if __GNUC__ >= 4
|
||||
#pragma GCC visibility pop
|
||||
#endif
|
||||
#endif
|
||||
_LTS_NS_END_
|
||||
#endif
|
213
vn.lts/pyscript/l2/SecurityFtdcL2MDUserApiDataType.h
Normal file
213
vn.lts/pyscript/l2/SecurityFtdcL2MDUserApiDataType.h
Normal file
@ -0,0 +1,213 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///@company shanghai liber information Technology Co.,Ltd
|
||||
///@file SecurityFtdcL2MDUserApiDataType.h
|
||||
///@brief 定义业务数据类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef SECURITY_L2MD_FTDCDATATYPE_H
|
||||
#define SECURITY_L2MD_FTDCDATATYPE_H
|
||||
|
||||
#include "LTS_ns.h"
|
||||
|
||||
_LTS_NS_BEGIN_
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcErrorIDType是一个错误代码类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef int TSecurityFtdcErrorIDType;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcErrorMsgType是一个错误信息类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef char TSecurityFtdcErrorMsgType[81];
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcBrokerIDType是一个经纪公司代码类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef char TSecurityFtdcBrokerIDType[11];
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcUserIDType是一个用户代码类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef char TSecurityFtdcUserIDType[16];
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcUserNameType是一个用户名称类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef char TSecurityFtdcUserNameType[81];
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcPasswordType是一个密码类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef char TSecurityFtdcPasswordType[41];
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcExchangeIDType是一个交易所代码类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef char TSecurityFtdcExchangeIDType[9];
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcInstrumentIDType是一个合约代码类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef char TSecurityFtdcInstrumentIDType[31];
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcDateType是一个日期类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef char TSecurityFtdcDateType[9];
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcTimeType是一个时间类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef char TSecurityFtdcTimeType[9];
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcPriceType是一个价格类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef double TSecurityFtdcPriceType;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcVolumeType是一个数量类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef int TSecurityFtdcVolumeType;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcLargeVolumeType是一个大额数量类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef double TSecurityFtdcLargeVolumeType;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcRatioType是一个比率类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef double TSecurityFtdcRatioType;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcMoneyType是一个资金类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef double TSecurityFtdcMoneyType;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcPriceLevelType是一个价格深度类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef int TSecurityFtdcPriceLevelType;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcBoolType是一个布尔型类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef int TSecurityFtdcBoolType;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcIndexType是一个指数类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef double TSecurityFtdcIndexType;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcDataLevelType是一个行情数据等级类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///全量行情
|
||||
#define SECURITY_FTDC_DL_FULL '0'
|
||||
///L10行情
|
||||
#define SECURITY_FTDC_DL_L10 '1'
|
||||
///L5行情
|
||||
#define SECURITY_FTDC_DL_L5 '2'
|
||||
|
||||
typedef char TSecurityFtdcDataLevelType;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcIPAddressType是一个IP地址类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef char TSecurityFtdcIPAddressType[16];
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcIPPortType是一个IP端口类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef int TSecurityFtdcIPPortType;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcBeginStringType是一个step起始串类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef char TSecurityFtdcBeginStringType[17];
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcBodyLengthType是一个消息体长度类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef int TSecurityFtdcBodyLengthType;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcMsgTypeType是一个消息类型类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef char TSecurityFtdcMsgTypeType[9];
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcSenderCompIDType是一个发送方代码类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef char TSecurityFtdcSenderCompIDType[33];
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcTargetCompIDType是一个接收方代码类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef char TSecurityFtdcTargetCompIDType[33];
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcMsgSeqNumType是一个头消息序号标签34类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef int TSecurityFtdcMsgSeqNumType;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcSendingTimeType是一个发送时间类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef char TSecurityFtdcSendingTimeType[21];
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcMessageEncodingType是一个消息中Encoded域的字符编码类型类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef char TSecurityFtdcMessageEncodingType[21];
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcCheckSumType是一个校验和类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef int TSecurityFtdcCheckSumType;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcEncryptMethodType是一个加密方法类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef char TSecurityFtdcEncryptMethodType[9];
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcHeartBtIntType是一个心跳间隔类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef int TSecurityFtdcHeartBtIntType;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcInterfaceVersionType是一个行情数据接口版本号类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef char TSecurityFtdcInterfaceVersionType[9];
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcMsgSeqIDType是一个消息序号标签10072类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef int TSecurityFtdcMsgSeqIDType;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcGroupIDType是一个组号类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef int TSecurityFtdcGroupIDType;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcGroupNoType是一个组序类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef int TSecurityFtdcGroupNoType;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcOrderKindType是一个报单类型类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef char TSecurityFtdcOrderKindType[2];
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///TFtdcFunctionCodeType是一个功能码类型
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
typedef char TSecurityFtdcFunctionCodeType[2];
|
||||
|
||||
_LTS_NS_END_
|
||||
|
||||
#endif
|
786
vn.lts/pyscript/l2/SecurityFtdcL2MDUserApiStruct.h
Normal file
786
vn.lts/pyscript/l2/SecurityFtdcL2MDUserApiStruct.h
Normal file
@ -0,0 +1,786 @@
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
///@company shanghai liber information Technology Co.,Ltd
|
||||
///@file SecurityFtdcL2MDUserApiStruct.h
|
||||
///@brief 定义业务数据结构
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(SECURITY_L2MD_FTDCSTRUCT_H)
|
||||
#define SECURITY_L2MD_FTDCSTRUCT_H
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include "SecurityFtdcL2MDUserApiDataType.h"
|
||||
|
||||
_LTS_NS_BEGIN_
|
||||
|
||||
///响应信息
|
||||
struct CSecurityFtdcRspInfoField
|
||||
{
|
||||
///错误代码
|
||||
TSecurityFtdcErrorIDType ErrorID;
|
||||
///错误信息
|
||||
TSecurityFtdcErrorMsgType ErrorMsg;
|
||||
};
|
||||
|
||||
///用户登录信息
|
||||
struct CSecurityFtdcUserLoginField
|
||||
{
|
||||
///交易日
|
||||
TSecurityFtdcDateType TradingDay;
|
||||
///经纪公司代码
|
||||
TSecurityFtdcBrokerIDType BrokerID;
|
||||
///用户代码
|
||||
TSecurityFtdcUserIDType UserID;
|
||||
///密码
|
||||
TSecurityFtdcPasswordType Password;
|
||||
///行情数据等级
|
||||
TSecurityFtdcDataLevelType DataLevel;
|
||||
};
|
||||
|
||||
///用户登出信息
|
||||
struct CSecurityFtdcUserLogoutField
|
||||
{
|
||||
///经纪公司代码
|
||||
TSecurityFtdcBrokerIDType BrokerID;
|
||||
///用户代码
|
||||
TSecurityFtdcUserIDType UserID;
|
||||
};
|
||||
|
||||
///指定的合约
|
||||
struct CSecurityFtdcSpecificInstrumentField
|
||||
{
|
||||
///合约代码
|
||||
TSecurityFtdcInstrumentIDType InstrumentID;
|
||||
///交易所代码
|
||||
TSecurityFtdcExchangeIDType ExchangeID;
|
||||
};
|
||||
|
||||
///Level2行情
|
||||
struct CSecurityFtdcL2MarketDataField
|
||||
{
|
||||
///交易日
|
||||
TSecurityFtdcDateType TradingDay;
|
||||
///时间戳
|
||||
TSecurityFtdcTimeType TimeStamp;
|
||||
///交易所代码
|
||||
TSecurityFtdcExchangeIDType ExchangeID;
|
||||
///合约代码
|
||||
TSecurityFtdcInstrumentIDType InstrumentID;
|
||||
///昨收盘价
|
||||
TSecurityFtdcPriceType PreClosePrice;
|
||||
///今开盘价
|
||||
TSecurityFtdcPriceType OpenPrice;
|
||||
///收盘价
|
||||
TSecurityFtdcPriceType ClosePrice;
|
||||
///净值估值
|
||||
TSecurityFtdcPriceType IOPV;
|
||||
///到期收益率
|
||||
TSecurityFtdcRatioType YieldToMaturity;
|
||||
///最高价
|
||||
TSecurityFtdcPriceType HighPrice;
|
||||
///最低价
|
||||
TSecurityFtdcPriceType LowPrice;
|
||||
///最新价
|
||||
TSecurityFtdcPriceType LastPrice;
|
||||
///成交笔数
|
||||
TSecurityFtdcVolumeType TradeCount;
|
||||
///成交总量
|
||||
TSecurityFtdcLargeVolumeType TotalTradeVolume;
|
||||
///成交总金额
|
||||
TSecurityFtdcMoneyType TotalTradeValue;
|
||||
///委托买入总量
|
||||
TSecurityFtdcLargeVolumeType TotalBidVolume;
|
||||
///加权平均委买价
|
||||
TSecurityFtdcPriceType WeightedAvgBidPrice;
|
||||
///债券加权平均委买价
|
||||
TSecurityFtdcPriceType AltWeightedAvgBidPrice;
|
||||
///委托卖出总量
|
||||
TSecurityFtdcLargeVolumeType TotalOfferVolume;
|
||||
///加权平均委卖价
|
||||
TSecurityFtdcPriceType WeightedAvgOfferPrice;
|
||||
///债券加权平均委卖价格
|
||||
TSecurityFtdcPriceType AltWeightedAvgOfferPrice;
|
||||
///买价深度
|
||||
TSecurityFtdcPriceLevelType BidPriceLevel;
|
||||
///卖价深度
|
||||
TSecurityFtdcPriceLevelType OfferPriceLevel;
|
||||
///申买价一
|
||||
TSecurityFtdcPriceType BidPrice1;
|
||||
///申买量一
|
||||
TSecurityFtdcVolumeType BidVolume1;
|
||||
///实际买总委托笔数一
|
||||
TSecurityFtdcVolumeType BidCount1;
|
||||
///申买价二
|
||||
TSecurityFtdcPriceType BidPrice2;
|
||||
///申买量二
|
||||
TSecurityFtdcVolumeType BidVolume2;
|
||||
///实际买总委托笔数二
|
||||
TSecurityFtdcVolumeType BidCount2;
|
||||
///申买价三
|
||||
TSecurityFtdcPriceType BidPrice3;
|
||||
///申买量三
|
||||
TSecurityFtdcVolumeType BidVolume3;
|
||||
///实际买总委托笔数三
|
||||
TSecurityFtdcVolumeType BidCount3;
|
||||
///申买价四
|
||||
TSecurityFtdcPriceType BidPrice4;
|
||||
///申买量四
|
||||
TSecurityFtdcVolumeType BidVolume4;
|
||||
///实际买总委托笔数四
|
||||
TSecurityFtdcVolumeType BidCount4;
|
||||
///申买价五
|
||||
TSecurityFtdcPriceType BidPrice5;
|
||||
///申买量五
|
||||
TSecurityFtdcVolumeType BidVolume5;
|
||||
///实际买总委托笔数五
|
||||
TSecurityFtdcVolumeType BidCount5;
|
||||
///申买价六
|
||||
TSecurityFtdcPriceType BidPrice6;
|
||||
///申买量六
|
||||
TSecurityFtdcVolumeType BidVolume6;
|
||||
///实际买总委托笔数六
|
||||
TSecurityFtdcVolumeType BidCount6;
|
||||
///申买价七
|
||||
TSecurityFtdcPriceType BidPrice7;
|
||||
///申买量七
|
||||
TSecurityFtdcVolumeType BidVolume7;
|
||||
///实际买总委托笔数七
|
||||
TSecurityFtdcVolumeType BidCount7;
|
||||
///申买价八
|
||||
TSecurityFtdcPriceType BidPrice8;
|
||||
///申买量八
|
||||
TSecurityFtdcVolumeType BidVolume8;
|
||||
///实际买总委托笔数八
|
||||
TSecurityFtdcVolumeType BidCount8;
|
||||
///申买价九
|
||||
TSecurityFtdcPriceType BidPrice9;
|
||||
///申买量九
|
||||
TSecurityFtdcVolumeType BidVolume9;
|
||||
///实际买总委托笔数九
|
||||
TSecurityFtdcVolumeType BidCount9;
|
||||
///申买价十
|
||||
TSecurityFtdcPriceType BidPriceA;
|
||||
///申买量十
|
||||
TSecurityFtdcVolumeType BidVolumeA;
|
||||
///实际买总委托笔数十
|
||||
TSecurityFtdcVolumeType BidCountA;
|
||||
///申卖价一
|
||||
TSecurityFtdcPriceType OfferPrice1;
|
||||
///申卖量一
|
||||
TSecurityFtdcVolumeType OfferVolume1;
|
||||
///实际卖总委托笔数一
|
||||
TSecurityFtdcVolumeType OfferCount1;
|
||||
///申卖价二
|
||||
TSecurityFtdcPriceType OfferPrice2;
|
||||
///申卖量二
|
||||
TSecurityFtdcVolumeType OfferVolume2;
|
||||
///实际卖总委托笔数二
|
||||
TSecurityFtdcVolumeType OfferCount2;
|
||||
///申卖价三
|
||||
TSecurityFtdcPriceType OfferPrice3;
|
||||
///申卖量三
|
||||
TSecurityFtdcVolumeType OfferVolume3;
|
||||
///实际卖总委托笔数三
|
||||
TSecurityFtdcVolumeType OfferCount3;
|
||||
///申卖价四
|
||||
TSecurityFtdcPriceType OfferPrice4;
|
||||
///申卖量四
|
||||
TSecurityFtdcVolumeType OfferVolume4;
|
||||
///实际卖总委托笔数四
|
||||
TSecurityFtdcVolumeType OfferCount4;
|
||||
///申卖价五
|
||||
TSecurityFtdcPriceType OfferPrice5;
|
||||
///申卖量五
|
||||
TSecurityFtdcVolumeType OfferVolume5;
|
||||
///实际卖总委托笔数五
|
||||
TSecurityFtdcVolumeType OfferCount5;
|
||||
///申卖价六
|
||||
TSecurityFtdcPriceType OfferPrice6;
|
||||
///申卖量六
|
||||
TSecurityFtdcVolumeType OfferVolume6;
|
||||
///实际卖总委托笔数六
|
||||
TSecurityFtdcVolumeType OfferCount6;
|
||||
///申卖价七
|
||||
TSecurityFtdcPriceType OfferPrice7;
|
||||
///申卖量七
|
||||
TSecurityFtdcVolumeType OfferVolume7;
|
||||
///实际卖总委托笔数七
|
||||
TSecurityFtdcVolumeType OfferCount7;
|
||||
///申卖价八
|
||||
TSecurityFtdcPriceType OfferPrice8;
|
||||
///申卖量八
|
||||
TSecurityFtdcVolumeType OfferVolume8;
|
||||
///实际卖总委托笔数八
|
||||
TSecurityFtdcVolumeType OfferCount8;
|
||||
///申卖价九
|
||||
TSecurityFtdcPriceType OfferPrice9;
|
||||
///申卖量九
|
||||
TSecurityFtdcVolumeType OfferVolume9;
|
||||
///实际卖总委托笔数九
|
||||
TSecurityFtdcVolumeType OfferCount9;
|
||||
///申卖价十
|
||||
TSecurityFtdcPriceType OfferPriceA;
|
||||
///申卖量十
|
||||
TSecurityFtdcVolumeType OfferVolumeA;
|
||||
///实际卖总委托笔数十
|
||||
TSecurityFtdcVolumeType OfferCountA;
|
||||
};
|
||||
|
||||
///Level2行情更新时间属性
|
||||
struct CSecurityFtdcL2UpdateTimeField
|
||||
{
|
||||
///交易日
|
||||
TSecurityFtdcDateType TradingDay;
|
||||
///时间戳
|
||||
TSecurityFtdcTimeType TimeStamp;
|
||||
///交易所代码
|
||||
TSecurityFtdcExchangeIDType ExchangeID;
|
||||
///合约代码
|
||||
TSecurityFtdcInstrumentIDType InstrumentID;
|
||||
};
|
||||
|
||||
///Level2行情静态属性
|
||||
struct CSecurityFtdcL2StaticField
|
||||
{
|
||||
///昨收盘价
|
||||
TSecurityFtdcPriceType PreClosePrice;
|
||||
///今开盘价
|
||||
TSecurityFtdcPriceType OpenPrice;
|
||||
///收盘价
|
||||
TSecurityFtdcPriceType ClosePrice;
|
||||
///净值估值
|
||||
TSecurityFtdcPriceType IOPV;
|
||||
///到期收益率
|
||||
TSecurityFtdcRatioType YieldToMaturity;
|
||||
};
|
||||
|
||||
///Level2行情价格区间属性
|
||||
struct CSecurityFtdcL2PriceIntervalField
|
||||
{
|
||||
///最高价
|
||||
TSecurityFtdcPriceType HighPrice;
|
||||
///最低价
|
||||
TSecurityFtdcPriceType LowPrice;
|
||||
};
|
||||
|
||||
///Level2行情基本信息
|
||||
struct CSecurityFtdcL2BaseField
|
||||
{
|
||||
///最新价
|
||||
TSecurityFtdcPriceType LastPrice;
|
||||
};
|
||||
|
||||
///Level2成交信息
|
||||
struct CSecurityFtdcL2TradedField
|
||||
{
|
||||
///成交笔数
|
||||
TSecurityFtdcVolumeType TradeCount;
|
||||
///成交总量
|
||||
TSecurityFtdcLargeVolumeType TotalTradeVolume;
|
||||
///成交总金额
|
||||
TSecurityFtdcMoneyType TotalTradeValue;
|
||||
};
|
||||
|
||||
///Level2行情数据属性
|
||||
struct CSecurityFtdcL2DataLevelField
|
||||
{
|
||||
///价格
|
||||
TSecurityFtdcPriceType Price;
|
||||
///数量
|
||||
TSecurityFtdcVolumeType Volume;
|
||||
///实际总委托笔数
|
||||
TSecurityFtdcVolumeType Count;
|
||||
};
|
||||
|
||||
///Level2委买信息
|
||||
struct CSecurityFtdcL2BidOrderField
|
||||
{
|
||||
///委托买入总量
|
||||
TSecurityFtdcLargeVolumeType TotalBidVolume;
|
||||
///加权平均委买价
|
||||
TSecurityFtdcPriceType WeightedAvgBidPrice;
|
||||
///债券加权平均委买价
|
||||
TSecurityFtdcPriceType AltWeightedAvgBidPrice;
|
||||
};
|
||||
|
||||
///Level2委卖信息
|
||||
struct CSecurityFtdcL2OfferOrderField
|
||||
{
|
||||
///委托卖出总量
|
||||
TSecurityFtdcLargeVolumeType TotalOfferVolume;
|
||||
///加权平均委卖价
|
||||
TSecurityFtdcPriceType WeightedAvgOfferPrice;
|
||||
///债券加权平均委卖价格
|
||||
TSecurityFtdcPriceType AltWeightedAvgOfferPrice;
|
||||
};
|
||||
|
||||
///Level2价格深度属性
|
||||
struct CSecurityFtdcL2PriceLevelField
|
||||
{
|
||||
///买价深度
|
||||
TSecurityFtdcPriceLevelType BidPriceLevel;
|
||||
///卖价深度
|
||||
TSecurityFtdcPriceLevelType OfferPriceLevel;
|
||||
};
|
||||
|
||||
///Level2行情申买一属性
|
||||
struct CSecurityFtdcL2Bid1Field
|
||||
{
|
||||
///申买价一
|
||||
TSecurityFtdcPriceType BidPrice1;
|
||||
///申买量一
|
||||
TSecurityFtdcVolumeType BidVolume1;
|
||||
///实际买总委托笔数一
|
||||
TSecurityFtdcVolumeType BidCount1;
|
||||
};
|
||||
|
||||
///Level2行情申卖一属性
|
||||
struct CSecurityFtdcL2Offer1Field
|
||||
{
|
||||
///申卖价一
|
||||
TSecurityFtdcPriceType OfferPrice1;
|
||||
///申卖量一
|
||||
TSecurityFtdcVolumeType OfferVolume1;
|
||||
///实际卖总委托笔数一
|
||||
TSecurityFtdcVolumeType OfferCount1;
|
||||
};
|
||||
|
||||
///Level2行情申买二属性
|
||||
struct CSecurityFtdcL2Bid2Field
|
||||
{
|
||||
///申买价二
|
||||
TSecurityFtdcPriceType BidPrice2;
|
||||
///申买量二
|
||||
TSecurityFtdcVolumeType BidVolume2;
|
||||
///实际买总委托笔数二
|
||||
TSecurityFtdcVolumeType BidCount2;
|
||||
};
|
||||
|
||||
///Level2行情申卖二属性
|
||||
struct CSecurityFtdcL2Offer2Field
|
||||
{
|
||||
///申卖价二
|
||||
TSecurityFtdcPriceType OfferPrice2;
|
||||
///申卖量二
|
||||
TSecurityFtdcVolumeType OfferVolume2;
|
||||
///实际卖总委托笔数二
|
||||
TSecurityFtdcVolumeType OfferCount2;
|
||||
};
|
||||
|
||||
///Level2行情申买三属性
|
||||
struct CSecurityFtdcL2Bid3Field
|
||||
{
|
||||
///申买价三
|
||||
TSecurityFtdcPriceType BidPrice3;
|
||||
///申买量三
|
||||
TSecurityFtdcVolumeType BidVolume3;
|
||||
///实际买总委托笔数三
|
||||
TSecurityFtdcVolumeType BidCount3;
|
||||
};
|
||||
|
||||
///Level2行情申卖三属性
|
||||
struct CSecurityFtdcL2Offer3Field
|
||||
{
|
||||
///申卖价三
|
||||
TSecurityFtdcPriceType OfferPrice3;
|
||||
///申卖量三
|
||||
TSecurityFtdcVolumeType OfferVolume3;
|
||||
///实际卖总委托笔数三
|
||||
TSecurityFtdcVolumeType OfferCount3;
|
||||
};
|
||||
|
||||
///Level2行情申买四属性
|
||||
struct CSecurityFtdcL2Bid4Field
|
||||
{
|
||||
///申买价四
|
||||
TSecurityFtdcPriceType BidPrice4;
|
||||
///申买量四
|
||||
TSecurityFtdcVolumeType BidVolume4;
|
||||
///实际买总委托笔数四
|
||||
TSecurityFtdcVolumeType BidCount4;
|
||||
};
|
||||
|
||||
///Level2行情申卖四属性
|
||||
struct CSecurityFtdcL2Offer4Field
|
||||
{
|
||||
///申卖价四
|
||||
TSecurityFtdcPriceType OfferPrice4;
|
||||
///申卖量四
|
||||
TSecurityFtdcVolumeType OfferVolume4;
|
||||
///实际卖总委托笔数四
|
||||
TSecurityFtdcVolumeType OfferCount4;
|
||||
};
|
||||
|
||||
///Level2行情申买五属性
|
||||
struct CSecurityFtdcL2Bid5Field
|
||||
{
|
||||
///申买价五
|
||||
TSecurityFtdcPriceType BidPrice5;
|
||||
///申买量五
|
||||
TSecurityFtdcVolumeType BidVolume5;
|
||||
///实际买总委托笔数五
|
||||
TSecurityFtdcVolumeType BidCount5;
|
||||
};
|
||||
|
||||
///Level2行情申卖五属性
|
||||
struct CSecurityFtdcL2Offer5Field
|
||||
{
|
||||
///申卖价五
|
||||
TSecurityFtdcPriceType OfferPrice5;
|
||||
///申卖量五
|
||||
TSecurityFtdcVolumeType OfferVolume5;
|
||||
///实际卖总委托笔数五
|
||||
TSecurityFtdcVolumeType OfferCount5;
|
||||
};
|
||||
|
||||
///Level2行情申买六属性
|
||||
struct CSecurityFtdcL2Bid6Field
|
||||
{
|
||||
///申买价六
|
||||
TSecurityFtdcPriceType BidPrice6;
|
||||
///申买量六
|
||||
TSecurityFtdcVolumeType BidVolume6;
|
||||
///实际买总委托笔数六
|
||||
TSecurityFtdcVolumeType BidCount6;
|
||||
};
|
||||
|
||||
///Level2行情申卖六属性
|
||||
struct CSecurityFtdcL2Offer6Field
|
||||
{
|
||||
///申卖价六
|
||||
TSecurityFtdcPriceType OfferPrice6;
|
||||
///申卖量六
|
||||
TSecurityFtdcVolumeType OfferVolume6;
|
||||
///实际卖总委托笔数六
|
||||
TSecurityFtdcVolumeType OfferCount6;
|
||||
};
|
||||
|
||||
///Level2行情申买七属性
|
||||
struct CSecurityFtdcL2Bid7Field
|
||||
{
|
||||
///申买价七
|
||||
TSecurityFtdcPriceType BidPrice7;
|
||||
///申买量七
|
||||
TSecurityFtdcVolumeType BidVolume7;
|
||||
///实际买总委托笔数七
|
||||
TSecurityFtdcVolumeType BidCount7;
|
||||
};
|
||||
|
||||
///Level2行情申卖七属性
|
||||
struct CSecurityFtdcL2Offer7Field
|
||||
{
|
||||
///申卖价七
|
||||
TSecurityFtdcPriceType OfferPrice7;
|
||||
///申卖量七
|
||||
TSecurityFtdcVolumeType OfferVolume7;
|
||||
///实际卖总委托笔数七
|
||||
TSecurityFtdcVolumeType OfferCount7;
|
||||
};
|
||||
|
||||
///Level2行情申买八属性
|
||||
struct CSecurityFtdcL2Bid8Field
|
||||
{
|
||||
///申买价八
|
||||
TSecurityFtdcPriceType BidPrice8;
|
||||
///申买量八
|
||||
TSecurityFtdcVolumeType BidVolume8;
|
||||
///实际买总委托笔数八
|
||||
TSecurityFtdcVolumeType BidCount8;
|
||||
};
|
||||
|
||||
///Level2行情申卖八属性
|
||||
struct CSecurityFtdcL2Offer8Field
|
||||
{
|
||||
///申卖价八
|
||||
TSecurityFtdcPriceType OfferPrice8;
|
||||
///申卖量八
|
||||
TSecurityFtdcVolumeType OfferVolume8;
|
||||
///实际卖总委托笔数八
|
||||
TSecurityFtdcVolumeType OfferCount8;
|
||||
};
|
||||
|
||||
///Level2行情申买九属性
|
||||
struct CSecurityFtdcL2Bid9Field
|
||||
{
|
||||
///申买价九
|
||||
TSecurityFtdcPriceType BidPrice9;
|
||||
///申买量九
|
||||
TSecurityFtdcVolumeType BidVolume9;
|
||||
///实际买总委托笔数九
|
||||
TSecurityFtdcVolumeType BidCount9;
|
||||
};
|
||||
|
||||
///Level2行情申卖九属性
|
||||
struct CSecurityFtdcL2Offer9Field
|
||||
{
|
||||
///申卖价九
|
||||
TSecurityFtdcPriceType OfferPrice9;
|
||||
///申卖量九
|
||||
TSecurityFtdcVolumeType OfferVolume9;
|
||||
///实际卖总委托笔数九
|
||||
TSecurityFtdcVolumeType OfferCount9;
|
||||
};
|
||||
|
||||
///Level2行情申买十属性
|
||||
struct CSecurityFtdcL2BidAField
|
||||
{
|
||||
///申买价十
|
||||
TSecurityFtdcPriceType BidPriceA;
|
||||
///申买量十
|
||||
TSecurityFtdcVolumeType BidVolumeA;
|
||||
///实际买总委托笔数十
|
||||
TSecurityFtdcVolumeType BidCountA;
|
||||
};
|
||||
|
||||
///Level2行情申卖十属性
|
||||
struct CSecurityFtdcL2OfferAField
|
||||
{
|
||||
///申卖价十
|
||||
TSecurityFtdcPriceType OfferPriceA;
|
||||
///申卖量十
|
||||
TSecurityFtdcVolumeType OfferVolumeA;
|
||||
///实际卖总委托笔数十
|
||||
TSecurityFtdcVolumeType OfferCountA;
|
||||
};
|
||||
|
||||
///Level2行情申买属性
|
||||
struct CSecurityFtdcL2BidField
|
||||
{
|
||||
///申买价一
|
||||
TSecurityFtdcPriceType BidPrice1;
|
||||
///申买量一
|
||||
TSecurityFtdcVolumeType BidVolume1;
|
||||
///实际买总委托笔数一
|
||||
TSecurityFtdcVolumeType BidCount1;
|
||||
///申买价二
|
||||
TSecurityFtdcPriceType BidPrice2;
|
||||
///申买量二
|
||||
TSecurityFtdcVolumeType BidVolume2;
|
||||
///实际买总委托笔数二
|
||||
TSecurityFtdcVolumeType BidCount2;
|
||||
///申买价三
|
||||
TSecurityFtdcPriceType BidPrice3;
|
||||
///申买量三
|
||||
TSecurityFtdcVolumeType BidVolume3;
|
||||
///实际买总委托笔数三
|
||||
TSecurityFtdcVolumeType BidCount3;
|
||||
///申买价四
|
||||
TSecurityFtdcPriceType BidPrice4;
|
||||
///申买量四
|
||||
TSecurityFtdcVolumeType BidVolume4;
|
||||
///实际买总委托笔数四
|
||||
TSecurityFtdcVolumeType BidCount4;
|
||||
///申买价五
|
||||
TSecurityFtdcPriceType BidPrice5;
|
||||
///申买量五
|
||||
TSecurityFtdcVolumeType BidVolume5;
|
||||
///实际买总委托笔数五
|
||||
TSecurityFtdcVolumeType BidCount5;
|
||||
///申买价六
|
||||
TSecurityFtdcPriceType BidPrice6;
|
||||
///申买量六
|
||||
TSecurityFtdcVolumeType BidVolume6;
|
||||
///实际买总委托笔数六
|
||||
TSecurityFtdcVolumeType BidCount6;
|
||||
///申买价七
|
||||
TSecurityFtdcPriceType BidPrice7;
|
||||
///申买量七
|
||||
TSecurityFtdcVolumeType BidVolume7;
|
||||
///实际买总委托笔数七
|
||||
TSecurityFtdcVolumeType BidCount7;
|
||||
///申买价八
|
||||
TSecurityFtdcPriceType BidPrice8;
|
||||
///申买量八
|
||||
TSecurityFtdcVolumeType BidVolume8;
|
||||
///实际买总委托笔数八
|
||||
TSecurityFtdcVolumeType BidCount8;
|
||||
///申买价九
|
||||
TSecurityFtdcPriceType BidPrice9;
|
||||
///申买量九
|
||||
TSecurityFtdcVolumeType BidVolume9;
|
||||
///实际买总委托笔数九
|
||||
TSecurityFtdcVolumeType BidCount9;
|
||||
///申买价十
|
||||
TSecurityFtdcPriceType BidPriceA;
|
||||
///申买量十
|
||||
TSecurityFtdcVolumeType BidVolumeA;
|
||||
///实际买总委托笔数十
|
||||
TSecurityFtdcVolumeType BidCountA;
|
||||
};
|
||||
|
||||
///Level2行情申卖属性
|
||||
struct CSecurityFtdcL2OfferField
|
||||
{
|
||||
///申卖价一
|
||||
TSecurityFtdcPriceType OfferPrice1;
|
||||
///申卖量一
|
||||
TSecurityFtdcVolumeType OfferVolume1;
|
||||
///实际卖总委托笔数一
|
||||
TSecurityFtdcVolumeType OfferCount1;
|
||||
///申卖价二
|
||||
TSecurityFtdcPriceType OfferPrice2;
|
||||
///申卖量二
|
||||
TSecurityFtdcVolumeType OfferVolume2;
|
||||
///实际卖总委托笔数二
|
||||
TSecurityFtdcVolumeType OfferCount2;
|
||||
///申卖价三
|
||||
TSecurityFtdcPriceType OfferPrice3;
|
||||
///申卖量三
|
||||
TSecurityFtdcVolumeType OfferVolume3;
|
||||
///实际卖总委托笔数三
|
||||
TSecurityFtdcVolumeType OfferCount3;
|
||||
///申卖价四
|
||||
TSecurityFtdcPriceType OfferPrice4;
|
||||
///申卖量四
|
||||
TSecurityFtdcVolumeType OfferVolume4;
|
||||
///实际卖总委托笔数四
|
||||
TSecurityFtdcVolumeType OfferCount4;
|
||||
///申卖价五
|
||||
TSecurityFtdcPriceType OfferPrice5;
|
||||
///申卖量五
|
||||
TSecurityFtdcVolumeType OfferVolume5;
|
||||
///实际卖总委托笔数五
|
||||
TSecurityFtdcVolumeType OfferCount5;
|
||||
///申卖价六
|
||||
TSecurityFtdcPriceType OfferPrice6;
|
||||
///申卖量六
|
||||
TSecurityFtdcVolumeType OfferVolume6;
|
||||
///实际卖总委托笔数六
|
||||
TSecurityFtdcVolumeType OfferCount6;
|
||||
///申卖价七
|
||||
TSecurityFtdcPriceType OfferPrice7;
|
||||
///申卖量七
|
||||
TSecurityFtdcVolumeType OfferVolume7;
|
||||
///实际卖总委托笔数七
|
||||
TSecurityFtdcVolumeType OfferCount7;
|
||||
///申卖价八
|
||||
TSecurityFtdcPriceType OfferPrice8;
|
||||
///申卖量八
|
||||
TSecurityFtdcVolumeType OfferVolume8;
|
||||
///实际卖总委托笔数八
|
||||
TSecurityFtdcVolumeType OfferCount8;
|
||||
///申卖价九
|
||||
TSecurityFtdcPriceType OfferPrice9;
|
||||
///申卖量九
|
||||
TSecurityFtdcVolumeType OfferVolume9;
|
||||
///实际卖总委托笔数九
|
||||
TSecurityFtdcVolumeType OfferCount9;
|
||||
///申卖价十
|
||||
TSecurityFtdcPriceType OfferPriceA;
|
||||
///申卖量十
|
||||
TSecurityFtdcVolumeType OfferVolumeA;
|
||||
///实际卖总委托笔数十
|
||||
TSecurityFtdcVolumeType OfferCountA;
|
||||
};
|
||||
|
||||
///Level2指数行情
|
||||
struct CSecurityFtdcL2IndexField
|
||||
{
|
||||
///交易日
|
||||
TSecurityFtdcDateType TradingDay;
|
||||
///行情时间(秒)
|
||||
TSecurityFtdcTimeType TimeStamp;
|
||||
///交易所代码
|
||||
TSecurityFtdcExchangeIDType ExchangeID;
|
||||
///指数代码
|
||||
TSecurityFtdcInstrumentIDType InstrumentID;
|
||||
///前收盘指数
|
||||
TSecurityFtdcIndexType PreCloseIndex;
|
||||
///今开盘指数
|
||||
TSecurityFtdcIndexType OpenIndex;
|
||||
///今日收盘指数
|
||||
TSecurityFtdcIndexType CloseIndex;
|
||||
///最高指数
|
||||
TSecurityFtdcIndexType HighIndex;
|
||||
///最低指数
|
||||
TSecurityFtdcIndexType LowIndex;
|
||||
///最新指数
|
||||
TSecurityFtdcIndexType LastIndex;
|
||||
///参与计算相应指数的成交金额(元)
|
||||
TSecurityFtdcMoneyType TurnOver;
|
||||
///参与计算相应指数的交易数量(手)
|
||||
TSecurityFtdcLargeVolumeType TotalVolume;
|
||||
};
|
||||
|
||||
///Level2行情用户信息
|
||||
struct CSecurityFtdcL2UserInfoField
|
||||
{
|
||||
///经纪公司代码
|
||||
TSecurityFtdcBrokerIDType BrokerID;
|
||||
///用户代码
|
||||
TSecurityFtdcUserIDType UserID;
|
||||
///用户名称
|
||||
TSecurityFtdcUserNameType UserName;
|
||||
///密码
|
||||
TSecurityFtdcPasswordType Password;
|
||||
///行情数据等级
|
||||
TSecurityFtdcDataLevelType DataLevel;
|
||||
};
|
||||
|
||||
///UDP组播组信息
|
||||
struct CSecurityFtdcMulticastGroupInfoField
|
||||
{
|
||||
///组播组IP地址
|
||||
TSecurityFtdcIPAddressType GroupIP;
|
||||
///组播组IP端口
|
||||
TSecurityFtdcIPPortType GroupPort;
|
||||
///源地址
|
||||
TSecurityFtdcIPAddressType SourceIP;
|
||||
};
|
||||
|
||||
///Level2逐笔委托
|
||||
struct CSecurityFtdcL2OrderField
|
||||
{
|
||||
///委托组
|
||||
TSecurityFtdcGroupIDType OrderGroupID;
|
||||
///委托序号
|
||||
TSecurityFtdcGroupNoType OrderIndex;
|
||||
///委托时间(秒)
|
||||
TSecurityFtdcTimeType OrderTime;
|
||||
///交易所代码
|
||||
TSecurityFtdcExchangeIDType ExchangeID;
|
||||
///合约代码
|
||||
TSecurityFtdcInstrumentIDType InstrumentID;
|
||||
///委托价格
|
||||
TSecurityFtdcPriceType Price;
|
||||
///委托数量
|
||||
TSecurityFtdcVolumeType Volume;
|
||||
///报单类型
|
||||
TSecurityFtdcOrderKindType OrderKind;
|
||||
///功能码
|
||||
TSecurityFtdcFunctionCodeType FunctionCode;
|
||||
};
|
||||
|
||||
///Level2逐笔成交
|
||||
struct CSecurityFtdcL2TradeField
|
||||
{
|
||||
///成交组
|
||||
TSecurityFtdcGroupIDType TradeGroupID;
|
||||
///成交序号
|
||||
TSecurityFtdcGroupNoType TradeIndex;
|
||||
///买方委托序号
|
||||
TSecurityFtdcGroupNoType BuyIndex;
|
||||
///卖方委托序号
|
||||
TSecurityFtdcGroupNoType SellIndex;
|
||||
///成交时间(秒)
|
||||
TSecurityFtdcTimeType TradeTime;
|
||||
///交易所代码
|
||||
TSecurityFtdcExchangeIDType ExchangeID;
|
||||
///合约代码
|
||||
TSecurityFtdcInstrumentIDType InstrumentID;
|
||||
///成交价格
|
||||
TSecurityFtdcPriceType Price;
|
||||
///成交数量
|
||||
TSecurityFtdcVolumeType Volume;
|
||||
///报单类型
|
||||
TSecurityFtdcOrderKindType OrderKind;
|
||||
///功能码
|
||||
TSecurityFtdcFunctionCodeType FunctionCode;
|
||||
};
|
||||
|
||||
|
||||
_LTS_NS_END_
|
||||
|
||||
#endif
|
98
vn.lts/pyscript/l2/generate_data_type.py
Normal file
98
vn.lts/pyscript/l2/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('SecurityFtdcL2MDUserApiDataType.h','r')
|
||||
fpy = open('l2_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()
|
||||
|
291
vn.lts/pyscript/l2/generate_l2_functions.py
Normal file
291
vn.lts/pyscript/l2/generate_l2_functions.py
Normal file
@ -0,0 +1,291 @@
|
||||
# encoding: UTF-8
|
||||
|
||||
__author__ = 'CHENXY'
|
||||
|
||||
from string import join
|
||||
from l2_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\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("\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('SecurityFtdcL2MDUserApi.h', 'r')
|
||||
ftask = open('lts_l2_task.cpp', 'w')
|
||||
fprocess = open('lts_l2_process.cpp', 'w')
|
||||
ffunction = open('lts_l2_function.cpp', 'w')
|
||||
fdefine = open('lts_l2_define.cpp', 'w')
|
||||
fswitch = open('lts_l2_switch.cpp', 'w')
|
||||
fheaderprocess = open('lts_l2_header_process.h', 'w')
|
||||
fheaderon = open('lts_l2_header_on.h', 'w')
|
||||
fheaderfunction = open('lts_l2_header_function.h', 'w')
|
||||
fwrap = open('lts_l2_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()
|
56
vn.lts/pyscript/l2/generate_struct.py
Normal file
56
vn.lts/pyscript/l2/generate_struct.py
Normal file
@ -0,0 +1,56 @@
|
||||
# encoding: UTF-8
|
||||
|
||||
__author__ = 'CHENXY'
|
||||
|
||||
from l2_data_type import *
|
||||
|
||||
def main():
|
||||
"""主函数"""
|
||||
fcpp = open('SecurityFtdcL2MDUserApiStruct.h', 'r')
|
||||
fpy = open('l2_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:
|
||||
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()
|
212
vn.lts/pyscript/l2/l2_data_type.py
Normal file
212
vn.lts/pyscript/l2/l2_data_type.py
Normal file
@ -0,0 +1,212 @@
|
||||
# encoding: UTF-8
|
||||
|
||||
defineDict = {}
|
||||
typedefDict = {}
|
||||
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
#@company shanghai liber information Technology Co.,Ltd
|
||||
#@file SecurityFtdcL2MDUserApiDataType.h
|
||||
#@brief 定义业务数据类型
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
#TFtdcErrorIDType是一个错误代码类型
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
typedefDict["TSecurityFtdcErrorIDType"] = "int"
|
||||
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
#TFtdcErrorMsgType是一个错误信息类型
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
typedefDict["TSecurityFtdcErrorMsgType"] = "string"
|
||||
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
#TFtdcBrokerIDType是一个经纪公司代码类型
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
typedefDict["TSecurityFtdcBrokerIDType"] = "string"
|
||||
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
#TFtdcUserIDType是一个用户代码类型
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
typedefDict["TSecurityFtdcUserIDType"] = "string"
|
||||
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
#TFtdcUserNameType是一个用户名称类型
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
typedefDict["TSecurityFtdcUserNameType"] = "string"
|
||||
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
#TFtdcPasswordType是一个密码类型
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
typedefDict["TSecurityFtdcPasswordType"] = "string"
|
||||
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
#TFtdcExchangeIDType是一个交易所代码类型
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
typedefDict["TSecurityFtdcExchangeIDType"] = "string"
|
||||
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
#TFtdcInstrumentIDType是一个合约代码类型
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
typedefDict["TSecurityFtdcInstrumentIDType"] = "string"
|
||||
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
#TFtdcDateType是一个日期类型
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
typedefDict["TSecurityFtdcDateType"] = "string"
|
||||
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
#TFtdcTimeType是一个时间类型
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
typedefDict["TSecurityFtdcTimeType"] = "string"
|
||||
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
#TFtdcPriceType是一个价格类型
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
typedefDict["TSecurityFtdcPriceType"] = "float"
|
||||
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
#TFtdcVolumeType是一个数量类型
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
typedefDict["TSecurityFtdcVolumeType"] = "int"
|
||||
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
#TFtdcLargeVolumeType是一个大额数量类型
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
typedefDict["TSecurityFtdcLargeVolumeType"] = "float"
|
||||
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
#TFtdcRatioType是一个比率类型
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
typedefDict["TSecurityFtdcRatioType"] = "float"
|
||||
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
#TFtdcMoneyType是一个资金类型
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
typedefDict["TSecurityFtdcMoneyType"] = "float"
|
||||
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
#TFtdcPriceLevelType是一个价格深度类型
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
typedefDict["TSecurityFtdcPriceLevelType"] = "int"
|
||||
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
#TFtdcBoolType是一个布尔型类型
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
typedefDict["TSecurityFtdcBoolType"] = "int"
|
||||
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
#TFtdcIndexType是一个指数类型
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
typedefDict["TSecurityFtdcIndexType"] = "float"
|
||||
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
#TFtdcDataLevelType是一个行情数据等级类型
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
#全量行情
|
||||
defineDict["SECURITY_FTDC_DL_FULL"] = '0'
|
||||
#L10行情
|
||||
defineDict["SECURITY_FTDC_DL_L10"] = '1'
|
||||
#L5行情
|
||||
defineDict["SECURITY_FTDC_DL_L5"] = '2'
|
||||
|
||||
typedefDict["TSecurityFtdcDataLevelType"] = "string"
|
||||
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
#TFtdcIPAddressType是一个IP地址类型
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
typedefDict["TSecurityFtdcIPAddressType"] = "string"
|
||||
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
#TFtdcIPPortType是一个IP端口类型
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
typedefDict["TSecurityFtdcIPPortType"] = "int"
|
||||
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
#TFtdcBeginStringType是一个step起始串类型
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
typedefDict["TSecurityFtdcBeginStringType"] = "string"
|
||||
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
#TFtdcBodyLengthType是一个消息体长度类型
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
typedefDict["TSecurityFtdcBodyLengthType"] = "int"
|
||||
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
#TFtdcMsgTypeType是一个消息类型类型
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
typedefDict["TSecurityFtdcMsgTypeType"] = "string"
|
||||
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
#TFtdcSenderCompIDType是一个发送方代码类型
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
typedefDict["TSecurityFtdcSenderCompIDType"] = "string"
|
||||
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
#TFtdcTargetCompIDType是一个接收方代码类型
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
typedefDict["TSecurityFtdcTargetCompIDType"] = "string"
|
||||
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
#TFtdcMsgSeqNumType是一个头消息序号标签34类型
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
typedefDict["TSecurityFtdcMsgSeqNumType"] = "int"
|
||||
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
#TFtdcSendingTimeType是一个发送时间类型
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
typedefDict["TSecurityFtdcSendingTimeType"] = "string"
|
||||
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
#TFtdcMessageEncodingType是一个消息中Encoded域的字符编码类型类型
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
typedefDict["TSecurityFtdcMessageEncodingType"] = "string"
|
||||
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
#TFtdcCheckSumType是一个校验和类型
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
typedefDict["TSecurityFtdcCheckSumType"] = "int"
|
||||
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
#TFtdcEncryptMethodType是一个加密方法类型
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
typedefDict["TSecurityFtdcEncryptMethodType"] = "string"
|
||||
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
#TFtdcHeartBtIntType是一个心跳间隔类型
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
typedefDict["TSecurityFtdcHeartBtIntType"] = "int"
|
||||
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
#TFtdcInterfaceVersionType是一个行情数据接口版本号类型
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
typedefDict["TSecurityFtdcInterfaceVersionType"] = "string"
|
||||
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
#TFtdcMsgSeqIDType是一个消息序号标签10072类型
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
typedefDict["TSecurityFtdcMsgSeqIDType"] = "int"
|
||||
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
#TFtdcGroupIDType是一个组号类型
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
typedefDict["TSecurityFtdcGroupIDType"] = "int"
|
||||
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
#TFtdcGroupNoType是一个组序类型
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
typedefDict["TSecurityFtdcGroupNoType"] = "int"
|
||||
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
#TFtdcOrderKindType是一个报单类型类型
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
typedefDict["TSecurityFtdcOrderKindType"] = "string"
|
||||
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
#TFtdcFunctionCodeType是一个功能码类型
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
typedefDict["TSecurityFtdcFunctionCodeType"] = "string"
|
||||
|
||||
|
790
vn.lts/pyscript/l2/l2_struct.py
Normal file
790
vn.lts/pyscript/l2/l2_struct.py
Normal file
@ -0,0 +1,790 @@
|
||||
# encoding: UTF-8
|
||||
|
||||
structDict = {}
|
||||
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
#@company shanghai liber information Technology Co.,Ltd
|
||||
#@file SecurityFtdcL2MDUserApiStruct.h
|
||||
#@brief 定义业务数据结构
|
||||
#//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#响应信息
|
||||
CSecurityFtdcRspInfoField = {}
|
||||
#错误代码
|
||||
CSecurityFtdcRspInfoField["ErrorID"] = "int"
|
||||
#错误信息
|
||||
CSecurityFtdcRspInfoField["ErrorMsg"] = "string"
|
||||
structDict['CSecurityFtdcRspInfoField'] = CSecurityFtdcRspInfoField
|
||||
|
||||
|
||||
#用户登录信息
|
||||
CSecurityFtdcUserLoginField = {}
|
||||
#交易日
|
||||
CSecurityFtdcUserLoginField["TradingDay"] = "string"
|
||||
#经纪公司代码
|
||||
CSecurityFtdcUserLoginField["BrokerID"] = "string"
|
||||
#用户代码
|
||||
CSecurityFtdcUserLoginField["UserID"] = "string"
|
||||
#密码
|
||||
CSecurityFtdcUserLoginField["Password"] = "string"
|
||||
#行情数据等级
|
||||
CSecurityFtdcUserLoginField["DataLevel"] = "string"
|
||||
structDict['CSecurityFtdcUserLoginField'] = CSecurityFtdcUserLoginField
|
||||
|
||||
|
||||
#用户登出信息
|
||||
CSecurityFtdcUserLogoutField = {}
|
||||
#经纪公司代码
|
||||
CSecurityFtdcUserLogoutField["BrokerID"] = "string"
|
||||
#用户代码
|
||||
CSecurityFtdcUserLogoutField["UserID"] = "string"
|
||||
structDict['CSecurityFtdcUserLogoutField'] = CSecurityFtdcUserLogoutField
|
||||
|
||||
|
||||
#指定的合约
|
||||
CSecurityFtdcSpecificInstrumentField = {}
|
||||
#合约代码
|
||||
CSecurityFtdcSpecificInstrumentField["InstrumentID"] = "string"
|
||||
#交易所代码
|
||||
CSecurityFtdcSpecificInstrumentField["ExchangeID"] = "string"
|
||||
structDict['CSecurityFtdcSpecificInstrumentField'] = CSecurityFtdcSpecificInstrumentField
|
||||
|
||||
|
||||
#Level2行情
|
||||
CSecurityFtdcL2MarketDataField = {}
|
||||
#交易日
|
||||
CSecurityFtdcL2MarketDataField["TradingDay"] = "string"
|
||||
#时间戳
|
||||
CSecurityFtdcL2MarketDataField["TimeStamp"] = "string"
|
||||
#交易所代码
|
||||
CSecurityFtdcL2MarketDataField["ExchangeID"] = "string"
|
||||
#合约代码
|
||||
CSecurityFtdcL2MarketDataField["InstrumentID"] = "string"
|
||||
#昨收盘价
|
||||
CSecurityFtdcL2MarketDataField["PreClosePrice"] = "float"
|
||||
#今开盘价
|
||||
CSecurityFtdcL2MarketDataField["OpenPrice"] = "float"
|
||||
#收盘价
|
||||
CSecurityFtdcL2MarketDataField["ClosePrice"] = "float"
|
||||
#净值估值
|
||||
CSecurityFtdcL2MarketDataField["IOPV"] = "float"
|
||||
#到期收益率
|
||||
CSecurityFtdcL2MarketDataField["YieldToMaturity"] = "float"
|
||||
#最高价
|
||||
CSecurityFtdcL2MarketDataField["HighPrice"] = "float"
|
||||
#最低价
|
||||
CSecurityFtdcL2MarketDataField["LowPrice"] = "float"
|
||||
#最新价
|
||||
CSecurityFtdcL2MarketDataField["LastPrice"] = "float"
|
||||
#成交笔数
|
||||
CSecurityFtdcL2MarketDataField["TradeCount"] = "int"
|
||||
#成交总量
|
||||
CSecurityFtdcL2MarketDataField["TotalTradeVolume"] = "float"
|
||||
#成交总金额
|
||||
CSecurityFtdcL2MarketDataField["TotalTradeValue"] = "float"
|
||||
#委托买入总量
|
||||
CSecurityFtdcL2MarketDataField["TotalBidVolume"] = "float"
|
||||
#加权平均委买价
|
||||
CSecurityFtdcL2MarketDataField["WeightedAvgBidPrice"] = "float"
|
||||
#债券加权平均委买价
|
||||
CSecurityFtdcL2MarketDataField["AltWeightedAvgBidPrice"] = "float"
|
||||
#委托卖出总量
|
||||
CSecurityFtdcL2MarketDataField["TotalOfferVolume"] = "float"
|
||||
#加权平均委卖价
|
||||
CSecurityFtdcL2MarketDataField["WeightedAvgOfferPrice"] = "float"
|
||||
#债券加权平均委卖价格
|
||||
CSecurityFtdcL2MarketDataField["AltWeightedAvgOfferPrice"] = "float"
|
||||
#买价深度
|
||||
CSecurityFtdcL2MarketDataField["BidPriceLevel"] = "int"
|
||||
#卖价深度
|
||||
CSecurityFtdcL2MarketDataField["OfferPriceLevel"] = "int"
|
||||
#申买价一
|
||||
CSecurityFtdcL2MarketDataField["BidPrice1"] = "float"
|
||||
#申买量一
|
||||
CSecurityFtdcL2MarketDataField["BidVolume1"] = "int"
|
||||
#实际买总委托笔数一
|
||||
CSecurityFtdcL2MarketDataField["BidCount1"] = "int"
|
||||
#申买价二
|
||||
CSecurityFtdcL2MarketDataField["BidPrice2"] = "float"
|
||||
#申买量二
|
||||
CSecurityFtdcL2MarketDataField["BidVolume2"] = "int"
|
||||
#实际买总委托笔数二
|
||||
CSecurityFtdcL2MarketDataField["BidCount2"] = "int"
|
||||
#申买价三
|
||||
CSecurityFtdcL2MarketDataField["BidPrice3"] = "float"
|
||||
#申买量三
|
||||
CSecurityFtdcL2MarketDataField["BidVolume3"] = "int"
|
||||
#实际买总委托笔数三
|
||||
CSecurityFtdcL2MarketDataField["BidCount3"] = "int"
|
||||
#申买价四
|
||||
CSecurityFtdcL2MarketDataField["BidPrice4"] = "float"
|
||||
#申买量四
|
||||
CSecurityFtdcL2MarketDataField["BidVolume4"] = "int"
|
||||
#实际买总委托笔数四
|
||||
CSecurityFtdcL2MarketDataField["BidCount4"] = "int"
|
||||
#申买价五
|
||||
CSecurityFtdcL2MarketDataField["BidPrice5"] = "float"
|
||||
#申买量五
|
||||
CSecurityFtdcL2MarketDataField["BidVolume5"] = "int"
|
||||
#实际买总委托笔数五
|
||||
CSecurityFtdcL2MarketDataField["BidCount5"] = "int"
|
||||
#申买价六
|
||||
CSecurityFtdcL2MarketDataField["BidPrice6"] = "float"
|
||||
#申买量六
|
||||
CSecurityFtdcL2MarketDataField["BidVolume6"] = "int"
|
||||
#实际买总委托笔数六
|
||||
CSecurityFtdcL2MarketDataField["BidCount6"] = "int"
|
||||
#申买价七
|
||||
CSecurityFtdcL2MarketDataField["BidPrice7"] = "float"
|
||||
#申买量七
|
||||
CSecurityFtdcL2MarketDataField["BidVolume7"] = "int"
|
||||
#实际买总委托笔数七
|
||||
CSecurityFtdcL2MarketDataField["BidCount7"] = "int"
|
||||
#申买价八
|
||||
CSecurityFtdcL2MarketDataField["BidPrice8"] = "float"
|
||||
#申买量八
|
||||
CSecurityFtdcL2MarketDataField["BidVolume8"] = "int"
|
||||
#实际买总委托笔数八
|
||||
CSecurityFtdcL2MarketDataField["BidCount8"] = "int"
|
||||
#申买价九
|
||||
CSecurityFtdcL2MarketDataField["BidPrice9"] = "float"
|
||||
#申买量九
|
||||
CSecurityFtdcL2MarketDataField["BidVolume9"] = "int"
|
||||
#实际买总委托笔数九
|
||||
CSecurityFtdcL2MarketDataField["BidCount9"] = "int"
|
||||
#申买价十
|
||||
CSecurityFtdcL2MarketDataField["BidPriceA"] = "float"
|
||||
#申买量十
|
||||
CSecurityFtdcL2MarketDataField["BidVolumeA"] = "int"
|
||||
#实际买总委托笔数十
|
||||
CSecurityFtdcL2MarketDataField["BidCountA"] = "int"
|
||||
#申卖价一
|
||||
CSecurityFtdcL2MarketDataField["OfferPrice1"] = "float"
|
||||
#申卖量一
|
||||
CSecurityFtdcL2MarketDataField["OfferVolume1"] = "int"
|
||||
#实际卖总委托笔数一
|
||||
CSecurityFtdcL2MarketDataField["OfferCount1"] = "int"
|
||||
#申卖价二
|
||||
CSecurityFtdcL2MarketDataField["OfferPrice2"] = "float"
|
||||
#申卖量二
|
||||
CSecurityFtdcL2MarketDataField["OfferVolume2"] = "int"
|
||||
#实际卖总委托笔数二
|
||||
CSecurityFtdcL2MarketDataField["OfferCount2"] = "int"
|
||||
#申卖价三
|
||||
CSecurityFtdcL2MarketDataField["OfferPrice3"] = "float"
|
||||
#申卖量三
|
||||
CSecurityFtdcL2MarketDataField["OfferVolume3"] = "int"
|
||||
#实际卖总委托笔数三
|
||||
CSecurityFtdcL2MarketDataField["OfferCount3"] = "int"
|
||||
#申卖价四
|
||||
CSecurityFtdcL2MarketDataField["OfferPrice4"] = "float"
|
||||
#申卖量四
|
||||
CSecurityFtdcL2MarketDataField["OfferVolume4"] = "int"
|
||||
#实际卖总委托笔数四
|
||||
CSecurityFtdcL2MarketDataField["OfferCount4"] = "int"
|
||||
#申卖价五
|
||||
CSecurityFtdcL2MarketDataField["OfferPrice5"] = "float"
|
||||
#申卖量五
|
||||
CSecurityFtdcL2MarketDataField["OfferVolume5"] = "int"
|
||||
#实际卖总委托笔数五
|
||||
CSecurityFtdcL2MarketDataField["OfferCount5"] = "int"
|
||||
#申卖价六
|
||||
CSecurityFtdcL2MarketDataField["OfferPrice6"] = "float"
|
||||
#申卖量六
|
||||
CSecurityFtdcL2MarketDataField["OfferVolume6"] = "int"
|
||||
#实际卖总委托笔数六
|
||||
CSecurityFtdcL2MarketDataField["OfferCount6"] = "int"
|
||||
#申卖价七
|
||||
CSecurityFtdcL2MarketDataField["OfferPrice7"] = "float"
|
||||
#申卖量七
|
||||
CSecurityFtdcL2MarketDataField["OfferVolume7"] = "int"
|
||||
#实际卖总委托笔数七
|
||||
CSecurityFtdcL2MarketDataField["OfferCount7"] = "int"
|
||||
#申卖价八
|
||||
CSecurityFtdcL2MarketDataField["OfferPrice8"] = "float"
|
||||
#申卖量八
|
||||
CSecurityFtdcL2MarketDataField["OfferVolume8"] = "int"
|
||||
#实际卖总委托笔数八
|
||||
CSecurityFtdcL2MarketDataField["OfferCount8"] = "int"
|
||||
#申卖价九
|
||||
CSecurityFtdcL2MarketDataField["OfferPrice9"] = "float"
|
||||
#申卖量九
|
||||
CSecurityFtdcL2MarketDataField["OfferVolume9"] = "int"
|
||||
#实际卖总委托笔数九
|
||||
CSecurityFtdcL2MarketDataField["OfferCount9"] = "int"
|
||||
#申卖价十
|
||||
CSecurityFtdcL2MarketDataField["OfferPriceA"] = "float"
|
||||
#申卖量十
|
||||
CSecurityFtdcL2MarketDataField["OfferVolumeA"] = "int"
|
||||
#实际卖总委托笔数十
|
||||
CSecurityFtdcL2MarketDataField["OfferCountA"] = "int"
|
||||
structDict['CSecurityFtdcL2MarketDataField'] = CSecurityFtdcL2MarketDataField
|
||||
|
||||
|
||||
#Level2行情更新时间属性
|
||||
CSecurityFtdcL2UpdateTimeField = {}
|
||||
#交易日
|
||||
CSecurityFtdcL2UpdateTimeField["TradingDay"] = "string"
|
||||
#时间戳
|
||||
CSecurityFtdcL2UpdateTimeField["TimeStamp"] = "string"
|
||||
#交易所代码
|
||||
CSecurityFtdcL2UpdateTimeField["ExchangeID"] = "string"
|
||||
#合约代码
|
||||
CSecurityFtdcL2UpdateTimeField["InstrumentID"] = "string"
|
||||
structDict['CSecurityFtdcL2UpdateTimeField'] = CSecurityFtdcL2UpdateTimeField
|
||||
|
||||
|
||||
#Level2行情静态属性
|
||||
CSecurityFtdcL2StaticField = {}
|
||||
#昨收盘价
|
||||
CSecurityFtdcL2StaticField["PreClosePrice"] = "float"
|
||||
#今开盘价
|
||||
CSecurityFtdcL2StaticField["OpenPrice"] = "float"
|
||||
#收盘价
|
||||
CSecurityFtdcL2StaticField["ClosePrice"] = "float"
|
||||
#净值估值
|
||||
CSecurityFtdcL2StaticField["IOPV"] = "float"
|
||||
#到期收益率
|
||||
CSecurityFtdcL2StaticField["YieldToMaturity"] = "float"
|
||||
structDict['CSecurityFtdcL2StaticField'] = CSecurityFtdcL2StaticField
|
||||
|
||||
|
||||
#Level2行情价格区间属性
|
||||
CSecurityFtdcL2PriceIntervalField = {}
|
||||
#最高价
|
||||
CSecurityFtdcL2PriceIntervalField["HighPrice"] = "float"
|
||||
#最低价
|
||||
CSecurityFtdcL2PriceIntervalField["LowPrice"] = "float"
|
||||
structDict['CSecurityFtdcL2PriceIntervalField'] = CSecurityFtdcL2PriceIntervalField
|
||||
|
||||
|
||||
#Level2行情基本信息
|
||||
CSecurityFtdcL2BaseField = {}
|
||||
#最新价
|
||||
CSecurityFtdcL2BaseField["LastPrice"] = "float"
|
||||
structDict['CSecurityFtdcL2BaseField'] = CSecurityFtdcL2BaseField
|
||||
|
||||
|
||||
#Level2成交信息
|
||||
CSecurityFtdcL2TradedField = {}
|
||||
#成交笔数
|
||||
CSecurityFtdcL2TradedField["TradeCount"] = "int"
|
||||
#成交总量
|
||||
CSecurityFtdcL2TradedField["TotalTradeVolume"] = "float"
|
||||
#成交总金额
|
||||
CSecurityFtdcL2TradedField["TotalTradeValue"] = "float"
|
||||
structDict['CSecurityFtdcL2TradedField'] = CSecurityFtdcL2TradedField
|
||||
|
||||
|
||||
#Level2行情数据属性
|
||||
CSecurityFtdcL2DataLevelField = {}
|
||||
#价格
|
||||
CSecurityFtdcL2DataLevelField["Price"] = "float"
|
||||
#数量
|
||||
CSecurityFtdcL2DataLevelField["Volume"] = "int"
|
||||
#实际总委托笔数
|
||||
CSecurityFtdcL2DataLevelField["Count"] = "int"
|
||||
structDict['CSecurityFtdcL2DataLevelField'] = CSecurityFtdcL2DataLevelField
|
||||
|
||||
|
||||
#Level2委买信息
|
||||
CSecurityFtdcL2BidOrderField = {}
|
||||
#委托买入总量
|
||||
CSecurityFtdcL2BidOrderField["TotalBidVolume"] = "float"
|
||||
#加权平均委买价
|
||||
CSecurityFtdcL2BidOrderField["WeightedAvgBidPrice"] = "float"
|
||||
#债券加权平均委买价
|
||||
CSecurityFtdcL2BidOrderField["AltWeightedAvgBidPrice"] = "float"
|
||||
structDict['CSecurityFtdcL2BidOrderField'] = CSecurityFtdcL2BidOrderField
|
||||
|
||||
|
||||
#Level2委卖信息
|
||||
CSecurityFtdcL2OfferOrderField = {}
|
||||
#委托卖出总量
|
||||
CSecurityFtdcL2OfferOrderField["TotalOfferVolume"] = "float"
|
||||
#加权平均委卖价
|
||||
CSecurityFtdcL2OfferOrderField["WeightedAvgOfferPrice"] = "float"
|
||||
#债券加权平均委卖价格
|
||||
CSecurityFtdcL2OfferOrderField["AltWeightedAvgOfferPrice"] = "float"
|
||||
structDict['CSecurityFtdcL2OfferOrderField'] = CSecurityFtdcL2OfferOrderField
|
||||
|
||||
|
||||
#Level2价格深度属性
|
||||
CSecurityFtdcL2PriceLevelField = {}
|
||||
#买价深度
|
||||
CSecurityFtdcL2PriceLevelField["BidPriceLevel"] = "int"
|
||||
#卖价深度
|
||||
CSecurityFtdcL2PriceLevelField["OfferPriceLevel"] = "int"
|
||||
structDict['CSecurityFtdcL2PriceLevelField'] = CSecurityFtdcL2PriceLevelField
|
||||
|
||||
|
||||
#Level2行情申买一属性
|
||||
CSecurityFtdcL2Bid1Field = {}
|
||||
#申买价一
|
||||
CSecurityFtdcL2Bid1Field["BidPrice1"] = "float"
|
||||
#申买量一
|
||||
CSecurityFtdcL2Bid1Field["BidVolume1"] = "int"
|
||||
#实际买总委托笔数一
|
||||
CSecurityFtdcL2Bid1Field["BidCount1"] = "int"
|
||||
structDict['CSecurityFtdcL2Bid1Field'] = CSecurityFtdcL2Bid1Field
|
||||
|
||||
|
||||
#Level2行情申卖一属性
|
||||
CSecurityFtdcL2Offer1Field = {}
|
||||
#申卖价一
|
||||
CSecurityFtdcL2Offer1Field["OfferPrice1"] = "float"
|
||||
#申卖量一
|
||||
CSecurityFtdcL2Offer1Field["OfferVolume1"] = "int"
|
||||
#实际卖总委托笔数一
|
||||
CSecurityFtdcL2Offer1Field["OfferCount1"] = "int"
|
||||
structDict['CSecurityFtdcL2Offer1Field'] = CSecurityFtdcL2Offer1Field
|
||||
|
||||
|
||||
#Level2行情申买二属性
|
||||
CSecurityFtdcL2Bid2Field = {}
|
||||
#申买价二
|
||||
CSecurityFtdcL2Bid2Field["BidPrice2"] = "float"
|
||||
#申买量二
|
||||
CSecurityFtdcL2Bid2Field["BidVolume2"] = "int"
|
||||
#实际买总委托笔数二
|
||||
CSecurityFtdcL2Bid2Field["BidCount2"] = "int"
|
||||
structDict['CSecurityFtdcL2Bid2Field'] = CSecurityFtdcL2Bid2Field
|
||||
|
||||
|
||||
#Level2行情申卖二属性
|
||||
CSecurityFtdcL2Offer2Field = {}
|
||||
#申卖价二
|
||||
CSecurityFtdcL2Offer2Field["OfferPrice2"] = "float"
|
||||
#申卖量二
|
||||
CSecurityFtdcL2Offer2Field["OfferVolume2"] = "int"
|
||||
#实际卖总委托笔数二
|
||||
CSecurityFtdcL2Offer2Field["OfferCount2"] = "int"
|
||||
structDict['CSecurityFtdcL2Offer2Field'] = CSecurityFtdcL2Offer2Field
|
||||
|
||||
|
||||
#Level2行情申买三属性
|
||||
CSecurityFtdcL2Bid3Field = {}
|
||||
#申买价三
|
||||
CSecurityFtdcL2Bid3Field["BidPrice3"] = "float"
|
||||
#申买量三
|
||||
CSecurityFtdcL2Bid3Field["BidVolume3"] = "int"
|
||||
#实际买总委托笔数三
|
||||
CSecurityFtdcL2Bid3Field["BidCount3"] = "int"
|
||||
structDict['CSecurityFtdcL2Bid3Field'] = CSecurityFtdcL2Bid3Field
|
||||
|
||||
|
||||
#Level2行情申卖三属性
|
||||
CSecurityFtdcL2Offer3Field = {}
|
||||
#申卖价三
|
||||
CSecurityFtdcL2Offer3Field["OfferPrice3"] = "float"
|
||||
#申卖量三
|
||||
CSecurityFtdcL2Offer3Field["OfferVolume3"] = "int"
|
||||
#实际卖总委托笔数三
|
||||
CSecurityFtdcL2Offer3Field["OfferCount3"] = "int"
|
||||
structDict['CSecurityFtdcL2Offer3Field'] = CSecurityFtdcL2Offer3Field
|
||||
|
||||
|
||||
#Level2行情申买四属性
|
||||
CSecurityFtdcL2Bid4Field = {}
|
||||
#申买价四
|
||||
CSecurityFtdcL2Bid4Field["BidPrice4"] = "float"
|
||||
#申买量四
|
||||
CSecurityFtdcL2Bid4Field["BidVolume4"] = "int"
|
||||
#实际买总委托笔数四
|
||||
CSecurityFtdcL2Bid4Field["BidCount4"] = "int"
|
||||
structDict['CSecurityFtdcL2Bid4Field'] = CSecurityFtdcL2Bid4Field
|
||||
|
||||
|
||||
#Level2行情申卖四属性
|
||||
CSecurityFtdcL2Offer4Field = {}
|
||||
#申卖价四
|
||||
CSecurityFtdcL2Offer4Field["OfferPrice4"] = "float"
|
||||
#申卖量四
|
||||
CSecurityFtdcL2Offer4Field["OfferVolume4"] = "int"
|
||||
#实际卖总委托笔数四
|
||||
CSecurityFtdcL2Offer4Field["OfferCount4"] = "int"
|
||||
structDict['CSecurityFtdcL2Offer4Field'] = CSecurityFtdcL2Offer4Field
|
||||
|
||||
|
||||
#Level2行情申买五属性
|
||||
CSecurityFtdcL2Bid5Field = {}
|
||||
#申买价五
|
||||
CSecurityFtdcL2Bid5Field["BidPrice5"] = "float"
|
||||
#申买量五
|
||||
CSecurityFtdcL2Bid5Field["BidVolume5"] = "int"
|
||||
#实际买总委托笔数五
|
||||
CSecurityFtdcL2Bid5Field["BidCount5"] = "int"
|
||||
structDict['CSecurityFtdcL2Bid5Field'] = CSecurityFtdcL2Bid5Field
|
||||
|
||||
|
||||
#Level2行情申卖五属性
|
||||
CSecurityFtdcL2Offer5Field = {}
|
||||
#申卖价五
|
||||
CSecurityFtdcL2Offer5Field["OfferPrice5"] = "float"
|
||||
#申卖量五
|
||||
CSecurityFtdcL2Offer5Field["OfferVolume5"] = "int"
|
||||
#实际卖总委托笔数五
|
||||
CSecurityFtdcL2Offer5Field["OfferCount5"] = "int"
|
||||
structDict['CSecurityFtdcL2Offer5Field'] = CSecurityFtdcL2Offer5Field
|
||||
|
||||
|
||||
#Level2行情申买六属性
|
||||
CSecurityFtdcL2Bid6Field = {}
|
||||
#申买价六
|
||||
CSecurityFtdcL2Bid6Field["BidPrice6"] = "float"
|
||||
#申买量六
|
||||
CSecurityFtdcL2Bid6Field["BidVolume6"] = "int"
|
||||
#实际买总委托笔数六
|
||||
CSecurityFtdcL2Bid6Field["BidCount6"] = "int"
|
||||
structDict['CSecurityFtdcL2Bid6Field'] = CSecurityFtdcL2Bid6Field
|
||||
|
||||
|
||||
#Level2行情申卖六属性
|
||||
CSecurityFtdcL2Offer6Field = {}
|
||||
#申卖价六
|
||||
CSecurityFtdcL2Offer6Field["OfferPrice6"] = "float"
|
||||
#申卖量六
|
||||
CSecurityFtdcL2Offer6Field["OfferVolume6"] = "int"
|
||||
#实际卖总委托笔数六
|
||||
CSecurityFtdcL2Offer6Field["OfferCount6"] = "int"
|
||||
structDict['CSecurityFtdcL2Offer6Field'] = CSecurityFtdcL2Offer6Field
|
||||
|
||||
|
||||
#Level2行情申买七属性
|
||||
CSecurityFtdcL2Bid7Field = {}
|
||||
#申买价七
|
||||
CSecurityFtdcL2Bid7Field["BidPrice7"] = "float"
|
||||
#申买量七
|
||||
CSecurityFtdcL2Bid7Field["BidVolume7"] = "int"
|
||||
#实际买总委托笔数七
|
||||
CSecurityFtdcL2Bid7Field["BidCount7"] = "int"
|
||||
structDict['CSecurityFtdcL2Bid7Field'] = CSecurityFtdcL2Bid7Field
|
||||
|
||||
|
||||
#Level2行情申卖七属性
|
||||
CSecurityFtdcL2Offer7Field = {}
|
||||
#申卖价七
|
||||
CSecurityFtdcL2Offer7Field["OfferPrice7"] = "float"
|
||||
#申卖量七
|
||||
CSecurityFtdcL2Offer7Field["OfferVolume7"] = "int"
|
||||
#实际卖总委托笔数七
|
||||
CSecurityFtdcL2Offer7Field["OfferCount7"] = "int"
|
||||
structDict['CSecurityFtdcL2Offer7Field'] = CSecurityFtdcL2Offer7Field
|
||||
|
||||
|
||||
#Level2行情申买八属性
|
||||
CSecurityFtdcL2Bid8Field = {}
|
||||
#申买价八
|
||||
CSecurityFtdcL2Bid8Field["BidPrice8"] = "float"
|
||||
#申买量八
|
||||
CSecurityFtdcL2Bid8Field["BidVolume8"] = "int"
|
||||
#实际买总委托笔数八
|
||||
CSecurityFtdcL2Bid8Field["BidCount8"] = "int"
|
||||
structDict['CSecurityFtdcL2Bid8Field'] = CSecurityFtdcL2Bid8Field
|
||||
|
||||
|
||||
#Level2行情申卖八属性
|
||||
CSecurityFtdcL2Offer8Field = {}
|
||||
#申卖价八
|
||||
CSecurityFtdcL2Offer8Field["OfferPrice8"] = "float"
|
||||
#申卖量八
|
||||
CSecurityFtdcL2Offer8Field["OfferVolume8"] = "int"
|
||||
#实际卖总委托笔数八
|
||||
CSecurityFtdcL2Offer8Field["OfferCount8"] = "int"
|
||||
structDict['CSecurityFtdcL2Offer8Field'] = CSecurityFtdcL2Offer8Field
|
||||
|
||||
|
||||
#Level2行情申买九属性
|
||||
CSecurityFtdcL2Bid9Field = {}
|
||||
#申买价九
|
||||
CSecurityFtdcL2Bid9Field["BidPrice9"] = "float"
|
||||
#申买量九
|
||||
CSecurityFtdcL2Bid9Field["BidVolume9"] = "int"
|
||||
#实际买总委托笔数九
|
||||
CSecurityFtdcL2Bid9Field["BidCount9"] = "int"
|
||||
structDict['CSecurityFtdcL2Bid9Field'] = CSecurityFtdcL2Bid9Field
|
||||
|
||||
|
||||
#Level2行情申卖九属性
|
||||
CSecurityFtdcL2Offer9Field = {}
|
||||
#申卖价九
|
||||
CSecurityFtdcL2Offer9Field["OfferPrice9"] = "float"
|
||||
#申卖量九
|
||||
CSecurityFtdcL2Offer9Field["OfferVolume9"] = "int"
|
||||
#实际卖总委托笔数九
|
||||
CSecurityFtdcL2Offer9Field["OfferCount9"] = "int"
|
||||
structDict['CSecurityFtdcL2Offer9Field'] = CSecurityFtdcL2Offer9Field
|
||||
|
||||
|
||||
#Level2行情申买十属性
|
||||
CSecurityFtdcL2BidAField = {}
|
||||
#申买价十
|
||||
CSecurityFtdcL2BidAField["BidPriceA"] = "float"
|
||||
#申买量十
|
||||
CSecurityFtdcL2BidAField["BidVolumeA"] = "int"
|
||||
#实际买总委托笔数十
|
||||
CSecurityFtdcL2BidAField["BidCountA"] = "int"
|
||||
structDict['CSecurityFtdcL2BidAField'] = CSecurityFtdcL2BidAField
|
||||
|
||||
|
||||
#Level2行情申卖十属性
|
||||
CSecurityFtdcL2OfferAField = {}
|
||||
#申卖价十
|
||||
CSecurityFtdcL2OfferAField["OfferPriceA"] = "float"
|
||||
#申卖量十
|
||||
CSecurityFtdcL2OfferAField["OfferVolumeA"] = "int"
|
||||
#实际卖总委托笔数十
|
||||
CSecurityFtdcL2OfferAField["OfferCountA"] = "int"
|
||||
structDict['CSecurityFtdcL2OfferAField'] = CSecurityFtdcL2OfferAField
|
||||
|
||||
|
||||
#Level2行情申买属性
|
||||
CSecurityFtdcL2BidField = {}
|
||||
#申买价一
|
||||
CSecurityFtdcL2BidField["BidPrice1"] = "float"
|
||||
#申买量一
|
||||
CSecurityFtdcL2BidField["BidVolume1"] = "int"
|
||||
#实际买总委托笔数一
|
||||
CSecurityFtdcL2BidField["BidCount1"] = "int"
|
||||
#申买价二
|
||||
CSecurityFtdcL2BidField["BidPrice2"] = "float"
|
||||
#申买量二
|
||||
CSecurityFtdcL2BidField["BidVolume2"] = "int"
|
||||
#实际买总委托笔数二
|
||||
CSecurityFtdcL2BidField["BidCount2"] = "int"
|
||||
#申买价三
|
||||
CSecurityFtdcL2BidField["BidPrice3"] = "float"
|
||||
#申买量三
|
||||
CSecurityFtdcL2BidField["BidVolume3"] = "int"
|
||||
#实际买总委托笔数三
|
||||
CSecurityFtdcL2BidField["BidCount3"] = "int"
|
||||
#申买价四
|
||||
CSecurityFtdcL2BidField["BidPrice4"] = "float"
|
||||
#申买量四
|
||||
CSecurityFtdcL2BidField["BidVolume4"] = "int"
|
||||
#实际买总委托笔数四
|
||||
CSecurityFtdcL2BidField["BidCount4"] = "int"
|
||||
#申买价五
|
||||
CSecurityFtdcL2BidField["BidPrice5"] = "float"
|
||||
#申买量五
|
||||
CSecurityFtdcL2BidField["BidVolume5"] = "int"
|
||||
#实际买总委托笔数五
|
||||
CSecurityFtdcL2BidField["BidCount5"] = "int"
|
||||
#申买价六
|
||||
CSecurityFtdcL2BidField["BidPrice6"] = "float"
|
||||
#申买量六
|
||||
CSecurityFtdcL2BidField["BidVolume6"] = "int"
|
||||
#实际买总委托笔数六
|
||||
CSecurityFtdcL2BidField["BidCount6"] = "int"
|
||||
#申买价七
|
||||
CSecurityFtdcL2BidField["BidPrice7"] = "float"
|
||||
#申买量七
|
||||
CSecurityFtdcL2BidField["BidVolume7"] = "int"
|
||||
#实际买总委托笔数七
|
||||
CSecurityFtdcL2BidField["BidCount7"] = "int"
|
||||
#申买价八
|
||||
CSecurityFtdcL2BidField["BidPrice8"] = "float"
|
||||
#申买量八
|
||||
CSecurityFtdcL2BidField["BidVolume8"] = "int"
|
||||
#实际买总委托笔数八
|
||||
CSecurityFtdcL2BidField["BidCount8"] = "int"
|
||||
#申买价九
|
||||
CSecurityFtdcL2BidField["BidPrice9"] = "float"
|
||||
#申买量九
|
||||
CSecurityFtdcL2BidField["BidVolume9"] = "int"
|
||||
#实际买总委托笔数九
|
||||
CSecurityFtdcL2BidField["BidCount9"] = "int"
|
||||
#申买价十
|
||||
CSecurityFtdcL2BidField["BidPriceA"] = "float"
|
||||
#申买量十
|
||||
CSecurityFtdcL2BidField["BidVolumeA"] = "int"
|
||||
#实际买总委托笔数十
|
||||
CSecurityFtdcL2BidField["BidCountA"] = "int"
|
||||
structDict['CSecurityFtdcL2BidField'] = CSecurityFtdcL2BidField
|
||||
|
||||
|
||||
#Level2行情申卖属性
|
||||
CSecurityFtdcL2OfferField = {}
|
||||
#申卖价一
|
||||
CSecurityFtdcL2OfferField["OfferPrice1"] = "float"
|
||||
#申卖量一
|
||||
CSecurityFtdcL2OfferField["OfferVolume1"] = "int"
|
||||
#实际卖总委托笔数一
|
||||
CSecurityFtdcL2OfferField["OfferCount1"] = "int"
|
||||
#申卖价二
|
||||
CSecurityFtdcL2OfferField["OfferPrice2"] = "float"
|
||||
#申卖量二
|
||||
CSecurityFtdcL2OfferField["OfferVolume2"] = "int"
|
||||
#实际卖总委托笔数二
|
||||
CSecurityFtdcL2OfferField["OfferCount2"] = "int"
|
||||
#申卖价三
|
||||
CSecurityFtdcL2OfferField["OfferPrice3"] = "float"
|
||||
#申卖量三
|
||||
CSecurityFtdcL2OfferField["OfferVolume3"] = "int"
|
||||
#实际卖总委托笔数三
|
||||
CSecurityFtdcL2OfferField["OfferCount3"] = "int"
|
||||
#申卖价四
|
||||
CSecurityFtdcL2OfferField["OfferPrice4"] = "float"
|
||||
#申卖量四
|
||||
CSecurityFtdcL2OfferField["OfferVolume4"] = "int"
|
||||
#实际卖总委托笔数四
|
||||
CSecurityFtdcL2OfferField["OfferCount4"] = "int"
|
||||
#申卖价五
|
||||
CSecurityFtdcL2OfferField["OfferPrice5"] = "float"
|
||||
#申卖量五
|
||||
CSecurityFtdcL2OfferField["OfferVolume5"] = "int"
|
||||
#实际卖总委托笔数五
|
||||
CSecurityFtdcL2OfferField["OfferCount5"] = "int"
|
||||
#申卖价六
|
||||
CSecurityFtdcL2OfferField["OfferPrice6"] = "float"
|
||||
#申卖量六
|
||||
CSecurityFtdcL2OfferField["OfferVolume6"] = "int"
|
||||
#实际卖总委托笔数六
|
||||
CSecurityFtdcL2OfferField["OfferCount6"] = "int"
|
||||
#申卖价七
|
||||
CSecurityFtdcL2OfferField["OfferPrice7"] = "float"
|
||||
#申卖量七
|
||||
CSecurityFtdcL2OfferField["OfferVolume7"] = "int"
|
||||
#实际卖总委托笔数七
|
||||
CSecurityFtdcL2OfferField["OfferCount7"] = "int"
|
||||
#申卖价八
|
||||
CSecurityFtdcL2OfferField["OfferPrice8"] = "float"
|
||||
#申卖量八
|
||||
CSecurityFtdcL2OfferField["OfferVolume8"] = "int"
|
||||
#实际卖总委托笔数八
|
||||
CSecurityFtdcL2OfferField["OfferCount8"] = "int"
|
||||
#申卖价九
|
||||
CSecurityFtdcL2OfferField["OfferPrice9"] = "float"
|
||||
#申卖量九
|
||||
CSecurityFtdcL2OfferField["OfferVolume9"] = "int"
|
||||
#实际卖总委托笔数九
|
||||
CSecurityFtdcL2OfferField["OfferCount9"] = "int"
|
||||
#申卖价十
|
||||
CSecurityFtdcL2OfferField["OfferPriceA"] = "float"
|
||||
#申卖量十
|
||||
CSecurityFtdcL2OfferField["OfferVolumeA"] = "int"
|
||||
#实际卖总委托笔数十
|
||||
CSecurityFtdcL2OfferField["OfferCountA"] = "int"
|
||||
structDict['CSecurityFtdcL2OfferField'] = CSecurityFtdcL2OfferField
|
||||
|
||||
|
||||
#Level2指数行情
|
||||
CSecurityFtdcL2IndexField = {}
|
||||
#交易日
|
||||
CSecurityFtdcL2IndexField["TradingDay"] = "string"
|
||||
#行情时间(秒)
|
||||
CSecurityFtdcL2IndexField["TimeStamp"] = "string"
|
||||
#交易所代码
|
||||
CSecurityFtdcL2IndexField["ExchangeID"] = "string"
|
||||
#指数代码
|
||||
CSecurityFtdcL2IndexField["InstrumentID"] = "string"
|
||||
#前收盘指数
|
||||
CSecurityFtdcL2IndexField["PreCloseIndex"] = "float"
|
||||
#今开盘指数
|
||||
CSecurityFtdcL2IndexField["OpenIndex"] = "float"
|
||||
#今日收盘指数
|
||||
CSecurityFtdcL2IndexField["CloseIndex"] = "float"
|
||||
#最高指数
|
||||
CSecurityFtdcL2IndexField["HighIndex"] = "float"
|
||||
#最低指数
|
||||
CSecurityFtdcL2IndexField["LowIndex"] = "float"
|
||||
#最新指数
|
||||
CSecurityFtdcL2IndexField["LastIndex"] = "float"
|
||||
#参与计算相应指数的成交金额(元)
|
||||
CSecurityFtdcL2IndexField["TurnOver"] = "float"
|
||||
#参与计算相应指数的交易数量(手)
|
||||
CSecurityFtdcL2IndexField["TotalVolume"] = "float"
|
||||
structDict['CSecurityFtdcL2IndexField'] = CSecurityFtdcL2IndexField
|
||||
|
||||
|
||||
#Level2行情用户信息
|
||||
CSecurityFtdcL2UserInfoField = {}
|
||||
#经纪公司代码
|
||||
CSecurityFtdcL2UserInfoField["BrokerID"] = "string"
|
||||
#用户代码
|
||||
CSecurityFtdcL2UserInfoField["UserID"] = "string"
|
||||
#用户名称
|
||||
CSecurityFtdcL2UserInfoField["UserName"] = "string"
|
||||
#密码
|
||||
CSecurityFtdcL2UserInfoField["Password"] = "string"
|
||||
#行情数据等级
|
||||
CSecurityFtdcL2UserInfoField["DataLevel"] = "string"
|
||||
structDict['CSecurityFtdcL2UserInfoField'] = CSecurityFtdcL2UserInfoField
|
||||
|
||||
|
||||
#UDP组播组信息
|
||||
CSecurityFtdcMulticastGroupInfoField = {}
|
||||
#组播组IP地址
|
||||
CSecurityFtdcMulticastGroupInfoField["GroupIP"] = "string"
|
||||
#组播组IP端口
|
||||
CSecurityFtdcMulticastGroupInfoField["GroupPort"] = "int"
|
||||
#源地址
|
||||
CSecurityFtdcMulticastGroupInfoField["SourceIP"] = "string"
|
||||
structDict['CSecurityFtdcMulticastGroupInfoField'] = CSecurityFtdcMulticastGroupInfoField
|
||||
|
||||
|
||||
#Level2逐笔委托
|
||||
CSecurityFtdcL2OrderField = {}
|
||||
#委托组
|
||||
CSecurityFtdcL2OrderField["OrderGroupID"] = "int"
|
||||
#委托序号
|
||||
CSecurityFtdcL2OrderField["OrderIndex"] = "int"
|
||||
#委托时间(秒)
|
||||
CSecurityFtdcL2OrderField["OrderTime"] = "string"
|
||||
#交易所代码
|
||||
CSecurityFtdcL2OrderField["ExchangeID"] = "string"
|
||||
#合约代码
|
||||
CSecurityFtdcL2OrderField["InstrumentID"] = "string"
|
||||
#委托价格
|
||||
CSecurityFtdcL2OrderField["Price"] = "float"
|
||||
#委托数量
|
||||
CSecurityFtdcL2OrderField["Volume"] = "int"
|
||||
#报单类型
|
||||
CSecurityFtdcL2OrderField["OrderKind"] = "string"
|
||||
#功能码
|
||||
CSecurityFtdcL2OrderField["FunctionCode"] = "string"
|
||||
structDict['CSecurityFtdcL2OrderField'] = CSecurityFtdcL2OrderField
|
||||
|
||||
|
||||
#Level2逐笔成交
|
||||
CSecurityFtdcL2TradeField = {}
|
||||
#成交组
|
||||
CSecurityFtdcL2TradeField["TradeGroupID"] = "int"
|
||||
#成交序号
|
||||
CSecurityFtdcL2TradeField["TradeIndex"] = "int"
|
||||
#买方委托序号
|
||||
CSecurityFtdcL2TradeField["BuyIndex"] = "int"
|
||||
#卖方委托序号
|
||||
CSecurityFtdcL2TradeField["SellIndex"] = "int"
|
||||
#成交时间(秒)
|
||||
CSecurityFtdcL2TradeField["TradeTime"] = "string"
|
||||
#交易所代码
|
||||
CSecurityFtdcL2TradeField["ExchangeID"] = "string"
|
||||
#合约代码
|
||||
CSecurityFtdcL2TradeField["InstrumentID"] = "string"
|
||||
#成交价格
|
||||
CSecurityFtdcL2TradeField["Price"] = "float"
|
||||
#成交数量
|
||||
CSecurityFtdcL2TradeField["Volume"] = "int"
|
||||
#报单类型
|
||||
CSecurityFtdcL2TradeField["OrderKind"] = "string"
|
||||
#功能码
|
||||
CSecurityFtdcL2TradeField["FunctionCode"] = "string"
|
||||
structDict['CSecurityFtdcL2TradeField'] = CSecurityFtdcL2TradeField
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
17
vn.lts/pyscript/l2/lts_l2_define.cpp
Normal file
17
vn.lts/pyscript/l2/lts_l2_define.cpp
Normal file
@ -0,0 +1,17 @@
|
||||
#define ONFRONTCONNECTED 1
|
||||
#define ONFRONTDISCONNECTED 2
|
||||
#define ONHEARTBEATWARNING 3
|
||||
#define ONRSPERROR 4
|
||||
#define ONRSPUSERLOGIN 5
|
||||
#define ONRSPUSERLOGOUT 6
|
||||
#define ONRSPSUBL2MARKETDATA 7
|
||||
#define ONRSPUNSUBL2MARKETDATA 8
|
||||
#define ONRSPSUBL2INDEX 9
|
||||
#define ONRSPUNSUBL2INDEX 10
|
||||
#define ONRTNL2MARKETDATA 11
|
||||
#define ONRTNL2INDEX 12
|
||||
#define ONRSPSUBL2ORDERANDTRADE 13
|
||||
#define ONRSPUNSUBL2ORDERANDTRADE 14
|
||||
#define ONRTNL2ORDER 15
|
||||
#define ONRTNL2TRADE 16
|
||||
#define ONNTFCHECKORDERLIST 17
|
23
vn.lts/pyscript/l2/lts_l2_function.cpp
Normal file
23
vn.lts/pyscript/l2/lts_l2_function.cpp
Normal file
@ -0,0 +1,23 @@
|
||||
int TdApi::reqUserLogin(dict req, int nRequestID)
|
||||
{
|
||||
CSecurityFtdcUserLoginField myreq = CSecurityFtdcUserLoginField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "TradingDay", myreq.TradingDay);
|
||||
getChar(req, "Password", myreq.Password);
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
getChar(req, "DataLevel", myreq.DataLevel);
|
||||
getChar(req, "UserID", myreq.UserID);
|
||||
int i = this->api->ReqUserLogin(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
||||
int TdApi::reqUserLogout(dict req, int nRequestID)
|
||||
{
|
||||
CSecurityFtdcUserLogoutField myreq = CSecurityFtdcUserLogoutField();
|
||||
memset(&myreq, 0, sizeof(myreq));
|
||||
getChar(req, "UserID", myreq.UserID);
|
||||
getChar(req, "BrokerID", myreq.BrokerID);
|
||||
int i = this->api->ReqUserLogout(&myreq, nRequestID);
|
||||
return i;
|
||||
};
|
||||
|
4
vn.lts/pyscript/l2/lts_l2_header_function.h
Normal file
4
vn.lts/pyscript/l2/lts_l2_header_function.h
Normal file
@ -0,0 +1,4 @@
|
||||
int reqUserLogin(dict req, int nRequestID);
|
||||
|
||||
int reqUserLogout(dict req, int nRequestID);
|
||||
|
30
vn.lts/pyscript/l2/lts_l2_header_on.h
Normal file
30
vn.lts/pyscript/l2/lts_l2_header_on.h
Normal file
@ -0,0 +1,30 @@
|
||||
|
||||
|
||||
|
||||
virtual void onRspError(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 onRspSubL2MarketData(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspUnSubL2MarketData(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspSubL2Index(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspUnSubL2Index(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRtnL2MarketData(dict data) {};
|
||||
|
||||
virtual void onRtnL2Index(dict data) {};
|
||||
|
||||
virtual void onRspSubL2OrderAndTrade(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspUnSubL2OrderAndTrade(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRtnL2Order(dict data) {};
|
||||
|
||||
virtual void onRtnL2Trade(dict data) {};
|
||||
|
||||
|
34
vn.lts/pyscript/l2/lts_l2_header_process.h
Normal file
34
vn.lts/pyscript/l2/lts_l2_header_process.h
Normal file
@ -0,0 +1,34 @@
|
||||
void processFrontConnected(Task task);
|
||||
|
||||
void processFrontDisconnected(Task task);
|
||||
|
||||
void processHeartBeatWarning(Task task);
|
||||
|
||||
void processRspError(Task task);
|
||||
|
||||
void processRspUserLogin(Task task);
|
||||
|
||||
void processRspUserLogout(Task task);
|
||||
|
||||
void processRspSubL2MarketData(Task task);
|
||||
|
||||
void processRspUnSubL2MarketData(Task task);
|
||||
|
||||
void processRspSubL2Index(Task task);
|
||||
|
||||
void processRspUnSubL2Index(Task task);
|
||||
|
||||
void processRtnL2MarketData(Task task);
|
||||
|
||||
void processRtnL2Index(Task task);
|
||||
|
||||
void processRspSubL2OrderAndTrade(Task task);
|
||||
|
||||
void processRspUnSubL2OrderAndTrade(Task task);
|
||||
|
||||
void processRtnL2Order(Task task);
|
||||
|
||||
void processRtnL2Trade(Task task);
|
||||
|
||||
void processNtfCheckOrderList(Task task);
|
||||
|
290
vn.lts/pyscript/l2/lts_l2_process.cpp
Normal file
290
vn.lts/pyscript/l2/lts_l2_process.cpp
Normal file
@ -0,0 +1,290 @@
|
||||
void TdApi::processFrontConnected(Task task)
|
||||
{
|
||||
this->onFrontConnected();
|
||||
};
|
||||
|
||||
void TdApi::processFrontDisconnected(Task task)
|
||||
{
|
||||
this->onFrontDisconnected(task.task_id);
|
||||
};
|
||||
|
||||
void TdApi::processHeartBeatWarning(Task task)
|
||||
{
|
||||
this->onHeartBeatWarning(task.task_id);
|
||||
};
|
||||
|
||||
void TdApi::processRspError(Task task)
|
||||
{
|
||||
CSecurityFtdcRspInfoField task_error = any_cast<CSecurityFtdcRspInfoField>(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 TdApi::processRspUserLogin(Task task)
|
||||
{
|
||||
CSecurityFtdcUserLoginField task_data = any_cast<CSecurityFtdcUserLoginField>(task.task_data);
|
||||
dict data;
|
||||
data["TradingDay"] = task_data.TradingDay;
|
||||
data["Password"] = task_data.Password;
|
||||
data["BrokerID"] = task_data.BrokerID;
|
||||
data["DataLevel"] = task_data.DataLevel;
|
||||
data["UserID"] = task_data.UserID;
|
||||
|
||||
CSecurityFtdcRspInfoField task_error = any_cast<CSecurityFtdcRspInfoField>(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 TdApi::processRspUserLogout(Task task)
|
||||
{
|
||||
CSecurityFtdcUserLogoutField task_data = any_cast<CSecurityFtdcUserLogoutField>(task.task_data);
|
||||
dict data;
|
||||
data["UserID"] = task_data.UserID;
|
||||
data["BrokerID"] = task_data.BrokerID;
|
||||
|
||||
CSecurityFtdcRspInfoField task_error = any_cast<CSecurityFtdcRspInfoField>(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 TdApi::processRspSubL2MarketData(Task task)
|
||||
{
|
||||
CSecurityFtdcSpecificInstrumentField task_data = any_cast<CSecurityFtdcSpecificInstrumentField>(task.task_data);
|
||||
dict data;
|
||||
data["InstrumentID"] = task_data.InstrumentID;
|
||||
data["ExchangeID"] = task_data.ExchangeID;
|
||||
|
||||
CSecurityFtdcRspInfoField task_error = any_cast<CSecurityFtdcRspInfoField>(task.task_error);
|
||||
dict error;
|
||||
error["ErrorMsg"] = task_error.ErrorMsg;
|
||||
error["ErrorID"] = task_error.ErrorID;
|
||||
|
||||
this->onRspSubL2MarketData(data, error, task.task_id, task.task_last);
|
||||
};
|
||||
|
||||
void TdApi::processRspUnSubL2MarketData(Task task)
|
||||
{
|
||||
CSecurityFtdcSpecificInstrumentField task_data = any_cast<CSecurityFtdcSpecificInstrumentField>(task.task_data);
|
||||
dict data;
|
||||
data["InstrumentID"] = task_data.InstrumentID;
|
||||
data["ExchangeID"] = task_data.ExchangeID;
|
||||
|
||||
CSecurityFtdcRspInfoField task_error = any_cast<CSecurityFtdcRspInfoField>(task.task_error);
|
||||
dict error;
|
||||
error["ErrorMsg"] = task_error.ErrorMsg;
|
||||
error["ErrorID"] = task_error.ErrorID;
|
||||
|
||||
this->onRspUnSubL2MarketData(data, error, task.task_id, task.task_last);
|
||||
};
|
||||
|
||||
void TdApi::processRspSubL2Index(Task task)
|
||||
{
|
||||
CSecurityFtdcSpecificInstrumentField task_data = any_cast<CSecurityFtdcSpecificInstrumentField>(task.task_data);
|
||||
dict data;
|
||||
data["InstrumentID"] = task_data.InstrumentID;
|
||||
data["ExchangeID"] = task_data.ExchangeID;
|
||||
|
||||
CSecurityFtdcRspInfoField task_error = any_cast<CSecurityFtdcRspInfoField>(task.task_error);
|
||||
dict error;
|
||||
error["ErrorMsg"] = task_error.ErrorMsg;
|
||||
error["ErrorID"] = task_error.ErrorID;
|
||||
|
||||
this->onRspSubL2Index(data, error, task.task_id, task.task_last);
|
||||
};
|
||||
|
||||
void TdApi::processRspUnSubL2Index(Task task)
|
||||
{
|
||||
CSecurityFtdcSpecificInstrumentField task_data = any_cast<CSecurityFtdcSpecificInstrumentField>(task.task_data);
|
||||
dict data;
|
||||
data["InstrumentID"] = task_data.InstrumentID;
|
||||
data["ExchangeID"] = task_data.ExchangeID;
|
||||
|
||||
CSecurityFtdcRspInfoField task_error = any_cast<CSecurityFtdcRspInfoField>(task.task_error);
|
||||
dict error;
|
||||
error["ErrorMsg"] = task_error.ErrorMsg;
|
||||
error["ErrorID"] = task_error.ErrorID;
|
||||
|
||||
this->onRspUnSubL2Index(data, error, task.task_id, task.task_last);
|
||||
};
|
||||
|
||||
void TdApi::processRtnL2MarketData(Task task)
|
||||
{
|
||||
CSecurityFtdcL2MarketDataField task_data = any_cast<CSecurityFtdcL2MarketDataField>(task.task_data);
|
||||
dict data;
|
||||
data["BidCount8"] = task_data.BidCount8;
|
||||
data["BidVolume4"] = task_data.BidVolume4;
|
||||
data["BidPrice9"] = task_data.BidPrice9;
|
||||
data["BidPrice8"] = task_data.BidPrice8;
|
||||
data["OfferVolume8"] = task_data.OfferVolume8;
|
||||
data["OfferCount9"] = task_data.OfferCount9;
|
||||
data["BidPrice5"] = task_data.BidPrice5;
|
||||
data["LowPrice"] = task_data.LowPrice;
|
||||
data["BidPrice7"] = task_data.BidPrice7;
|
||||
data["AltWeightedAvgOfferPrice"] = task_data.AltWeightedAvgOfferPrice;
|
||||
data["BidPrice1"] = task_data.BidPrice1;
|
||||
data["OfferCount3"] = task_data.OfferCount3;
|
||||
data["TotalTradeVolume"] = task_data.TotalTradeVolume;
|
||||
data["BidPrice2"] = task_data.BidPrice2;
|
||||
data["BidVolume1"] = task_data.BidVolume1;
|
||||
data["OfferVolume3"] = task_data.OfferVolume3;
|
||||
data["PreClosePrice"] = task_data.PreClosePrice;
|
||||
data["OfferVolumeA"] = task_data.OfferVolumeA;
|
||||
data["BidCount3"] = task_data.BidCount3;
|
||||
data["BidCount2"] = task_data.BidCount2;
|
||||
data["BidCount1"] = task_data.BidCount1;
|
||||
data["BidPriceLevel"] = task_data.BidPriceLevel;
|
||||
data["BidCount7"] = task_data.BidCount7;
|
||||
data["BidCount6"] = task_data.BidCount6;
|
||||
data["BidCount5"] = task_data.BidCount5;
|
||||
data["BidCount4"] = task_data.BidCount4;
|
||||
data["BidVolume7"] = task_data.BidVolume7;
|
||||
data["BidVolume6"] = task_data.BidVolume6;
|
||||
data["TotalOfferVolume"] = task_data.TotalOfferVolume;
|
||||
data["TotalBidVolume"] = task_data.TotalBidVolume;
|
||||
data["BidVolume3"] = task_data.BidVolume3;
|
||||
data["BidVolume2"] = task_data.BidVolume2;
|
||||
data["OpenPrice"] = task_data.OpenPrice;
|
||||
data["OfferPriceA"] = task_data.OfferPriceA;
|
||||
data["OfferCount7"] = task_data.OfferCount7;
|
||||
data["OfferCount6"] = task_data.OfferCount6;
|
||||
data["TradeCount"] = task_data.TradeCount;
|
||||
data["BidPrice4"] = task_data.BidPrice4;
|
||||
data["WeightedAvgOfferPrice"] = task_data.WeightedAvgOfferPrice;
|
||||
data["OfferVolume6"] = task_data.OfferVolume6;
|
||||
data["HighPrice"] = task_data.HighPrice;
|
||||
data["OfferVolume9"] = task_data.OfferVolume9;
|
||||
data["InstrumentID"] = task_data.InstrumentID;
|
||||
data["ClosePrice"] = task_data.ClosePrice;
|
||||
data["ExchangeID"] = task_data.ExchangeID;
|
||||
data["BidPrice6"] = task_data.BidPrice6;
|
||||
data["OfferPrice7"] = task_data.OfferPrice7;
|
||||
data["AltWeightedAvgBidPrice"] = task_data.AltWeightedAvgBidPrice;
|
||||
data["TimeStamp"] = task_data.TimeStamp;
|
||||
data["WeightedAvgBidPrice"] = task_data.WeightedAvgBidPrice;
|
||||
data["BidVolume9"] = task_data.BidVolume9;
|
||||
data["TotalTradeValue"] = task_data.TotalTradeValue;
|
||||
data["OfferCount4"] = task_data.OfferCount4;
|
||||
data["TradingDay"] = task_data.TradingDay;
|
||||
data["BidCountA"] = task_data.BidCountA;
|
||||
data["BidPrice3"] = task_data.BidPrice3;
|
||||
data["IOPV"] = task_data.IOPV;
|
||||
data["OfferCount1"] = task_data.OfferCount1;
|
||||
data["BidVolumeA"] = task_data.BidVolumeA;
|
||||
data["OfferPrice9"] = task_data.OfferPrice9;
|
||||
data["BidCount9"] = task_data.BidCount9;
|
||||
data["OfferPrice8"] = task_data.OfferPrice8;
|
||||
data["YieldToMaturity"] = task_data.YieldToMaturity;
|
||||
data["LastPrice"] = task_data.LastPrice;
|
||||
data["OfferCount8"] = task_data.OfferCount8;
|
||||
data["OfferPrice4"] = task_data.OfferPrice4;
|
||||
data["OfferPrice5"] = task_data.OfferPrice5;
|
||||
data["OfferPrice6"] = task_data.OfferPrice6;
|
||||
data["BidVolume8"] = task_data.BidVolume8;
|
||||
data["OfferCount5"] = task_data.OfferCount5;
|
||||
data["OfferPrice1"] = task_data.OfferPrice1;
|
||||
data["OfferPrice2"] = task_data.OfferPrice2;
|
||||
data["OfferPrice3"] = task_data.OfferPrice3;
|
||||
data["OfferVolume4"] = task_data.OfferVolume4;
|
||||
data["OfferVolume5"] = task_data.OfferVolume5;
|
||||
data["OfferPriceLevel"] = task_data.OfferPriceLevel;
|
||||
data["OfferVolume7"] = task_data.OfferVolume7;
|
||||
data["OfferVolume1"] = task_data.OfferVolume1;
|
||||
data["OfferVolume2"] = task_data.OfferVolume2;
|
||||
data["OfferCount2"] = task_data.OfferCount2;
|
||||
data["BidPriceA"] = task_data.BidPriceA;
|
||||
data["BidVolume5"] = task_data.BidVolume5;
|
||||
data["OfferCountA"] = task_data.OfferCountA;
|
||||
|
||||
this->onRtnL2MarketData(data);
|
||||
};
|
||||
|
||||
void TdApi::processRtnL2Index(Task task)
|
||||
{
|
||||
CSecurityFtdcL2IndexField task_data = any_cast<CSecurityFtdcL2IndexField>(task.task_data);
|
||||
dict data;
|
||||
data["InstrumentID"] = task_data.InstrumentID;
|
||||
data["ExchangeID"] = task_data.ExchangeID;
|
||||
data["HighIndex"] = task_data.HighIndex;
|
||||
data["TimeStamp"] = task_data.TimeStamp;
|
||||
data["CloseIndex"] = task_data.CloseIndex;
|
||||
data["PreCloseIndex"] = task_data.PreCloseIndex;
|
||||
data["LastIndex"] = task_data.LastIndex;
|
||||
data["TradingDay"] = task_data.TradingDay;
|
||||
data["OpenIndex"] = task_data.OpenIndex;
|
||||
data["TotalVolume"] = task_data.TotalVolume;
|
||||
data["LowIndex"] = task_data.LowIndex;
|
||||
data["TurnOver"] = task_data.TurnOver;
|
||||
|
||||
this->onRtnL2Index(data);
|
||||
};
|
||||
|
||||
void TdApi::processRspSubL2OrderAndTrade(Task task)
|
||||
{
|
||||
CSecurityFtdcRspInfoField task_error = any_cast<CSecurityFtdcRspInfoField>(task.task_error);
|
||||
dict error;
|
||||
error["ErrorMsg"] = task_error.ErrorMsg;
|
||||
error["ErrorID"] = task_error.ErrorID;
|
||||
|
||||
this->onRspSubL2OrderAndTrade(error, task.task_id, task.task_last);
|
||||
};
|
||||
|
||||
void TdApi::processRspUnSubL2OrderAndTrade(Task task)
|
||||
{
|
||||
CSecurityFtdcRspInfoField task_error = any_cast<CSecurityFtdcRspInfoField>(task.task_error);
|
||||
dict error;
|
||||
error["ErrorMsg"] = task_error.ErrorMsg;
|
||||
error["ErrorID"] = task_error.ErrorID;
|
||||
|
||||
this->onRspUnSubL2OrderAndTrade(error, task.task_id, task.task_last);
|
||||
};
|
||||
|
||||
void TdApi::processRtnL2Order(Task task)
|
||||
{
|
||||
CSecurityFtdcL2OrderField task_data = any_cast<CSecurityFtdcL2OrderField>(task.task_data);
|
||||
dict data;
|
||||
data["InstrumentID"] = task_data.InstrumentID;
|
||||
data["OrderTime"] = task_data.OrderTime;
|
||||
data["OrderKind"] = task_data.OrderKind;
|
||||
data["Price"] = task_data.Price;
|
||||
data["ExchangeID"] = task_data.ExchangeID;
|
||||
data["OrderGroupID"] = task_data.OrderGroupID;
|
||||
data["Volume"] = task_data.Volume;
|
||||
data["FunctionCode"] = task_data.FunctionCode;
|
||||
data["OrderIndex"] = task_data.OrderIndex;
|
||||
|
||||
this->onRtnL2Order(data);
|
||||
};
|
||||
|
||||
void TdApi::processRtnL2Trade(Task task)
|
||||
{
|
||||
CSecurityFtdcL2TradeField task_data = any_cast<CSecurityFtdcL2TradeField>(task.task_data);
|
||||
dict data;
|
||||
data["TradeGroupID"] = task_data.TradeGroupID;
|
||||
data["SellIndex"] = task_data.SellIndex;
|
||||
data["ExchangeID"] = task_data.ExchangeID;
|
||||
data["OrderKind"] = task_data.OrderKind;
|
||||
data["TradeIndex"] = task_data.TradeIndex;
|
||||
data["Price"] = task_data.Price;
|
||||
data["InstrumentID"] = task_data.InstrumentID;
|
||||
data["BuyIndex"] = task_data.BuyIndex;
|
||||
data["Volume"] = task_data.Volume;
|
||||
data["FunctionCode"] = task_data.FunctionCode;
|
||||
data["TradeTime"] = task_data.TradeTime;
|
||||
|
||||
this->onRtnL2Trade(data);
|
||||
};
|
||||
|
||||
void TdApi::processNtfCheckOrderList(Task task)
|
||||
{
|
||||
this->onNtfCheckOrderList();
|
||||
};
|
||||
|
102
vn.lts/pyscript/l2/lts_l2_switch.cpp
Normal file
102
vn.lts/pyscript/l2/lts_l2_switch.cpp
Normal file
@ -0,0 +1,102 @@
|
||||
case ONFRONTCONNECTED:
|
||||
{
|
||||
this->processFrontConnected(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONFRONTDISCONNECTED:
|
||||
{
|
||||
this->processFrontDisconnected(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONHEARTBEATWARNING:
|
||||
{
|
||||
this->processHeartBeatWarning(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPERROR:
|
||||
{
|
||||
this->processRspError(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPUSERLOGIN:
|
||||
{
|
||||
this->processRspUserLogin(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPUSERLOGOUT:
|
||||
{
|
||||
this->processRspUserLogout(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPSUBL2MARKETDATA:
|
||||
{
|
||||
this->processRspSubL2MarketData(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPUNSUBL2MARKETDATA:
|
||||
{
|
||||
this->processRspUnSubL2MarketData(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPSUBL2INDEX:
|
||||
{
|
||||
this->processRspSubL2Index(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPUNSUBL2INDEX:
|
||||
{
|
||||
this->processRspUnSubL2Index(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRTNL2MARKETDATA:
|
||||
{
|
||||
this->processRtnL2MarketData(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRTNL2INDEX:
|
||||
{
|
||||
this->processRtnL2Index(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPSUBL2ORDERANDTRADE:
|
||||
{
|
||||
this->processRspSubL2OrderAndTrade(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRSPUNSUBL2ORDERANDTRADE:
|
||||
{
|
||||
this->processRspUnSubL2OrderAndTrade(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRTNL2ORDER:
|
||||
{
|
||||
this->processRtnL2Order(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONRTNL2TRADE:
|
||||
{
|
||||
this->processRtnL2Trade(task);
|
||||
break;
|
||||
}
|
||||
|
||||
case ONNTFCHECKORDERLIST:
|
||||
{
|
||||
this->processNtfCheckOrderList(task);
|
||||
break;
|
||||
}
|
||||
|
370
vn.lts/pyscript/l2/lts_l2_task.cpp
Normal file
370
vn.lts/pyscript/l2/lts_l2_task.cpp
Normal file
@ -0,0 +1,370 @@
|
||||
void TdApi::OnFrontConnected()
|
||||
{
|
||||
Task task = Task();
|
||||
task.task_name = ONFRONTCONNECTED;
|
||||
this->task_queue.push(task);
|
||||
};
|
||||
|
||||
void TdApi::OnFrontDisconnected(int nReason)
|
||||
{
|
||||
Task task = Task();
|
||||
task.task_name = ONFRONTDISCONNECTED;
|
||||
task.task_id = nReason;
|
||||
this->task_queue.push(task);
|
||||
};
|
||||
|
||||
void TdApi::OnHeartBeatWarning(int nTimeLapse)
|
||||
{
|
||||
Task task = Task();
|
||||
task.task_name = ONHEARTBEATWARNING;
|
||||
task.task_id = nTimeLapse;
|
||||
this->task_queue.push(task);
|
||||
};
|
||||
|
||||
void TdApi::OnRspError(CSecurityFtdcRspInfoField *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 TdApi::OnRspUserLogin(CSecurityFtdcUserLoginField *pUserLogin, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast)
|
||||
{
|
||||
Task task = Task();
|
||||
task.task_name = ONRSPUSERLOGIN;
|
||||
|
||||
if (pUserLogin)
|
||||
{
|
||||
task.task_data = *pUserLogin;
|
||||
}
|
||||
else
|
||||
{
|
||||
CSecurityFtdcUserLoginField empty_data = CSecurityFtdcUserLoginField();
|
||||
memset(&empty_data, 0, sizeof(empty_data));
|
||||
task.task_data = empty_data;
|
||||
}
|
||||
|
||||
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 TdApi::OnRspUserLogout(CSecurityFtdcUserLogoutField *pUserLogout, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast)
|
||||
{
|
||||
Task task = Task();
|
||||
task.task_name = ONRSPUSERLOGOUT;
|
||||
|
||||
if (pUserLogout)
|
||||
{
|
||||
task.task_data = *pUserLogout;
|
||||
}
|
||||
else
|
||||
{
|
||||
CSecurityFtdcUserLogoutField empty_data = CSecurityFtdcUserLogoutField();
|
||||
memset(&empty_data, 0, sizeof(empty_data));
|
||||
task.task_data = empty_data;
|
||||
}
|
||||
|
||||
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 TdApi::OnRspSubL2MarketData(CSecurityFtdcSpecificInstrumentField *pSpecificInstrument, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast)
|
||||
{
|
||||
Task task = Task();
|
||||
task.task_name = ONRSPSUBL2MARKETDATA;
|
||||
|
||||
if (pSpecificInstrument)
|
||||
{
|
||||
task.task_data = *pSpecificInstrument;
|
||||
}
|
||||
else
|
||||
{
|
||||
CSecurityFtdcSpecificInstrumentField empty_data = CSecurityFtdcSpecificInstrumentField();
|
||||
memset(&empty_data, 0, sizeof(empty_data));
|
||||
task.task_data = empty_data;
|
||||
}
|
||||
|
||||
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 TdApi::OnRspUnSubL2MarketData(CSecurityFtdcSpecificInstrumentField *pSpecificInstrument, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast)
|
||||
{
|
||||
Task task = Task();
|
||||
task.task_name = ONRSPUNSUBL2MARKETDATA;
|
||||
|
||||
if (pSpecificInstrument)
|
||||
{
|
||||
task.task_data = *pSpecificInstrument;
|
||||
}
|
||||
else
|
||||
{
|
||||
CSecurityFtdcSpecificInstrumentField empty_data = CSecurityFtdcSpecificInstrumentField();
|
||||
memset(&empty_data, 0, sizeof(empty_data));
|
||||
task.task_data = empty_data;
|
||||
}
|
||||
|
||||
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 TdApi::OnRspSubL2Index(CSecurityFtdcSpecificInstrumentField *pSpecificInstrument, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast)
|
||||
{
|
||||
Task task = Task();
|
||||
task.task_name = ONRSPSUBL2INDEX;
|
||||
|
||||
if (pSpecificInstrument)
|
||||
{
|
||||
task.task_data = *pSpecificInstrument;
|
||||
}
|
||||
else
|
||||
{
|
||||
CSecurityFtdcSpecificInstrumentField empty_data = CSecurityFtdcSpecificInstrumentField();
|
||||
memset(&empty_data, 0, sizeof(empty_data));
|
||||
task.task_data = empty_data;
|
||||
}
|
||||
|
||||
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 TdApi::OnRspUnSubL2Index(CSecurityFtdcSpecificInstrumentField *pSpecificInstrument, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast)
|
||||
{
|
||||
Task task = Task();
|
||||
task.task_name = ONRSPUNSUBL2INDEX;
|
||||
|
||||
if (pSpecificInstrument)
|
||||
{
|
||||
task.task_data = *pSpecificInstrument;
|
||||
}
|
||||
else
|
||||
{
|
||||
CSecurityFtdcSpecificInstrumentField empty_data = CSecurityFtdcSpecificInstrumentField();
|
||||
memset(&empty_data, 0, sizeof(empty_data));
|
||||
task.task_data = empty_data;
|
||||
}
|
||||
|
||||
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 TdApi::OnRtnL2MarketData(CSecurityFtdcL2MarketDataField *pL2MarketData)
|
||||
{
|
||||
Task task = Task();
|
||||
task.task_name = ONRTNL2MARKETDATA;
|
||||
|
||||
if (pL2MarketData)
|
||||
{
|
||||
task.task_data = *pL2MarketData;
|
||||
}
|
||||
else
|
||||
{
|
||||
CSecurityFtdcL2MarketDataField empty_data = CSecurityFtdcL2MarketDataField();
|
||||
memset(&empty_data, 0, sizeof(empty_data));
|
||||
task.task_data = empty_data;
|
||||
}
|
||||
this->task_queue.push(task);
|
||||
};
|
||||
|
||||
void TdApi::OnRtnL2Index(CSecurityFtdcL2IndexField *pL2Index)
|
||||
{
|
||||
Task task = Task();
|
||||
task.task_name = ONRTNL2INDEX;
|
||||
|
||||
if (pL2Index)
|
||||
{
|
||||
task.task_data = *pL2Index;
|
||||
}
|
||||
else
|
||||
{
|
||||
CSecurityFtdcL2IndexField empty_data = CSecurityFtdcL2IndexField();
|
||||
memset(&empty_data, 0, sizeof(empty_data));
|
||||
task.task_data = empty_data;
|
||||
}
|
||||
this->task_queue.push(task);
|
||||
};
|
||||
|
||||
void TdApi::OnRspSubL2OrderAndTrade(CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast)
|
||||
{
|
||||
Task task = Task();
|
||||
task.task_name = ONRSPSUBL2ORDERANDTRADE;
|
||||
|
||||
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 TdApi::OnRspUnSubL2OrderAndTrade(CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast)
|
||||
{
|
||||
Task task = Task();
|
||||
task.task_name = ONRSPUNSUBL2ORDERANDTRADE;
|
||||
|
||||
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 TdApi::OnRtnL2Order(CSecurityFtdcL2OrderField *pL2Order)
|
||||
{
|
||||
Task task = Task();
|
||||
task.task_name = ONRTNL2ORDER;
|
||||
|
||||
if (pL2Order)
|
||||
{
|
||||
task.task_data = *pL2Order;
|
||||
}
|
||||
else
|
||||
{
|
||||
CSecurityFtdcL2OrderField empty_data = CSecurityFtdcL2OrderField();
|
||||
memset(&empty_data, 0, sizeof(empty_data));
|
||||
task.task_data = empty_data;
|
||||
}
|
||||
this->task_queue.push(task);
|
||||
};
|
||||
|
||||
void TdApi::OnRtnL2Trade(CSecurityFtdcL2TradeField *pL2Trade)
|
||||
{
|
||||
Task task = Task();
|
||||
task.task_name = ONRTNL2TRADE;
|
||||
|
||||
if (pL2Trade)
|
||||
{
|
||||
task.task_data = *pL2Trade;
|
||||
}
|
||||
else
|
||||
{
|
||||
CSecurityFtdcL2TradeField empty_data = CSecurityFtdcL2TradeField();
|
||||
memset(&empty_data, 0, sizeof(empty_data));
|
||||
task.task_data = empty_data;
|
||||
}
|
||||
this->task_queue.push(task);
|
||||
};
|
||||
|
||||
void TdApi::OnNtfCheckOrderList(TSecurityFtdcInstrumentIDType InstrumentID, TSecurityFtdcFunctionCodeType FunctionCode)
|
||||
{
|
||||
Task task = Task();
|
||||
task.task_name = ONNTFCHECKORDERLIST;
|
||||
|
||||
if (nstrumentID)
|
||||
{
|
||||
task.task_data = InstrumentID;
|
||||
}
|
||||
else
|
||||
{
|
||||
TSecurityFtdcInstrumentIDType empty_data = TSecurityFtdcInstrumentIDType();
|
||||
memset(&empty_data, 0, sizeof(empty_data));
|
||||
task.task_data = empty_data;
|
||||
}
|
||||
|
||||
if (unctionCode)
|
||||
{
|
||||
task.task_data = FunctionCode;
|
||||
}
|
||||
else
|
||||
{
|
||||
TSecurityFtdcFunctionCodeType empty_data = TSecurityFtdcFunctionCodeType();
|
||||
memset(&empty_data, 0, sizeof(empty_data));
|
||||
task.task_data = empty_data;
|
||||
}
|
||||
this->task_queue.push(task);
|
||||
};
|
||||
|
182
vn.lts/pyscript/l2/lts_l2_wrap.cpp
Normal file
182
vn.lts/pyscript/l2/lts_l2_wrap.cpp
Normal file
@ -0,0 +1,182 @@
|
||||
virtual void onRspError(dict error, int id, bool last)
|
||||
{
|
||||
PyLock lock;
|
||||
|
||||
try
|
||||
{
|
||||
this->get_override("onRspError")(error, 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 onRspSubL2MarketData(dict data, dict error, int id, bool last)
|
||||
{
|
||||
PyLock lock;
|
||||
|
||||
try
|
||||
{
|
||||
this->get_override("onRspSubL2MarketData")(data, error, id, last);
|
||||
}
|
||||
catch (error_already_set const &)
|
||||
{
|
||||
PyErr_Print();
|
||||
}
|
||||
};
|
||||
|
||||
virtual void onRspUnSubL2MarketData(dict data, dict error, int id, bool last)
|
||||
{
|
||||
PyLock lock;
|
||||
|
||||
try
|
||||
{
|
||||
this->get_override("onRspUnSubL2MarketData")(data, error, id, last);
|
||||
}
|
||||
catch (error_already_set const &)
|
||||
{
|
||||
PyErr_Print();
|
||||
}
|
||||
};
|
||||
|
||||
virtual void onRspSubL2Index(dict data, dict error, int id, bool last)
|
||||
{
|
||||
PyLock lock;
|
||||
|
||||
try
|
||||
{
|
||||
this->get_override("onRspSubL2Index")(data, error, id, last);
|
||||
}
|
||||
catch (error_already_set const &)
|
||||
{
|
||||
PyErr_Print();
|
||||
}
|
||||
};
|
||||
|
||||
virtual void onRspUnSubL2Index(dict data, dict error, int id, bool last)
|
||||
{
|
||||
PyLock lock;
|
||||
|
||||
try
|
||||
{
|
||||
this->get_override("onRspUnSubL2Index")(data, error, id, last);
|
||||
}
|
||||
catch (error_already_set const &)
|
||||
{
|
||||
PyErr_Print();
|
||||
}
|
||||
};
|
||||
|
||||
virtual void onRtnL2MarketData(dict data)
|
||||
{
|
||||
PyLock lock;
|
||||
|
||||
try
|
||||
{
|
||||
this->get_override("onRtnL2MarketData")(data);
|
||||
}
|
||||
catch (error_already_set const &)
|
||||
{
|
||||
PyErr_Print();
|
||||
}
|
||||
};
|
||||
|
||||
virtual void onRtnL2Index(dict data)
|
||||
{
|
||||
PyLock lock;
|
||||
|
||||
try
|
||||
{
|
||||
this->get_override("onRtnL2Index")(data);
|
||||
}
|
||||
catch (error_already_set const &)
|
||||
{
|
||||
PyErr_Print();
|
||||
}
|
||||
};
|
||||
|
||||
virtual void onRspSubL2OrderAndTrade(dict data, dict error, int id, bool last)
|
||||
{
|
||||
PyLock lock;
|
||||
|
||||
try
|
||||
{
|
||||
this->get_override("onRspSubL2OrderAndTrade")(data, error, id, last);
|
||||
}
|
||||
catch (error_already_set const &)
|
||||
{
|
||||
PyErr_Print();
|
||||
}
|
||||
};
|
||||
|
||||
virtual void onRspUnSubL2OrderAndTrade(dict data, dict error, int id, bool last)
|
||||
{
|
||||
PyLock lock;
|
||||
|
||||
try
|
||||
{
|
||||
this->get_override("onRspUnSubL2OrderAndTrade")(data, error, id, last);
|
||||
}
|
||||
catch (error_already_set const &)
|
||||
{
|
||||
PyErr_Print();
|
||||
}
|
||||
};
|
||||
|
||||
virtual void onRtnL2Order(dict data)
|
||||
{
|
||||
PyLock lock;
|
||||
|
||||
try
|
||||
{
|
||||
this->get_override("onRtnL2Order")(data);
|
||||
}
|
||||
catch (error_already_set const &)
|
||||
{
|
||||
PyErr_Print();
|
||||
}
|
||||
};
|
||||
|
||||
virtual void onRtnL2Trade(dict data)
|
||||
{
|
||||
PyLock lock;
|
||||
|
||||
try
|
||||
{
|
||||
this->get_override("onRtnL2Trade")(data);
|
||||
}
|
||||
catch (error_already_set const &)
|
||||
{
|
||||
PyErr_Print();
|
||||
}
|
||||
};
|
||||
|
BIN
vn.lts/vnltsl2/test/L2mduserapi.dll
Normal file
BIN
vn.lts/vnltsl2/test/L2mduserapi.dll
Normal file
Binary file not shown.
226
vn.lts/vnltsl2/test/l2test.py
Normal file
226
vn.lts/vnltsl2/test/l2test.py
Normal file
@ -0,0 +1,226 @@
|
||||
# encoding: UTF-8
|
||||
|
||||
import sys
|
||||
from time import sleep
|
||||
|
||||
from PyQt4 import QtGui
|
||||
|
||||
from vnltsl2 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 TestL2MdApi(L2MdApi):
|
||||
"""测试用实例"""
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def __init__(self):
|
||||
"""Constructor"""
|
||||
super(TestL2MdApi, self).__init__()
|
||||
self.brokerID = None
|
||||
self.userID = None
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@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)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def onRspUserLogin(self, data, error, n, last):
|
||||
"""登陆回报"""
|
||||
self.brokerID = data['BrokerID']
|
||||
self.userID = data['UserID']
|
||||
print_dict(data)
|
||||
print_dict(error)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@simple_log
|
||||
def onRspUserLogout(self, data, error, n, last):
|
||||
"""登出回报"""
|
||||
print_dict(data)
|
||||
print_dict(error)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@simple_log
|
||||
def onRspSubL2MarketData(self, data, error, n, last):
|
||||
"""订阅L2合约回报"""
|
||||
print_dict(data)
|
||||
print_dict(error)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@simple_log
|
||||
def onRspUnSubL2MarketData(self, data, error, n, last):
|
||||
"""退订L2合约回报"""
|
||||
print_dict(data)
|
||||
print_dict(error)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@simple_log
|
||||
def onRspSubL2Index(self, data, error, n, last):
|
||||
"""订阅L2指数回报"""
|
||||
print_dict(data)
|
||||
print_dict(error)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@simple_log
|
||||
def onRspUnSubL2Index(self, data, error, n, last):
|
||||
"""退订L2指数回报"""
|
||||
print_dict(data)
|
||||
print_dict(error)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@simple_log
|
||||
def onRtnL2MarketData(self, data):
|
||||
"""L2行情推送"""
|
||||
print_dict(data)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@simple_log
|
||||
def onRtnL2Index(self, data):
|
||||
"""L2指数行情推送"""
|
||||
print_dict(data)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@simple_log
|
||||
def onRtnL2Order(self, data):
|
||||
"""L2订单推送"""
|
||||
print_dict(data)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@simple_log
|
||||
def onRtnL2Trade(self, data):
|
||||
"""L2成交推送"""
|
||||
print_dict(data)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@simple_log
|
||||
def onRspSubL2OrderAndTrade(self, error, n, last):
|
||||
"""订阅L2订单、成交回报"""
|
||||
print_dict(error)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@simple_log
|
||||
def onRspUnSubL2OrderAndTrade(self, error, n, last):
|
||||
"""退订L2订单、成交回报"""
|
||||
print_dict(error)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@simple_log
|
||||
def onNtfCheckOrderList(self, instrumentID, functionID):
|
||||
"""通知清理SSE买卖一队列中数量为0的报单"""
|
||||
print 'instrumentID: %s' % instrumentID
|
||||
print 'functionID: %s' % functionID
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def main():
|
||||
"""主测试函数,出现堵塞时可以考虑使用sleep"""
|
||||
reqid = 0
|
||||
|
||||
# 创建Qt应用对象,用于事件循环
|
||||
app = QtGui.QApplication(sys.argv)
|
||||
|
||||
# 创建API对象
|
||||
api = TestL2MdApi()
|
||||
|
||||
# 在C++环境中创建MdApi对象,传入参数是希望用来保存.con文件的地址
|
||||
api.createFtdcL2MDUserApi('')
|
||||
|
||||
# 注册前置机地址
|
||||
api.registerFront("tcp://101.231.210.2:8900") # 另一个地址tcp://222.66.55.171:8900
|
||||
|
||||
# 初始化api,连接前置机
|
||||
api.init()
|
||||
sleep(0.5)
|
||||
|
||||
# 登陆,测试通过
|
||||
loginReq = {} # 创建一个空字典
|
||||
loginReq['UserID'] = '' # 参数作为字典键值的方式传入
|
||||
loginReq['Password'] = '' # 键名和C++中的结构体成员名对应
|
||||
loginReq['BrokerID'] = '2011'
|
||||
loginReq['DataLevel'] = '1' # '0'全量行情 '1'10档 '2'5档
|
||||
reqid = reqid + 1 # 请求数必须保持唯一性
|
||||
i = api.reqUserLogin(loginReq, 1)
|
||||
sleep(0.5)
|
||||
|
||||
## 登出,测试失败
|
||||
#reqid = reqid + 1
|
||||
#logoutReq = {}
|
||||
#logoutReq['UserID'] = api.userID
|
||||
#loginReq['BrokerID'] = api.brokerID
|
||||
#i = api.reqUserLogout(logoutReq, 1)
|
||||
#sleep(0.5)
|
||||
|
||||
## 安全退出,测试通过
|
||||
#i = api.exit()
|
||||
|
||||
# 获取交易日,测试通过
|
||||
#day = api.getTradingDay()
|
||||
#print 'Trading Day is:' + str(day)
|
||||
#sleep(0.5)
|
||||
|
||||
# 订阅L2合约,测试通过
|
||||
subReq = {}
|
||||
subReq['InstrumentID'] = '510050'
|
||||
subReq['ExchangeID'] = 'SSE'
|
||||
i = api.subscribeL2MarketData(subReq)
|
||||
|
||||
## 退订L2合约,测试通过
|
||||
#i = api.unSubscribeL2MarketData(subReq)
|
||||
|
||||
## 订阅L2指数,测试通过
|
||||
#subReq = {}
|
||||
#subReq['InstrumentID'] = '000300'
|
||||
#subReq['ExchangeID'] = 'SSE'
|
||||
#i = api.subscribeL2Index(subReq)
|
||||
|
||||
## 退订L2合约,测试通过
|
||||
#i = api.unSubscribeL2Index(subReq)
|
||||
|
||||
# 订阅L2报单和成交,测试提示无此权限
|
||||
i = api.subscribeL2OrderAndTrade()
|
||||
|
||||
# 退订L2报单和成交,测试通过
|
||||
i = api.unSubscribeL2OrderAndTrade()
|
||||
|
||||
# 连续运行,用于输出行情
|
||||
app.exec_()
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
BIN
vn.lts/vnltsl2/test/vnltsl2.pyd
Normal file
BIN
vn.lts/vnltsl2/test/vnltsl2.pyd
Normal file
Binary file not shown.
32
vn.lts/vnltsl2/vnltsl2/ReadMe.txt
Normal file
32
vn.lts/vnltsl2/vnltsl2/ReadMe.txt
Normal file
@ -0,0 +1,32 @@
|
||||
========================================================================
|
||||
动态链接库:vnltsl2 项目概述
|
||||
========================================================================
|
||||
|
||||
应用程序向导已为您创建了此 vnltsl2 DLL。
|
||||
|
||||
本文件概要介绍组成 vnltsl2 应用程序的每个文件的内容。
|
||||
|
||||
|
||||
vnltsl2.vcxproj
|
||||
这是使用应用程序向导生成的 VC++ 项目的主项目文件,其中包含生成该文件的 Visual C++ 的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。
|
||||
|
||||
vnltsl2.vcxproj.filters
|
||||
这是使用“应用程序向导”生成的 VC++ 项目筛选器文件。它包含有关项目文件与筛选器之间的关联信息。在 IDE 中,通过这种关联,在特定节点下以分组形式显示具有相似扩展名的文件。例如,“.cpp”文件与“源文件”筛选器关联。
|
||||
|
||||
vnltsl2.cpp
|
||||
这是主 DLL 源文件。
|
||||
|
||||
此 DLL 在创建时不导出任何符号。因此,生成时不会产生 .lib 文件。如果希望此项目成为其他某个项目的项目依赖项,则需要添加代码以从 DLL 导出某些符号,以便产生一个导出库,或者,也可以在项目“属性页”对话框中的“链接器”文件夹中,将“常规”属性页上的“忽略输入库”属性设置为“是”。
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
其他标准文件:
|
||||
|
||||
StdAfx.h, StdAfx.cpp
|
||||
这些文件用于生成名为 vnltsl2.pch 的预编译头 (PCH) 文件和名为 StdAfx.obj 的预编译类型文件。
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
其他注释:
|
||||
|
||||
应用程序向导使用“TODO:”注释来指示应添加或自定义的源代码部分。
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
19
vn.lts/vnltsl2/vnltsl2/dllmain.cpp
Normal file
19
vn.lts/vnltsl2/vnltsl2/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.lts/vnltsl2/vnltsl2/stdafx.cpp
Normal file
8
vn.lts/vnltsl2/vnltsl2/stdafx.cpp
Normal file
@ -0,0 +1,8 @@
|
||||
// stdafx.cpp : 只包括标准包含文件的源文件
|
||||
// vnltsl2.pch 将作为预编译头
|
||||
// stdafx.obj 将包含预编译类型信息
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
// TODO: 在 STDAFX.H 中
|
||||
// 引用任何所需的附加头文件,而不是在此文件中引用
|
16
vn.lts/vnltsl2/vnltsl2/stdafx.h
Normal file
16
vn.lts/vnltsl2/vnltsl2/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.lts/vnltsl2/vnltsl2/targetver.h
Normal file
8
vn.lts/vnltsl2/vnltsl2/targetver.h
Normal file
@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
// 包括 SDKDDKVer.h 将定义可用的最高版本的 Windows 平台。
|
||||
|
||||
// 如果要为以前的 Windows 平台生成应用程序,请包括 WinSDKVer.h,并将
|
||||
// WIN32_WINNT 宏设置为要支持的平台,然后再包括 SDKDDKVer.h。
|
||||
|
||||
#include <SDKDDKVer.h>
|
1249
vn.lts/vnltsl2/vnltsl2/vnltsl2.cpp
Normal file
1249
vn.lts/vnltsl2/vnltsl2/vnltsl2.cpp
Normal file
File diff suppressed because it is too large
Load Diff
347
vn.lts/vnltsl2/vnltsl2/vnltsl2.h
Normal file
347
vn.lts/vnltsl2/vnltsl2/vnltsl2.h
Normal file
@ -0,0 +1,347 @@
|
||||
//说明部分
|
||||
|
||||
//系统
|
||||
#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 "SecurityFtdcL2MDUserApi.h"
|
||||
_USING_LTS_NS_
|
||||
|
||||
//命名空间
|
||||
using namespace std;
|
||||
using namespace boost::python;
|
||||
using namespace boost;
|
||||
|
||||
//常量
|
||||
#define ONFRONTCONNECTED 1
|
||||
#define ONFRONTDISCONNECTED 2
|
||||
#define ONHEARTBEATWARNING 3
|
||||
#define ONRSPERROR 4
|
||||
#define ONRSPUSERLOGIN 5
|
||||
#define ONRSPUSERLOGOUT 6
|
||||
#define ONRSPSUBL2MARKETDATA 7
|
||||
#define ONRSPUNSUBL2MARKETDATA 8
|
||||
#define ONRSPSUBL2INDEX 9
|
||||
#define ONRSPUNSUBL2INDEX 10
|
||||
#define ONRTNL2MARKETDATA 11
|
||||
#define ONRTNL2INDEX 12
|
||||
#define ONRSPSUBL2ORDERANDTRADE 13
|
||||
#define ONRSPUNSUBL2ORDERANDTRADE 14
|
||||
#define ONRTNL2ORDER 15
|
||||
#define ONRTNL2TRADE 16
|
||||
#define ONNTFCHECKORDERLIST 17
|
||||
|
||||
|
||||
|
||||
///-------------------------------------------------------------------------------------
|
||||
///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 L2MdApi : public CSecurityFtdcL2MDUserSpi
|
||||
{
|
||||
private:
|
||||
CSecurityFtdcL2MDUserApi* api; //API对象
|
||||
thread *task_thread; //工作线程指针(向python中推送数据)
|
||||
ConcurrentQueue<Task> task_queue; //任务队列
|
||||
|
||||
public:
|
||||
L2MdApi()
|
||||
{
|
||||
function0<void> f = boost::bind(&L2MdApi::processTask, this);
|
||||
thread t(f);
|
||||
this->task_thread = &t;
|
||||
};
|
||||
|
||||
~L2MdApi()
|
||||
{
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
//API回调函数
|
||||
//-------------------------------------------------------------------------------------
|
||||
|
||||
///当客户端与交易后台建立起通信连接时(还未登录前),该方法被调用。
|
||||
virtual void OnFrontConnected();
|
||||
|
||||
///当客户端与交易后台通信连接断开时,该方法被调用。当发生这个情况后,API会自动重新连接,客户端可不做处理。
|
||||
///@param nReason 错误原因
|
||||
/// 0x1001 网络读失败
|
||||
/// 0x1002 网络写失败
|
||||
/// 0x2001 接收心跳超时
|
||||
/// 0x2002 发送心跳失败
|
||||
/// 0x2003 收到错误报文
|
||||
virtual void OnFrontDisconnected(int nReason);
|
||||
|
||||
///心跳超时警告
|
||||
virtual void OnHeartBeatWarning(int nTimeLapse);
|
||||
|
||||
///错误应答
|
||||
virtual void OnRspError(CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) ;
|
||||
|
||||
///登录请求响应
|
||||
virtual void OnRspUserLogin(CSecurityFtdcUserLoginField *pUserLogin, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) ;
|
||||
|
||||
///登出请求响应
|
||||
virtual void OnRspUserLogout(CSecurityFtdcUserLogoutField *pUserLogout, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) ;
|
||||
|
||||
///订阅Level2行情应答
|
||||
virtual void OnRspSubL2MarketData(CSecurityFtdcSpecificInstrumentField *pSpecificInstrument, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) ;
|
||||
|
||||
///取消订阅Level2行情应答
|
||||
virtual void OnRspUnSubL2MarketData(CSecurityFtdcSpecificInstrumentField *pSpecificInstrument, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) ;
|
||||
|
||||
///订阅Level2指数行情应答
|
||||
virtual void OnRspSubL2Index(CSecurityFtdcSpecificInstrumentField *pSpecificInstrument, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) ;
|
||||
|
||||
///取消订阅Level2指数行情应答
|
||||
virtual void OnRspUnSubL2Index(CSecurityFtdcSpecificInstrumentField *pSpecificInstrument, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) ;
|
||||
|
||||
///Level2行情通知
|
||||
virtual void OnRtnL2MarketData(CSecurityFtdcL2MarketDataField *pL2MarketData) ;
|
||||
|
||||
///Level2指数行情通知
|
||||
virtual void OnRtnL2Index(CSecurityFtdcL2IndexField *pL2Index) ;
|
||||
|
||||
///订阅逐笔委托及成交应答
|
||||
virtual void OnRspSubL2OrderAndTrade(CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) ;
|
||||
|
||||
///取消订阅逐笔委托及成交应答
|
||||
virtual void OnRspUnSubL2OrderAndTrade(CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) ;
|
||||
|
||||
///Level2委托通知
|
||||
virtual void OnRtnL2Order(CSecurityFtdcL2OrderField *pL2Order) ;
|
||||
|
||||
///Level2成交通知
|
||||
virtual void OnRtnL2Trade(CSecurityFtdcL2TradeField *pL2Trade) ;
|
||||
|
||||
///通知清理SSE买卖一队列中数量为0的报单
|
||||
virtual void OnNtfCheckOrderList(TSecurityFtdcInstrumentIDType InstrumentID, TSecurityFtdcFunctionCodeType FunctionCode) ;
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
//task:任务
|
||||
//-------------------------------------------------------------------------------------
|
||||
|
||||
void processTask();
|
||||
|
||||
void processFrontConnected(Task task);
|
||||
|
||||
void processFrontDisconnected(Task task);
|
||||
|
||||
void processHeartBeatWarning(Task task);
|
||||
|
||||
void processRspError(Task task);
|
||||
|
||||
void processRspUserLogin(Task task);
|
||||
|
||||
void processRspUserLogout(Task task);
|
||||
|
||||
void processRspSubL2MarketData(Task task);
|
||||
|
||||
void processRspUnSubL2MarketData(Task task);
|
||||
|
||||
void processRspSubL2Index(Task task);
|
||||
|
||||
void processRspUnSubL2Index(Task task);
|
||||
|
||||
void processRtnL2MarketData(Task task);
|
||||
|
||||
void processRtnL2Index(Task task);
|
||||
|
||||
void processRspSubL2OrderAndTrade(Task task);
|
||||
|
||||
void processRspUnSubL2OrderAndTrade(Task task);
|
||||
|
||||
void processRtnL2Order(Task task);
|
||||
|
||||
void processRtnL2Trade(Task task);
|
||||
|
||||
void processNtfCheckOrderList(Task task);
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
//data:回调函数的数据字典
|
||||
//error:回调函数的错误字典
|
||||
//id:请求id
|
||||
//last:是否为最后返回
|
||||
//i:整数
|
||||
//-------------------------------------------------------------------------------------
|
||||
|
||||
virtual void onFrontConnected(){};
|
||||
|
||||
virtual void onFrontDisconnected(int i){};
|
||||
|
||||
virtual void onHeartBeatWarning(int i){};
|
||||
|
||||
virtual void onRspError(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 onRspSubL2MarketData(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspUnSubL2MarketData(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspSubL2Index(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspUnSubL2Index(dict data, dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRtnL2MarketData(dict data) {};
|
||||
|
||||
virtual void onRtnL2Index(dict data) {};
|
||||
|
||||
virtual void onRspSubL2OrderAndTrade(dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRspUnSubL2OrderAndTrade(dict error, int id, bool last) {};
|
||||
|
||||
virtual void onRtnL2Order(dict data) {};
|
||||
|
||||
virtual void onRtnL2Trade(dict data) {};
|
||||
|
||||
virtual void onNtfCheckOrderList(string instrumentID, string functionCode) {};
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
//req:主动函数的请求字典
|
||||
//-------------------------------------------------------------------------------------
|
||||
|
||||
void createFtdcL2MDUserApi(string pszFlowPath = "");
|
||||
|
||||
void release();
|
||||
|
||||
void init();
|
||||
|
||||
int join();
|
||||
|
||||
int exit();
|
||||
|
||||
string getTradingDay();
|
||||
|
||||
void registerFront(string pszFrontAddress);
|
||||
|
||||
int subscribeL2MarketData(dict req);
|
||||
|
||||
int unSubscribeL2MarketData(dict req);
|
||||
|
||||
int subscribeL2Index(dict req);
|
||||
|
||||
int unSubscribeL2Index(dict req);
|
||||
|
||||
int subscribeL2OrderAndTrade();
|
||||
|
||||
int unSubscribeL2OrderAndTrade();
|
||||
|
||||
int reqUserLogin(dict req, int nRequestID);
|
||||
|
||||
int reqUserLogout(dict req, int nRequestID);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user