def test_reportedFinancials(self): from pyEX import Client c = Client(version="sandbox") c.tenK(SYMBOL) c.tenQ(SYMBOL) c.twentyF("BABA") c.fortyF("SHOP")
def test_technicalsDF(self): '''test this one for real since its complicated''' from pyEX import Client c = Client(version='sandbox') c.technicalsDF('aapl', 'rsi') c.technicalsDF('aapl', 'rsi', '1m') c.technicalsDF('aapl', 'kvo', '1m', 2, 5) c.technicalsDF('aapl', 'macd', '1m', 12, 26, 9)
def test_optionsDF(self): from pyEX import Client with patch('requests.get') as mock: mock.return_value = MagicMock() mock.return_value.status_code = 200 mock.return_value.json = MagicMock(return_value=[]) c = Client() c.optionsDF(SYMBOL, 'test')
def test_incomeDF(self): from pyEX import Client with patch('requests.get') as mock: mock.return_value = MagicMock() mock.return_value.status_code = 200 mock.return_value.json = MagicMock(return_value=[]) c = Client() c.incomeStatementDF(SYMBOL)
def test_quotecrypto(self): from pyEX import Client with patch('requests.get') as mock: mock.return_value = MagicMock() mock.return_value.status_code = 200 mock.return_value.json = MagicMock(return_value=[]) c = Client() c.cryptoQuoteDF(SYMBOL)
def test_institutionalOwnershipDF(self): from pyEX import Client with patch('requests.get') as mock: mock.return_value = MagicMock() mock.return_value.status_code = 200 mock.return_value.json = MagicMock(return_value=[]) c = Client() c.institutionalOwnershipDF(SYMBOL)
def test_balancesheetDF(self): from pyEX import Client with patch('requests.get') as mock: mock.return_value = MagicMock() mock.return_value.status_code = 200 mock.return_value.json = MagicMock(return_value=[]) c = Client() c.balanceSheetDF(SYMBOL)
def test_technicalsDF(self): """test this one for real since its complicated""" from pyEX import Client c = Client(version="sandbox") c.technicalsDF("aapl", "rsi") c.technicalsDF("aapl", "rsi", "1m") c.technicalsDF("aapl", "kvo", "1m", 2, 5) c.technicalsDF("aapl", "macd", "1m", 12, 26, 9)
def test_insiderTransactionsDF(self): from pyEX import Client with patch('requests.get') as mock, \ patch('pickle.dump'): mock.return_value = MagicMock() mock.return_value.status_code = 200 mock.return_value.json = MagicMock(return_value=[]) c = Client(version='sandbox') c.insiderTransactionsDF(SYMBOL)
def test_institutionalOwnershipDF(self): from pyEX import Client with patch("requests.get") as mock, patch("pickle.dump"): mock.return_value = MagicMock() mock.return_value.status_code = 200 mock.return_value.json = MagicMock(return_value=[]) c = Client(version="sandbox") c.institutionalOwnershipDF(SYMBOL)
def test_intradayDF(self): from pyEX import Client with patch('requests.get') as mock, \ patch('pickle.dump'): mock.return_value = MagicMock() mock.return_value.status_code = 200 mock.return_value.json = MagicMock(return_value=[{'date': '1', 'minute': '1'}]) c = Client(version='sandbox') c.intradayDF(SYMBOL)
def test_pricecrypto(self): from pyEX import Client with patch("requests.get") as mock, patch("pickle.dump"): mock.return_value = MagicMock() mock.return_value.status_code = 200 mock.return_value.json = MagicMock(return_value=[]) c = Client(version="sandbox") c.cryptoPriceDF(SYMBOL)
def test_bookcrypto(self): from pyEX import Client with patch("requests.get") as mock: mock.return_value = MagicMock() mock.return_value.status_code = 200 mock.return_value.json = MagicMock(return_value=[]) c = Client(version="sandbox") c.cryptoBookDF(SYMBOL)
def test_optionsDF(self): from pyEX import Client with patch("requests.get") as mock: mock.return_value = MagicMock() mock.return_value.status_code = 200 mock.return_value.json = MagicMock(return_value=[]) c = Client(version="sandbox") c.stockOptionsDF(SYMBOL, "test")
def test_insiderSummaryDF(self): from pyEX import Client with patch("requests.get") as mock: mock.return_value = MagicMock() mock.return_value.status_code = 200 mock.return_value.json = MagicMock(return_value=[]) c = Client(version="sandbox") c.insiderSummaryDF(SYMBOL)
def test_intradayDF(self): from pyEX import Client with patch('requests.get') as mock, \ patch('pickle.dump'): mock.return_value = MagicMock() mock.return_value.status_code = 200 mock.return_value.json = MagicMock(return_value=[]) c = Client() c.intradayDF(SYMBOL)
def test_quotecrypto(self): from pyEX import Client with patch('requests.get') as mock, \ patch('pickle.dump'): mock.return_value = MagicMock() mock.return_value.status_code = 200 mock.return_value.json = MagicMock(return_value=[]) c = Client(version='sandbox') c.cryptoQuoteDF(SYMBOL)
def test_intradayDF(self): from pyEX import Client with patch("requests.get") as mock, patch("pickle.dump"): mock.return_value = MagicMock() mock.return_value.status_code = 200 mock.return_value.json = MagicMock( return_value=[{"date": "1", "minute": "1"}] ) c = Client(version="sandbox") c.intradayDF(SYMBOL)
def check_holiday(ords): new_ords = [] c = Client(authorizations['pyEX']) holiday_ords = [ holiday.toordinal() for holiday in c.calendarDF( type='holiday', direction='next', last=10)['date'].tolist() ] for ord in ords: if ord in holiday_ords: ord -= 1 new_ords.append(ord) return new_ords
def _get_data(symbol, start, end, client=None): if client is None and not os.environ.get('IEX_TOKEN'): raise PyEXception( 'Must provide pyEX client or set IEX_TOKEN environment variable') elif client is None: client = Client() df = client.chartDF(symbol, '5y') if start: df = df[df.index > start] if end: df = df[df.index < end] return df
def test_tops(self): from pyEX import Client with patch("requests.get") as mock: mock.return_value = MagicMock() mock.return_value.status_code = 200 c = Client(version="sandbox")
def test_incomeDF(self): from pyEX import Client with patch("requests.get") as mock, patch("pickle.dump"): mock.return_value = MagicMock() mock.return_value.status_code = 200 mock.return_value.json = MagicMock( return_value={ "income": [{ "reportDate": 1, "b": 2 }], "symbol": "aapl" }) c = Client(version="sandbox") c.incomeStatementDF(SYMBOL)
def test_balancesheetDF(self): from pyEX import Client with patch("requests.get") as mock: mock.return_value = MagicMock() mock.return_value.status_code = 200 mock.return_value.json = MagicMock( return_value={ "balancesheet": [{ "reportDate": 1, "b": 2 }], "symbol": "aapl", }) c = Client(version="sandbox") c.balanceSheetDF(SYMBOL)
def test_cashflowDF(self): from pyEX import Client with patch("requests.get") as mock: mock.return_value = MagicMock() mock.return_value.status_code = 200 mock.return_value.json = MagicMock( return_value={ "cashflow": [{ "reportDate": 1, "b": 2 }], "symbol": SYMBOL }) c = Client(version="sandbox") c.cashFlowDF(SYMBOL)
def test_convertfx(self): from pyEX import Client with patch('requests.get') as mock: mock.return_value = MagicMock() mock.return_value.status_code = 200 mock.return_value.json = MagicMock(return_value=[]) c = Client() c.convertFXDF() c.convertFXDF(SYMBOL) c.convertFXDF(SYMBOL, amount=1.0)
def test_usage(self): from pyEX import Client, PyEXception c = Client("sktest") with patch("pyEX.account._get"): c.usage() c.usage("messages") try: c.usage("test") assert False except PyEXception: pass
def test_convertfx(self): from pyEX import Client with patch("requests.get") as mock, patch("pickle.dump"): mock.return_value = MagicMock() mock.return_value.status_code = 200 mock.return_value.json = MagicMock(return_value=[]) c = Client(version="sandbox") c.convertFXDF() c.convertFXDF(SYMBOL) c.convertFXDF(SYMBOL, amount=1.0)
def test_client_notoken(self): import os from pyEX import Client, PyEXception tmp = os.environ.pop('IEX_TOKEN', '') try: Client() assert False except PyEXception: pass os.environ['IEX_TOKEN'] = tmp
def test_usage(self): from pyEX import Client from pyEX import PyEXception c = Client('test') with patch('pyEX.client._getJson'): c.usage() c.usage('messages') try: c.usage('test') assert False except PyEXception: pass
def test_account(self): from pyEX import Client c = Client("sktest") with patch("pyEX.account._getJson"): c.account() c.metadata()