Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@achvaicer
Created October 22, 2013 21:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save achvaicer/7108500 to your computer and use it in GitHub Desktop.
Save achvaicer/7108500 to your computer and use it in GitHub Desktop.
Get Quotes request example from Bloomberg Data License
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