Created
October 22, 2013 21:30
-
-
Save achvaicer/7108500 to your computer and use it in GitHub Desktop.
Get Quotes request example from Bloomberg Data License
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static void GetQuotes(PerSecurityWSClient client) | |
{ | |
var instrument_search = "PETR4 BZ"; | |
Console.WriteLine("Fazendo requisição de preços de {0}", instrument_search); | |
var instruments = new List<Instrument> { new Instrument() { id = instrument_search, yellowkey = MarketSector.Equity, yellowkeySpecified = true, type = InstrumentType.TICKER, typeSpecified = false } }; | |
var submitQuotesRequest = client.submitGetQuotesRequest(new SubmitGetQuotesRequest() | |
{ | |
headers = new QuotesHeaders() | |
{ | |
datetimerange = new DateTimeRange() { startDateTime = DateTime.Now.AddHours(-1), endDateTime = DateTime.Now }, | |
daterange = new DateRange() | |
{ | |
period = new Period() { start = DateTime.Today, end = DateTime.Today } | |
} | |
}, | |
instruments = new Instruments() | |
{ | |
instrument = instruments.ToArray() | |
} | |
}); | |
var quotes = new RetrieveGetQuotesResponse() | |
{ | |
statusCode = new ResponseStatus() { code = 100 } | |
}; | |
while (quotes.statusCode.code == 100) | |
{ | |
WaitingForResponse(); | |
quotes = client.retrieveGetQuotesResponse(new RetrieveGetQuotesRequest() | |
{ | |
responseId = submitQuotesRequest.responseId | |
}); | |
} | |
if (quotes.statusCode.code > 0) | |
throw new Exception(quotes.statusCode.description); | |
foreach (var instr in quotes.instrumentDatas) | |
{ | |
foreach (var quote in instr.quotes) | |
{ | |
Console.WriteLine("Instrument: {0} Date: {1} Price: {2}", instr.instrument.id, quote.dateTime, quote.price); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment