void run(int argc, char **argv) { if (!parseCommandLine(argc, argv)) return; SessionOptions sessionOptions; sessionOptions.setServerHost(d_host.c_str()); sessionOptions.setServerPort(d_port); std::cout <<"Connecting to " << d_host << ":" << d_port << std::endl; Session session(sessionOptions); if (!session.start()) { std::cerr << "Failed to start session." << std::endl; return; } if (!session.openService("//blp/refdata")) { std::cerr << "Failed to open //blp/refdata" << std::endl; return; } sendIntradayTickRequest(session); // wait for events from session. eventLoop(session); session.stop(); }
void input::run() { //if (!parseCommandLine(argc, argv)) return; SessionOptions sessionOptions; sessionOptions.setServerHost(d_host.c_str()); sessionOptions.setServerPort(d_port); //std::cout << "Connecting to " + d_host + ":" << d_port << std::endl; Session session(sessionOptions); if (!session.start()) { std::cout << "Failed to start session." << std::endl; return; } if (!session.openService("//blp/refdata")) { std::cout << "Failed to open //blp/refdata" << std::endl; return; } sendRefDataRequest(session); // wait for events from session. try { eventLoop(session); } catch (Exception &e) { std::cerr << "Library Exception !!!" << e.description() << std::endl; } catch (...) { std::cerr << "Unknown Exception !!!" << std::endl; } session.stop(); }
void run(int argc, char **argv) { if (!parseCommandLine(argc, argv)) { printUsage(); return; } SessionOptions sessionOptions; sessionOptions.setServerHost(d_host.c_str()); sessionOptions.setServerPort(d_port); std::cout << "Connecting to " + d_host + ":" << d_port << std::endl; SessionEventHandler eventHandler(d_identities, d_tokens, d_securities, d_field); Session session(sessionOptions, &eventHandler); if (!session.start()) { std::cerr << "Failed to start session. Exiting..." << std::endl; std::exit(-1); } openServices(&session); EventQueue authQueue; // Authorize all the users that are interested in receiving data if (authorizeUsers(&authQueue, &session)) { // Make the various requests that we need to make session.subscribe(d_subscriptions); } else { std::cerr << "Unable to authorize users, Press Enter to Exit" << std::endl; } // wait for enter key to exit application char dummy[2]; std::cin.getline(dummy,2); { // Check if there were any authorization events received on the // 'authQueue' Event event; while (0 == authQueue.tryNextEvent(&event)) { printEvent(event); } } session.stop(); std::cout << "Exiting...\n"; }
void run(int argc, char **argv) { if (!parseCommandLine(argc, argv)) return; SessionOptions sessionOptions; sessionOptions.setServerHost(d_host.c_str()); sessionOptions.setServerPort(d_port); std::string authOptions = "AuthenticationType=OS_LOGON"; if (d_useDS) { authOptions = "AuthenticationType=DIRECTORY_SERVICE;DirSvcPropertyName="; authOptions.append(d_DSProperty); } std::cout << "authOptions = " << authOptions << std::endl; sessionOptions.setAuthenticationOptions(authOptions.c_str()); std::cout << "Connecting to " << d_host << ":" << d_port << std::endl; d_session = new Session(sessionOptions); if (!d_session->start()) { std::cerr <<"Failed to start session." << std::endl; return; } if (!d_session->openService("//blp/refdata")) { std::cerr << "Failed to open //blp/refdata" << std::endl; return; } if (!d_session->openService("//blp/apiauth")) { std::cerr << "Failed to open //blp/apiauth" << std::endl; return; } CorrelationId tokenReqId(99); d_session->generateToken(tokenReqId); while (true) { Event event = d_session->nextEvent(); if (event.eventType() == Event::TOKEN_STATUS) { if (!processTokenStatus(event)) { break; } } else { if (!processEvent(event)) { break; } } } }
void run(int argc, char **argv) { d_host = "localhost"; d_port = 8194; if (!parseCommandLine(argc, argv)) return; SessionOptions sessionOptions; sessionOptions.setServerHost(d_host.c_str()); sessionOptions.setServerPort(d_port); std::cout << "Connecting to " << d_host << ":" << d_port << std::endl; Session session(sessionOptions); if (!session.start()) { std::cerr <<"Failed to start session." << std::endl; return; } if (!session.openService("//blp/refdata")) { std::cerr <<"Failed to open //blp/refdata" << std::endl; return; } Service refDataService = session.getService("//blp/refdata"); Request request = refDataService.createRequest("HistoricalDataRequest"); request.getElement("securities").appendValue("IBM US Equity"); request.getElement("securities").appendValue("MSFT US Equity"); request.getElement("fields").appendValue("PX_LAST"); request.getElement("fields").appendValue("OPEN"); request.set("periodicityAdjustment", "ACTUAL"); request.set("periodicitySelection", "MONTHLY"); request.set("startDate", "20060101"); request.set("endDate", "20061231"); request.set("maxDataPoints", 100); std::cout << "Sending Request: " << request << std:: endl; session.sendRequest(request); while (true) { Event event = session.nextEvent(); MessageIterator msgIter(event); while (msgIter.next()) { Message msg = msgIter.message(); msg.asElement().print(std::cout); std::cout << std::endl; } if (event.eventType() == Event::RESPONSE) { break; } } }
void createSession() { SessionOptions sessionOptions; sessionOptions.setServerHost(d_host.c_str()); sessionOptions.setServerPort(d_port); std::cout << "Connecting to " + d_host + ":" << d_port << std::endl; d_session = new Session(sessionOptions, new SessionEventHandler(d_identities, d_uuids)); bool sessionStarted = d_session->start(); if (!sessionStarted) { std::cerr << "Failed to start session. Exiting..." << std::endl; std::exit(-1); } }
void runRefData(double** refData, double** yesterdayData, std::vector<std::string>bonds){ d_host = "localhost"; d_port = 8194; SessionOptions sessionOptions; sessionOptions.setServerHost(d_host.c_str()); sessionOptions.setServerPort(d_port); Session session(sessionOptions); if (!session.start()){ std::cout << "Failed to start session" << std::endl; return; } if (!session.openService(APIREFDATA_SVC)){ std::cout << "Failed to open ref data service" << std::endl; return; } getTodayData(session, refData, bonds); getYesterdayData(session, yesterdayData, bonds); }
void run(int argc, char **argv) { if (!parseCommandLine(argc, argv)) return; SessionOptions sessionOptions; sessionOptions.setServerHost(d_host.c_str()); sessionOptions.setServerPort(d_port); std::cout << "Connecting to " + d_host + ":" << d_port << std::endl; Session session(sessionOptions); if (!startSession(session)) return; Service refDataService = session.getService("//blp/refdata"); Request request = refDataService.createRequest("ReferenceDataRequest"); request.append("securities", "IBM US Equity"); request.append("fields", "PX_LAST"); request.append("fields", "DS002"); session.sendRequest(request, d_cid); while (true) { Event event = session.nextEvent(); MessageIterator msgIter(event); while (msgIter.next()) { Message msg = msgIter.message(); if (event.eventType() == Event::RESPONSE || event.eventType() == Event::PARTIAL_RESPONSE) { ((Window *)msg.correlationId().asPointer())-> displaySecurityInfo(msg); } } if (event.eventType() == Event::RESPONSE) { // received final response break; } } }
int runHistData(double** data, std::vector<std::string>bonds, int history){ d_host = "localhost"; d_port = 8194; SessionOptions sessionOptions; sessionOptions.setServerHost(d_host.c_str()); sessionOptions.setServerPort(d_port); Session session(sessionOptions); if (!session.start()){ std::cout << "Failed to start session" << std::endl; return 0; } if (!session.openService(APIREFDATA_SVC)){ std::cout << "Failed to open ref data service" << std::endl; return 0; } Service refDataService = session.getService(APIREFDATA_SVC); Request request_hist = refDataService.createRequest("HistoricalDataRequest"); std::wstring stemp2 = std::to_wstring(bonds.size()); LPCWSTR sw2 = stemp2.c_str(); OutputDebugString(L"number bonds "); OutputDebugString(sw2); for (int i = 0; i < bonds.size(); i++){ const char* ISIN = bonds.at(i).c_str(); request_hist.getElement("securities").appendValue(ISIN); } request_hist.getElement("fields").appendValue("YLD_YTM_MID"); request_hist.set("periodicitySelection", "DAILY"); std::string endDate = today; std::string startDate = prevDate(history); request_hist.set("startDate", startDate.c_str()); request_hist.set("endDate", endDate.c_str()); session.sendRequest(request_hist); int i = 0; while (true){ Event event = session.nextEvent(); MessageIterator msgIter(event); while (msgIter.next()){ Message message = msgIter.message(); if (message.messageType() == "HistoricalDataResponse"){ i = parse_historical_response(message, data, true); } std::cout << std::endl; } if (event.eventType() == Event::RESPONSE){ break; } } return i; OutputDebugString(L"i HERE "); std::wstring stemp = std::to_wstring(i); LPCWSTR sw = stemp.c_str(); OutputDebugString(sw); }