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


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

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


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

示例1: getHistoryPrices

bool getHistoryPrices(IO2GSession *session, const char *sInstrument, const char *sTimeframe, DATE dtFrom, DATE dtTo, ResponseListener *responseListener)
{
    O2G2Ptr<IO2GRequestFactory> factory = session->getRequestFactory();
    if (!factory)
    {
        std::cout << "Cannot create request factory" << std::endl;
        return false;
    }
    //find timeframe by identifier
    O2G2Ptr<IO2GTimeframeCollection> timeframeCollection = factory->getTimeFrameCollection();
    O2G2Ptr<IO2GTimeframe> timeframe = timeframeCollection->get(sTimeframe);
    if (!timeframe)
    {
        std::cout << "Timeframe '" << sTimeframe << "' is incorrect!" << std::endl;
        return false;
    }
    O2G2Ptr<IO2GRequest> request = factory->createMarketDataSnapshotRequestInstrument(sInstrument, timeframe, timeframe->getQueryDepth());
    DATE dtFirst = dtTo;
     // there is limit for returned candles amount
    do
    {
        factory->fillMarketDataSnapshotRequestTime(request, dtFrom, dtFirst, false);
        responseListener->setRequestID(request->getRequestID());
        session->sendRequest(request);
        if (!responseListener->waitEvents())
        {
            std::cout << "Response waiting timeout expired" << std::endl;
            return false;
        }
        // shift "to" bound to oldest datetime of returned data
        O2G2Ptr<IO2GResponse> response = responseListener->getResponse();
        if (response && response->getType() == MarketDataSnapshot)
        {
            O2G2Ptr<IO2GResponseReaderFactory> readerFactory = session->getResponseReaderFactory();
            if (readerFactory)
            {
                O2G2Ptr<IO2GMarketDataSnapshotResponseReader> reader = readerFactory->createMarketDataSnapshotReader(response);
                if (reader->size() > 0)
                {
                    if (abs(dtFirst - reader->getDate(0)) > 0.0001)
                        dtFirst = reader->getDate(0); // earliest datetime of returned data
                    else
                        break;
                }
                else
                {
                    std::cout << "0 rows received" << std::endl;
                    break;
                }
            }
            printPrices(session, response);
        }
        else
        {
            break;
        }
    } while (dtFirst - dtFrom > 0.0001);
    return true;
}
开发者ID:BryanFletcher,项目名称:FXCM,代码行数:59,代码来源:main.cpp

示例2: toOleTime

std::vector<Prices> ForexConnectClient::getHistoricalPrices(const std::string& instrument,
							    const boost::posix_time::ptime& from,
							    const boost::posix_time::ptime& to,
    							    const std::string& timeFrame)
{
    std::vector<Prices> prices;
    O2G2Ptr<IO2GTimeframeCollection> timeframeCollection = mpRequestFactory->getTimeFrameCollection();
    O2G2Ptr<IO2GTimeframe> timeframe = timeframeCollection->get(timeFrame.c_str());
    if (!timeframe)
    {
        BOOST_LOG_TRIVIAL(error) << "Timeframe '" << timeFrame << "' is incorrect!";
        return prices;
    }
    O2G2Ptr<IO2GRequest> request = mpRequestFactory->createMarketDataSnapshotRequestInstrument(instrument.c_str(),
											       timeframe,
											       timeframe->getQueryDepth());
    DATE dtFrom = toOleTime(from);
    DATE dtTo = toOleTime(to);
    DATE dtFirst = dtTo;
    do
    {
        mpRequestFactory->fillMarketDataSnapshotRequestTime(request, dtFrom, dtFirst, false);
        mpResponseListener->setRequestID(request->getRequestID());
        mpSession->sendRequest(request);
        if (!mpResponseListener->waitEvents())
        {
            BOOST_LOG_TRIVIAL(error) << "Response waiting timeout expired";
            return prices;
        }
        // shift "to" bound to oldest datetime of returned data
        O2G2Ptr<IO2GResponse> response = mpResponseListener->getResponse();
        if (response && response->getType() == MarketDataSnapshot)
        {
	    O2G2Ptr<IO2GMarketDataSnapshotResponseReader> reader = mpResponseReaderFactory->createMarketDataSnapshotReader(response);
	    if (reader->size() > 0)
	    {
		if (fabs(dtFirst - reader->getDate(0)) > 0.0001)
		    dtFirst = reader->getDate(0); // earliest datetime of returned data
		else
		    break;
	    }
	    else
	    {
		BOOST_LOG_TRIVIAL(warning) << "0 rows received";
		break;
	    }
	    std::vector<Prices> prc = getPricesFromResponse(response);
	    prices.insert(prices.end(), prc.begin(), prc.end());
	}
	else
	{
	    break;
	}
    } while (dtFirst - dtFrom > 0.0001);
    return prices;
}
开发者ID:neka-nat,项目名称:python-forexconnect,代码行数:56,代码来源:ForexConnectClient.cpp

示例3: onSessionStatusChanged

void SessionStatusListener::onSessionStatusChanged(IO2GSessionStatus::O2GSessionStatus status)
{
    BOOST_LOG_TRIVIAL(trace) << __PRETTY_FUNCTION__;
    switch (status)
    {
    case IO2GSessionStatus::Disconnected:
        BOOST_LOG_TRIVIAL(info) << "status::disconnected";
        mConnected = false;
        mDisconnected = true;
        SetEvent(mSessionEvent);
        break;
    case IO2GSessionStatus::Connecting:
        BOOST_LOG_TRIVIAL(info) << "status::connecting";
        break;
    case IO2GSessionStatus::TradingSessionRequested:
    {
        BOOST_LOG_TRIVIAL(info) << "status::trading session requested";
        O2G2Ptr<IO2GSessionDescriptorCollection> descriptors = mSession->getTradingSessionDescriptors();
        bool found = false;
        if (descriptors)
        {
            if (mPrintSubsessions)
                BOOST_LOG_TRIVIAL(info) << "descriptors available:";
            for (int i = 0; i < descriptors->size(); ++i)
            {
                O2G2Ptr<IO2GSessionDescriptor> descriptor = descriptors->get(i);
                if (mPrintSubsessions)
                    BOOST_LOG_TRIVIAL(info) << "  id:='" << descriptor->getID()
					    << "' name='" << descriptor->getName()
					    << "' description='" << descriptor->getDescription()
					    << "' " << (descriptor->requiresPin() ? "requires pin" : "");
                if (mSessionID == descriptor->getID())
                {
                    found = true;
                    break;
                }
            }
        }
        if (!found)
        {
            onLoginFailed("The specified sub session identifier is not found");
        }
        else
        {
            mSession->setTradingSession(mSessionID.c_str(), mPin.c_str());
        }
    }
    break;
    case IO2GSessionStatus::Connected:
        BOOST_LOG_TRIVIAL(info) << "status::connected";
        mConnected = true;
        mDisconnected = false;
        SetEvent(mSessionEvent);
        break;
    case IO2GSessionStatus::Reconnecting:
        BOOST_LOG_TRIVIAL(info) << "status::reconnecting";
        break;
    case IO2GSessionStatus::Disconnecting:
        BOOST_LOG_TRIVIAL(info) << "status::disconnecting";
        break;
    case IO2GSessionStatus::SessionLost:
        BOOST_LOG_TRIVIAL(info) << "status::session lost";
        break;
    }
}
开发者ID:aniss,项目名称:python-forexconnect,代码行数:65,代码来源:SessionStatusListener.cpp


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