public void run(PerSecurityWS ps) { try { // Setting header for the request GetFundamentalsHeaders getFundHeaders = new GetFundamentalsHeaders(); GetDataHeaders getDataHeaders = new GetDataHeaders(); getDataHeaders.closingvaluesSpecified = true; getDataHeaders.closingvalues = true; getDataHeaders.secmasterSpecified = true; getDataHeaders.secmaster = true; getDataHeaders.derivedSpecified = true; getDataHeaders.derived = true; // Setting instruments for the request Instrument ticker = new Instrument(); ticker.id = "IBM US"; ticker.type = InstrumentType.TICKER; ticker.yellowkey = MarketSector.Equity; Instrument bbUniqueId = new Instrument(); bbUniqueId.id = "EQ0086119600001000"; bbUniqueId.type = InstrumentType.BB_UNIQUE; Instrument[] instr = new Instrument[] { ticker, bbUniqueId }; String[] field = new String[] { "TOP_ANALYST_PERFORM_RANK_TRR" }; // Sending submit get data request SubmitGetDataRequest sbmtGetDtReq = new SubmitGetDataRequest(); sbmtGetDtReq.headers = getDataHeaders; sbmtGetDtReq.fields = field; Instruments instrmnts = new Instruments(); instrmnts.instrument = instr; sbmtGetDtReq.instruments = instrmnts; Console.WriteLine("Sending submit get bulk data request"); SubmitGetDataResponse sbmtGetDtResp = ps .submitGetDataRequest(sbmtGetDtReq); Console.WriteLine("Submit get data request status: " + sbmtGetDtResp.statusCode.description + " response ID: " + sbmtGetDtResp.responseId); // Sending retrieve get data request RetrieveGetDataRequest rtvGetDtReq = new RetrieveGetDataRequest(); rtvGetDtReq.responseId = sbmtGetDtResp.responseId; RetrieveGetDataResponse rtvGetDtResp = new RetrieveGetDataResponse(); Console.WriteLine("Sending retrieve get data request"); // Keep polling for response till the data is available do { System.Threading.Thread.Sleep(PerSecurity.POLL_INTERVAL); rtvGetDtResp = ps.retrieveGetDataResponse(rtvGetDtReq); } while (rtvGetDtResp.statusCode.code == PerSecurity.DATA_NOT_AVAILABLE); // Display data if (rtvGetDtResp.statusCode.code == PerSecurity.SUCCESS) { Console.WriteLine("Retrieve get data request successful. Response ID: " + rtvGetDtResp.responseId); for (int i = 0; i < rtvGetDtResp.instrumentDatas.Length; i++) { InstrumentData data = rtvGetDtResp.instrumentDatas[i]; Console.WriteLine(data.instrument.id); Data[] datas = data.data; for (int j = 0; j < datas.Length; j++) { //Displaying bulk data if (datas[j].isArray) { for (int k = 0; k < datas[j].bulkarray.Length; k++) for (int l = 0; l < datas[j].bulkarray[k].data.Length; l++) { Console.WriteLine(datas[j].bulkarray[k].data[l].type + ": " + datas[j].bulkarray[k].data[l].value); } } //Displaying non-bulk data else Console.WriteLine(datas[j].value); } } } else if (rtvGetDtResp.statusCode.code == PerSecurity.REQUEST_ERROR) Console.WriteLine("Error in submitted request"); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public void run(PerSecurityWS ps) { //Setting request headers GetHistoryHeaders getHistHeaders = new GetHistoryHeaders(); DateRange dtRange = new DateRange(); Duration duration = new Duration(); duration.days = 3; dtRange.duration = duration; getHistHeaders.daterange = dtRange; //Setting instruments Instruments instrs = new Instruments(); instrs.macro = new Macro[2]; instrs.macro[0] = new Macro(); instrs.macro[0].primaryQualifier = new PrimaryQualifier(); instrs.macro[0].primaryQualifier.primaryQualifierType = MacroType.SECTYP; instrs.macro[0].primaryQualifier.primaryQualifierValue = "CONVERTS"; instrs.macro[0].secondaryQualifier = new SecondaryQualifier[1]; instrs.macro[0].secondaryQualifier[0] = new SecondaryQualifier(); instrs.macro[0].secondaryQualifier[0].secondaryQualifierOperator = SecondaryQualifierOperator.Equals; instrs.macro[0].secondaryQualifier[0].secondaryQualifierType = SecondaryQualifierType.TICKER; instrs.macro[0].secondaryQualifier[0].secondaryQualifierValue = "F"; //A sample of incorrect macro instrs.macro[1] = new Macro(); instrs.macro[1].primaryQualifier = new PrimaryQualifier(); instrs.macro[1].primaryQualifier.primaryQualifierType = MacroType.SECTYP; instrs.macro[1].primaryQualifier.primaryQualifierValue = "converts_err"; instrs.macro[1].secondaryQualifier = new SecondaryQualifier[1]; instrs.macro[1].secondaryQualifier[0] = new SecondaryQualifier(); instrs.macro[1].secondaryQualifier[0].secondaryQualifierOperator = SecondaryQualifierOperator.Equals; instrs.macro[1].secondaryQualifier[0].secondaryQualifierType = SecondaryQualifierType.TICKER; instrs.macro[1].secondaryQualifier[0].secondaryQualifierValue = "F"; //Setting get history request parameters string[] fields = new string[] {"PX_LAST"}; SubmitGetHistoryRequest sbmtGtHistReq = new SubmitGetHistoryRequest(); sbmtGtHistReq.headers = getHistHeaders; sbmtGtHistReq.instruments = instrs; sbmtGtHistReq.fields = fields; try { Console.WriteLine("Submit Get History request"); SubmitGetHistoryResponse sbmtGtHistResp = ps.submitGetHistoryRequest(sbmtGtHistReq); System.Console.WriteLine("status " + sbmtGtHistResp.statusCode.description); System.Console.WriteLine("Submit Get Data request - response ID = " + sbmtGtHistResp.responseId); Console.WriteLine("Retrieve data request"); RetrieveGetHistoryRequest rtrvGtHistReq = new RetrieveGetHistoryRequest(); rtrvGtHistReq.responseId = sbmtGtHistResp.responseId; RetrieveGetHistoryResponse rtrvGtHistResp = new RetrieveGetHistoryResponse(); //Keep sending the request until status code is "0"(success) do { System.Threading.Thread.Sleep(PerSecurity.POLL_INTERVAL); rtrvGtHistResp = ps.retrieveGetHistoryResponse(rtrvGtHistReq); } while (rtrvGtHistResp.statusCode.code== PerSecurity.DATA_NOT_AVAILABLE ); //Displaying data if (rtrvGtHistResp.statusCode.code == PerSecurity.SUCCESS) { for (int i = 0; i < rtrvGtHistResp.instrumentDatas.Length; i++) { if(rtrvGtHistResp.instrumentDatas[i].code.Equals("0")) { System.Console.WriteLine("Data for :" + rtrvGtHistResp.instrumentDatas[i].instrument.id + " " + rtrvGtHistResp.instrumentDatas[i].instrument.yellowkey); Console.WriteLine(rtrvGtHistResp.instrumentDatas[i].date.ToString()); for (int j = 0; j < rtrvGtHistResp.instrumentDatas[i].data.Length; j++) { Console.WriteLine(sbmtGtHistReq.fields[j] + " : " + rtrvGtHistResp. instrumentDatas[i].data[j].value); } } else { System.Console.WriteLine("\nError Code " + rtrvGtHistResp.instrumentDatas[i].code + ": incorrect macro. The Macro object is as follows:"); Console.WriteLine("Primary Qualifier - "); Console.WriteLine("Primary Qualifier type:" + rtrvGtHistResp.instrumentDatas[i]. macro.primaryQualifier.primaryQualifierType); Console.WriteLine("Primary Qualifier value:" + rtrvGtHistResp.instrumentDatas[i]. macro.primaryQualifier.primaryQualifierValue); Console.WriteLine("Secondary Qualifier -"); for (int l = 0; l < rtrvGtHistResp.instrumentDatas[i].macro.secondaryQualifier. Length; l++) { Console.WriteLine("Secondary Qualifier type :" + rtrvGtHistResp.instrumentDatas[i]. macro.secondaryQualifier[l].secondaryQualifierType); Console.WriteLine("Secondary Qualifier Value :" + rtrvGtHistResp.instrumentDatas[i] .macro.secondaryQualifier[l].secondaryQualifierValue); Console.WriteLine("Secondary Qualifier Operator :" + rtrvGtHistResp.instrumentDatas[i] .macro.secondaryQualifier[l].secondaryQualifierOperator); } } } } else if (rtrvGtHistResp.statusCode.code == PerSecurity.REQUEST_ERROR) { Console.WriteLine("Error in the submitted request"); } } catch (Exception e) { Console.WriteLine(e.Message); } }
public void run(PerSecurityWS ps) { try{ //Setting headers GetHistoryHeaders getHistHeaders = new GetHistoryHeaders(); getHistHeaders.display_pricing_srcSpecified = true; getHistHeaders.display_pricing_src = true; Instrument ticker = new Instrument(); ticker.id = "IBM US"; ticker.typeSpecified = true; ticker.yellowkeySpecified = true; ticker.type = InstrumentType.TICKER; ticker.yellowkey = MarketSector.Equity; Instrument[] instr = new Instrument[] { ticker }; Instruments instrs = new Instruments(); instrs.instrument = instr; String[] fields = new String[] { "PX_LAST" }; //Sending Request SubmitGetHistoryRequest sbmtGtHistReq = new SubmitGetHistoryRequest(); sbmtGtHistReq.headers = getHistHeaders; sbmtGtHistReq.instruments = instrs; sbmtGtHistReq.fields = fields; Console.WriteLine("Submit Get History request"); SubmitGetHistoryResponse sbmtGtHistResp = ps .submitGetHistoryRequest(sbmtGtHistReq); Console.WriteLine("Submit Get Data request - Status: " + sbmtGtHistResp.statusCode.description + " response ID = " + sbmtGtHistResp.responseId); Console.WriteLine("Sending retrieve data request"); RetrieveGetHistoryRequest rtrvGtHistReq = new RetrieveGetHistoryRequest(); rtrvGtHistReq.responseId=sbmtGtHistResp.responseId; RetrieveGetHistoryResponse rtrvGtHistResp = new RetrieveGetHistoryResponse(); // Keep polling for response till the data is available do { System.Threading.Thread.Sleep(PerSecurity.POLL_INTERVAL); rtrvGtHistResp = ps.retrieveGetHistoryResponse(rtrvGtHistReq); } while (rtrvGtHistResp.statusCode.code == PerSecurity.DATA_NOT_AVAILABLE); // Displaying data if (rtrvGtHistResp.statusCode.code == PerSecurity.SUCCESS) { Console.WriteLine("Retrieve get data request successful Response ID: " + rtrvGtHistResp.responseId); for (int i = 0; i < rtrvGtHistResp.instrumentDatas.Length; i++) { Console.WriteLine("Data for :" + rtrvGtHistResp.instrumentDatas[i].instrument.id + " " + rtrvGtHistResp.instrumentDatas[i].instrument.yellowkey); Console.WriteLine("Time: " + rtrvGtHistResp.instrumentDatas[i].date.Hour.ToString() + ":" + rtrvGtHistResp.instrumentDatas[i].date.Minute.ToString() + ":" + rtrvGtHistResp.instrumentDatas[i].date.Second.ToString()); Console.WriteLine("Pricing Source: " + rtrvGtHistResp.instrumentDatas[i].pricingSource); for (int j = 0; j < rtrvGtHistResp.instrumentDatas[i].data.Length; j++) { Console.WriteLine(fields[j] + " : " + rtrvGtHistResp.instrumentDatas[i].data[j].value); } } } else if (rtrvGtHistResp.statusCode.code == PerSecurity.REQUEST_ERROR) Console.WriteLine(" Error in the submitted request" ); }catch(Exception ex) { Console.WriteLine(ex.Message); } }
public void run(PerSecurityWS ps) { //Set request header GetDataHeaders getDataHeaders = new GetDataHeaders(); getDataHeaders.secmaster = true; getDataHeaders.secmasterSpecified = true; getDataHeaders.closingvalues = true; getDataHeaders.closingvaluesSpecified = true; //Defining the instruments for the bulk request Instrument ticker = new Instrument(); ticker.id = "IBM US"; ticker.yellowkeySpecified = true; ticker.yellowkey = MarketSector.Equity; ticker.typeSpecified = false; ticker.type = InstrumentType.TICKER; Console.WriteLine("Submit get Data request"); SubmitGetDataRequest sbmtGtDtreq = new SubmitGetDataRequest(); sbmtGtDtreq.headers = getDataHeaders; sbmtGtDtreq.fields = new string[]{"TOP_ANALYST_PERFORM_RANK_TRR"};//Bulk field Instruments instrs = new Instruments(); instrs.instrument = new Instrument[] { ticker }; sbmtGtDtreq.instruments = instrs; try { SubmitGetDataResponse sbmtGtDtresp = ps.submitGetDataRequest(sbmtGtDtreq); System.Console.WriteLine("Request ID = " + sbmtGtDtresp.requestId + " " + sbmtGtDtresp.responseId); System.Console.WriteLine("status of Get Data request : " + sbmtGtDtresp.statusCode.description); Console.WriteLine("Retrieve get data request"); RetrieveGetDataRequest rtrvGtDrReq = new RetrieveGetDataRequest(); rtrvGtDrReq.responseId = sbmtGtDtresp.responseId; RetrieveGetDataResponse rtrvGtDrResp = new RetrieveGetDataResponse(); do { System.Threading.Thread.Sleep(PerSecurity.POLL_INTERVAL); rtrvGtDrResp = ps.retrieveGetDataResponse(rtrvGtDrReq); } while(rtrvGtDrResp.statusCode.code==PerSecurity.DATA_NOT_AVAILABLE); if(rtrvGtDrResp.statusCode.code==PerSecurity.SUCCESS){ Console.WriteLine("Response ID " + rtrvGtDrResp.responseId); for (int i = 0; i < rtrvGtDrResp.instrumentDatas.Length; i++) { System.Console.WriteLine("Data for :" + rtrvGtDrResp.instrumentDatas[i].instrument.id + " " + rtrvGtDrResp.instrumentDatas[i].instrument.yellowkey); for (int j = 0; j < rtrvGtDrResp.instrumentDatas[i].data.Length; j++) { if (rtrvGtDrResp.instrumentDatas[i].data[j].isArray == true) { for (int k = 0; k < rtrvGtDrResp.instrumentDatas[i].data[j].bulkarray.Length; k++) { Console.WriteLine("-------------------------"); for (int l = 0; l < rtrvGtDrResp.instrumentDatas[i].data[j]. bulkarray[k].data.Length; l++) Console.WriteLine(rtrvGtDrResp.instrumentDatas[i]. data[j].bulkarray[k].data[l].value); } } else System.Console.WriteLine(" " + sbmtGtDtreq.fields[j] + " : " + rtrvGtDrResp.instrumentDatas[i].data[j].value); } } } else if (rtrvGtDrResp.statusCode.code == PerSecurity.REQUEST_ERROR) { Console.WriteLine("Error in the submitted request"); } } catch(Exception e) { Console.WriteLine(e.Message); } }
public void run(PerSecurityWS ps) { try { //Setting header information QuotesHeaders headers = new QuotesHeaders(); DateTime start = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 10, 10, 0); DateTime end = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 10, 11, 0); if (new DateTime().DayOfWeek == DayOfWeek.Saturday) { TimeSpan ts1 = new TimeSpan(1, 0, 0, 0); start= start.Subtract(ts1); end= end.Subtract(ts1); } else if (new DateTime().DayOfWeek == DayOfWeek.Sunday) { start.AddDays(-2); end.AddDays(-2); } DateTimeRange dtr = new DateTimeRange(); dtr.startDateTime = start; dtr.endDateTime = end; dtr.region = "NY"; headers.datetimerange = dtr; //Setting instruments Instrument ticker = new Instrument(); ticker.id = "IBM US"; ticker.yellowkeySpecified = true; ticker.typeSpecified = true; ticker.yellowkey = MarketSector.Equity; ticker.type = InstrumentType.TICKER; Instruments instrs = new Instruments(); instrs.instrument = new Instrument[] { ticker }; SubmitGetAllQuotesRequest req = new SubmitGetAllQuotesRequest(); req.headers = headers; req.instruments = instrs; Console.WriteLine("Sending submit get all quotes request"); SubmitGetAllQuotesResponse resp = ps.submitGetAllQuotesRequest(req); String responseId = resp.responseId; Console.WriteLine("Submit get all quotes request status: " + resp.statusCode.description + " responseId: " + resp.responseId); RetrieveGetAllQuotesRequest rreq = new RetrieveGetAllQuotesRequest(); rreq.responseId = responseId; RetrieveGetAllQuotesResponse rresp = ps.retrieveGetAllQuotesResponse(rreq); Console.WriteLine("Sending retrieve get all quotes request"); // Keep polling for response till the data is available do { System.Threading.Thread.Sleep(PerSecurity.POLL_INTERVAL); rresp = ps.retrieveGetAllQuotesResponse(rreq); } while (rresp.statusCode.code == PerSecurity.DATA_NOT_AVAILABLE); // Display data if (rresp.statusCode.code == PerSecurity.SUCCESS) { Console.WriteLine("Retrieve get all quotes request successful. Response ID:" + rresp.responseId); for (int i = 0; i < rresp.instrumentDatas.Length; i++) { Console.WriteLine("Data for :" + rresp.instrumentDatas[i].instrument.id + " " + rresp.instrumentDatas[i].instrument.yellowkey); for (int j = 0; j < rresp.instrumentDatas[i].quotes.Length; j++) { for (int k = 0; k < rresp.instrumentDatas[i].quotes[j].matchedQuote.Length; k++) { Console.WriteLine(" type = " + rresp.instrumentDatas[i].quotes[j].matchedQuote[k].type + ", price = " + rresp.instrumentDatas[i].quotes[j].matchedQuote[k].price + ", volume = " + rresp.instrumentDatas[i].quotes[j].matchedQuote[k].volume ); } } } } else if (rresp.statusCode.code == PerSecurity.REQUEST_ERROR) Console.WriteLine("Error in submitted request"); } catch (Exception e) { Console.WriteLine(e.Message); } }
public void run(PerSecurityWS ps) { //Setting request header information GetDataHeaders getDataHeaders = new GetDataHeaders(); getDataHeaders.secmaster = true; getDataHeaders.secmasterSpecified = true; getDataHeaders.closingvalues = true; getDataHeaders.closingvaluesSpecified = true; getDataHeaders.derived = true; getDataHeaders.derivedSpecified = true; getDataHeaders.exclusive_pricing_srcSpecified = true; getDataHeaders.exclusive_pricing_src = true; //Setting Instrument information Instrument bbUniqueId = new Instrument(); bbUniqueId.id = "EQ0086119600001000"; bbUniqueId.type = InstrumentType.BB_UNIQUE; bbUniqueId.typeSpecified = true; Instrument ticker = new Instrument(); ticker.id = "IBM"; ticker.yellowkey = MarketSector.Equity; ticker.yellowkeySpecified = true; ticker.type = InstrumentType.TICKER; ticker.typeSpecified = true; //Setting the get data request parameter SubmitGetDataRequest sbmtGtDtreq = new SubmitGetDataRequest(); sbmtGtDtreq.headers = getDataHeaders; sbmtGtDtreq.fields = new string[] { "ID_BB_UNIQUE", "TICKER", "PX_LAST", "PX_ASK", "PX_BID", "VWAP_DT" }; Instruments instrs = new Instruments(); instrs.instrument = new Instrument[] { ticker, bbUniqueId }; sbmtGtDtreq.instruments = new Instruments(); sbmtGtDtreq.instruments = instrs; try { Console.WriteLine("Submit Get Data Request"); SubmitGetDataResponse sbmtGtDtresp = ps.submitGetDataRequest(sbmtGtDtreq); System.Console.WriteLine("status " + sbmtGtDtresp.statusCode.description); System.Console.WriteLine("Submit Get Data request - response ID = " + sbmtGtDtresp.responseId); //retrieve get data request. The response ID sent for the request is the response ID //received from SubmitGetDataRequest() Console.WriteLine("Retrieve data request"); RetrieveGetDataRequest rtrvGtDrReq = new RetrieveGetDataRequest(); rtrvGtDrReq.responseId = sbmtGtDtresp.responseId; RetrieveGetDataResponse rtrvGtDrResp = new RetrieveGetDataResponse(); //Keep sending the request if status is 100 do { System.Threading.Thread.Sleep(PerSecurity.POLL_INTERVAL); rtrvGtDrResp = ps.retrieveGetDataResponse(rtrvGtDrReq); } while (rtrvGtDrResp.statusCode.code == PerSecurity.DATA_NOT_AVAILABLE); if (rtrvGtDrResp.statusCode.code == PerSecurity.SUCCESS) { //Displaying the RetrieveGetDataResponse for (int i = 0; i < rtrvGtDrResp.instrumentDatas.Length; i++) { Console.WriteLine("Data for :" + rtrvGtDrResp.instrumentDatas[i].instrument.id + " " + rtrvGtDrResp.instrumentDatas[i].instrument.yellowkey); for (int j = 0; j < rtrvGtDrResp.instrumentDatas[i].data.Length; j++) { if (rtrvGtDrResp.instrumentDatas[i].data[j].isArray == true) { //In case this is a bulk field request for (int k = 0; k < rtrvGtDrResp.instrumentDatas[i].data[j].bulkarray.Length; k++) { Console.WriteLine("-------------------------"); for (int l = 0; l < rtrvGtDrResp.instrumentDatas[i].data[j]. bulkarray[k].data.Length; l++) Console.WriteLine(rtrvGtDrResp. instrumentDatas[i].data[j].bulkarray[k].data[l].value); } } else Console.WriteLine(" " + sbmtGtDtreq.fields[j] + " : " + rtrvGtDrResp. instrumentDatas[i].data[j].value); } } } else if (rtrvGtDrResp.statusCode.code == PerSecurity.REQUEST_ERROR) Console.WriteLine("Error in the submitted request"); } catch (Exception e) { Console.WriteLine(e.Message + " " + e.StackTrace); } }
public void run(PerSecurityWS ps) { try { //Setting overrides Override[] ovride = new Override[4]; ovride[0] = new Override(); ovride[0].field = "VWAP_START_DT"; DateTime start = DateTime.Today; ovride[0].value = start.ToString();// "20080227"; ovride[1] = new Override(); ovride[1].field = "VWAP_END_DT"; DateTime end = DateTime.Today.Subtract(TimeSpan.FromDays(5)); ovride[1].value = end.ToString();//"20080227"; ovride[2] = new Override(); ovride[2].field = "VWAP_START_TIME"; ovride[2].value = "1000"; ovride[3] = new Override(); ovride[3].field = "VWAP_END_TIME"; ovride[3].value = "1100"; //Setting the instruments for request Instrument bbUniqueId = new Instrument(); bbUniqueId.id = "EQ0086119600001000"; bbUniqueId.yellowkeySpecified = false; bbUniqueId.type = InstrumentType.BB_UNIQUE; bbUniqueId.typeSpecified = true; bbUniqueId.overrides = ovride; Instrument ticker = new Instrument(); ticker.id = "IBM US"; ticker.yellowkeySpecified = true; ticker.yellowkey = MarketSector.Equity; ticker.typeSpecified = false; ticker.type = InstrumentType.TICKER; ticker.overrides = ovride; //Setting request header GetDataHeaders getDataHeaders = new GetDataHeaders(); getDataHeaders.secmaster = true; getDataHeaders.secmasterSpecified = true; getDataHeaders.closingvalues = true; getDataHeaders.closingvaluesSpecified = true; getDataHeaders.programflag = ProgramFlag.daily; getDataHeaders.rundate = DateTime.Today.ToString(); getDataHeaders.time = "1430"; getDataHeaders.derived = true; //Submit get data request Console.WriteLine("Submit get data request"); SubmitGetDataRequest sbmtGtDrReq = new SubmitGetDataRequest(); sbmtGtDrReq.headers = getDataHeaders; sbmtGtDrReq.fields = new string[]{"ID_BB_UNIQUE","TICKER","PX_LAST","PX_ASK","PX_BID","VWAP_DT"}; Instruments instrs = new Instruments(); instrs.instrument = new Instrument[] {ticker, bbUniqueId}; sbmtGtDrReq.instruments = instrs; SubmitGetDataResponse sbmtGetDtResp= ps.submitGetDataRequest(sbmtGtDrReq); System.Console.WriteLine("Submit get data response Id = " + sbmtGetDtResp.responseId + "\n"); System.Threading.Thread.Sleep(100000); //Submit scheduled request for the get data request sent above Console.WriteLine("Submit scheduled request"); SubmitScheduledRequest sbmtSchReq = new SubmitScheduledRequest(); SubmitScheduledResponse sbmtSchResp = ps.submitScheduledRequest(sbmtSchReq); Console.WriteLine("Submit Schedule request responseID : " + sbmtSchResp.responseId + "\n"); //Submit retrieve scheduled request to display all the scheduled files and check to see //if the daily job requested was addeds Console.WriteLine("Retrieve scheduled request"); RetrieveScheduledRequest schReq = new RetrieveScheduledRequest(); schReq.responseId = sbmtSchResp.responseId; RetrieveScheduledResponse schResp = new RetrieveScheduledResponse(); //Keep sending the request until the entire response is received do { System.Threading.Thread.Sleep(PerSecurity.POLL_INTERVAL); schResp = ps.retrieveScheduledResponse(schReq); } while(schResp.statusCode.code==PerSecurity.DATA_NOT_AVAILABLE); Console.WriteLine(schResp.responseId); for(int i=0;i<schResp.fileDatas.Length;i++) { if (schResp.fileDatas[i].responseId == sbmtGetDtResp.responseId) Console.WriteLine("Response ID requested by submit get data request: " + schResp.fileDatas[i].responseId); else Console.WriteLine("Response ID: " + schResp.fileDatas[i].responseId + "\n"); Console.WriteLine("Response Header for retrieve schedule request"); Console.WriteLine("Date: " + schResp.fileDatas[i].headers.getdataHeaders.rundate + " Time: " + schResp.fileDatas[i].headers.getdataHeaders.time + " Scheduled: " + schResp.fileDatas[i].headers.getdataHeaders.programflag); Console.WriteLine("Fields"); for(int j=0;j<schResp.fileDatas[i].fields.Length;j++) { Console.WriteLine(schResp.fileDatas[i].fields[j]); } Console.WriteLine("Instruments"); for(int j=0;j<schResp.fileDatas[i].instruments.instrument.Length;j++) { Console.WriteLine("ID: " + schResp.fileDatas[i].instruments.instrument[j].id + "Type: " + schResp.fileDatas[i].instruments.instrument[j].type); } } //Sending a request to cancel the request for the daily job Console.WriteLine("Submit Cancel request"); CancelHeaders cancelHeaders = new CancelHeaders(); cancelHeaders.programflag = ProgramFlag.daily; SubmitCancelRequest sbCancelReq = new SubmitCancelRequest(); sbCancelReq.responseId[0] = sbmtGetDtResp.responseId; sbCancelReq.headers = cancelHeaders; Boolean flag = true; SubmitCancelResponse sbCancelResp = ps.submitCancelRequest(sbCancelReq); if(sbCancelResp.statusCode.code==0) { Console.WriteLine("Submit Cancel request response ID: " + sbCancelResp.responseId); } //Checked the scheduled request to check if the daily job has been removed Console.WriteLine("Submit scheduled request"); SubmitScheduledRequest sbmtSchReqCheck = new SubmitScheduledRequest(); SubmitScheduledResponse sbmtSchRespCheck = ps.submitScheduledRequest(sbmtSchReqCheck); Console.WriteLine("Submit Schedule request responseID : " + sbmtSchRespCheck.responseId + "\n"); Console.WriteLine("Retrieve scheduled request"); RetrieveScheduledRequest schReqCheck = new RetrieveScheduledRequest(); schReqCheck.responseId = sbmtSchRespCheck.responseId; RetrieveScheduledResponse schRespCheck = new RetrieveScheduledResponse(); do { System.Threading.Thread.Sleep(PerSecurity.POLL_INTERVAL); schRespCheck = ps.retrieveScheduledResponse(schReqCheck); } while(schRespCheck.fileDatas==null); Console.WriteLine("response ID for retrieveSchedule respone: " + schResp.responseId); String dispRespId = null; for(int i=0;i<schRespCheck.fileDatas.Length;i++) { if(schRespCheck.fileDatas[i].responseId==sbmtGetDtResp.responseId) { flag= true; dispRespId = schRespCheck.fileDatas[i].responseId; } else flag=false; } if(flag) Console.WriteLine("The daily job with response ID: " + dispRespId + "wasnt cancelled successfully"); else Console.WriteLine("The daily job was cancelled successfully"); } catch(Exception e) { Console.WriteLine(e.Message + e.StackTrace); } }
public void run(PerSecurityWS ps) { try { //Setting headers GetActionsHeaders getActionHeaders = new GetActionsHeaders(); getActionHeaders.actions_date = ActionsDate.entry; String[] actions = new String[] { "DVD_CASH", "DISTRIBUTIONS" }; getActionHeaders.actions = actions; //Setting Instruments Instruments instruments = new Instruments(); Instrument instr = new Instrument(); instr.id = "COP US"; instr.yellowkeySpecified = true; instr.typeSpecified = true; instr.yellowkey = MarketSector.Equity; instr.type = InstrumentType.TICKER; instruments.instrument = new Instrument[] { instr }; //Submitting request SubmitGetActionsRequest req = new SubmitGetActionsRequest(); req.headers = getActionHeaders; req.instruments = instruments; SubmitGetActionsResponse resp = null; resp = ps.submitGetActionsRequest(req); String responseId = resp.responseId; Console.WriteLine("Submit get actions request status: " + resp.statusCode.description + " responseId: " + responseId); //Submit retrieve request RetrieveGetActionsRequest rtrvReq = new RetrieveGetActionsRequest(); rtrvReq.responseId = responseId; Console.WriteLine("Sending retrieve get actions request"); RetrieveGetActionsResponse rtrvResp = new RetrieveGetActionsResponse(); // Keep polling for response till the data is available do { System.Threading.Thread.Sleep(PerSecurity.POLL_INTERVAL); rtrvResp = ps.retrieveGetActionsResponse(rtrvReq); } while (rtrvResp.statusCode.code == PerSecurity.DATA_NOT_AVAILABLE); //Display data if (rtrvResp.statusCode.code == PerSecurity.SUCCESS) { Console.WriteLine("Retrieve get quotes request successful. Response ID:" + rtrvResp.responseId); for (int i = 0; i < rtrvResp.instrumentDatas.Length; i++) { Console.WriteLine("Data for :" + rtrvResp.instrumentDatas[i].instrument.id + " " + rtrvResp.instrumentDatas[i].instrument.yellowkey ); Console.WriteLine(", Company id = " + rtrvResp.instrumentDatas[i].standardFields.companyId.ToString()); Console.WriteLine(", Security id = " + rtrvResp.instrumentDatas[i].standardFields.securityId.ToString()); if (rtrvResp.instrumentDatas[i].data != null) { for (int j = 0; j < rtrvResp.instrumentDatas[i].data.Length; j++) { Console.WriteLine(": field = " + rtrvResp.instrumentDatas[i].data[j].field + ", value = " + rtrvResp.instrumentDatas[i].data[j].value); } } } } else if (rtrvResp.statusCode.code == PerSecurity.REQUEST_ERROR) Console.WriteLine("Error in submitted request"); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public bool Run(int jobKeyCode, string yellowkey, PerSecurityWS ps, DataTable dtKickouts, string[] fields, ref XmlDocument xdocNewInvestmentData, ref XmlDocument xdocNewInvestmentDataNoBbg, string InvestmentField) { #region prepare request Instruments instrs = new Instruments(); List<Instrument> instrsList = new List<Instrument>(); Dictionary<string, string> assetTypes = new Dictionary<string, string>(); Dictionary<string, string> sourceInvestments = new Dictionary<string, string>(); Hashtable htInvType2AssetType = InitAssetTypeMap(); Hashtable htIntlOptions = new Hashtable(); GetDataHeaders getDataHeaders = new GetDataHeaders(); try { //Setting request header information getDataHeaders.secmaster = true; getDataHeaders.secmasterSpecified = true; getDataHeaders.closingvalues = true; getDataHeaders.closingvaluesSpecified = true; getDataHeaders.derived = true; getDataHeaders.derivedSpecified = true; foreach (DataRow dr in dtKickouts.Rows) { assetTypes[dr["Investment"].ToString()] = htInvType2AssetType[dr["SourceInvestmentType"].ToString()].ToString(); sourceInvestments[dr["Investment"].ToString()] = dr["SourceInvestment"].ToString(); if (SuppressBloombergQuery(dr) == false) { Instrument istr = new Instrument(); //istr.id = dr["Investment"].ToString(); istr.id = dr[InvestmentField].ToString(); switch (dr["SourceInvestmentType"].ToString()) { case "FIGOVI": istr.type = InstrumentType.ISIN; break; default: istr.type = InstrumentType.TICKER; break; } istr.typeSpecified = true; AssignYellowKey(dr, ref istr, ref htIntlOptions); instrsList.Add(istr); } else { XmlNode xnodeInvestmentWoBbg = null; XmlNode nodeInvestmentAttributeWoBbg = null; xnodeInvestmentWoBbg = xdocNewInvestmentDataNoBbg.CreateElement("Investment"); nodeInvestmentAttributeWoBbg = xdocNewInvestmentDataNoBbg.CreateElement("Investment"); //nodeInvestmentAttributeWoBbg.InnerXml = dr["Investment"].ToString(); nodeInvestmentAttributeWoBbg.InnerXml = dr[InvestmentField].ToString(); xnodeInvestmentWoBbg.AppendChild(nodeInvestmentAttributeWoBbg); nodeInvestmentAttributeWoBbg = xdocNewInvestmentDataNoBbg.CreateElement("SourceInvestment"); if (sourceInvestments.ContainsKey(dr["Investment"].ToString())) nodeInvestmentAttributeWoBbg.InnerXml = sourceInvestments[dr["Investment"].ToString()]; else nodeInvestmentAttributeWoBbg.InnerXml = dr["Investment"].ToString(); xnodeInvestmentWoBbg.AppendChild(nodeInvestmentAttributeWoBbg); XmlNode sourceInvestmentTypeNode = xdocNewInvestmentDataNoBbg.CreateElement("SourceInvestmentType"); DataRow[] drKickoutRows = dtKickouts.Select("SourceInvestment='" + nodeInvestmentAttributeWoBbg.InnerXml + "'"); if (drKickoutRows.Length > 0) sourceInvestmentTypeNode.InnerXml = drKickoutRows[0]["SourceInvestmentType"].ToString(); xnodeInvestmentWoBbg.AppendChild(sourceInvestmentTypeNode); //foreach(DataColumn dc in dr.Table.Columns) // if (dc.ColumnName != "Investment") // { // xnodeInvestmentWoBbg = xdocNewInvestmentData.CreateElement(dc.ColumnName); // xnodeInvestmentWoBbg.InnerXml = dr[dc.ColumnName].ToString(); // xnodeInvestmentWoBbg.AppendChild(xnodeInvestmentWoBbg); // } //set up investment node(s) for GV load BuildGenevaInvestment(jobKeyCode, dtKickouts, xdocNewInvestmentDataNoBbg, ref xnodeInvestmentWoBbg, assetTypes, htIntlOptions); //add to list of new investments xdocNewInvestmentDataNoBbg.SelectSingleNode("//InvestmentRecords").AppendChild(xnodeInvestmentWoBbg); } } instrs.instrument = instrsList.ToArray(); } catch (Exception ex) { log.ErrorFormat(jobKeyCode,"{0}", ex); log.ErrorFormat(jobKeyCode,"{0}", ex.StackTrace); } #endregion #region submit request SubmitGetDataRequest sbmtGtDtreq = new SubmitGetDataRequest(); sbmtGtDtreq.headers = getDataHeaders; sbmtGtDtreq.fields = fields; sbmtGtDtreq.instruments = instrs; #region unused //Instrument bbUniqueId = new Instrument(); //bbUniqueId.id = "GB0003252318"; //bbUniqueId.type = InstrumentType.ISIN; //bbUniqueId.typeSpecified = true; //Setting the get data request parameter // SubmitGetDataRequest sbmtGtDtreq = new SubmitGetDataRequest(); // sbmtGtDtreq.headers = getDataHeaders; // sbmtGtDtreq.fields = new string[] { "ID_BB_UNIQUE", "TICKER", "PX_LAST", "PX_ASK", "PX_BID", "VWAP_DT" }; // sbmtGtDtreq.fields = new string[] { "ID_BB_UNIQUE", "PX_LAST"}; // Instruments instrs = new Instruments(); // System.Collections.Generic.List<Instrument> instrsList = new System.Collections.Generic.List<Instrument>(); // instrsList.Add(ticker); // instrsList.Add(bbUniqueId); //instrs.instrument = new Instrument[] { ticker, bbUniqueId }; // instrs.instrument = new Instrument[] {bbUniqueId }; // sbmtGtDtreq.instruments = new Instruments(); // sbmtGtDtreq.instruments = instrs; #endregion XmlNode xnodeInvestment = null; XmlNode nodeInvestmentAttribute = null; try { log.Info(jobKeyCode, "Submit Get Data Request"); SubmitGetDataResponse sbmtGtDtresp = ps.submitGetDataRequest(sbmtGtDtreq); log.Info(jobKeyCode, "status " + sbmtGtDtresp.statusCode.description); log.Info(jobKeyCode, "Submit Get Data request - response ID = " + sbmtGtDtresp.responseId); //retrieve get data request. The response ID sent for the request is the response ID //received from SubmitGetDataRequest() log.Info(jobKeyCode, "Retrieve data request"); RetrieveGetDataRequest rtrvGtDrReq = new RetrieveGetDataRequest(); rtrvGtDrReq.responseId = sbmtGtDtresp.responseId; RetrieveGetDataResponse rtrvGtDrResp = new RetrieveGetDataResponse(); //Keep sending the request if status is 100, up to 10 mins DateTime dtStart = DateTime.Now; do { System.Threading.Thread.Sleep(Bits.ModulesNS.SecMasterDataRetrieveHeavy.POLL_INTERVAL); rtrvGtDrResp = ps.retrieveGetDataResponse(rtrvGtDrReq); if (dtStart.AddMinutes(10) < DateTime.Now) throw new Exception("Timeout exceeded. Bloomberg DLWS unavailable."); } while (rtrvGtDrResp.statusCode.code == Bits.ModulesNS.SecMasterDataRetrieveHeavy.DATA_NOT_AVAILABLE); #endregion #region process response if (rtrvGtDrResp.statusCode.code == Bits.ModulesNS.SecMasterDataRetrieveHeavy.SUCCESS) { //BAMSym back conversion if (dtKickouts.Columns.Contains("Symbol") && dtKickouts.Select("Symbol<>Investment").Length > 0) { foreach(DataRow drBamSym in dtKickouts.Select("Symbol<>Investment")) { for (int i = 0; i < rtrvGtDrResp.instrumentDatas.Length; i++) { if (rtrvGtDrResp.instrumentDatas[i].instrument.id.ToString().ToUpper() == drBamSym["Symbol"].ToString().ToUpper() && rtrvGtDrResp.instrumentDatas[i].instrument.yellowkey.ToString().ToUpper() == drBamSym["FeedSymbol"].ToString().ToUpper()) { rtrvGtDrResp.instrumentDatas[i].instrument.id =drBamSym["Investment"].ToString(); } } } } //Displaying and building the output for RetrieveGetDataResponse for (int i = 0; i < rtrvGtDrResp.instrumentDatas.Length; i++) { //prepare new investment xnodeInvestment = xdocNewInvestmentData.CreateElement("Investment"); log.Info(jobKeyCode, "Data for :" + rtrvGtDrResp.instrumentDatas[i].instrument.id + " " + rtrvGtDrResp.instrumentDatas[i].instrument.yellowkey); //add all request fields to investment node nodeInvestmentAttribute = xdocNewInvestmentData.CreateElement("Investment"); nodeInvestmentAttribute.InnerXml = rtrvGtDrResp.instrumentDatas[i].instrument.id; xnodeInvestment.AppendChild(nodeInvestmentAttribute); nodeInvestmentAttribute = xdocNewInvestmentData.CreateElement("SourceInvestment"); if (sourceInvestments.ContainsKey(rtrvGtDrResp.instrumentDatas[i].instrument.id)) nodeInvestmentAttribute.InnerXml = sourceInvestments[rtrvGtDrResp.instrumentDatas[i].instrument.id]; else nodeInvestmentAttribute.InnerXml = rtrvGtDrResp.instrumentDatas[i].instrument.id; xnodeInvestment.AppendChild(nodeInvestmentAttribute); XmlNode sourceInvestmentTypeNode = xdocNewInvestmentData.CreateElement("SourceInvestmentType"); DataRow[] drKickoutRows = dtKickouts.Select("SourceInvestment='" + nodeInvestmentAttribute.InnerXml + "'"); if (drKickoutRows.Length > 0) sourceInvestmentTypeNode.InnerXml = drKickoutRows[0]["SourceInvestmentType"].ToString(); xnodeInvestment.AppendChild(sourceInvestmentTypeNode); //accumulate bbg response data for investment for (int j = 0; j < rtrvGtDrResp.instrumentDatas[i].data.Length; j++) { if (rtrvGtDrResp.instrumentDatas[i].data[j].isArray == true) { //In case this is a bulk field request for (int k = 0; k < rtrvGtDrResp.instrumentDatas[i].data[j].bulkarray.Length; k++) { log.Info(jobKeyCode, "-------------------------"); for (int l = 0; l < rtrvGtDrResp.instrumentDatas[i].data[j]. bulkarray[k].data.Length; l++) log.Info(jobKeyCode, rtrvGtDrResp. instrumentDatas[i].data[j].bulkarray[k].data[l].value); } } else { nodeInvestmentAttribute = xdocNewInvestmentData.CreateElement(sbmtGtDtreq.fields[j]); nodeInvestmentAttribute.InnerText = rtrvGtDrResp.instrumentDatas[i].data[j].value; xnodeInvestment.AppendChild(nodeInvestmentAttribute); log.Info(jobKeyCode, " " + sbmtGtDtreq.fields[j] + " : " + rtrvGtDrResp.instrumentDatas[i].data[j].value); } } //set up investment node(s) for GV load BuildGenevaInvestment(jobKeyCode, dtKickouts, xdocNewInvestmentData, ref xnodeInvestment, assetTypes, htIntlOptions); //add to list of new investments xdocNewInvestmentData.SelectSingleNode("//InvestmentRecords").AppendChild(xnodeInvestment); } } else if (rtrvGtDrResp.statusCode.code == Bits.ModulesNS.SecMasterDataRetrieveHeavy.REQUEST_ERROR) log.Info(jobKeyCode, "Error in the submitted request"); #endregion } catch (Exception e) { log.Info(jobKeyCode, e.Message + " " + e.StackTrace); return false; } return true; }
public void run(PerSecurityWS ps) { //Setting request header information GetCompanyHeaders gtCompHdrs = new GetCompanyHeaders(); gtCompHdrs.creditrisk = true; //Setting instruments Instrument ticker = new Instrument(); ticker.id = "AAPL US"; ticker.yellowkey = MarketSector.Equity; ticker.yellowkeySpecified = true; //Setting the get Company request parameter SubmitGetCompanyRequest sbmtGtCompReq = new SubmitGetCompanyRequest(); sbmtGtCompReq.headers = gtCompHdrs; Instruments instrs = new Instruments(); instrs.instrument = new Instrument[] { ticker }; sbmtGtCompReq.instruments = instrs; //Setting fields for the request FieldSet fieldSet = new FieldSet(); fieldSet.fieldmacro = FieldMacro.BO_CREDIT_RISK_COMPANY; sbmtGtCompReq.fieldset = fieldSet; try { Console.WriteLine("Submit Get Company Request"); SubmitGetCompanyResponse sbmtGtCompResp = ps.submitGetCompanyRequest(sbmtGtCompReq); System.Console.WriteLine("status " + sbmtGtCompResp.statusCode.description); System.Console.WriteLine("Submit Get Company request - response ID = " + sbmtGtCompResp.responseId); //retrieve get company request. The response ID sent for the request is the response ID //received from SubmitGetCompanyRequest() Console.WriteLine("Retrieve Company request"); RetrieveGetCompanyRequest rtvGrCompReq = new RetrieveGetCompanyRequest(); rtvGrCompReq.responseId = sbmtGtCompResp.responseId; RetrieveGetCompanyResponse rtrvGtCompResp = new RetrieveGetCompanyResponse(); //Keep sending the request if status is 100 do { System.Threading.Thread.Sleep(PerSecurity.POLL_INTERVAL); rtrvGtCompResp = ps.retrieveGetCompanyResponse(rtvGrCompReq); } while (rtrvGtCompResp.statusCode.code == PerSecurity.DATA_NOT_AVAILABLE); if (rtrvGtCompResp.statusCode.code == PerSecurity.SUCCESS) { //Displaying the rtrvGtCompResp for (int i = 0; i < rtrvGtCompResp.instrumentDatas.Length; i++) { Console.WriteLine("Data for :" + rtrvGtCompResp.instrumentDatas[i].instrument.id + " " + rtrvGtCompResp.instrumentDatas[i].instrument.yellowkey); for (int j = 0; j < rtrvGtCompResp.instrumentDatas[i].data.Length; j++) { if (rtrvGtCompResp.instrumentDatas[i].data[j].isArray == true) { //In case this is a bulk field request for (int k = 0; k < rtrvGtCompResp.instrumentDatas[i].data[j].bulkarray.Length; k++) { Console.WriteLine("-------------------------_"); for (int l = 0; l < rtrvGtCompResp.instrumentDatas[i].data[j]. bulkarray[k].data.Length; l++) Console.WriteLine(rtrvGtCompResp.instrumentDatas[i].data[j].bulkarray[k].data[l].value); } } else Console.WriteLine(" " + rtrvGtCompResp.fields[j] + " : " + rtrvGtCompResp.instrumentDatas[i].data[j].value); } } } else if (rtrvGtCompResp.statusCode.code == PerSecurity.REQUEST_ERROR) Console.WriteLine("Error in the submitted request"); } catch (Exception e) { Console.WriteLine(e.Message); } }
public void run(PerSecurityWS ps) { //Setting request headers GetHistoryHeaders getHistHeaders = new GetHistoryHeaders(); DateRange dtRange = new DateRange(); dtRange.period = new Period(); dtRange.period.start = DateTime.Today.Subtract(TimeSpan.FromDays(7)); dtRange.period.end = DateTime.Today; getHistHeaders.daterange = dtRange; getHistHeaders.version = SecMasterDataRetrieveHeavy.BbgDlwsHeavyWS.Version.@new; //Setting instruments Instrument ticker = new Instrument(); ticker = new Instrument(); ticker.id = "IBM US"; ticker.yellowkey = MarketSector.Equity; ticker.yellowkeySpecified = true; Instrument bbUniqueId = new Instrument(); bbUniqueId.id = "EQ0086119600001000"; bbUniqueId.yellowkeySpecified = true; bbUniqueId.yellowkey = MarketSector.Equity; bbUniqueId.type = InstrumentType.BB_UNIQUE; bbUniqueId.typeSpecified = true; Instrument[] instr = new Instrument[]{ticker, bbUniqueId}; Instruments instrs = new Instruments(); instrs.instrument = instr; //Setting get history request parameters string[] fields = new string[] {"PX_LAST","PX_HIGH","PX_LOW" }; SubmitGetHistoryRequest sbmtGtHistReq = new SubmitGetHistoryRequest(); sbmtGtHistReq.headers = getHistHeaders; sbmtGtHistReq.instruments = instrs; sbmtGtHistReq.fields = fields; try { Console.WriteLine("Submit Get History request"); SubmitGetHistoryResponse sbmtGtHistResp = ps.submitGetHistoryRequest(sbmtGtHistReq); System.Console.WriteLine("status " + sbmtGtHistResp.statusCode.description); System.Console.WriteLine("Submit Get Data request - response ID = " + sbmtGtHistResp.responseId); Console.WriteLine("Retrieve data request"); RetrieveGetHistoryRequest rtrvGtHistReq = new RetrieveGetHistoryRequest(); rtrvGtHistReq.responseId = sbmtGtHistResp.responseId; RetrieveGetHistoryResponse rtrvGtHistResp = new RetrieveGetHistoryResponse(); //Keep sending the request until status code is "0"(success) do { System.Threading.Thread.Sleep(PerSecurity.POLL_INTERVAL); rtrvGtHistResp = ps.retrieveGetHistoryResponse(rtrvGtHistReq); } while (rtrvGtHistResp.statusCode.code== PerSecurity.DATA_NOT_AVAILABLE ); //Displaying data if (rtrvGtHistResp.statusCode.code == PerSecurity.SUCCESS) { for (int i = 0; i < rtrvGtHistResp.instrumentDatas.Length; i++) { System.Console.WriteLine("Data for :" + rtrvGtHistResp.instrumentDatas[i].instrument.id + " " + rtrvGtHistResp.instrumentDatas[i].instrument.yellowkey); Console.WriteLine(rtrvGtHistResp.instrumentDatas[i].date.ToString()); for (int j = 0; j < rtrvGtHistResp.instrumentDatas[i].data.Length; j++) { Console.WriteLine(sbmtGtHistReq.fields[j] + " : " + rtrvGtHistResp. instrumentDatas[i].data[j].value); } } } else if (rtrvGtHistResp.statusCode.code == PerSecurity.REQUEST_ERROR) { Console.WriteLine("Error in the submitted request"); } } catch (Exception e) { Console.WriteLine(e.Message); } }
public void run(PerSecurityWS ps) { try { //Setting headers GetDataHeaders getDataHeaders = new GetDataHeaders(); getDataHeaders.programflag = ProgramFlag.daily; getDataHeaders.secmaster = true; getDataHeaders.derived = true; //Setting Instrument information Instrument bbUniqueId = new Instrument(); bbUniqueId.id = "EQ0086119600001000"; bbUniqueId.type = InstrumentType.BB_UNIQUE; bbUniqueId.typeSpecified = true; Instrument ticker = new Instrument(); ticker.id = "IBM"; ticker.yellowkey = MarketSector.Equity; ticker.yellowkeySpecified = true; ticker.type = InstrumentType.TICKER; ticker.typeSpecified = true; Instruments instrs1 = new Instruments(); instrs1.instrument = new Instrument[] { ticker }; Instruments instrs2 = new Instruments(); instrs2.instrument = new Instrument[] { bbUniqueId }; SubmitGetDataRequest sbmtGtDtReq1 = new SubmitGetDataRequest(); sbmtGtDtReq1.headers = getDataHeaders; sbmtGtDtReq1.fields = new string[] { "PX_LAST" }; sbmtGtDtReq1.instruments = instrs1; SubmitGetDataRequest sbmtGtDtReq2 = new SubmitGetDataRequest(); sbmtGtDtReq2.headers = getDataHeaders; sbmtGtDtReq2.fields = new string[] { "PX_LAST" }; sbmtGtDtReq2.instruments = instrs2; SubmitGetDataResponse sbmtGtDtResp1 = ps.submitGetDataRequest(sbmtGtDtReq1); SubmitGetDataResponse sbmtGtDtResp2 = ps.submitGetDataRequest(sbmtGtDtReq1); Console.WriteLine("Scheduled Req 1 GetData --> " + sbmtGtDtResp1.responseId); Console.WriteLine("Scheduled Req 2 GetData --> " + sbmtGtDtResp2.responseId); System.Threading.Thread.Sleep(30000); SubmitCancelRequest submitCancelRequest = new SubmitCancelRequest(); Console.WriteLine("Sending submit cancel request"); CancelHeaders cancelHeaders = new CancelHeaders(); cancelHeaders.programflag = ProgramFlag.monthly; submitCancelRequest.headers = cancelHeaders; String[] responseIds = { sbmtGtDtResp1.responseId, sbmtGtDtResp2.responseId, "dummy_id.out" }; submitCancelRequest.responseId = responseIds; SubmitCancelResponse submitCancelResponse = ps.submitCancelRequest(submitCancelRequest); Console.WriteLine("Submit cancel request status: " + submitCancelResponse.statusCode.description + " responseId: " + submitCancelResponse.responseId); do { System.Threading.Thread.Sleep(PerSecurity.POLL_INTERVAL); submitCancelResponse = ps.submitCancelRequest(submitCancelRequest); } while (submitCancelResponse.statusCode.code == PerSecurity.DATA_NOT_AVAILABLE); RetrieveCancelRequest rreq = new RetrieveCancelRequest(); rreq.responseId = submitCancelResponse.responseId; RetrieveCancelResponse retrieveCancelResponse = ps.retrieveCancelResponse(rreq); Console.WriteLine("Sending retrieve cancel request"); // Keep polling for response till the data is available do { System.Threading.Thread.Sleep(PerSecurity.POLL_INTERVAL); retrieveCancelResponse = ps.retrieveCancelResponse(rreq); } while (retrieveCancelResponse.statusCode.code == PerSecurity.DATA_NOT_AVAILABLE); // Display data if (retrieveCancelResponse.statusCode.code == PerSecurity.SUCCESS) { Console.WriteLine("Retrieve cancel request successful."); CancelResponseStatus[] ls = retrieveCancelResponse.cancelResponseStatus; for (int i = 0; i < ls.Length; i++) { Console.WriteLine("The cancel status for response id :" + ls[i].responseId + " is " + ls[i].cancelStatus.ToString()); } } else if (retrieveCancelResponse.statusCode.code == PerSecurity.REQUEST_ERROR) Console.WriteLine("Error in submitted request"); } catch (Exception e) { Console.WriteLine(e.Message); } }
public void run(PerSecurityWS ps) { try { //Setting request headers GetHistoryHeaders getHistHeaders = new GetHistoryHeaders(); getHistHeaders.display_pricing_srcSpecified = true; getHistHeaders.display_pricing_src = true; Instrument ticker = new Instrument(); ticker = new Instrument(); ticker.id = "IBM"; ticker.yellowkey = MarketSector.Equity; ticker.yellowkeySpecified = true; Instrument[] instr = new Instrument[] { ticker }; Instruments instrs = new Instruments(); instrs.instrument = instr; string[] fields = new string[] { "PX_LAST" }; SubmitGetHistoryRequest sbmtGtHistReq = new SubmitGetHistoryRequest(); sbmtGtHistReq.headers = getHistHeaders; sbmtGtHistReq.instruments = instrs; sbmtGtHistReq.fields = fields; Console.WriteLine("Submit Get History request"); SubmitGetHistoryResponse sbmtGtHistResp = ps.submitGetHistoryRequest(sbmtGtHistReq); System.Console.WriteLine("status " + sbmtGtHistResp.statusCode.description); System.Console.WriteLine("Submit Get Data request - response ID = " + sbmtGtHistResp.responseId); Console.WriteLine("Retrieve data request"); RetrieveGetHistoryRequest rtrvGtHistReq = new RetrieveGetHistoryRequest(); rtrvGtHistReq.responseId = sbmtGtHistResp.responseId; RetrieveGetHistoryResponse rtrvGtHistResp = new RetrieveGetHistoryResponse(); //Keep sending the request until status code is "0"(success) do { System.Threading.Thread.Sleep(PerSecurity.POLL_INTERVAL); rtrvGtHistResp = ps.retrieveGetHistoryResponse(rtrvGtHistReq); } while (rtrvGtHistResp.statusCode.code == PerSecurity.DATA_NOT_AVAILABLE); //Displaying data if (rtrvGtHistResp.statusCode.code == PerSecurity.SUCCESS) { for (int i = 0; i < rtrvGtHistResp.instrumentDatas.Length; i++) { System.Console.WriteLine("Data for :" + rtrvGtHistResp.instrumentDatas[i].instrument.id + " " + rtrvGtHistResp.instrumentDatas[i].instrument.yellowkey); Console.WriteLine("Date: " + rtrvGtHistResp.instrumentDatas[i].date.ToString()); Console.WriteLine("Pricing Source: " + rtrvGtHistResp.instrumentDatas[i].pricingSource); for (int j = 0; j < rtrvGtHistResp.instrumentDatas[i].data.Length; j++) { Console.WriteLine(sbmtGtHistReq.fields[j] + " : " + rtrvGtHistResp. instrumentDatas[i].data[j].value); } } } else if (rtrvGtHistResp.statusCode.code == PerSecurity.REQUEST_ERROR) { Console.WriteLine("Error in the submitted request"); } } catch (Exception e) { Console.WriteLine(e.Message + e.StackTrace); } }
public void run(PerSecurityWS ps) { try { //Setting request header information GetDataHeaders getDataHdrs = new GetDataHeaders(); getDataHdrs.secmasterSpecified = true; getDataHdrs.secmaster = true; //Setting instruments for request Instruments instrs = new Instruments(); instrs.macro = new Macro[2]; instrs.macro[0] = new Macro(); instrs.macro[0].primaryQualifier = new PrimaryQualifier(); instrs.macro[0].primaryQualifier.primaryQualifierType = MacroType.SECTYP; instrs.macro[0].primaryQualifier.primaryQualifierValue = "OPT_CHAIN"; instrs.macro[0].secondaryQualifier = new SecondaryQualifier[1]; instrs.macro[0].secondaryQualifier[0] = new SecondaryQualifier(); instrs.macro[0].secondaryQualifier[0].secondaryQualifierOperator = SecondaryQualifierOperator.Equals; instrs.macro[0].secondaryQualifier[0].secondaryQualifierType = SecondaryQualifierType.SECURITY_DES; instrs.macro[0].secondaryQualifier[0].secondaryQualifierValue = "SPX Index"; instrs.macro[0].overrides = new Override[1]; //A sample of incorrect macro instrs.macro[1] = new Macro(); instrs.macro[1].primaryQualifier = new PrimaryQualifier(); instrs.macro[1].primaryQualifier.primaryQualifierType = MacroType.SECTYP; instrs.macro[1].primaryQualifier.primaryQualifierValue = "OPTCHAIN"; instrs.macro[1].secondaryQualifier = new SecondaryQualifier[1]; instrs.macro[1].secondaryQualifier[0] = new SecondaryQualifier(); instrs.macro[1].secondaryQualifier[0].secondaryQualifierOperator = SecondaryQualifierOperator.Equals; instrs.macro[1].secondaryQualifier[0].secondaryQualifierType = SecondaryQualifierType.SECURITY_DES; instrs.macro[1].secondaryQualifier[0].secondaryQualifierValue = "SPX Index"; //Setting fields for the request string[] field = new string[] { "NAME", "TICKER", "PX_LAST" }; //Submit get data request Console.WriteLine("Sending submit get data request"); SubmitGetDataRequest sbmtGtDtreq = new SubmitGetDataRequest(); sbmtGtDtreq.headers = getDataHdrs; sbmtGtDtreq.fields = field; sbmtGtDtreq.instruments = instrs; SubmitGetDataResponse sbmtGtDtresp = ps.submitGetDataRequest(sbmtGtDtreq); System.Console.WriteLine("status " + sbmtGtDtresp.statusCode.description); System.Console.WriteLine("Submit Get Data request - response ID = " + sbmtGtDtresp.responseId); //retrieve get data request. The response ID sent for the request is the response ID //received from SubmitGetDataRequest() Console.WriteLine("Retrieve data request"); RetrieveGetDataRequest rtrvGtDrReq = new RetrieveGetDataRequest(); rtrvGtDrReq.responseId = sbmtGtDtresp.responseId; RetrieveGetDataResponse rtrvGtDrResp = new RetrieveGetDataResponse(); //Keep sending the request until status code is "0"(success) do { System.Threading.Thread.Sleep(PerSecurity.POLL_INTERVAL); rtrvGtDrResp = ps.retrieveGetDataResponse(rtrvGtDrReq); } while (rtrvGtDrResp.statusCode.code == PerSecurity.DATA_NOT_AVAILABLE); if (rtrvGtDrResp.statusCode.code == PerSecurity.SUCCESS) { Console.WriteLine("Retrieve get data request successful"); for (int i = 0; i < rtrvGtDrResp.instrumentDatas.Length; i++) { if (rtrvGtDrResp.instrumentDatas[i].code.Equals("0")) { System.Console.WriteLine("Data for :" + rtrvGtDrResp.instrumentDatas[i].instrument.id + " " + rtrvGtDrResp.instrumentDatas[i].instrument.yellowkey); for (int j = 0; j < rtrvGtDrResp.instrumentDatas[i].data.Length; j++) { if (rtrvGtDrResp.instrumentDatas[i].data[j].isArray == true) { //In case this is a bulk field request for (int k = 0; k < rtrvGtDrResp.instrumentDatas[i].data[j]. bulkarray.Length; k++) { Console.WriteLine("-------------------------"); for (int l = 0; l < rtrvGtDrResp.instrumentDatas[i].data[j]. bulkarray[k].data.Length; l++) Console.WriteLine(rtrvGtDrResp.instrumentDatas[i].data[j] .bulkarray[k].data[l].value); } } else System.Console.WriteLine(" " + sbmtGtDtreq.fields[j] + " : " + rtrvGtDrResp.instrumentDatas[i].data[j].value); } } //If an incorrect macro was passed in the request, display the error code and the incorrect macro else { System.Console.WriteLine("\n Error Code " + rtrvGtDrResp.instrumentDatas[i].code + ": incorrect macro. The Macro object is as follows:"); Console.WriteLine("Primary Qualifier -"); Console.WriteLine("Primary Qualifier type:" + rtrvGtDrResp.instrumentDatas[i]. macro.primaryQualifier.primaryQualifierType); Console.WriteLine("Primary Qualifier value:" + rtrvGtDrResp.instrumentDatas[i]. macro.primaryQualifier.primaryQualifierValue); Console.WriteLine("Secondary Qualifier -"); for (int l = 0; l < rtrvGtDrResp.instrumentDatas[i].macro.secondaryQualifier.Length; l++) { Console.WriteLine("Secondary Qualifier type :" + rtrvGtDrResp.instrumentDatas[i]. macro.secondaryQualifier[l].secondaryQualifierType); Console.WriteLine("Secondary Qualifier Value :" + rtrvGtDrResp.instrumentDatas[i]. macro.secondaryQualifier[l].secondaryQualifierValue); Console.WriteLine("Secondary Qualifier Operator :" + rtrvGtDrResp.instrumentDatas[i]. macro.secondaryQualifier[l].secondaryQualifierOperator); } } } } else if (rtrvGtDrResp.statusCode.code == PerSecurity.REQUEST_ERROR) Console.WriteLine("Error in the submitted request"); } catch (Exception e) { Console.WriteLine(e.Message + " " + e.StackTrace); } }
public void run(PerSecurityWS ps) { try{ // Setting headers for the request GetDataHeaders getDataHeaders = new GetDataHeaders(); getDataHeaders.closingvaluesSpecified = true; getDataHeaders.closingvalues = true; getDataHeaders.secmasterSpecified = true; getDataHeaders.secmaster = true; getDataHeaders.derivedSpecified = true; getDataHeaders.derived = true; // Setting list of instruments for data request Instrument ticker = new Instrument(); ticker = new Instrument(); ticker.id = "IBM US"; ticker.type= InstrumentType.TICKER; ticker.yellowkey = MarketSector.Equity; Instrument[] instr = new Instrument[] { ticker }; String[] field = new String[] { "ID_BB_UNIQUE", "TICKER", "PX_LAST", "PX_ASK", "PX_BID", "VWAP_DT" }; BvalFieldSet fieldset = new BvalFieldSet(); fieldset.fieldmacro = BvalFieldMacro.BVAL_BOND; // Submit get data request SubmitGetDataRequest sbmtGetDtReq = new SubmitGetDataRequest(); sbmtGetDtReq.headers = getDataHeaders; sbmtGetDtReq.fields = field; sbmtGetDtReq.fieldsets = new BvalFieldSet[] { fieldset }; Instruments instrmnts = new Instruments(); instrmnts.instrument = instr; sbmtGetDtReq.instruments = instrmnts ; Console.WriteLine("Sending submit get data request"); SubmitGetDataResponse sbmtGetDtResp = ps .submitGetDataRequest(sbmtGetDtReq); Console.WriteLine("Submit get data request status: " + sbmtGetDtResp.statusCode.description + " responseId: " + sbmtGetDtResp.responseId); // Submit retrieve data RetrieveGetDataRequest rtvGetDtReq = new RetrieveGetDataRequest(); rtvGetDtReq.responseId = sbmtGetDtResp.responseId; RetrieveGetDataResponse rtvGetDtResp = new RetrieveGetDataResponse(); Console.WriteLine("Sending retrieve get data request"); // Keep polling for response till the data is available do { System.Threading.Thread.Sleep(PerSecurity.POLL_INTERVAL); rtvGetDtResp = ps.retrieveGetDataResponse(rtvGetDtReq); } while (rtvGetDtResp.statusCode.code == PerSecurity.DATA_NOT_AVAILABLE); // Display data if (rtvGetDtResp.statusCode.code == PerSecurity.SUCCESS) { Console.WriteLine("Retrieve get data request successful. Response ID:" + rtvGetDtResp.responseId); for (int i = 0; i < rtvGetDtResp.instrumentDatas.Length; i++) { Console.WriteLine("Data for :" + rtvGetDtResp.instrumentDatas[i].instrument.id + " " + rtvGetDtResp.instrumentDatas[i].instrument.yellowkey); for (int j = 0; j < rtvGetDtResp.instrumentDatas[i].data.Length; j++) { Console.WriteLine(" " + rtvGetDtResp.fields[j] + ": " + rtvGetDtResp.instrumentDatas[i].data[j].value); } } } else if (rtvGetDtResp.statusCode.code == PerSecurity.REQUEST_ERROR) Console.WriteLine("Error in submitted request"); } catch (Exception e) { Console.WriteLine(e.Message); } }