当前位置: 首页>>代码示例>>C++>>正文


C++ O2G2Ptr::getStatus方法代码示例

本文整理汇总了C++中O2G2Ptr::getStatus方法的典型用法代码示例。如果您正苦于以下问题:C++ O2G2Ptr::getStatus方法的具体用法?C++ O2G2Ptr::getStatus怎么用?C++ O2G2Ptr::getStatus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在O2G2Ptr的用法示例。


在下文中一共展示了O2G2Ptr::getStatus方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char *argv[])
{
    std::string procName = "CreateEntry";
    if (argc == 1)
    {
        printHelp(procName);
        return -1;
    }

    LoginParams *loginParams = new LoginParams(argc, argv);
    SampleParams *sampleParams = new SampleParams(argc, argv);

    printSampleParams(procName, loginParams, sampleParams);
    if (!checkObligatoryParams(loginParams, sampleParams))
        return -1;

    IO2GSession *session = CO2GTransport::createSession();
    session->useTableManager(Yes, 0);

    SessionStatusListener *sessionListener = new SessionStatusListener(session, false,
                                                                       loginParams->getSessionID(),
                                                                       loginParams->getPin());
    session->subscribeSessionStatus(sessionListener);

    bool bConnected = login(session, sessionListener, loginParams);
    bool bWasError = false;

    if (bConnected)
    {
        bool bIsAccountEmpty = !sampleParams->getAccount() || strlen(sampleParams->getAccount()) == 0;
        ResponseListener *responseListener = new ResponseListener();
        TableListener *tableListener = new TableListener(responseListener);
        session->subscribeResponse(responseListener);

        O2G2Ptr<IO2GTableManager> tableManager = session->getTableManager();
        O2GTableManagerStatus managerStatus = tableManager->getStatus();
        while (managerStatus == TablesLoading)
        {
            Sleep(50);
            managerStatus = tableManager->getStatus();
        }

        if (managerStatus == TablesLoadFailed)
        {
            std::cout << "Cannot refresh all tables of table manager" << std::endl;
        }

        O2G2Ptr<IO2GAccountRow> account = getAccount(tableManager, sampleParams->getAccount());

        if (account)
        {
            if (bIsAccountEmpty)
            {
                sampleParams->setAccount(account->getAccountID());
                std::cout << "Account: " << sampleParams->getAccount() << std::endl;
            }
            O2G2Ptr<IO2GOfferRow> offer = getOffer(tableManager, 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();
                    int iCondDistEntryLimit = tradingSettingsProvider->getCondDistEntryLimit(sampleParams->getInstrument());
                    int iCondDistEntryStop = tradingSettingsProvider->getCondDistEntryStop(sampleParams->getInstrument());

                    std::string sOrderType = getEntryOrderType(offer->getBid(), offer->getAsk(), sampleParams->getRate(),
                            sampleParams->getBuySell(), offer->getPointSize(), iCondDistEntryLimit, iCondDistEntryStop);

                    O2G2Ptr<IO2GRequest> request = createEntryOrderRequest(session, offer->getOfferID(), account->getAccountID(), iAmount,
                        sampleParams->getRate(), sampleParams->getBuySell(), sOrderType.c_str(), sampleParams->getExpDate());
                    if (request)
                    {
                        tableListener->subscribeEvents(tableManager);

                        responseListener->setRequestID(request->getRequestID());
                        tableListener->setRequestID(request->getRequestID());
                        session->sendRequest(request);
                        if (responseListener->waitEvents())
                        {
                            std::cout << "Done!" << std::endl;
                        }
                        else
                        {
                            std::cout << "Response waiting timeout expired" << std::endl;
                            bWasError = true;
                        }

                        tableListener->unsubscribeEvents(tableManager);
                        tableListener->release();
                    }
                    else
                    {
                        std::cout << "Cannot create request" << std::endl;
                        bWasError = true;
                    }
                }
                else
//.........这里部分代码省略.........
开发者ID:mmarti3600,项目名称:FXCM-ForexConnect-win32-cpp,代码行数:101,代码来源:main.cpp

示例2: main

int main(int argc, char *argv[])
{
    std::string procName = "PrintTable";
    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))
        return -1;

    IO2GSession *session = CO2GTransport::createSession();
    session->useTableManager(Yes, 0);

    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<IO2GTableManager> tableManager = session->getTableManager();
        O2GTableManagerStatus managerStatus = tableManager->getStatus();
        while (managerStatus == TablesLoading)
        {
            Sleep(50);
            managerStatus = tableManager->getStatus();
        }

        if (managerStatus == TablesLoadFailed)
        {
            std::cout << "Cannot refresh all tables of table manager" << std::endl;
        }

        O2G2Ptr<IO2GAccountRow> account = getAccount(tableManager, sampleParams->getAccount());
        if (account)
        {
            if (bIsAccountEmpty)
            {
                sampleParams->setAccount(account->getAccountID());
                std::cout << "Account: " << sampleParams->getAccount() << std::endl;
            }
        }
        else
        {
            std::cout << "No valid accounts" << std::endl;
            bWasError = true;
        }

        printOrders(tableManager, sampleParams->getAccount());
        std::cout << "Done!" << std::endl;

        logout(session, sessionListener);
    }
    else
    {
        bWasError = true;
    }

    session->unsubscribeSessionStatus(sessionListener);
    sessionListener->release();
    session->release();

    if (bWasError)
        return -1;
    return 0;
}
开发者ID:BryanFletcher,项目名称:FXCM,代码行数:78,代码来源:main.cpp

示例3: main

int main(int argc, char *argv[])
{
    std::string procName = "CreateOTO";
    if (argc == 1)
    {
        printHelp(procName);
        return -1;
    }

    LoginParams *loginParams = new LoginParams(argc, argv);
    SampleParams *sampleParams = new SampleParams(argc, argv);

    printSampleParams(procName, loginParams, sampleParams);
    if (!checkObligatoryParams(loginParams, sampleParams))
        return -1;

    IO2GSession *session = CO2GTransport::createSession();
    session->useTableManager(Yes, 0);

    SessionStatusListener *sessionListener = new SessionStatusListener(session, false,
                                                                       loginParams->getSessionID(),
                                                                       loginParams->getPin());
    session->subscribeSessionStatus(sessionListener);

    bool bConnected = login(session, sessionListener, loginParams);
    bool bWasError = false;

    if (bConnected)
    {
        bool bIsAccountEmpty = !sampleParams->getAccount() || strlen(sampleParams->getAccount()) == 0;
        ResponseListener *responseListener = new ResponseListener();
        TableListener *tableListener = new TableListener(responseListener);
        session->subscribeResponse(responseListener);

        O2G2Ptr<IO2GTableManager> tableManager = session->getTableManager();
        O2GTableManagerStatus managerStatus = tableManager->getStatus();
        while (managerStatus == TablesLoading)
        {
            Sleep(50);
            managerStatus = tableManager->getStatus();
        }

        if (managerStatus == TablesLoadFailed)
        {
            std::cout << "Cannot refresh all tables of table manager" << std::endl;
        }

        O2G2Ptr<IO2GAccountRow> account = getAccount(tableManager, sampleParams->getAccount());

        if (account)
        {
            if (bIsAccountEmpty)
            {
                sampleParams->setAccount(account->getAccountID());
                std::cout << "Account: " << sampleParams->getAccount() << std::endl;
            }
            O2G2Ptr<IO2GOfferRow> offer = getOffer(tableManager, 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();

                    // For the purpose of this example we will place primary order 30 pips below the current market price
                    // and our secondary order 15 pips below the current market price
                    double dRatePrimary = offer->getAsk() - 30.0 * offer->getPointSize();
                    double dRateSecondary = offer->getAsk() - 15.0 * offer->getPointSize();
                    O2G2Ptr<IO2GRequest> request = createOTORequest(session, offer->getOfferID(), account->getAccountID(), iAmount, dRatePrimary, dRateSecondary);
                    if (request)
                    {
                        tableListener->subscribeEvents(tableManager);

                        std::vector<std::string> requestIDs(request->getChildrenCount());

                        for (int i=0; i<request->getChildrenCount(); ++i)
                        {
                            requestIDs[i] = request->getChildRequest(i)->getRequestID();
                        }

                        responseListener->setRequestIDs(requestIDs);
                        tableListener->setRequestIDs(requestIDs);
                        session->sendRequest(request);

                        if (responseListener->waitEvents())
                        {
                            std::cout << "Done!" << std::endl;
                        }
                        else
                        {
                            std::cout << "Response waiting timeout expired" << std::endl;
                            bWasError = true;
                        }

                        tableListener->unsubscribeEvents(tableManager);
                        tableListener->release();
                    }
                    else
//.........这里部分代码省略.........
开发者ID:BryanFletcher,项目名称:FXCM,代码行数:101,代码来源:main.cpp

示例4: main

int main(int argc, char *argv[])
{
    std::string procName = "NetStopLimit";
    if (argc == 1)
    {
        printHelp(procName);
        return -1;
    }

    LoginParams *loginParams = new LoginParams(argc, argv);
    SampleParams *sampleParams = new SampleParams(argc, argv);

    printSampleParams(procName, loginParams, sampleParams);
    if (!checkObligatoryParams(loginParams, sampleParams))
        return -1;

    IO2GSession *session = CO2GTransport::createSession();
    session->useTableManager(Yes, 0);

    SessionStatusListener *sessionListener = new SessionStatusListener(session, false,
                                                                       loginParams->getSessionID(),
                                                                       loginParams->getPin());
    session->subscribeSessionStatus(sessionListener);

    bool bConnected = login(session, sessionListener, loginParams);
    bool bWasError = false;

    if (bConnected)
    {
        bool bIsAccountEmpty = !sampleParams->getAccount() || strlen(sampleParams->getAccount()) == 0;
        ResponseListener *responseListener = new ResponseListener();
        TableListener *tableListener = new TableListener(responseListener);
        session->subscribeResponse(responseListener);

        O2G2Ptr<IO2GTableManager> tableManager = session->getTableManager();
        O2GTableManagerStatus managerStatus = tableManager->getStatus();
        while (managerStatus == TablesLoading)
        {
            Sleep(50);
            managerStatus = tableManager->getStatus();
        }

        if (managerStatus == TablesLoadFailed)
        {
            std::cout << "Cannot refresh all tables of table manager" << std::endl;
        }

        O2G2Ptr<IO2GAccountRow> account = getAccount(tableManager, sampleParams->getAccount());

        if (account)
        {
            if (bIsAccountEmpty)
            {
                sampleParams->setAccount(account->getAccountID());
                std::cout << "Account: " << sampleParams->getAccount() << std::endl;
            }
            O2G2Ptr<IO2GOfferRow> offer = getOffer(tableManager, sampleParams->getInstrument());
            if (offer)
            {
                O2G2Ptr<IO2GTradeRow> trade = getTrade(tableManager, sampleParams->getAccount(), offer->getOfferID());
                if (trade)
                {
                    const char *sBuySell = strcmp(trade->getBuySell(), O2G2::Buy) == 0 ? O2G2::Sell : O2G2::Buy;
                    O2G2Ptr<IO2GRequest> requestStop = createNetEntryOrderRequest(session, offer->getOfferID(),
                            account->getAccountID(), sampleParams->getRateStop(), sBuySell, O2G2::Orders::StopEntry);
                    if (requestStop)
                    {
                        tableListener->subscribeEvents(tableManager);

                        responseListener->setRequestID(requestStop->getRequestID());
                        tableListener->setRequestID(requestStop->getRequestID());
                        session->sendRequest(requestStop);
                        if (responseListener->waitEvents())
                        {
                            O2G2Ptr<IO2GRequest> requestLimit = createNetEntryOrderRequest(session, offer->getOfferID(),
                                    account->getAccountID(), sampleParams->getRateLimit(), sBuySell, O2G2::Orders::LimitEntry);
                            if (requestLimit)
                            {
                                responseListener->setRequestID(requestLimit->getRequestID());
                                tableListener->setRequestID(requestLimit->getRequestID());
                                session->sendRequest(requestLimit);
                                if (responseListener->waitEvents())
                                {
                                    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;
                            }
                        }
                        else
                        {
                            std::cout << "Response waiting timeout expired" << std::endl;
//.........这里部分代码省略.........
开发者ID:BryanFletcher,项目名称:FXCM,代码行数:101,代码来源:main.cpp


注:本文中的O2G2Ptr::getStatus方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。