本文整理汇总了C++中O2G2Ptr::getRow方法的典型用法代码示例。如果您正苦于以下问题:C++ O2G2Ptr::getRow方法的具体用法?C++ O2G2Ptr::getRow怎么用?C++ O2G2Ptr::getRow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类O2G2Ptr
的用法示例。
在下文中一共展示了O2G2Ptr::getRow方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getCloseOrdersData
bool getCloseOrdersData(IO2GSession *session, ResponseListener *responseListener, const char *sAccountID, const char *sOfferID, CloseOrderData &closeOrdersData)
{
O2G2Ptr<IO2GRequestFactory> requestFactory = session->getRequestFactory();
if (!requestFactory)
{
std::cout << "Cannot create request factory" << std::endl;
return false;
}
O2G2Ptr<IO2GRequest> request = requestFactory->createRefreshTableRequestByAccount(Trades, sAccountID);
if (!request)
{
std::cout << requestFactory->getLastError() << std::endl;
return false;
}
responseListener->setRequestID(request->getRequestID());
session->sendRequest(request);
if (!responseListener->waitEvents())
{
std::cout << "Response waiting timeout expired" << std::endl;
return false;
}
O2G2Ptr<IO2GResponse> response = responseListener->getResponse();
bool bIsTradesFound = false;
if (response)
{
O2G2Ptr<IO2GResponseReaderFactory> readerFactory = session->getResponseReaderFactory();
O2G2Ptr<IO2GTradesTableResponseReader> responseReader = readerFactory->createTradesTableReader(response);
for (int i = 0; i < responseReader->size(); ++i)
{
O2G2Ptr<IO2GTradeRow> trade = responseReader->getRow(i);
if (strcmp(sOfferID, trade->getOfferID()) != 0)
continue;
bIsTradesFound = true;
std::string sBuySell = trade->getBuySell();
// Set opposite side
OrderSide side = (sBuySell == O2G2::Buy) ? Sell : Buy;
if (closeOrdersData.offerID != sOfferID)
{
closeOrdersData.offerID = sOfferID;
closeOrdersData.account = sAccountID;
closeOrdersData.side = side;
}
else
{
OrderSide currentSide = closeOrdersData.side;
if (currentSide != Both && currentSide != side)
closeOrdersData.side = Both;
}
}
}
return bIsTradesFound;
}
示例2: strcmp
// Find the first opened position by AccountID and OfferID
IO2GTradeRow *getTrade(IO2GTableManager *tableManager, const char *sAccountID, const char *sOfferID)
{
O2G2Ptr<IO2GTradesTable> tradesTable = (IO2GTradesTable *)tableManager->getTable(Trades);
for (int i = 0; i < tradesTable->size(); ++i)
{
O2G2Ptr<IO2GTradeRow> trade = tradesTable->getRow(i);
if (strcmp(sAccountID, trade->getAccountID()) == 0 &&
strcmp(sOfferID, trade->getOfferID()) == 0)
return trade.Detach();
}
return NULL;
}
示例3: if
IO2GOfferRow *getOfferAndPrint(IO2GSession *session, const char *sInstrument)
{
if (!session || !sInstrument)
return NULL;
IO2GOfferRow *resultOffer = NULL;
O2G2Ptr<IO2GLoginRules> loginRules = session->getLoginRules();
if (loginRules)
{
O2G2Ptr<IO2GResponse> response = loginRules->getTableRefreshResponse(Offers);
if (response)
{
O2G2Ptr<IO2GResponseReaderFactory> readerFactory = session->getResponseReaderFactory();
if (readerFactory)
{
O2G2Ptr<IO2GOffersTableResponseReader> reader = readerFactory->createOffersTableReader(response);
for (int i = 0; i < reader->size(); ++i)
{
O2G2Ptr<IO2GOfferRow> offer = reader->getRow(i);
if (offer)
{
if (strcmp(offer->getSubscriptionStatus(), O2G2::SubscriptionStatuses::ViewOnly) == 0)
printf("%s : [V]iew only\n", offer->getInstrument());
else if (strcmp(offer->getSubscriptionStatus(), O2G2::SubscriptionStatuses::Disable) == 0)
printf("%s : [D]isabled\n", offer->getInstrument());
else if (strcmp(offer->getSubscriptionStatus(), O2G2::SubscriptionStatuses::Tradable) == 0)
printf("%s : Available for [T]rade\n", offer->getInstrument());
else
printf("%s : %s\n", offer->getInstrument(), offer->getSubscriptionStatus());
if (strcmp(offer->getInstrument(), sInstrument) == 0)
resultOffer = offer.Detach();
}
}
}
}
}
return resultOffer;
}
示例4: isOrderExists
bool isOrderExists(IO2GSession *session, const char *sAccountID, const char *sOrderID, ResponseListener *responseListener)
{
if (!session || !responseListener || !sAccountID)
return false;
O2G2Ptr<IO2GRequestFactory> requestFactory = session->getRequestFactory();
if (!requestFactory)
{
std::cout << "Cannot create request factory" << std::endl;
return false;
}
O2G2Ptr<IO2GRequest> request = requestFactory->createRefreshTableRequestByAccount(Orders, sAccountID);
responseListener->setRequestID(request->getRequestID());
session->sendRequest(request);
if (!responseListener->waitEvents())
{
std::cout << "Response waiting timeout expired" << std::endl;
return false;
}
O2G2Ptr<IO2GResponse> response = responseListener->getResponse();
if (response)
{
O2G2Ptr<IO2GResponseReaderFactory> readerFactory = session->getResponseReaderFactory();
if (readerFactory)
{
O2G2Ptr<IO2GOrdersTableResponseReader> ordersResponseReader = readerFactory->createOrdersTableReader(response);
for (int i = 0; i < ordersResponseReader->size(); ++i)
{
O2G2Ptr<IO2GOrderRow> order = ordersResponseReader->getRow(i);
if (sOrderID && strcmp(order->getOrderID(), sOrderID) == 0)
return true;
}
}
}
return false;
}
示例5: init
void ForexConnectClient::init()
{
mpSession = CO2GTransport::createSession();
mpListener = new SessionStatusListener(mpSession, false);
mpSession->subscribeSessionStatus(mpListener);
mpSession->useTableManager(Yes, 0);
if (!login())
{
throw std::runtime_error("Login fail.");
}
mpLoginRules = mpSession->getLoginRules();
if (!mpLoginRules->isTableLoadedByDefault(Accounts))
{
logout();
throw std::runtime_error("Accounts table not loaded");
}
O2G2Ptr<IO2GResponse> response = mpLoginRules->getTableRefreshResponse(Accounts);
if(!response)
{
logout();
throw std::runtime_error("No response to refresh accounts table request");
}
mpResponseReaderFactory = mpSession->getResponseReaderFactory();
O2G2Ptr<IO2GAccountsTableResponseReader> accountsResponseReader = mpResponseReaderFactory->createAccountsTableReader(response);
mpAccountRow = accountsResponseReader->getRow(0);
mAccountID = mpAccountRow->getAccountID();
mpResponseListener = new ResponseListener(mpSession);
mpSession->subscribeResponse(mpResponseListener);
mpRequestFactory = mpSession->getRequestFactory();
}
示例6: printTradingSettings
// Print trading settings of the first account
bool printTradingSettings(IO2GSession *session)
{
O2G2Ptr<IO2GLoginRules> loginRules = session->getLoginRules();
if (!loginRules)
{
std::cout << "Cannot get login rules" << std::endl;
return false;
}
O2G2Ptr<IO2GResponse> accountsResponse = loginRules->getTableRefreshResponse(Accounts);
if (!accountsResponse)
{
std::cout << "Cannot get response" << std::endl;
return false;
}
O2G2Ptr<IO2GResponse> offersResponse = loginRules->getTableRefreshResponse(Offers);
if (!offersResponse)
{
std::cout << "Cannot get response" << std::endl;
return false;
}
O2G2Ptr<IO2GTradingSettingsProvider> tradingSettingsProvider = loginRules->getTradingSettingsProvider();
O2G2Ptr<IO2GResponseReaderFactory> factory = session->getResponseReaderFactory();
if (!factory)
{
std::cout << "Cannot create response reader factory" << std::endl;
return false;
}
O2G2Ptr<IO2GAccountsTableResponseReader> accountsReader = factory->createAccountsTableReader(accountsResponse);
O2G2Ptr<IO2GOffersTableResponseReader> instrumentsReader = factory->createOffersTableReader(offersResponse);
O2G2Ptr<IO2GAccountRow> account = accountsReader->getRow(0);
for (int i = 0; i < instrumentsReader->size(); ++i)
{
O2G2Ptr<IO2GOfferRow> instrumentRow = instrumentsReader->getRow(i);
const char *sInstrument = instrumentRow->getInstrument();
int condDistStopForTrade = tradingSettingsProvider->getCondDistStopForTrade(sInstrument);
int condDistLimitForTrade = tradingSettingsProvider->getCondDistLimitForTrade(sInstrument);
int condDistEntryStop = tradingSettingsProvider->getCondDistEntryStop(sInstrument);
int condDistEntryLimit = tradingSettingsProvider->getCondDistEntryLimit(sInstrument);
int minQuantity = tradingSettingsProvider->getMinQuantity(sInstrument, account);
int maxQuantity = tradingSettingsProvider->getMaxQuantity(sInstrument, account);
int baseUnitSize = tradingSettingsProvider->getBaseUnitSize(sInstrument, account);
O2GMarketStatus marketStatus = tradingSettingsProvider->getMarketStatus(sInstrument);
int minTrailingStep = tradingSettingsProvider->getMinTrailingStep();
int maxTrailingStep = tradingSettingsProvider->getMaxTrailingStep();
double mmr = tradingSettingsProvider->getMMR(sInstrument, account);
std::string sMarketStatus = "unknown";
switch (marketStatus)
{
case MarketStatusOpen:
sMarketStatus = "Market Open";
break;
case MarketStatusClosed:
sMarketStatus = "Market Close";
break;
}
std::cout << "Instrument: " << sInstrument << ", Status: " << sMarketStatus << std::endl;
std::cout << "Cond.Dist: ST=" << condDistStopForTrade << "; LT=" << condDistLimitForTrade << std::endl;
std::cout << "Cond.Dist entry stop=" << condDistEntryStop << "; entry limit=" << condDistEntryLimit << std::endl;
std::cout << "Quantity: Min=" << minQuantity << "; Max=" << maxQuantity
<< "; Base unit size=" << baseUnitSize << "; MMR=" << mmr << std::endl;
double mmr2=0, emr=0, lmr=0;
if (tradingSettingsProvider->getMargins(sInstrument, account, mmr2, emr, lmr))
{
std::cout << "Three level margin: MMR=" << mmr2 << "; EMR=" << emr
<< "; LMR=" << lmr << std::endl;
}
else
{
std::cout << "Single level margin: MMR=" << mmr2 << "; EMR=" << emr
<< "; LMR=" << lmr << std::endl;
}
std::cout << "Trailing step: " << minTrailingStep << "-" << maxTrailingStep << std::endl;
}
return true;
}