// RTCQuoteAPIDemo.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include "RTCQuoteAPI.h"

using namespace std;

class QuoteAPI : public RTCQuoteAPISpi
{
	RTCQuoteAPI *m_pQuote;

public:
	void Go()
	{
		char strHost[] = ".";
		char strstrSystemName[] = "";
		char strServiceKey[] = "";

		m_pQuote = RTCQuoteAPI::CreateRTCQuoteAPI();
		m_pQuote->RegisterSpi(this);
		m_pQuote->RegisterFront(strHost, strstrSystemName, strServiceKey, 1);

		m_pQuote->Join();
	}

	void OnFrontConnected()
	{
		char *strSymbol = "TC.S.SSE.510050";

		cout << "OnFrontConnected" << endl;
		m_pQuote->SubscribeMarketData(&strSymbol, 1);
		m_pQuote->SubscribeGreeksData(&strSymbol, 1);
	}

	void OnRtnDepthMarketData(ICEDepthMarketDataField *pDepthMarketData)
	{
		if(pDepthMarketData)
			cout << "OnRtnDepthMarketData() InstrumentID:" << pDepthMarketData->InstrumentID << ",BidPrice1:" << pDepthMarketData->BidPrice1 << endl;
	}

	void OnRtnGreeksData(ICEGreeksDataField *pGreeksData)
	{
		if(pGreeksData)
		{
			cout << "OnRtnGreeksData() InstrumentID:" << pGreeksData->InstrumentID << ",ImpVol:" << pGreeksData->ImpVol << endl;
			cout << "OnRtnGreeksData() InstrumentID:" << pGreeksData->InstrumentID << ",TradingDay:" << pGreeksData->TradingDay  << ",UpdateTime:" << pGreeksData->UpdateTime << endl;
		}
	}
};

int _tmain(int argc, _TCHAR* argv[])
{
	QuoteAPI test;

	test.Go();
	return 0;
}

