コード例 #1
0
ファイル: GetFundsRequest.cs プロジェクト: BrianGoff/BITS
        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);
            }
        }
コード例 #2
0
ファイル: Reference.cs プロジェクト: BrianGoff/BITS
 /// <remarks/>
 public void submitGetDataRequestAsync(SubmitGetDataRequest submitGetDataRequest1) {
     this.submitGetDataRequestAsync(submitGetDataRequest1, null);
 }
コード例 #3
0
ファイル: Reference.cs プロジェクト: BrianGoff/BITS
 /// <remarks/>
 public void submitGetDataRequestAsync(SubmitGetDataRequest submitGetDataRequest1, object userState) {
     if ((this.submitGetDataRequestOperationCompleted == null)) {
         this.submitGetDataRequestOperationCompleted = new System.Threading.SendOrPostCallback(this.OnsubmitGetDataRequestOperationCompleted);
     }
     this.InvokeAsync("submitGetDataRequest", new object[] {
                 submitGetDataRequest1}, this.submitGetDataRequestOperationCompleted, userState);
 }
コード例 #4
0
        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);
            }
        }
コード例 #5
0
ファイル: BulkRequest.cs プロジェクト: BrianGoff/BITS
		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);
			}
		}
コード例 #6
0
ファイル: ScheduledRequest.cs プロジェクト: BrianGoff/BITS
		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);
			}

			
		}
コード例 #7
0
        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;
        }
コード例 #8
0
ファイル: CancelAllRequest.cs プロジェクト: BrianGoff/BITS
        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);
            }
        }
コード例 #9
0
ファイル: GetDataMacroRequest.cs プロジェクト: BrianGoff/BITS
        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);
            }
        }
コード例 #10
0
        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);
		}
        }