本文整理汇总了C++中O2G2Ptr::getUpdateType方法的典型用法代码示例。如果您正苦于以下问题:C++ O2G2Ptr::getUpdateType方法的具体用法?C++ O2G2Ptr::getUpdateType怎么用?C++ O2G2Ptr::getUpdateType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类O2G2Ptr
的用法示例。
在下文中一共展示了O2G2Ptr::getUpdateType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onTablesUpdates
/** Request update data received data handler. */
void ResponseListener::onTablesUpdates(IO2GResponse *data)
{
if (data)
{
O2G2Ptr<IO2GResponseReaderFactory> factory = mSession->getResponseReaderFactory();
if (factory)
{
O2G2Ptr<IO2GTablesUpdatesReader> reader = factory->createTablesUpdatesReader(data);
if (reader)
{
for (int i = 0; i < reader->size(); ++i)
{
if (reader->getUpdateTable(i) == Orders)
{
O2G2Ptr<IO2GOrderRow> order = reader->getOrderRow(i);
if (reader->getUpdateType(i) == Insert)
{
if (mRequestID == order->getRequestID())
{
std::cout << "The order has been added. OrderID='" << order->getOrderID() << "', "
<< "Type='" << order->getType() << "', "
<< "BuySell='" << order->getBuySell() << "', "
<< "Rate='" << order->getRate() << "', "
<< "TimeInForce='" << order->getTimeInForce() << "'"
<< std::endl;
SetEvent(mResponseEvent);
}
}
}
}
}
}
}
}
示例2: onTablesUpdates
/** Request update data received data handler. */
void ResponseListener::onTablesUpdates(IO2GResponse *data)
{
if (data)
{
O2G2Ptr<IO2GResponseReaderFactory> factory = mSession->getResponseReaderFactory();
if (factory)
{
O2G2Ptr<IO2GTablesUpdatesReader> reader = factory->createTablesUpdatesReader(data);
if (reader)
{
for (int i = 0; i < reader->size(); ++i)
{
switch (reader->getUpdateTable(i))
{
case Orders:
{
O2G2Ptr<IO2GOrderRow> order = reader->getOrderRow(i);
if (mRequestID != order->getRequestID())
break;
switch (reader->getUpdateType(i))
{
case Insert:
if ((isClosingOrder(order) || isOpeningOrder(order)) &&
mOrderMonitorNetting == NULL)
{
std::cout << "The order has been added. OrderID='" << order->getOrderID() << "', "
<< "Rate='" << order->getRate() << "', "
<< "TimeInForce='" << order->getTimeInForce() << "'"
<< std::endl;
O2G2Ptr<IO2GTradeRow> trade = NULL;
std::string sTradeID = std::string(order->getTradeID());
if (mTradesTable)
{
for (int j = 0; j < mTradesTable->size(); ++j)
{
if (sTradeID == mTradesTable->getRow(j)->getTradeID())
{
trade = mTradesTable->getRow(j);
break;
}
}
}
if (trade)
mOrderMonitorNetting = new OrderMonitorNetting(order, trade->getAmount());
else
mOrderMonitorNetting = new OrderMonitorNetting(order, 0);
}
break;
case Delete:
if (mOrderMonitorNetting)
{
std::cout << "The order has been deleted. OrderID='" << order->getOrderID() << "'"
<< std::endl;
mOrderMonitorNetting->onOrderDeleted(order);
if (mOrderMonitorNetting->isOrderCompleted())
{
printResult();
SetEvent(mResponseEvent);
}
}
break;
}
}
break;
case Trades:
{
O2G2Ptr<IO2GTradeRow> trade = reader->getTradeRow(i);
switch (reader->getUpdateType(i))
{
case Insert:
{
if (mOrderMonitorNetting)
{
mOrderMonitorNetting->onTradeAdded(trade);
if (mOrderMonitorNetting->isOrderCompleted())
{
printResult();
SetEvent(mResponseEvent);
}
}
}
break;
case Update:
{
if (mOrderMonitorNetting)
{
mOrderMonitorNetting->onTradeUpdated(trade);
if (mOrderMonitorNetting->isOrderCompleted())
{
printResult();
SetEvent(mResponseEvent);
}
}
}
break;
}
}
break;
case ClosedTrades:
//.........这里部分代码省略.........
示例3: main
int main(int argc, char *argv[])
{
std::string procName = "GetLastOrderUpdate";
if (argc == 1)
{
printHelp(procName);
return -1;
}
bool bWasError = false;
LoginParams *loginParams = new LoginParams(argc, argv);
SampleParams *sampleParams = new SampleParams(argc, argv);
printSampleParams(procName, loginParams, sampleParams);
if (!checkObligatoryParams(loginParams, sampleParams))
{
delete loginParams;
delete sampleParams;
return -1;
}
IO2GSession *session = CO2GTransport::createSession();
SessionStatusListener *sessionListener = new SessionStatusListener(session, true,
loginParams->getSessionID(),
loginParams->getPin());
session->subscribeSessionStatus(sessionListener);
bool bConnected = login(session, sessionListener, loginParams);
if (bConnected)
{
bool bIsAccountEmpty = !sampleParams->getAccount() || strlen(sampleParams->getAccount()) == 0;
O2G2Ptr<IO2GAccountRow> account = getAccount(session, sampleParams->getAccount());
ResponseListener *responseListener = new ResponseListener(session);
session->subscribeResponse(responseListener);
if (account)
{
if (bIsAccountEmpty)
{
sampleParams->setAccount(account->getAccountID());
std::cout << "Account: " << sampleParams->getAccount() << std::endl;
}
O2G2Ptr<IO2GOfferRow> offer = getOffer(session, sampleParams->getInstrument());
if (offer)
{
O2G2Ptr<IO2GLoginRules> loginRules = session->getLoginRules();
if (loginRules)
{
O2G2Ptr<IO2GTradingSettingsProvider> tradingSettingsProvider = loginRules->getTradingSettingsProvider();
int iBaseUnitSize = tradingSettingsProvider->getBaseUnitSize(sampleParams->getInstrument(), account);
int iAmount = iBaseUnitSize * sampleParams->getLots();
O2G2Ptr<IO2GRequest> request = createTrueMarketOrderRequest(session, offer->getOfferID(), account->getAccountID(), iAmount, sampleParams->getBuySell());
if (request)
{
responseListener->setRequestID(request->getRequestID());
session->sendRequest(request);
if (responseListener->waitEvents())
{
std::string sOrderID = responseListener->getOrderID();
if (!sOrderID.empty())
{
O2G2Ptr<IO2GRequest> updateRequest = getLastOrderUpdateRequest(session, sOrderID.c_str(), account->getAccountName());
if (updateRequest)
{
responseListener->setRequestID(updateRequest->getRequestID());
session->sendRequest(updateRequest);
if (responseListener->waitEvents())
{
O2G2Ptr<IO2GResponse> response = responseListener->getResponse();
if (response && response->getType() == GetLastOrderUpdate)
{
O2G2Ptr<IO2GResponseReaderFactory> readerFactory = session->getResponseReaderFactory();
if (readerFactory)
{
O2G2Ptr<IO2GLastOrderUpdateResponseReader> reader = readerFactory->createLastOrderUpdateResponseReader(response);
char sTime[20];
formatDate(reader->getOrder()->getStatusTime(), sTime);
std::cout << "Last order update: UpdateType='" << reader->getUpdateType() << "', "
<< "OrderID='" << reader->getOrder()->getOrderID() << "', "
<< "Status='" << reader->getOrder()->getStatus() << "', "
<< "StatusTime='" << sTime << "'"
<< std::endl;
}
}
std::cout << "Done!" << std::endl;
}
else
{
std::cout << "Response waiting timeout expired" << std::endl;
bWasError = true;
}
}
else
{
std::cout << "Cannot create request" << std::endl;
bWasError = true;
}
}
//.........这里部分代码省略.........
示例4: onTablesUpdates
/** Request update data received data handler. */
void ResponseListener::onTablesUpdates(IO2GResponse *data)
{
if (data)
{
O2G2Ptr<IO2GResponseReaderFactory> factory = mSession->getResponseReaderFactory();
if (factory)
{
O2G2Ptr<IO2GTablesUpdatesReader> reader = factory->createTablesUpdatesReader(data);
if (reader)
{
for (int i = 0; i < reader->size(); ++i)
{
switch (reader->getUpdateTable(i))
{
case Orders:
{
O2G2Ptr<IO2GOrderRow> order = reader->getOrderRow(i);
if (reader->getUpdateType(i) == Insert)
{
if (mBatchOrderMonitor)
{
std::cout << "The order has been added. OrderID='" << order->getOrderID() << "', "
<< "Rate='" << order->getRate() << "', "
<< "TimeInForce='" << order->getTimeInForce() << "'"
<< std::endl;
mBatchOrderMonitor->onOrderAdded(order);
}
}
else if (reader->getUpdateType(i) == Delete)
{
if (mBatchOrderMonitor)
{
std::cout << "The order has been deleted. OrderID='" << order->getOrderID() << "'"
<< std::endl;
mBatchOrderMonitor->onOrderDeleted(order);
if (mBatchOrderMonitor->isBatchExecuted())
{
printResult();
SetEvent(mResponseEvent);
}
}
}
}
break;
case Trades:
{
if (reader->getUpdateType(i) == Insert)
{
O2G2Ptr<IO2GTradeRow> trade = reader->getTradeRow(i);
if (mBatchOrderMonitor)
{
mBatchOrderMonitor->onTradeAdded(trade);
if (mBatchOrderMonitor->isBatchExecuted())
{
printResult();
SetEvent(mResponseEvent);
}
}
}
}
break;
case ClosedTrades:
{
if (reader->getUpdateType(i) == Insert)
{
O2G2Ptr<IO2GClosedTradeRow> closedTrade = reader->getClosedTradeRow(i);
if (mBatchOrderMonitor)
{
mBatchOrderMonitor->onClosedTradeAdded(closedTrade);
if (mBatchOrderMonitor->isBatchExecuted())
{
printResult();
SetEvent(mResponseEvent);
}
}
}
}
break;
case Messages:
{
if (reader->getUpdateType(i) == Insert)
{
O2G2Ptr<IO2GMessageRow> message = reader->getMessageRow(i);
if (mBatchOrderMonitor)
{
mBatchOrderMonitor->onMessageAdded(message);
if (mBatchOrderMonitor->isBatchExecuted())
{
printResult();
SetEvent(mResponseEvent);
}
}
}
}
break;
case Accounts:
{
if (reader->getUpdateType(i) == Update && reader->getUpdateTable(i) == Accounts)
{
//.........这里部分代码省略.........