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 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); } }