
#pragma once


// CQuoteAPI command target

#include "CTCQuoteAPIEx.h"
#include "CITCQuoteAPIExEvents.h"
#include "..\TCORE\include\TCQuoteAPIDefinitions.h"


struct stcSubQuote
{
	CString strSymbol;
	long nStartTime;
	long nEndTime;
};

class CQuoteEventReceiver
{
public:
	CQuoteEventReceiver(void){};
	virtual ~CQuoteEventReceiver(void){};
	virtual void OnQuoteCommandMsg(long lMsgType, long lMsgCode, LPCTSTR strMsg){};
	virtual void OnQuoteData(long lSymbolType, long lDataType, LPDISPATCH lpDispData){};
	virtual void OnQuoteDataSyn(long lSymbolType, long lDataType, LPDISPATCH lpDispData, LPCTSTR lpModifiedFields){};
	virtual void OnQuoteSymbolClassificationsUpdate(){};
};

class CQuoteAPI : public CCmdTarget
{
	DECLARE_DYNAMIC(CQuoteAPI)

public:
	CQuoteAPI();
	virtual ~CQuoteAPI();
protected:
	afx_msg void OnCommandMsg(long MsgType, long MsgCode, LPCTSTR MsgString);	//连线QuoteAPI成功之后会收到讯息
	afx_msg void OnQuoteData(long lSymbolType, long lDataType, LPDISPATCH lpDispData);	//报价资料
	afx_msg void OnQuoteDataSyn(long lSymbolType, long lDataType, LPDISPATCH lpDispData, LPCTSTR lpModifiedFields);	//报价资料(不并tick)
	afx_msg void OnSymbolClassificationsUpdate();	//商品分类表更新
	DECLARE_MESSAGE_MAP()
	DECLARE_DISPATCH_MAP()
	DECLARE_INTERFACE_MAP()
public:
	CTCQuoteAPIEx* m_pInterface;
	DWORD m_dwCookie;

	BOOL Init(CQuoteEventReceiver* pEventReceiver);	//初始化
	void UnAdvise();
	long Connect(LPCTSTR HostAddress, LPCTSTR SystemName, LPCTSTR AppID, long ConnectType);	//跟Tcore连线
	void Disconnect();	//断线
	void DoSub(stcSubQuote SubQuote, long nType);	//订阅报价
	void DoUnSub(stcSubQuote SubQuote, long nType);	//解订报价
	void SetSubscriptionLevel(long lLevel);	//设定报价资料是否不并tick
	CString GetSymbolClassifications(LPCTSTR Classify, LPCTSTR Exchange, LPCTSTR Symbol, LPCTSTR Month, LPCTSTR CallPut);	//取得商品分类表

protected:
	CQuoteEventReceiver* m_pEventReceiver;
	bool bConnect;
};

