136 lines
4.0 KiB
C++
136 lines
4.0 KiB
C++
/////////////////////////////////////////////////////////////////////////
|
||
///@company shanghai liber information Technology Co.,Ltd
|
||
///@file SecurityFtdcMdApi.h
|
||
///@brief 定义客户端接口
|
||
/////////////////////////////////////////////////////////////////////////
|
||
|
||
#if !defined(SECURITY_FTDCMDAPI_H)
|
||
#define SECURITY_FTDCMDAPI_H
|
||
|
||
#if _MSC_VER > 1000
|
||
#pragma once
|
||
#endif // _MSC_VER > 1000
|
||
|
||
#include "SecurityFtdcUserApiStruct.h"
|
||
|
||
#if defined(ISLIB) && defined(WIN32)
|
||
#ifdef LIB_MD_API_EXPORT
|
||
#define MD_API_EXPORT __declspec(dllexport)
|
||
#else
|
||
#define MD_API_EXPORT __declspec(dllimport)
|
||
#endif
|
||
#else
|
||
#define MD_API_EXPORT
|
||
#endif
|
||
|
||
class CSecurityFtdcMdSpi
|
||
{
|
||
public:
|
||
///当客户端与交易后台建立起通信连接时(还未登录前),该方法被调用。
|
||
virtual void OnFrontConnected(){};
|
||
|
||
///当客户端与交易后台通信连接断开时,该方法被调用。当发生这个情况后,API会自动重新连接,客户端可不做处理。
|
||
///@param nReason 错误原因
|
||
/// 0x1001 网络读失败
|
||
/// 0x1002 网络写失败
|
||
/// 0x2001 接收心跳超时
|
||
/// 0x2002 发送心跳失败
|
||
/// 0x2003 收到错误报文
|
||
virtual void OnFrontDisconnected(int nReason){};
|
||
|
||
///心跳超时警告。当长时间未收到报文时,该方法被调用。
|
||
///@param nTimeLapse 距离上次接收报文的时间
|
||
virtual void OnHeartBeatWarning(int nTimeLapse){};
|
||
|
||
|
||
///错误应答
|
||
virtual void OnRspError(CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||
|
||
///登录请求响应
|
||
virtual void OnRspUserLogin(CSecurityFtdcRspUserLoginField *pRspUserLogin, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||
|
||
///登出请求响应
|
||
virtual void OnRspUserLogout(CSecurityFtdcUserLogoutField *pUserLogout, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||
|
||
///订阅行情应答
|
||
virtual void OnRspSubMarketData(CSecurityFtdcSpecificInstrumentField *pSpecificInstrument, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||
|
||
///取消订阅行情应答
|
||
virtual void OnRspUnSubMarketData(CSecurityFtdcSpecificInstrumentField *pSpecificInstrument, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) {};
|
||
|
||
///深度行情通知
|
||
virtual void OnRtnDepthMarketData(CSecurityFtdcDepthMarketDataField *pDepthMarketData) {};
|
||
};
|
||
|
||
#ifndef WINDOWS
|
||
#if __GNUC__ >= 4
|
||
#pragma GCC visibility push(default)
|
||
#endif
|
||
#endif
|
||
|
||
class MD_API_EXPORT CSecurityFtdcMdApi
|
||
{
|
||
public:
|
||
///创建MdApi
|
||
///@param pszFlowPath 存贮订阅信息文件的目录,默认为当前目录
|
||
///@return 创建出的UserApi
|
||
///modify for udp marketdata
|
||
static CSecurityFtdcMdApi *CreateFtdcMdApi(const char *pszFlowPath = "");
|
||
|
||
///删除接口对象本身
|
||
///@remark 不再使用本接口对象时,调用该函数删除接口对象
|
||
virtual void Release() = 0;
|
||
|
||
///初始化
|
||
///@remark 初始化运行环境,只有调用后,接口才开始工作
|
||
virtual void Init() = 0;
|
||
|
||
///等待接口线程结束运行
|
||
///@return 线程退出代码
|
||
virtual int Join() = 0;
|
||
|
||
///获取当前交易日
|
||
///@retrun 获取到的交易日
|
||
///@remark 只有登录成功后,才能得到正确的交易日
|
||
virtual const char *GetTradingDay() = 0;
|
||
|
||
///注册前置机网络地址
|
||
///@param pszFrontAddress:前置机网络地址。
|
||
///@remark 网络地址的格式为:“protocol://ipaddress:port”,如:”tcp://127.0.0.1:17001”。
|
||
///@remark “tcp”代表传输协议,“127.0.0.1”代表服务器地址。”17001”代表服务器端口号。
|
||
virtual void RegisterFront(char *pszFrontAddress) = 0;
|
||
|
||
///注册回调接口
|
||
///@param pSpi 派生自回调接口类的实例
|
||
virtual void RegisterSpi(CSecurityFtdcMdSpi *pSpi) = 0;
|
||
|
||
///订阅行情。
|
||
///@param ppInstrumentID 合约ID
|
||
///@param nCount 要订阅/退订行情的合约个数
|
||
///@remark
|
||
virtual int SubscribeMarketData(char *ppInstrumentID[], int nCount, char* pExchageID) = 0;
|
||
|
||
///退订行情。
|
||
///@param ppInstrumentID 合约ID
|
||
///@param nCount 要订阅/退订行情的合约个数
|
||
///@remark
|
||
virtual int UnSubscribeMarketData(char *ppInstrumentID[], int nCount, char* pExchageID) = 0;
|
||
|
||
///用户登录请求
|
||
virtual int ReqUserLogin(CSecurityFtdcReqUserLoginField *pReqUserLoginField, int nRequestID) = 0;
|
||
|
||
|
||
///登出请求
|
||
virtual int ReqUserLogout(CSecurityFtdcUserLogoutField *pUserLogout, int nRequestID) = 0;
|
||
protected:
|
||
~CSecurityFtdcMdApi(){};
|
||
};
|
||
|
||
#ifndef WINDOWS
|
||
#if __GNUC__ >= 4
|
||
#pragma GCC visibility pop
|
||
#endif
|
||
#endif
|
||
|
||
#endif
|