Пример #1
0
        public void run(PerSecurityWSDL.PerSecurityWS ps)
        {
            try
            {
                //Setting headers
                GetActionsHeaders getActionHeaders = new GetActionsHeaders();
                getActionHeaders.actions_date = ActionsDate.entry;
                String[] actions = new String[] { "DVD_CASH", "DISTRIBUTIONS" };
                getActionHeaders.actions = actions;

                //Setting Instruments 
                Instruments instruments = new Instruments();
                Instrument instr = new Instrument();
                instr.id = "COP US";
                instr.yellowkeySpecified = true;
                instr.typeSpecified = true;
                instr.yellowkey = MarketSector.Equity;
                instr.type = InstrumentType.TICKER;
                instruments.instrument = new Instrument[] { instr };

                //Submitting request
                SubmitGetActionsRequest req = new SubmitGetActionsRequest();
                req.headers = getActionHeaders;
                req.instruments = instruments;
                SubmitGetActionsResponse resp = null;
                resp = ps.submitGetActionsRequest(req);
                String responseId = resp.responseId;
                Console.WriteLine("Submit get actions request status: " + resp.statusCode.description +
                         " responseId: " + responseId);

                //Submit retrieve request
                RetrieveGetActionsRequest rtrvReq = new RetrieveGetActionsRequest();
                rtrvReq.responseId = responseId;
                Console.WriteLine("Sending retrieve get actions request");
                RetrieveGetActionsResponse rtrvResp = new RetrieveGetActionsResponse();

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

                //Display data
                if (rtrvResp.statusCode.code == PerSecurity.SUCCESS)
                {
                    Console.WriteLine("Retrieve get quotes request successful.  Response ID:" + rtrvResp.responseId);
                    for (int i = 0; i < rtrvResp.instrumentDatas.Length; i++)
                    {
                        Console.WriteLine("Data for :"
                                + rtrvResp.instrumentDatas[i].instrument.id + " "
                                + rtrvResp.instrumentDatas[i].instrument.yellowkey
                                );
                        Console.WriteLine(", Company id = " + rtrvResp.instrumentDatas[i].standardFields.companyId.ToString());
                        Console.WriteLine(", Security id = " + rtrvResp.instrumentDatas[i].standardFields.securityId.ToString());
                        if (rtrvResp.instrumentDatas[i].data != null)
                        {
                            for (int j = 0; j < rtrvResp.instrumentDatas[i].data.Length; j++)
                            {
                                Console.WriteLine(": field =  "
                                        + rtrvResp.instrumentDatas[i].data[j].field
                                        + ", value =  "
                                        + rtrvResp.instrumentDatas[i].data[j].value);
                            }
                        }

                    }
                }
                else if (rtrvResp.statusCode.code == PerSecurity.REQUEST_ERROR)
                    Console.WriteLine("Error in submitted request");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Пример #2
0
        public void run(PerSecurityWSDL.PerSecurityWS ps)
        {
            try
            {
                // Setting headers
                GetActionsHeaders getActionHeaders = new GetActionsHeaders();
                getActionHeaders.actions_date          = ActionsDate.entry;
                getActionHeaders.actions_dateSpecified = true;
                string[] actions = new string[] { "DVD_CASH", "DISTRIBUTIONS" };
                getActionHeaders.actions = actions;

                // Setting Instruments
                Instruments instruments = new Instruments();
                Instrument  instr       = new Instrument();
                instr.id = "COP US";
                instr.yellowkeySpecified = true;
                instr.typeSpecified      = true;
                instr.yellowkey          = MarketSector.Equity;
                instr.type             = InstrumentType.TICKER;
                instruments.instrument = new Instrument[] { instr };

                // Submitting request
                SubmitGetActionsRequest req = new SubmitGetActionsRequest();
                req.headers     = getActionHeaders;
                req.instruments = instruments;

                submitGetActionsRequestRequest  subGetActReqReq  = new submitGetActionsRequestRequest(req);
                submitGetActionsRequestResponse subGetActReqResp = ps.submitGetActionsRequest(subGetActReqReq);
                SubmitGetActionsResponse        subGetActResp    = subGetActReqResp.submitGetActionsResponse;

                string responseId = subGetActResp.responseId;
                Console.WriteLine("Submit get actions request status: " + subGetActResp.statusCode.description +
                                  " responseId: " + responseId);

                // Submit retrieve request
                RetrieveGetActionsRequest rtrvGetActionsReq = new RetrieveGetActionsRequest();
                rtrvGetActionsReq.responseId = responseId;
                Console.WriteLine("Sending retrieve get actions request");

                retrieveGetActionsResponseRequest  rtrvGetActionsRespReq = new retrieveGetActionsResponseRequest(rtrvGetActionsReq);
                retrieveGetActionsResponseResponse rtrvGetActionsRespResp;

                RetrieveGetActionsResponse rtrvGetActionsResp;

                // Keep polling for response till the data is available
                do
                {
                    System.Threading.Thread.Sleep(PerSecurity.PollInterval);
                    rtrvGetActionsRespResp = ps.retrieveGetActionsResponse(rtrvGetActionsRespReq);
                    rtrvGetActionsResp     = rtrvGetActionsRespResp.retrieveGetActionsResponse;
                } while (rtrvGetActionsResp.statusCode.code == PerSecurity.DataNotAvailable);

                // Display data
                if (rtrvGetActionsResp.statusCode.code == PerSecurity.Success)
                {
                    Console.WriteLine("Retrieve get quotes request successful.  Response ID:" + rtrvGetActionsResp.responseId);
                    for (int i = 0; i < rtrvGetActionsResp.instrumentDatas.Length; i++)
                    {
                        Console.WriteLine("Data for :"
                                          + rtrvGetActionsResp.instrumentDatas[i].instrument.id + " "
                                          + rtrvGetActionsResp.instrumentDatas[i].instrument.yellowkey
                                          );
                        Console.WriteLine(", Company id = " + rtrvGetActionsResp.instrumentDatas[i].standardFields.companyId.ToString());
                        Console.WriteLine(", Security id = " + rtrvGetActionsResp.instrumentDatas[i].standardFields.securityId.ToString());
                        if (rtrvGetActionsResp.instrumentDatas[i].data != null)
                        {
                            for (int j = 0; j < rtrvGetActionsResp.instrumentDatas[i].data.Length; j++)
                            {
                                Console.WriteLine(": field =  "
                                                  + rtrvGetActionsResp.instrumentDatas[i].data[j].field
                                                  + ", value =  "
                                                  + rtrvGetActionsResp.instrumentDatas[i].data[j].value);
                            }
                        }
                    }
                }
                else if (rtrvGetActionsResp.statusCode.code == PerSecurity.RequestError)
                {
                    Console.WriteLine("Error in submitted request");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }