Skip to content

Commit

Permalink
Fix Ticker.shares
Browse files Browse the repository at this point in the history
  • Loading branch information
ValueRaider committed Dec 18, 2022
1 parent 4fc1525 commit ce4c2e4
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions yfinance/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,18 +207,19 @@ def get_json(url, proxy=None, session=None):
data = _json.loads(json_str)

if "_cs" in data and "_cr" in data:
data = _json.loads(decrypt_cryptojs_stores(data))

if "context" in data and "dispatcher" in data["context"]:
# Keep old code, just in case
data = data['context']['dispatcher']['stores']
data_stores = _json.loads(decrypt_cryptojs_stores(data))
else:
if "context" in data and "dispatcher" in data["context"]:
# Keep old code, just in case
data_stores = data['context']['dispatcher']['stores']
else:
data_stores = data

data = data['QuoteSummaryStore']
data = data_stores['QuoteSummaryStore']
# add data about Shares Outstanding for companies' tickers if they are available
try:
data['annualBasicAverageShares'] = _json.loads(
json_str)['context']['dispatcher']['stores'][
'QuoteTimeSeriesStore']['timeSeries']['annualBasicAverageShares']
data['annualBasicAverageShares'] = \
data_stores['QuoteTimeSeriesStore']['timeSeries']['annualBasicAverageShares']
except Exception:
pass

Expand Down

0 comments on commit ce4c2e4

Please sign in to comment.