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

New way of parsing iexapi data #23

Merged
merged 4 commits into from
Oct 18, 2017
Merged

New way of parsing iexapi data #23

merged 4 commits into from
Oct 18, 2017

Conversation

javilinux
Copy link
Contributor

No description provided.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.08%) to 77.622% when pulling 143f583 on javilinux:parsingiexapi into f365c2f on iranzo:master.

quote['l_cur'] = content.split(",")[9].split(":")[1]
quote['c'] = content.split(",")[20].split(":")[1]
quote['cp'] = float(content.split(",")[21].split(":")[1]) * 100
for x in content:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about:

def get(self, symbol):
  url = self.prefix + "%s/quote" % symbol
  content = json.loads(requests.get(url).content)
  quote = {'t': symbol}

  if "change" in content:
   quote['c']=content['change']
  if "changePercent" in content:
   quote['cp']=content['changePercent']
  if "latestPrice" in content:
    quote['l_cur'] = content['latestPrice']
  return quote

using json.loads, converts the content into a dictionary (parsing the return of the api), so it returns something like:

{u'avgTotalVolume': 1837021,
u'calculationPrice': u'close',
u'change': 0.23,
u'changePercent': 0.0019,
u'close': 121.12,
u'closeTime': 1508270652819,
u'companyName': u'Red Hat Inc.',
u'delayedPrice': 121.12,
u'delayedPriceTime': 1508273890029,
u'iexAskPrice': 0,
u'iexAskSize': 0,
u'iexBidPrice': 0,
u'iexBidSize': 0,
u'iexLastUpdated': 1508270387285,
u'iexMarketPercent': 0.04233,
u'iexRealtimePrice': 121.07,
u'iexRealtimeSize': 100,
u'iexVolume': 46128,
u'latestPrice': 121.12,
u'latestSource': u'Close',
u'latestTime': u'October 17, 2017',
u'latestUpdate': 1508270652819,
u'latestVolume': 1089724,
u'marketCap': 21431842805,
u'open': 120.36,
u'openTime': 1508247000757,
u'peRatio': 81.84,
u'previousClose': 120.89,
u'primaryExchange': u'New York Stock Exchange',
u'sector': u'Technology',
u'symbol': u'RHT',
u'week52High': 122.31,
u'week52Low': 68.54,
u'ytdChange': 0.7273245864232744}

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.3%) to 77.383% when pulling 362a445 on javilinux:parsingiexapi into f365c2f on iranzo:master.

@iranzo iranzo merged commit 3501974 into iranzo:master Oct 18, 2017
@iranzo
Copy link
Owner

iranzo commented Oct 18, 2017

Thanks for implementing the changes!

@javilinux javilinux deleted the parsingiexapi branch October 18, 2017 08:25
@javilinux javilinux restored the parsingiexapi branch October 18, 2017 08:25
@javilinux javilinux deleted the parsingiexapi branch October 19, 2017 21:08
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

Successfully merging this pull request may close these issues.

None yet

3 participants