Exemple #1
0
        public void run(PerSecurityWS ps)
        {
            try
            {
                // Setting the instruments for request
                Instrument bbUniqueId = new Instrument();
                bbUniqueId.id = "EQ0086119600001000";
                bbUniqueId.yellowkeySpecified = false;
                bbUniqueId.type          = InstrumentType.BB_UNIQUE;
                bbUniqueId.typeSpecified = true;

                Instrument ticker = new Instrument();
                ticker.id = "IBM US";
                ticker.yellowkeySpecified = true;
                ticker.yellowkey          = MarketSector.Equity;
                ticker.typeSpecified      = false;
                ticker.type = InstrumentType.TICKER;

                // Setting request header
                GetDataHeaders getDataHeaders = new GetDataHeaders();
                getDataHeaders.secmaster              = true;
                getDataHeaders.secmasterSpecified     = true;
                getDataHeaders.closingvalues          = true;
                getDataHeaders.closingvaluesSpecified = true;
                getDataHeaders.programflagSpecified   = true;
                getDataHeaders.programflag            = ProgramFlag.daily;
                getDataHeaders.rundate             = DateTime.Today.ToString("yyyyMMdd");
                getDataHeaders.time                = "0010";
                getDataHeaders.derived             = true;
                getDataHeaders.specialchar         = SpecialChar.fraction;
                getDataHeaders.dateformat          = DateFormat.ddmmyyyy;
                getDataHeaders.dateformatSpecified = true;

                Instruments instrs = new Instruments();
                instrs.instrument = new Instrument[] { bbUniqueId, ticker };

                // Submit getdata request
                SubmitGetDataRequest sbmtGtDrReq = new SubmitGetDataRequest();
                sbmtGtDrReq.headers     = getDataHeaders;
                sbmtGtDrReq.fields      = new string[] { "ID_BB_UNIQUE", "TICKER", "PX_LAST", "PX_ASK", "PX_BID", "VWAP_DT" };
                sbmtGtDrReq.instruments = instrs;

                Console.WriteLine("Submit getdata request");

                submitGetDataRequestRequest  sbmtGtDrReqReq   = new submitGetDataRequestRequest(sbmtGtDrReq);
                submitGetDataRequestResponse sbmtGetDtReqResp = ps.submitGetDataRequest(sbmtGtDrReqReq);
                SubmitGetDataResponse        sbmtGetDtResp    = sbmtGetDtReqResp.submitGetDataResponse;

                System.Console.WriteLine("Submit getdata response Id = " + sbmtGetDtResp.responseId + "\n");

                // Submit scheduled request for the getdata request sent above
                SubmitScheduledRequest sbmtSchReq = new SubmitScheduledRequest();
                Console.WriteLine("Submit scheduled request");

                submitScheduledRequestRequest  sbmtSchReqReq  = new submitScheduledRequestRequest(sbmtSchReq);
                submitScheduledRequestResponse sbmtSchReqResp = ps.submitScheduledRequest(sbmtSchReqReq);
                SubmitScheduledResponse        sbmtSchResp    = sbmtSchReqResp.submitScheduledResponse;

                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 rtrvSchReq = new RetrieveScheduledRequest();
                rtrvSchReq.responseId = sbmtSchResp.responseId;

                retrieveScheduledResponseRequest  rtrvSchRespReq = new retrieveScheduledResponseRequest(rtrvSchReq);
                retrieveScheduledResponseResponse rtrvSchRespResp;

                RetrieveScheduledResponse rtrvSchResp;

                // Keep sending the request until the entire response is received
                do
                {
                    Console.WriteLine("Polling for scheduled request");
                    System.Threading.Thread.Sleep(PerSecurity.PollInterval);
                    rtrvSchRespResp = ps.retrieveScheduledResponse(rtrvSchRespReq);
                    rtrvSchResp     = rtrvSchRespResp.retrieveScheduledResponse;
                }while (rtrvSchResp.statusCode.code == PerSecurity.DataNotAvailable);
                Console.WriteLine(rtrvSchResp.responseId);

                for (int i = 0; i < rtrvSchResp.fileDatas.Length; i++)
                {
                    if (rtrvSchResp.fileDatas[i].responseId == sbmtGetDtResp.responseId)
                    {
                        Console.WriteLine("Response ID requested by submit getdata request: " +
                                          rtrvSchResp.fileDatas[i].responseId);
                    }
                    else
                    {
                        Console.WriteLine("Response ID: " + rtrvSchResp.fileDatas[i].responseId + "\n");
                    }

                    Console.WriteLine("Response Header for retrieve schedule request");

                    Dictionary <string, dynamic> headerRef = new Dictionary <string, dynamic>();
                    headerRef.Add("getdata", rtrvSchResp.fileDatas[i].headers.getdataHeaders);
                    headerRef.Add("gethistory", rtrvSchResp.fileDatas[i].headers.gethistoryHeaders);
                    headerRef.Add("getquotes", rtrvSchResp.fileDatas[i].headers.getquotesHeaders);
                    headerRef.Add("getallquotes", rtrvSchResp.fileDatas[i].headers.getallquotesHeaders);
                    headerRef.Add("getactions", rtrvSchResp.fileDatas[i].headers.getactionsHeaders);
                    headerRef.Add("getcompany", rtrvSchResp.fileDatas[i].headers.getcompanyHeaders);
                    headerRef.Add("getfundamentals", rtrvSchResp.fileDatas[i].headers.getfundamentalsHeaders);

                    foreach (KeyValuePair <string, dynamic> header in headerRef)
                    {
                        if (header.Value != null)
                        {
                            Console.WriteLine("ProgramName: " + header.Key);
                            Console.WriteLine("Date: " + header.Value.rundate +
                                              " Time: " + header.Value.time + " Scheduled: " +
                                              header.Value.programflag);

                            if (rtrvSchResp.fileDatas[i].fields != null)
                            {
                                Console.WriteLine("Fields");
                                for (int j = 0; j < rtrvSchResp.fileDatas[i].fields.Length; j++)
                                {
                                    Console.WriteLine(rtrvSchResp.fileDatas[i].fields[j]);
                                }
                            }

                            if (rtrvSchResp.fileDatas[i].instruments != null)
                            {
                                Console.WriteLine("Instruments");
                                for (int j = 0; j < rtrvSchResp.fileDatas[i].instruments.instrument.Length; j++)
                                {
                                    Console.WriteLine("ID: " + rtrvSchResp.fileDatas[i].instruments.instrument[j].id +
                                                      " Type: " + rtrvSchResp.fileDatas[i].instruments.instrument[j].type);
                                }
                            }
                        }
                    }
                }

                // Sending a request to cancel the request for the daily job

                CancelHeaders cancelHeaders = new CancelHeaders();
                cancelHeaders.programflag = ProgramFlag.daily;

                SubmitCancelRequest sbCancelReq = new SubmitCancelRequest();

                // use the responce id of the original multiday request submitted above.
                sbCancelReq.responseId = new string[] { sbmtGetDtResp.responseId };
                sbCancelReq.headers    = cancelHeaders;

                Console.WriteLine("Submit Cancel request");

                submitCancelRequestRequest  sbCancelReqReq  = new submitCancelRequestRequest(sbCancelReq);
                submitCancelRequestResponse sbCancelReqResp = ps.submitCancelRequest(sbCancelReqReq);
                SubmitCancelResponse        sbCancelResp    = sbCancelReqResp.submitCancelResponse;

                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
                SubmitScheduledRequest sbmtSchReqCheck = new SubmitScheduledRequest();

                Console.WriteLine("Submit scheduled request");

                submitScheduledRequestRequest  sbmtSchReqReqCheck  = new submitScheduledRequestRequest(sbmtSchReqCheck);
                submitScheduledRequestResponse sbmtSchReqRespCheck = ps.submitScheduledRequest(sbmtSchReqReqCheck);
                SubmitScheduledResponse        sbmtSchRespCheck    = sbmtSchReqRespCheck.submitScheduledResponse;

                Console.WriteLine("Submit Schedule request responseID : " + sbmtSchRespCheck.responseId + "\n");

                Console.WriteLine("Retrieve scheduled request");
                RetrieveScheduledRequest schReqCheck = new RetrieveScheduledRequest();
                schReqCheck.responseId = sbmtSchRespCheck.responseId;

                retrieveScheduledResponseRequest  schRespReqCheck = new retrieveScheduledResponseRequest(schReqCheck);
                retrieveScheduledResponseResponse schRespRespCheck;

                RetrieveScheduledResponse schRespCheck;
                int pollCnt = 0;
                do
                {
                    System.Threading.Thread.Sleep(PerSecurity.PollInterval);
                    schRespRespCheck = ps.retrieveScheduledResponse(schRespReqCheck);
                    schRespCheck     = schRespRespCheck.retrieveScheduledResponse;
                    pollCnt++;
                }while (schRespCheck.fileDatas == null && pollCnt < 5); // Keep polling for few times

                Console.WriteLine("response ID for retrieveSchedule respone: " + schRespCheck.responseId);

                bool   flag       = false;
                string dispRespId = null;
                if (schRespCheck.fileDatas != null)
                {
                    for (int i = 0; i < schRespCheck.fileDatas.Length; i++)
                    {
                        if (schRespCheck.fileDatas[i].responseId == sbmtGetDtResp.responseId)
                        {
                            flag       = true;
                            dispRespId = schRespCheck.fileDatas[i].responseId;
                            break;
                        }
                    }
                }
                if (flag)
                {
                    Console.WriteLine("The daily job with response ID: " + dispRespId +
                                      " was not cancelled successfully");
                }
                else
                {
                    Console.WriteLine("The daily job was cancelled successfully");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message + e.StackTrace);
            }
        }
Exemple #2
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);
			}

			
		}