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