Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misalignment of parsed outputs in .get_all() function #12

Open
nnamdi-i opened this issue Dec 19, 2013 · 6 comments
Open

Misalignment of parsed outputs in .get_all() function #12

nnamdi-i opened this issue Dec 19, 2013 · 6 comments

Comments

@nnamdi-i
Copy link

Maybe Yahoo Finance has changed the reporting structure (frustrating), but the results from the .get_all() function no longer aligns up with the attribute name.

code:
print ystockquote.get_all("GOOG")

Output (Lengthy, but as you can see certain fields are misaligned e.g. 'stock_exchange'):
{'previous_close': '1069.86', 'shares_owned': '"Google Inc."', 'change_from_52_week_low': '695.52', 'revenue': '36.746', 'average_daily_volume': '000', 'todays_range_realtime': '"1059.04 - 1084.95"', 'today_open': '1071.85', 'last_trade_realtime_time': '1084.95', 'fiftytwo_week_high': '"N/A - N/A"', 'ebitda': '44.15', 'fifty_sma': '+3.82%', 'pe_realtime': '12.26', 'ask_realtime': '1097.00', 'percent_change_50_sma': '+39.90', 'percent_change_from_52_week_low': '-7.5601', 'price_paid': '"N/A - N/A"', 'pe': 'N/A', 'holdings_value': '"Choose Brokerage"', 'price_eps_estimate_next_year': '17.599B', 'dividend_per_share': '0.00', 'twohundred_sma': '1044.85', 'trade_links': '2212546', 'market_cap': '2212546', 'todays_value_change_realtime': '"- - +1.39%"', 'change_realtime': '"+14.89"', 'low_limit': '" +===== "', 'volume': '"695.52 - 1092.3101"', 'todays_high': '1059.04', 'ask_size': '-', 'holdings_gain': '"-"', 'shares_outstanding': '"-"', 'holdings_gain_realtime': '"N/A - N/A"', 'last_trade_price': '"Dec 18 - 1084.75"', 'notes': '000', 'change_percent': '"+1.39%"', 'change_percent_realtime': '"N/A - +1.39%"', 'ticker_trend': '087', 'todays_low': '-', 'bid_realtime': '1054.00', 'change_50_sma': '+16.43%', 'more_info': 'N/A', 'price_book': '52.09', 'price_eps_estimate_current_year': '248.353', 'order_book_realtime': '100', 'todays_range': '-', 'change_from_52_week_high': '+389.23', 'book_value': '-', 'market_cap_realtime': '362.4B', 'dividend_yield': 'N/A', 'percent_change_from_52_week_high': '029', 'holdings_gain_percent': '1118.59', 'stock_exchange': '-0.69%', 'annualized_gain': '"- - -"', 'high_limit': '100', 'todays_value_change': '1084.75', 'short_ratio': '6.23', 'company_name': ' 276', 'trade_date': '-', 'dividend_pay_date': '"N/A"', 'change_200_sma': '+153.094', 'peg': '57.386B', 'bid_size': '"NasdaqNM"', 'last_trade_time_plus': '"N/A - 1084.75"', 'eps_estimate_next_quarter': '-', 'eps_estimate_current_year': '1836150', 'fiftytwo_week_range': '+55.96%', 'fiftytwo_week_low': '1092.3101', 'last_trade_date': '"12/18/2013"', 'holdings_value_realtime': '"GOOG"', 'ex_dividend_date': '"N/A"', 'after_hours_change_realtime': '"N/A - N/A"', 'price_sales': '-', 'change': '+14.89', 'eps_estimate_next_year': '"GOOG"', 'holdings_gain_percent_realtime': '-', 'eps': '300', 'one_year_target': '931.656', 'last_trade_time': '"4:00pm"', 'float_shares': 'N/A', 'change_percent_change': '"+14.89 - +1.39%"', 'last_trade_size': ' 334'}

rarmknecht added a commit to rarmknecht/ystockquote that referenced this issue Jan 15, 2014
@jplehmann
Copy link

So the actual problem which you figured out but didn't state here is that Yahoo's "CSV" output is crap. They are not quoting values which include commas, which screws up the alignment. This is really annoying.

The patch you provided involves multiple queries, which isn't very efficient. I'm not sure of the best solution at the moment.

@jplehmann
Copy link

The broken fields which I identified are float and lastTradeSize. @rarmknecht seems to have also identified even more:

# Seperate Queries - results may contain commas
 +        float_shares=''.join(_request(symbol, 'f6').split(',')),  # f6
 +        shares_outstanding=''.join(_request(symbol, 'j2').split(',')),  # j2
 +        ask_size=''.join(_request(symbol, 'a5').split(',')),  # a5
 +        bid_size=''.join(_request(symbol, 'b6').split(',')),  # b6
 +        last_trade_size=''.join(_request(symbol, 'k3').split(',')),  # k3

@jplehmann
Copy link

I've been using the Yahoo API for years without this problem, and I realize that it's because my query didn't include the offending fields. I guess that's the best we can do right now unless someone can see something in this format that I cannot.

The ideal fix I think would be to remove these from query_all and let the user individually query them, OR add an additional "all" query which does the individual queries as the PR above does.

@jplehmann
Copy link

BTW here's a brief code to demonstrate the problem:

# 6 fields
print ysq._request('GOOG', 'a5a0b6k3f6g3')
# 8 commas (5 expected)
200,1204.9399,200,3,359,   278,834,000,"-"

jplehmann added a commit to jplehmann/ystockquote that referenced this issue Feb 22, 2014
jplehmann added a commit to jplehmann/ystockquote that referenced this issue Feb 22, 2014
jplehmann added a commit to jplehmann/ystockquote that referenced this issue Feb 22, 2014
@rarmknecht
Copy link

"The ideal fix I think would be to remove these from query_all and let the user individually query them, OR add an additional "all" query which does the individual queries as the PR above does."

That sounds like a decent work around. Certainly more efficient and user friendly than the solution I provided that makes multiple queries without being clear to the user that that is occuring.

@ttshivers
Copy link

The issue that is causing this is actually the first line of the ids:
ydb2r1b3qpoc1d1cd2c6t1k2p2c8m5c3m6gm7hm8k1m3lm4l1t8w1g1w4g3p

The indicators c3 and m6 are not accounted for when the dictionary that you return is being built.

  • c3 is commission
  • m6 is percent_change_200_sma

You can simply fix this by accounting for these values when you build the dictionary, or just remove c3 and m6 from the id line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants