Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ Authors

Contributors
------------

None yet. Why not be the first?
* Sadha Chilukoori - <srchilukoori@gmail.com>
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ Changelog
------------------

* First release on PyPI.

0.1.0 (2020-03-07)
------------------
* Adding get_watchlists method
18 changes: 17 additions & 1 deletion src/tdam_api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,15 @@ def wrapper(*args, **kwargs):

class TDClient:
def __init__(
self, access_token=None, refresh_token=None, app_id=None, authenticated=True
self, access_token=None, refresh_token=None, app_id=None, authenticated=True, account_id=None
):
if authenticated:
self.access_token = self._get_auth_var(access_token, "TDAM_ACCESS_TOKEN")
self.refresh_token = self._get_auth_var(refresh_token, "TDAM_REFRESH_TOKEN")

self.app_id = self._get_auth_var(app_id, "TDAM_APP_ID")
self._authenticated = authenticated
self._acc_id = self._get_auth_var(account_id, "TDAM_ACC_ID")

def _get_auth_var(self, param: str, env_var: str) -> str:
if param is None:
Expand Down Expand Up @@ -290,3 +291,18 @@ def get_option(
if expiry in e:
out = Option(data[e][Option.float_to_strike(strike)][0])
return out

def get_watchlists(
self
):
"""
------------------------------------------------------------------------
Returns all watchlists available on the account
------------------------------------------------------------------------
"""
params = {}
resp: requests.Response = self._get_with_retry(Urls.watchlist % self._acc_id, params=params)

output = resp.json()

return output
2 changes: 2 additions & 0 deletions src/tdam_api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ class Urls:

hours = _base + "marketdata/hours"
movers = _base + "marketdata/%s/movers"

watchlist = _base + "accounts/%s/watchlists"