-
Notifications
You must be signed in to change notification settings - Fork 18
/
ctpmdapi.h
61 lines (53 loc) · 1.82 KB
/
ctpmdapi.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef CTPMDAPI_H
#define CTPMDAPI_H
#include <QObject>
#include "ctpApi/ThostFtdcMdApi.h"
#include <atomic>
#include <QDir>
#include <QDebug>
#include "eventengine.h"
#include "dataengine.h"
class CtpMdApi : public QObject, public CThostFtdcMdSpi
{
Q_OBJECT
public:
CtpMdApi(EventEngine *ee, DataEngine* de)
{
this->ee = ee;
this->de = de;
}
//判断是否连接
bool get_is_md_connect();
bool get_is_md_logout();
//md连接交易所
void ctp_md_init(QString mdaddress);
//释放md资源
void ctp_md_release();
//md登录登出
void ctp_md_login();
void ctp_md_logout();
//md订阅合约
void ctp_md_subscribe(QString instrumendid);
private:
CThostFtdcMdApi *MdApi;
EventEngine* ee;
DataEngine* de;
int requestID{ 0 };
std::atomic<bool> is_md_connect{ false };
std::atomic<bool> is_md_logout{ false };
signals:
public slots:
private:
/****************************Spi回调函数****************************************/
//当客户端与交易后台建立起通信连接时(还未登录前),该方法被调用
void OnFrontConnected() override;
///当客户端与交易后台通信连接断开时,该方法被调用。当发生这个情况后,API会自动重新连接,客户端可不做处理。
void OnFrontDisconnected(int nReason) override;
///登录请求响应
void OnRspUserLogin(CThostFtdcRspUserLoginField *pRspUserLogin, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) override;
///登出请求响应
void OnRspUserLogout(CThostFtdcUserLogoutField *pUserLogout, CThostFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast) override;
//行情回报响应
void OnRtnDepthMarketData(CThostFtdcDepthMarketDataField *pDepthMarketData) override;
};
#endif // CTPMDAPI_H