Exemplo n.º 1
0
    def test_reportedFinancials(self):
        from pyEX import Client

        c = Client(version="sandbox")
        c.tenK(SYMBOL)
        c.tenQ(SYMBOL)
        c.twentyF("BABA")
        c.fortyF("SHOP")
Exemplo n.º 2
0
 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)
Exemplo n.º 3
0
    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')
Exemplo n.º 4
0
    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)
Exemplo n.º 5
0
    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)
Exemplo n.º 6
0
    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)
Exemplo n.º 7
0
    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)
Exemplo n.º 8
0
    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)
Exemplo n.º 9
0
    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)
Exemplo n.º 10
0
    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)
Exemplo n.º 11
0
    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)
Exemplo n.º 12
0
    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)
Exemplo n.º 13
0
    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)
Exemplo n.º 14
0
    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")
Exemplo n.º 15
0
    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)
Exemplo n.º 16
0
    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)
Exemplo n.º 17
0
    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)
Exemplo n.º 18
0
    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)
Exemplo n.º 19
0
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
Exemplo n.º 20
0
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
Exemplo n.º 21
0
    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")
Exemplo n.º 22
0
    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)
Exemplo n.º 23
0
    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)
Exemplo n.º 24
0
    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)
Exemplo n.º 25
0
    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)
Exemplo n.º 26
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
Exemplo n.º 27
0
    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)
Exemplo n.º 28
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
Exemplo n.º 29
0
 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
Exemplo n.º 30
0
    def test_account(self):
        from pyEX import Client

        c = Client("sktest")
        with patch("pyEX.account._getJson"):
            c.account()
            c.metadata()