Example #1
0
		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);
			}

			
		}