#include #include //#define __WORDSIZE 64; #include #include #include #define __LINUX 1 #ifdef __CINT__ class pthread_cond_t; class pthread_mutex_t; #endif #include #ifdef __MAKECINT__ #pragma link off class _FTCOMSTAT-; #pragma link off class _FTDCB-; #endif #include "TObject.h" class MyClient : public OTClient,public TObject { int i,i1; public: int id; int id1; int id2; MyClient () { i = i1 = 0; } virtual ~MyClient () { } virtual void onLogin () { printf ("login ok\n"); requestListExchanges (); // id = requestTickStream (&OTDataEntity ("N", "IBM")); // id1 = requestTickStream (&OTDataEntity ("N", "GE")); struct tm begDate = { 0, 0, 9, 15, 11, 104 }; struct tm endDate = { 0, 1, 9, 15, 11, 104 }; id=requestHistData (&OTDataEntity ("Q", "MSFT"), mktime(&begDate), mktime(&endDate), OT_HIST_RAW_TICKS, 1); } virtual void onError (OTError * error) { printf ("-----> Error id=%d, code=%d, error=%s\n", error->getRequestId(), error->getCode(), error->getDescription()); } virtual void onListExchanges (OTExchange * listExchange, int exchangeNum) { bool first = false; for (int i = 0; i < exchangeNum; i++) { printf("exchange num = %d ==============================>\n", i+1); if( !first ) { printf("requestID = %d\n", listExchange[i].getRequestId()); printf("URL = %s\n",listExchange[i].getSubscriptionURL()); first = true; } printf(" available = %d\n",listExchange[i].getAvailable()); printf(" exchange code = %s\n",listExchange[i].getCode()); printf(" exchange title = %s\n",listExchange[i].getTitle()); printf(" exchange desc = %s\n",listExchange[i].getDescription()); } } virtual void onTodaysOHL (int requestId, double openPrice, double highPrice, double lowPrice) { printf ("reqId = %d, openPrice =%f, highPrice = %f, lowPrice = %f\n", requestId, openPrice, highPrice, lowPrice); } virtual void onMessage (OTMessage *message) { printf ("msgCode=%d msg=%s\n", message->getCode(),message->getDescription()); } virtual void onRealtimeQuote (OTQuote *quote) { printf ("RealTimeQuote: id = %d, timestamp = %d , askPrice = %f, bidPrice = %f, askSize = %d, bidSize = %d, \ askExchange = %s , indicator = %c, tickIndicator = %c \n", quote->getRequestId(), quote->getTimestamp(), quote->getAskPrice(), quote->getBidPrice(), quote->getAskSize(), quote->getBidSize(), quote->getAskExchange(), quote->getIndicator(), quote->getTickIndicator() ); if (quote->getSymbol()) { printf ("symbol= %s\n", quote->getSymbol()); } } virtual void onRealtimeMMQuote (OTMMQuote * mmQuote) { printf ("RealTimeMMQuote: id = %d, timestamp = %d, askPrice = %f, bidPrice = %f, askSize = %d, bidSize = %d, \ mmid = %s, indicator = %c \n", mmQuote->getRequestId(), mmQuote->getTimestamp(), mmQuote->getAskPrice(), mmQuote->getBidPrice(), mmQuote->getAskSize(), mmQuote->getBidSize(), mmQuote->getMMID(), mmQuote->getIndicator() ); if (mmQuote->getSymbol()) { printf ("symbol= %s\n", mmQuote->getSymbol()); } } virtual void onRealtimeTrade (OTTrade *trade) { printf ("RealTimeTrade: id = %d, timestamp = %d, price = %f, size = %d, volume = %lld ", trade->getRequestId(), trade->getTimestamp(), trade->getPrice(), trade->getSize(), trade->getVolume() ); /* printf ("sequenceNumber = %d, indicator = %c, tickIndicator = %c, isOpen = %d, isHigh = %d, isLow = %d, isClose = %d, isUpdateLast = %d \ isUpdateVolume = %d, isCancel = %d, isFromBook = %d \n", trade->getSequenceNumber(), trade->getIndicator(), trade->getTickIndicator(), trade->isOpen(), trade->isHigh(), trade->isLow(), trade->isClose(), trade->isUpdateLast(), trade->isUpdateVolume(), trade->isCancel(), trade->isFromBook() );*/ if (trade->getSymbol()) { printf ("symbol= %s\n", trade->getSymbol()); } } virtual void onHistQuote (OTQuote *quote) { printf ("HistQuote: id = %d, timestamp = %d , askPrice = %f, bidPrice = %f, askSize = %d, bidSize = %d, \ askExchange = %s , indicator = %c, tickIndicator = %c \n", quote->getRequestId(), quote->getTimestamp(), quote->getAskPrice(), quote->getBidPrice(), quote->getAskSize(), quote->getBidSize(), quote->getAskExchange(), quote->getIndicator(), quote->getTickIndicator() ); } virtual void onHistMMQuote (OTMMQuote *mmQuote) { printf ("HistMMQuote: id = %d, timestamp = %d, askPrice = %f, bidPrice = %f, askSize = %d, bidSize = %d, \ mmid = %4s, indicator = %c \n", mmQuote->getRequestId(), mmQuote->getTimestamp(), mmQuote->getAskPrice(), mmQuote->getBidPrice(), mmQuote->getAskSize(), mmQuote->getBidSize(), mmQuote->getMMID(), mmQuote->getIndicator() ); } virtual void onHistTrade (OTTrade *trade) { printf ("HistTrade: id = %d, timestamp = %d, price = %f, size = %d, volume = %lld ", trade->getRequestId(), trade->getTimestamp(), trade->getPrice(), trade->getSize(), trade->getVolume() ); printf ("sequenceNumber = %d, indicator = %c, tickIndicator = %c, isOpen = %d, isHigh = %d, isLow = %d, isClose = %d, isUpdateLast = %d \ isUpdateVolume = %d, isCancel = %d, isFromBook = %d \n", trade->getSequenceNumber(), trade->getIndicator(), trade->getTickIndicator(), trade->isOpen(), trade->isHigh(), trade->isLow(), trade->isClose(), trade->isUpdateLast(), trade->isUpdateVolume(), trade->isCancel(), trade->isFromBook() ); } virtual void onHistOHLC (OTOHLC *data) { printf ("OHLC id=%-2d timestamp = %d O=$%.2f H=$%.2f L=$%.2f C=$%.2f volume=%lld\n",data->getRequestId(), data->getTimestamp(),data->getOpenPrice(), data->getHighPrice(), data->getLowPrice(), data->getClosePrice(), data->getVolume()); } virtual void onRestoreConnection () { printf ("onRestoreConnection\n"); } virtual void onStatusChanged (int status) { printf("onStatusChanged - new status %d \n", status); } virtual void onEquityInit (OTEquityInit *equityInit) { printf ("onEquityInit = \n"); printf ("reqId = %d, instumentType = %d, currency = %s, companyName =%s, cusip = %s, isin = %s, ", equityInit->getRequestId(), equityInit->getInstrumentType(), equityInit->getCurrency(), equityInit->getCompanyName(), equityInit->getCUSIP(), equityInit->getISIN()); printf ("prevCloseDate =%s, prevClosePrice =%f, annualHighDate =%s, annualHighPrice =%f,", equityInit->getPrevCloseDate(), equityInit->getPrevClosePrice(), equityInit->getAnnualHighDate(), equityInit->getAnnualHighPrice()); printf ("annualLowDate =%s, annualLowPrice =%f, earningsDate =%s, earningsPrice =%f,", equityInit->getAnnualLowDate(), equityInit->getAnnualLowPrice(), equityInit->getEarningsDate(), equityInit->getEarningsPrice()); printf ("totalShares =%lld, averageVolume =%lld, isUPC11830 =%d, isSmallCap =%d, isTestlssue =%d\n", equityInit->getTotalShares(), equityInit->getAverageVolume(), equityInit->isUPC11830(), equityInit->isSmallCap(), equityInit->isTestlssue()); } virtual void onBookCancel (OTBookCancel *bookCancel) { printf ("onBookCancel\n"); printf ("Id =%2d, timestamp = %d, orderRef = %s, size =%d\n", bookCancel->getRequestId(), bookCancel->getTimestamp(), bookCancel->getOrderRef(), bookCancel->getSize()); } virtual void onBookChange (OTBookChange *bookChange) { printf ("onBookChange\n"); printf ("Id =%2d, timestamp = %d, orderRef = %s, size =%d price =%f \n", bookChange->getRequestId(), bookChange->getTimestamp(), bookChange->getOrderRef(), bookChange->getSize(), bookChange->getPrice()); } virtual void onBookDelete (OTBookDelete *bookDelete) { printf ("onBookDelete\n"); printf ("Id =%2d, timestamp = %d, orderRef = %s, sideIndicator =%c deleteType =%c \n", bookDelete->getRequestId(), bookDelete->getTimestamp(), bookDelete->getOrderRef(), bookDelete->getSide(), bookDelete->getDeleteType()); } virtual void onBookExecute (OTBookExecute *bookExecute) { printf ("onBookExecute\n"); printf ("Id =%2d, timestamp = %d, orderRef = %s, size =%d matchNumber =%d \n", bookExecute->getRequestId(), bookExecute->getTimestamp(), bookExecute->getOrderRef(), bookExecute->getSize(), bookExecute->getMatchNumber()); } virtual void onBookOrder (OTBookOrder *bookOrder) { printf ("onBookOrder\n"); printf ("Id =%2d, timestamp = %d, orderRef = %s, size =%d sideIndicator =%c, display = %d, price = %f \n", bookOrder->getRequestId(), bookOrder->getTimestamp(), bookOrder->getOrderRef(), bookOrder->getSize(), bookOrder->getSide(), bookOrder->getDisplay(), bookOrder->getPrice()); } virtual void onBookPriceLevel (OTBookPriceLevel *bookPriceLevel) { printf ("onBookPriceLevel\n"); printf ("Id =%2d, timestamp = %d, size =%d sideIndicator =%c, levelId = %s, price = %f \n", bookPriceLevel->getRequestId(), bookPriceLevel->getTimestamp(), bookPriceLevel->getSize(), bookPriceLevel->getSide(), bookPriceLevel->getLevelId(), bookPriceLevel->getPrice()); } virtual void onBookPurge (OTBookPurge *bookPurge) { printf ("onBookPurge\n"); printf ("Id =%2d, timestamp = %d, exchangeNameBase = %s\n", bookPurge->getRequestId(), bookPurge->getTimestamp(), bookPurge->getExchangeNameRoot()); } virtual void onBookReplace (OTBookReplace *bookReplace) { printf ("onBookReplace\n"); printf ("Id =%2d, timestamp = %d, orderRef = %s, size =%d, sideIndicator =%c, price = %f \n", bookReplace->getRequestId(), bookReplace->getTimestamp(), bookReplace->getOrderRef(), bookReplace->getSize(), bookReplace->getSide(), bookReplace->getPrice()); } virtual void onRealtimeBBO (OTBBO *bbo) { printf ("onRealtimeBBO\n"); printf ("Id =%2d, timestamp = %d, size =%d, side =%c, price = %f symbol =%s \n", bbo->getRequestId(), bbo->getTimestamp(), bbo->getSize(), bbo->getSide(), bbo->getPrice(), bbo->getSymbol()); } };