jchristian / yahoo_stock_quotes

Provides a wrapper around the Yahoo Finance API for retrieving stock quotes and historical data
25 stars 13 forks source link

Can you add/open the method to return dictionary of properties? #2

Closed Vyeche closed 9 years ago

Vyeche commented 10 years ago

Hi,

I'm trying to access the properties without the "\"Google Inc.\"" characters. I noticed that the IEnumerable returns a hidden dictionary. Is it possible that those can be cleaned?

Will it be possible to just ask for one quote and get its properties, instead of asking for multiple?

jchristian commented 10 years ago

Can you clarify this a bit for me?

If you want just one quote, you should be able to do something like this:

var google_quote = quote_service.Quote("GOOG").Return(/*Quote Parameters*/).First();

var name = google_quote.Name;
var price = google_quote.LatestTradePrice;
//etc...

Why do you need "Google Inc." to access the properties?

jchristian commented 10 years ago

Oh, do you mean all the properties are coming back with "Google Inc." in them? There could be a problem with the parsing. Could you give me an example of this happening?

Vyeche commented 10 years ago

I'll try to explain, First issue, the properties were coming back with extra characters. - "\"Google Inc.\""

Where symbol is string[] or new {"GOOG"} var quotes = quoteService.Quote(symbol).Return(QuoteReturnParameter.Symbol, QuoteReturnParameter.Name, QuoteReturnParameter.LatestTradePrice, QuoteReturnParameter.LatestTradeTime);

The results look like this inside the return_parameter_dictionary (non-public): {{Symbol, "GOOG"}} -> "\"GOOG\"" {{Name, "Google Inc"}} -> "\"Google Inc.\"" {{LatestTradePrice, 557.35}} -> "557.35" {{LatestTradeTime, "4:00pm"}} -> "\"4:00pm\"" When I try to use this as json, it wont work because the extra quote level. Do you see what I mean?

I'm cleaning it with as a temp solution: var r = new Regex(@"[\""]");

Second issue. can you convert them to a list of string instead of Generic IEnumberable? I noticed that your non-public members: return_parameter_dictionary already is a dictionary of string, string', maybe create a public method to access this?

jchristian commented 9 years ago

The quotes should be removed now.