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); } }
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); } }
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); } }