예제 #1
0
        public void run(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);
            }
        }