Skip to content

Commit

Permalink
Merge pull request #92 from timkpaine/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
timkpaine authored May 26, 2020
2 parents abc5dab + 45124cb commit 9410d18
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tdameritrade/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ def replaceSavedOrder(self, accountId, savedOrderId, order):
'''
return self._request(REPLACE_SAVED_ORDER.format(accountId=accountId, savedOrderId=savedOrderId), method='PUT', data=order).json()

def hours(self, market=None, date=None):
def hours(self, market="EQUITY", date=None):
'''get market hours
Args:
Expand Down
32 changes: 32 additions & 0 deletions tdameritrade/tests/test_client.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# for Coverage
from mock import patch, MagicMock
import pytest
from tdameritrade.exceptions import TDAAPIError

from mock import MagicMock, patch

Expand Down Expand Up @@ -55,7 +56,22 @@ def test_accounts(self, tdclient):
m.return_value.json.return_value = [MagicMock()]
tdclient.accounts()
m.return_value.json.return_value = [{'test': 1, 'test2': 2}]
tdclient.accounts(positions=True)
tdclient.accounts(positions=True, orders=True)
tdclient.accounts(orders=True)
tdclient.accountsDF()
m.return_value.json.return_value = [{'test': 1}]
tdclient.accountsDF()


def test_accounts_no_accountIDs(self):
from tdameritrade import TDClient
with patch('tdameritrade.session.TDASession.request') as m:
m.return_value.status_code = 200
m.return_value.json.return_value = [MagicMock()]
tdc = TDClient(client_id=123,
refresh_token='reftoken',)
tdc.accounts()

def test_search(self, tdclient):
with patch('tdameritrade.session.TDASession.request') as m:
Expand All @@ -64,6 +80,12 @@ def test_search(self, tdclient):
tdclient.search('aapl')
tdclient.searchDF('aapl')

def test_fundementalSearch(self, tdclient):
with patch('tdameritrade.session.TDASession.request') as m:
m.return_value.status_code = 200
tdclient.fundamentalSearch('aapl')
tdclient.fundamentalSearch('aapl')

def test_instrument(self, tdclient):
with patch('tdameritrade.session.TDASession.request') as m:
m.return_value.status_code = 200
Expand All @@ -84,6 +106,16 @@ def test_history(self, tdclient):
m.return_value.json.return_value = {'candles': [{'datetime': 1, 'test2': 2}]}
tdclient.history('aapl')
tdclient.historyDF('aapl')
tdclient.history('aapl', periodType="day")
with pytest.raises(TDAAPIError):
tdclient.history('aapl', periodType="daily")
with pytest.raises(TDAAPIError):
tdclient.history('aapl', frequency="invalid")

def test_hours(self, tdclient):
with patch('tdameritrade.session.TDASession.request') as m:
m.return_value.status_code = 200
tdclient.hours()

def test_movers(self):
with patch('tdameritrade.session.TDASession.request') as m:
Expand Down

0 comments on commit 9410d18

Please sign in to comment.