Beispiel #1
0
        public void run(PerSecurity_Dotnet.PerSecurityWSDL.PerSecurityWS ps)
        {
            // Setting request headers
            GetHistoryHeaders getHistHeaders = new GetHistoryHeaders();
            DateRange         dtRange        = new DateRange();

            dtRange.period           = new Period();
            dtRange.period.start     = DateTime.Today.Subtract(TimeSpan.FromDays(7));
            dtRange.period.end       = DateTime.Today;
            getHistHeaders.daterange = dtRange;
            getHistHeaders.version   = PerSecurity_Dotnet.PerSecurityWSDL.Version.@new;

            // Setting instruments
            Instrument ticker = new Instrument();

            ticker                    = new Instrument();
            ticker.id                 = "IBM US";
            ticker.yellowkey          = MarketSector.Equity;
            ticker.yellowkeySpecified = true;

            Instrument bbUniqueId = new Instrument();

            bbUniqueId.id = "EQ0086119600001000";
            bbUniqueId.yellowkeySpecified = true;
            bbUniqueId.yellowkey          = MarketSector.Equity;
            bbUniqueId.type          = InstrumentType.BB_UNIQUE;
            bbUniqueId.typeSpecified = true;

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

            instrs.instrument = instr;

            // Setting GetHistory request parameters
            string[] fields = new string[] { "PX_LAST", "PX_HIGH", "PX_LOW" };
            SubmitGetHistoryRequest sbmtGtHistReq = new SubmitGetHistoryRequest();

            sbmtGtHistReq.headers     = getHistHeaders;
            sbmtGtHistReq.instruments = instrs;
            sbmtGtHistReq.fields      = fields;
            submitGetHistoryRequestRequest sbmtGtHistReqReq = new submitGetHistoryRequestRequest(sbmtGtHistReq);

            try
            {
                Console.WriteLine("Submit gethistory request");
                submitGetHistoryRequestResponse sbmtGtHistReqResp = ps.submitGetHistoryRequest(sbmtGtHistReqReq);
                SubmitGetHistoryResponse        sbmtGtHistResp    = sbmtGtHistReqResp.submitGetHistoryResponse;

                System.Console.WriteLine("status " + sbmtGtHistResp.statusCode.description);
                System.Console.WriteLine("Submit getdata request -  response ID = " + sbmtGtHistResp.responseId);

                Console.WriteLine("Retrieve getdata request");
                RetrieveGetHistoryRequest rtrvGtHistReq = new RetrieveGetHistoryRequest();
                rtrvGtHistReq.responseId = sbmtGtHistResp.responseId;

                retrieveGetHistoryResponseRequest  rtrvGtHistRespReq  = new retrieveGetHistoryResponseRequest(rtrvGtHistReq);
                retrieveGetHistoryResponseResponse rtrvGtHistRespResp = new retrieveGetHistoryResponseResponse();

                RetrieveGetHistoryResponse rtrvGtHistResp;

                // Keep polling until data becomes available
                do
                {
                    System.Threading.Thread.Sleep(PerSecurity.PollInterval);
                    rtrvGtHistRespResp = ps.retrieveGetHistoryResponse(rtrvGtHistRespReq);
                    rtrvGtHistResp     = rtrvGtHistRespResp.retrieveGetHistoryResponse;
                }while (rtrvGtHistResp.statusCode.code == PerSecurity.DataNotAvailable);

                // Displaying data
                if (rtrvGtHistResp.statusCode.code == PerSecurity.Success)
                {
                    for (int i = 0; i < rtrvGtHistResp.instrumentDatas.Length; i++)
                    {
                        System.Console.WriteLine("Data for :" + rtrvGtHistResp.instrumentDatas[i].instrument.id +
                                                 "  " + rtrvGtHistResp.instrumentDatas[i].instrument.yellowkey);
                        Console.WriteLine(rtrvGtHistResp.instrumentDatas[i].date.ToString());
                        for (int j = 0; j < rtrvGtHistResp.instrumentDatas[i].data.Length; j++)
                        {
                            Console.WriteLine(sbmtGtHistReq.fields[j] + " : " + rtrvGtHistResp.instrumentDatas[i].data[j].value);
                        }
                    }
                }
                else if (rtrvGtHistResp.statusCode.code == PerSecurity.RequestError)
                {
                    Console.WriteLine("Error in the submitted request");
                }
            }

            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Beispiel #2
0
        public void run(PerSecurity_Dotnet.PerSecurityWSDL.PerSecurityWS ps)
        {
            // Setting request headers
            GetHistoryHeaders getHistHeaders = new GetHistoryHeaders();
            DateRange         dtRange        = new DateRange();
            Duration          duration       = new Duration();

            duration.days            = 3;
            dtRange.duration         = duration;
            getHistHeaders.daterange = dtRange;

            // Setting instruments
            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.TICKER;
            instrs.macro[0].secondaryQualifier[0].secondaryQualifierValue    = "AMZN US Equity";

            // 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 = "converts_err";

            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.TICKER;
            instrs.macro[1].secondaryQualifier[0].secondaryQualifierValue    = "F";

            // Setting GetHistory request parameters
            string[] fields = new string[] { "PX_LAST" };
            SubmitGetHistoryRequest sbmtGtHistReq = new SubmitGetHistoryRequest();

            sbmtGtHistReq.headers     = getHistHeaders;
            sbmtGtHistReq.instruments = instrs;
            sbmtGtHistReq.fields      = fields;

            try
            {
                Console.WriteLine("Submit gethistory request");

                submitGetHistoryRequestRequest  sbmtGtHistReqReq   = new submitGetHistoryRequestRequest(sbmtGtHistReq);
                submitGetHistoryRequestResponse sbmtGtHistRespResp = ps.submitGetHistoryRequest(sbmtGtHistReqReq);
                SubmitGetHistoryResponse        sbmtGtHistResp     = sbmtGtHistRespResp.submitGetHistoryResponse;

                System.Console.WriteLine("status " + sbmtGtHistResp.statusCode.description);
                System.Console.WriteLine("Submit gethistory request -  response ID = " + sbmtGtHistResp.responseId);

                Console.WriteLine("Retrieve gethistory request");
                RetrieveGetHistoryRequest rtrvGtHistReq = new RetrieveGetHistoryRequest();
                rtrvGtHistReq.responseId = sbmtGtHistResp.responseId;

                retrieveGetHistoryResponseRequest  rtrvGtHistRespReq = new retrieveGetHistoryResponseRequest(rtrvGtHistReq);
                retrieveGetHistoryResponseResponse rtrvGtHistRespResp;

                RetrieveGetHistoryResponse rtrvGtHistResp;

                // keep polling until data becomes available
                do
                {
                    System.Threading.Thread.Sleep(PerSecurity.PollInterval);

                    rtrvGtHistRespResp = ps.retrieveGetHistoryResponse(rtrvGtHistRespReq);
                    rtrvGtHistResp     = rtrvGtHistRespResp.retrieveGetHistoryResponse;
                }while (rtrvGtHistResp.statusCode.code == PerSecurity.DataNotAvailable);

                // Displaying data
                if (rtrvGtHistResp.statusCode.code == PerSecurity.Success)
                {
                    for (int i = 0; i < rtrvGtHistResp.instrumentDatas.Length; i++)
                    {
                        if (rtrvGtHistResp.instrumentDatas[i].code.Equals("0"))
                        {
                            System.Console.WriteLine("Data for :" + rtrvGtHistResp.instrumentDatas[i].instrument.id +
                                                     "  " + rtrvGtHistResp.instrumentDatas[i].instrument.yellowkey);
                            Console.WriteLine(rtrvGtHistResp.instrumentDatas[i].date.ToString());
                            for (int j = 0; j < rtrvGtHistResp.instrumentDatas[i].data.Length; j++)
                            {
                                Console.WriteLine(sbmtGtHistReq.fields[j] + " : " + rtrvGtHistResp.
                                                  instrumentDatas[i].data[j].value);
                            }
                        }
                        else
                        {
                            System.Console.WriteLine("\nError Code " + rtrvGtHistResp.instrumentDatas[i].code + ": incorrect macro. The Macro object is as follows:");
                            Console.WriteLine("Primary Qualifier - ");
                            Console.WriteLine("Primary Qualifier type:" + rtrvGtHistResp.instrumentDatas[i].
                                              macro.primaryQualifier.primaryQualifierType);
                            Console.WriteLine("Primary Qualifier value:" + rtrvGtHistResp.instrumentDatas[i].
                                              macro.primaryQualifier.primaryQualifierValue);
                            Console.WriteLine("Secondary Qualifier -");
                            for (int l = 0; l < rtrvGtHistResp.instrumentDatas[i].macro.secondaryQualifier.
                                 Length; l++)
                            {
                                Console.WriteLine("Secondary Qualifier type :" + rtrvGtHistResp.instrumentDatas[i].
                                                  macro.secondaryQualifier[l].secondaryQualifierType);
                                Console.WriteLine("Secondary Qualifier Value :" + rtrvGtHistResp.instrumentDatas[i]
                                                  .macro.secondaryQualifier[l].secondaryQualifierValue);
                                Console.WriteLine("Secondary Qualifier Operator :" + rtrvGtHistResp.instrumentDatas[i]
                                                  .macro.secondaryQualifier[l].secondaryQualifierOperator);
                            }
                        }
                    }
                }
                else if (rtrvGtHistResp.statusCode.code == PerSecurity.RequestError)
                {
                    Console.WriteLine("Error in the submitted request");
                }
            }

            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Beispiel #3
0
        public void run(PerSecurity_Dotnet.PerSecurityWSDL.PerSecurityWS ps)
        {
            //Setting request headers
            GetHistoryHeaders getHistHeaders = new GetHistoryHeaders();
            DateRange dtRange = new DateRange();
            dtRange.period = new Period();
            dtRange.period.start = DateTime.Today.Subtract(TimeSpan.FromDays(7));
            dtRange.period.end = DateTime.Today;
            getHistHeaders.daterange = dtRange;
            getHistHeaders.version = PerSecurity_Dotnet.PerSecurityWSDL.Version.@new;
            //Setting instruments
            Instrument ticker = new Instrument();
            ticker = new Instrument();
            ticker.id = "IBM US";
            ticker.yellowkey = MarketSector.Equity;
            ticker.yellowkeySpecified = true;

            Instrument bbUniqueId = new Instrument();
            bbUniqueId.id = "EQ0086119600001000";
            bbUniqueId.yellowkeySpecified = true;
            bbUniqueId.yellowkey = MarketSector.Equity;
            bbUniqueId.type = InstrumentType.BB_UNIQUE;
            bbUniqueId.typeSpecified = true;

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

            //Setting get history request parameters
            string[] fields =  new string[] {"PX_LAST","PX_HIGH","PX_LOW" }; 
            SubmitGetHistoryRequest sbmtGtHistReq = new SubmitGetHistoryRequest();
            sbmtGtHistReq.headers = getHistHeaders;
            sbmtGtHistReq.instruments = instrs;
            sbmtGtHistReq.fields = fields;
            try
            {
                Console.WriteLine("Submit Get History request");
                SubmitGetHistoryResponse sbmtGtHistResp = ps.submitGetHistoryRequest(sbmtGtHistReq);
                System.Console.WriteLine("status " + sbmtGtHistResp.statusCode.description);
                System.Console.WriteLine("Submit Get Data request -  response ID = " + sbmtGtHistResp.responseId);

                Console.WriteLine("Retrieve data request");
                RetrieveGetHistoryRequest rtrvGtHistReq = new RetrieveGetHistoryRequest();
                rtrvGtHistReq.responseId = sbmtGtHistResp.responseId;
                RetrieveGetHistoryResponse rtrvGtHistResp = new RetrieveGetHistoryResponse();

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

                //Displaying data
                if (rtrvGtHistResp.statusCode.code == PerSecurity.SUCCESS)
                {
                    for (int i = 0; i < rtrvGtHistResp.instrumentDatas.Length; i++)
                    {
                        System.Console.WriteLine("Data for :" + rtrvGtHistResp.instrumentDatas[i].instrument.id +
                            "  " + rtrvGtHistResp.instrumentDatas[i].instrument.yellowkey);
                        Console.WriteLine(rtrvGtHistResp.instrumentDatas[i].date.ToString());
                        for (int j = 0; j < rtrvGtHistResp.instrumentDatas[i].data.Length; j++)
                        {

                            Console.WriteLine(sbmtGtHistReq.fields[j] + " : " + rtrvGtHistResp.
                                instrumentDatas[i].data[j].value);
                        }
                    }
                }
                else if (rtrvGtHistResp.statusCode.code == PerSecurity.REQUEST_ERROR)
                {
                    Console.WriteLine("Error in the submitted request");
                }
			}

        
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

        }
         public void run(PerSecurityWSDL.PerSecurityWS ps)
        {
            try{
                //Setting headers
                GetHistoryHeaders getHistHeaders = new GetHistoryHeaders();
                getHistHeaders.display_pricing_srcSpecified = true;
                getHistHeaders.display_pricing_src = true;

                Instrument ticker = new Instrument();
                ticker.id = "IBM US";
                ticker.typeSpecified = true;
                ticker.yellowkeySpecified = true;
                ticker.type = InstrumentType.TICKER;
                ticker.yellowkey = MarketSector.Equity;
                Instrument[] instr = new Instrument[] { ticker };
                Instruments instrs = new Instruments();
                instrs.instrument = instr;

                String[] fields = new String[] { "PX_LAST" };

                //Sending Request
            SubmitGetHistoryRequest sbmtGtHistReq = new SubmitGetHistoryRequest();
			sbmtGtHistReq.headers = getHistHeaders;
            sbmtGtHistReq.instruments = instrs;
			sbmtGtHistReq.fields = fields;
			Console.WriteLine("Submit Get History request");
			SubmitGetHistoryResponse sbmtGtHistResp = ps
					.submitGetHistoryRequest(sbmtGtHistReq);
            Console.WriteLine("Submit Get Data request - Status: "
					+ sbmtGtHistResp.statusCode.description + " response ID = "
					+ sbmtGtHistResp.responseId);
            Console.WriteLine("Sending retrieve data request");
			RetrieveGetHistoryRequest rtrvGtHistReq = new RetrieveGetHistoryRequest();
			rtrvGtHistReq.responseId=sbmtGtHistResp.responseId;
			RetrieveGetHistoryResponse rtrvGtHistResp = new RetrieveGetHistoryResponse();

                	// Keep polling for response till the data is available
			do {
				System.Threading.Thread.Sleep(PerSecurity.POLL_INTERVAL);
				rtrvGtHistResp = ps.retrieveGetHistoryResponse(rtrvGtHistReq);
			} while (rtrvGtHistResp.statusCode.code == PerSecurity.DATA_NOT_AVAILABLE);

			// Displaying data
			if (rtrvGtHistResp.statusCode.code == PerSecurity.SUCCESS) {
				Console.WriteLine("Retrieve get data request successful Response ID: " + rtrvGtHistResp.responseId);
				for (int i = 0; i < rtrvGtHistResp.instrumentDatas.Length; i++) {
					Console.WriteLine("Data for :"
                            + rtrvGtHistResp.instrumentDatas[i].instrument.id
							+ " "
                            + rtrvGtHistResp.instrumentDatas[i].instrument.yellowkey);
                    Console.WriteLine("Time: " + rtrvGtHistResp.instrumentDatas[i].date.Hour.ToString() + ":" + rtrvGtHistResp.instrumentDatas[i].date.Minute.ToString() + ":" + rtrvGtHistResp.instrumentDatas[i].date.Second.ToString());
                    Console.WriteLine("Pricing Source: " + rtrvGtHistResp.instrumentDatas[i].pricingSource);
                    for (int j = 0; j < rtrvGtHistResp.instrumentDatas[i].data.Length; j++)
                    {
						Console.WriteLine(fields[j]
								+ " : "
                                + rtrvGtHistResp.instrumentDatas[i].data[j].value);
					}
				}
			} else if (rtrvGtHistResp.statusCode.code == PerSecurity.REQUEST_ERROR)
				Console.WriteLine(" Error in the submitted request" );

            }catch(Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
         }
Beispiel #5
0
         public void run(PerSecurity_Dotnet.PerSecurityWSDL.PerSecurityWS ps)
        {
            //Setting request headers
            GetHistoryHeaders getHistHeaders = new GetHistoryHeaders();
            DateRange dtRange = new DateRange();
            Duration duration = new Duration();
            duration.days = 3;
            dtRange.duration = duration;
            getHistHeaders.daterange = dtRange;

            //Setting instruments
            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 = "CONVERTS";

            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.TICKER;
            instrs.macro[0].secondaryQualifier[0].secondaryQualifierValue = "F";

            //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 = "converts_err";

            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.TICKER;
            instrs.macro[1].secondaryQualifier[0].secondaryQualifierValue = "F";

            //Setting get history request parameters
            string[] fields =  new string[] {"PX_LAST"}; 
            SubmitGetHistoryRequest sbmtGtHistReq = new SubmitGetHistoryRequest();
            sbmtGtHistReq.headers = getHistHeaders;
            sbmtGtHistReq.instruments = instrs;
            sbmtGtHistReq.fields = fields;
            try
            {
                Console.WriteLine("Submit Get History request");
                SubmitGetHistoryResponse sbmtGtHistResp = ps.submitGetHistoryRequest(sbmtGtHistReq);
                System.Console.WriteLine("status " + sbmtGtHistResp.statusCode.description);
                System.Console.WriteLine("Submit Get Data request -  response ID = " + sbmtGtHistResp.responseId);

                Console.WriteLine("Retrieve data request");
                RetrieveGetHistoryRequest rtrvGtHistReq = new RetrieveGetHistoryRequest();
                rtrvGtHistReq.responseId = sbmtGtHistResp.responseId;
                RetrieveGetHistoryResponse rtrvGtHistResp = new RetrieveGetHistoryResponse();

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

                //Displaying data
                if (rtrvGtHistResp.statusCode.code == PerSecurity.SUCCESS)
                {
                    for (int i = 0; i < rtrvGtHistResp.instrumentDatas.Length; i++)
                    {
                        if(rtrvGtHistResp.instrumentDatas[i].code.Equals("0"))
                        {
                        System.Console.WriteLine("Data for :" + rtrvGtHistResp.instrumentDatas[i].instrument.id +
                            "  " + rtrvGtHistResp.instrumentDatas[i].instrument.yellowkey);
                        Console.WriteLine(rtrvGtHistResp.instrumentDatas[i].date.ToString());
                        for (int j = 0; j < rtrvGtHistResp.instrumentDatas[i].data.Length; j++)
                        {

                            Console.WriteLine(sbmtGtHistReq.fields[j] + " : " + rtrvGtHistResp.
                                instrumentDatas[i].data[j].value);
                        }
                        }
                        else
                        {
                             System.Console.WriteLine("\nError Code " + rtrvGtHistResp.instrumentDatas[i].code + ": incorrect macro. The Macro object is as follows:");
                            Console.WriteLine("Primary Qualifier - ");
                            Console.WriteLine("Primary Qualifier type:" + rtrvGtHistResp.instrumentDatas[i].
                                macro.primaryQualifier.primaryQualifierType);
                            Console.WriteLine("Primary Qualifier value:" + rtrvGtHistResp.instrumentDatas[i].
                                macro.primaryQualifier.primaryQualifierValue);
                            Console.WriteLine("Secondary Qualifier -");
                            for (int l = 0; l < rtrvGtHistResp.instrumentDatas[i].macro.secondaryQualifier.
                                Length; l++)
                            {
                                Console.WriteLine("Secondary Qualifier type :" + rtrvGtHistResp.instrumentDatas[i].
                                    macro.secondaryQualifier[l].secondaryQualifierType);
                                Console.WriteLine("Secondary Qualifier Value :" + rtrvGtHistResp.instrumentDatas[i]
                                    .macro.secondaryQualifier[l].secondaryQualifierValue);
                                Console.WriteLine("Secondary Qualifier Operator :" + rtrvGtHistResp.instrumentDatas[i]
                                    .macro.secondaryQualifier[l].secondaryQualifierOperator);
                            }
                        }
                    }
                }
                else if (rtrvGtHistResp.statusCode.code == PerSecurity.REQUEST_ERROR)
                {
                    Console.WriteLine("Error in the submitted request");
                }
			}

        
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

        }
        public void run(PerSecurityWS ps)
        {
            try
            {
                //Setting request headers
                GetHistoryHeaders getHistHeaders = new GetHistoryHeaders();
                getHistHeaders.display_pricing_srcSpecified = true;
                getHistHeaders.display_pricing_src = true;

                Instrument ticker = new Instrument();
                ticker = new Instrument();
                ticker.id = "IBM";
                ticker.yellowkey = MarketSector.Equity;
                ticker.yellowkeySpecified = true;

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

                string[] fields = new string[] { "PX_LAST" };
                SubmitGetHistoryRequest sbmtGtHistReq = new SubmitGetHistoryRequest();
                sbmtGtHistReq.headers = getHistHeaders;
                sbmtGtHistReq.instruments = instrs;
                sbmtGtHistReq.fields = fields;
              
                    Console.WriteLine("Submit Get History request");
                    SubmitGetHistoryResponse sbmtGtHistResp = ps.submitGetHistoryRequest(sbmtGtHistReq);
                    System.Console.WriteLine("status " + sbmtGtHistResp.statusCode.description);
                    System.Console.WriteLine("Submit Get Data request -  response ID = " + sbmtGtHistResp.responseId);

                    Console.WriteLine("Retrieve data request");
                    RetrieveGetHistoryRequest rtrvGtHistReq = new RetrieveGetHistoryRequest();
                    rtrvGtHistReq.responseId = sbmtGtHistResp.responseId;
                    RetrieveGetHistoryResponse rtrvGtHistResp = new RetrieveGetHistoryResponse();

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

                    //Displaying data
                    if (rtrvGtHistResp.statusCode.code == PerSecurity.SUCCESS)
                    {
                        for (int i = 0; i < rtrvGtHistResp.instrumentDatas.Length; i++)
                        {
                            System.Console.WriteLine("Data for :" + rtrvGtHistResp.instrumentDatas[i].instrument.id +
                                "  " + rtrvGtHistResp.instrumentDatas[i].instrument.yellowkey);
                            Console.WriteLine("Date: " + rtrvGtHistResp.instrumentDatas[i].date.ToString());
                            Console.WriteLine("Pricing Source: " + rtrvGtHistResp.instrumentDatas[i].pricingSource);
                            for (int j = 0; j < rtrvGtHistResp.instrumentDatas[i].data.Length; j++)
                            {

                                Console.WriteLine(sbmtGtHistReq.fields[j] + " : " + rtrvGtHistResp.
                                    instrumentDatas[i].data[j].value);
                            }
                        }
                    }
                    else if (rtrvGtHistResp.statusCode.code == PerSecurity.REQUEST_ERROR)
                    {
                        Console.WriteLine("Error in the submitted request");
                    }

                   
                 }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message + e.StackTrace);
                }
            }
Beispiel #7
0
        public void run(PerSecurityWSDL.PerSecurityWS ps)
        {
            try
            {
                // Setting headers
                GetHistoryHeaders getHistHeaders = new GetHistoryHeaders();
                getHistHeaders.display_pricing_srcSpecified = true;
                getHistHeaders.display_pricing_src          = true;

                DateRange dtRange = new DateRange();
                dtRange.period           = new Period();
                dtRange.period.start     = DateTime.Today.Subtract(TimeSpan.FromDays(7));
                dtRange.period.end       = DateTime.Today;
                getHistHeaders.daterange = dtRange;

                Instrument ticker = new Instrument();
                ticker.id                 = "IBM US";
                ticker.typeSpecified      = true;
                ticker.yellowkeySpecified = true;
                ticker.type               = InstrumentType.TICKER;
                ticker.yellowkey          = MarketSector.Equity;
                Instrument[] instr  = new Instrument[] { ticker };
                Instruments  instrs = new Instruments();
                instrs.instrument = instr;

                string[] fields = new string[] { "PX_LAST" };

                // Sending Request
                SubmitGetHistoryRequest sbmtGtHistReq = new SubmitGetHistoryRequest();
                sbmtGtHistReq.headers     = getHistHeaders;
                sbmtGtHistReq.instruments = instrs;
                sbmtGtHistReq.fields      = fields;

                Console.WriteLine("Submit gethistory request");

                submitGetHistoryRequestRequest  sbmtGtHistReqReq  = new submitGetHistoryRequestRequest(sbmtGtHistReq);
                submitGetHistoryRequestResponse sbmtGtHistReqResp = ps.submitGetHistoryRequest(sbmtGtHistReqReq);
                SubmitGetHistoryResponse        sbmtGtHistResp    = sbmtGtHistReqResp.submitGetHistoryResponse;

                Console.WriteLine("Submit gethistory request - Status: "
                                  + sbmtGtHistResp.statusCode.description + " response ID = "
                                  + sbmtGtHistResp.responseId);
                Console.WriteLine("Sending retrieve gethistory request");

                RetrieveGetHistoryRequest rtrvGtHistReq = new RetrieveGetHistoryRequest();
                rtrvGtHistReq.responseId = sbmtGtHistResp.responseId;

                retrieveGetHistoryResponseRequest  rtrvGtHistRespReq = new retrieveGetHistoryResponseRequest(rtrvGtHistReq);
                retrieveGetHistoryResponseResponse rtrvGtHistRespResp;

                RetrieveGetHistoryResponse rtrvGtHistResp;

                // Keep polling for response till the data is available
                do
                {
                    System.Threading.Thread.Sleep(PerSecurity.PollInterval);
                    rtrvGtHistRespResp = ps.retrieveGetHistoryResponse(rtrvGtHistRespReq);
                    rtrvGtHistResp     = rtrvGtHistRespResp.retrieveGetHistoryResponse;
                } while (rtrvGtHistResp.statusCode.code == PerSecurity.DataNotAvailable);

                // Displaying data
                if (rtrvGtHistResp.statusCode.code == PerSecurity.Success)
                {
                    Console.WriteLine("Retrieve gethistory request successful Response ID: " + rtrvGtHistResp.responseId);
                    for (int i = 0; i < rtrvGtHistResp.instrumentDatas.Length; i++)
                    {
                        Console.WriteLine("Data for :"
                                          + rtrvGtHistResp.instrumentDatas[i].instrument.id
                                          + " "
                                          + rtrvGtHistResp.instrumentDatas[i].instrument.yellowkey);
                        Console.WriteLine("Time: " + rtrvGtHistResp.instrumentDatas[i].date.Hour.ToString() + ":" + rtrvGtHistResp.instrumentDatas[i].date.Minute.ToString() + ":" + rtrvGtHistResp.instrumentDatas[i].date.Second.ToString());
                        Console.WriteLine("Pricing Source: " + rtrvGtHistResp.instrumentDatas[i].pricingSource);
                        for (int j = 0; j < rtrvGtHistResp.instrumentDatas[i].data.Length; j++)
                        {
                            Console.WriteLine(fields[j]
                                              + " : "
                                              + rtrvGtHistResp.instrumentDatas[i].data[j].value);
                        }
                    }
                }
                else if (rtrvGtHistResp.statusCode.code == PerSecurity.RequestError)
                {
                    Console.WriteLine(" Error in the submitted request");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }