Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        public void run(PerSecurityWS ps)
        {
            try
            {
                //Setting request header information
                GetFundamentalsHeaders getFundsHdrs = new GetFundamentalsHeaders();
                DateTime start = new DateTime(2008, 1, 1);
                DateTime end = DateTime.Today;
                getFundsHdrs.daterange = new DateRange();
                getFundsHdrs.daterange.period = new Period();
                getFundsHdrs.daterange.period.start = start;
                getFundsHdrs.daterange.period.end = end;
                getFundsHdrs.periodicity = Periodicity.a;

                

                //Setting instruments for request
                FundInstrument ticker = new FundInstrument();
                ticker.id = "JPM US";
                ticker.yellowkey = MarketSector.Equity;
                ticker.yellowkeySpecified = true;
                ticker.type = InstrumentType.TICKER;
                ticker.typeSpecified = true;

                FundInstruments instrs = new FundInstruments();
                instrs.instrument = new FundInstrument[] { ticker};

                //Setting fields for the request
                string[] field = new string[] { "FISCAL_YEAR_PERIOD", "LATEST_PERIOD_END_DT_FULL_RECORD","NET_REV"};

                //Submit get data request
                Console.WriteLine("Sending get Fundamentals request");
                SubmitGetFundamentalsRequest sbmtGtFundsReq = new SubmitGetFundamentalsRequest();
                sbmtGtFundsReq.headers = getFundsHdrs;
                sbmtGtFundsReq.fields = field;
                sbmtGtFundsReq.instruments = instrs;

                SubmitGetFundamentalsResponse sbmtGtFundsResp = ps.submitGetFundamentalsRequest(sbmtGtFundsReq);
                System.Console.WriteLine("status " + sbmtGtFundsResp.statusCode.description);
                System.Console.WriteLine("Submit Get Fundamentals request -  response ID = " + sbmtGtFundsResp.responseId);

                //retrieve get data request. The response ID sent for the request is the response ID
                //received from SubmitGetDataRequest()

                Console.WriteLine("Retrieve Fundamentals request");
                RetrieveGetFundamentalsRequest rtrvGtFundsReq = new RetrieveGetFundamentalsRequest();
                rtrvGtFundsReq.responseId = sbmtGtFundsResp.responseId;
                RetrieveGetFundamentalsResponse rtrvGtFundsResp = new RetrieveGetFundamentalsResponse();

                //Keep sending the request until status code is "0"(success)
                do
                {
                    System.Threading.Thread.Sleep(PerSecurity.POLL_INTERVAL);
                    rtrvGtFundsResp = ps.retrieveGetFundamentalsResponse(rtrvGtFundsReq);
                }
                while (rtrvGtFundsResp.statusCode.code == PerSecurity.DATA_NOT_AVAILABLE);

                if (rtrvGtFundsResp.statusCode.code == PerSecurity.SUCCESS)
                {
                    Console.WriteLine("Retrieve get data request successful");
                    for (int i = 0; i < rtrvGtFundsResp.instrumentDatas.Length; i++)
                    {
                        if (rtrvGtFundsResp.instrumentDatas[i].code.Equals("0"))
                        {
                            System.Console.WriteLine("Data for :" + rtrvGtFundsResp.instrumentDatas[i].instrument.id +
                                "  " + rtrvGtFundsResp.instrumentDatas[i].instrument.yellowkey);
                            for (int j = 0; j < rtrvGtFundsResp.instrumentDatas[i].data.Length; j++)
                            {
                                if (rtrvGtFundsResp.instrumentDatas[i].data[j].isArray == true)
                                {
                                    //In case this is a bulk field request
                                    for (int k = 0; k < rtrvGtFundsResp.instrumentDatas[i].data[j].
                                        bulkarray.Length; k++)
                                    {
                                        Console.WriteLine("-------------------------");
                                        for (int l = 0; l < rtrvGtFundsResp.instrumentDatas[i].data[j].
                                            bulkarray[k].data.Length; l++)
                                            Console.WriteLine(rtrvGtFundsResp.instrumentDatas[i].data[j]
                                                .bulkarray[k].data[l].value);
                                    }
                                }
                                else

                                    System.Console.WriteLine("	" + sbmtGtFundsReq.fields[j] + " : " +
                                        rtrvGtFundsResp.instrumentDatas[i].data[j].value);
                            }
                        }

                    }

                }
                else if (rtrvGtFundsResp.statusCode.code == PerSecurity.REQUEST_ERROR)
                    Console.WriteLine("Error in the submitted request");
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message + "  " + e.StackTrace);
            }
        }