Skip to content

Commit

Permalink
fix for tkp-archive#9
Browse files Browse the repository at this point in the history
  • Loading branch information
timkpaine committed Feb 19, 2018
1 parent 008bb19 commit 6d7bc86
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 15 deletions.
5 changes: 0 additions & 5 deletions pyEX/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ def _wsURL(url):
return '/1.0/' + url


def _df(resp):
df = {k: [v] for k, v in resp.items()}
return pd.DataFrame(df)


def _strToList(st):
if isinstance(st, str):
return [st]
Expand Down
10 changes: 5 additions & 5 deletions pyEX/stocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from IPython.display import Image as ImageI
from PIL import Image as ImageP
from io import BytesIO
from .common import _TIMEFRAME_CHART, _TIMEFRAME_DIVSPLIT, _LIST_OPTIONS, _getJson, _df, _raiseIfNotStr, PyEXception, _strOrDate
from .common import _TIMEFRAME_CHART, _TIMEFRAME_DIVSPLIT, _LIST_OPTIONS, _getJson, _raiseIfNotStr, PyEXception, _strOrDate


def book(symbol):
Expand Down Expand Up @@ -49,7 +49,7 @@ def company(symbol):

def companyDF(symbol):
'''https://iextrading.com/developer/docs/#company'''
return _df(company(symbol))
return pd.io.json.json_normalize(company(symbol))


def delayedQuote(symbol):
Expand Down Expand Up @@ -157,7 +157,7 @@ def stockStats(symbol):

def stockStatsDF(symbol):
'''https://iextrading.com/developer/docs/#key-stats'''
return _df(stockStats(symbol))
return pd.io.json.json_normalize(stockStats(symbol))


def list(option='mostactive'):
Expand Down Expand Up @@ -253,7 +253,7 @@ def yesterday(symbol):

def yesterdayDF(symbol):
'''https://iextrading.com/developer/docs/#previous'''
return _df(yesterday(symbol))
return pd.io.json.json_normalize(yesterday(symbol))


def marketYesterday():
Expand Down Expand Up @@ -285,7 +285,7 @@ def quote(symbol):

def quoteDF(symbol):
'''https://iextrading.com/developer/docs/#quote'''
return _df(quote(symbol))
return pd.io.json.json_normalize(quote(symbol))


def relevant(symbol):
Expand Down
4 changes: 0 additions & 4 deletions tests/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ def test_wsURL(self):
from pyEX.common import _wsURL
_wsURL('test')

def test_df(self):
from pyEX.common import _df
_df({'A': 'B'})

def test_strToList(self):
from pyEX.common import _strToList
_strToList('test')
Expand Down
5 changes: 4 additions & 1 deletion tests/test_stocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def test_companyDF(self):
with patch('requests.get') as mock:
mock.return_value = MagicMock()
mock.return_value.status_code = 200
mock.return_value.json = MagicMock(return_value={'test': {'test2': 4}})
companyDF('test')

def test_quote(self):
Expand All @@ -47,6 +48,7 @@ def test_quoteDF(self):
with patch('requests.get') as mock:
mock.return_value = MagicMock()
mock.return_value.status_code = 200
mock.return_value.json = MagicMock(return_value={'test': {'test2': 4}})
quoteDF('test')

def test_price(self):
Expand Down Expand Up @@ -121,6 +123,7 @@ def test_yesterdayDF(self):
with patch('requests.get') as mock:
mock.return_value = MagicMock()
mock.return_value.status_code = 200
mock.return_value.json = MagicMock(return_value={'test': {'test2': 4}})
yesterdayDF('test')

def test_marketYesterday(self):
Expand Down Expand Up @@ -195,6 +198,7 @@ def test_statsDF(self):
with patch('requests.get') as mock:
mock.return_value = MagicMock()
mock.return_value.status_code = 200
mock.return_value.json = MagicMock(return_value=[])
stockStatsDF('test')

def test_financials(self):
Expand Down Expand Up @@ -313,7 +317,6 @@ def test_newsDF(self):
mock.return_value = MagicMock()
mock.return_value.status_code = 200
mock.return_value.json = MagicMock(return_value=[])
mock.return_value.json = MagicMock(return_value=[])
newsDF('test')

def test_marketNews(self):
Expand Down

0 comments on commit 6d7bc86

Please sign in to comment.