From 1b50cddecd0ff3705a945e9e7f0b1afd78b86630 Mon Sep 17 00:00:00 2001 From: sadha chilukoori Date: Sat, 7 Mar 2020 08:49:24 -0800 Subject: [PATCH 1/2] Changes: 1. Add account id to the TDClient class 2. Add watchlist url to the Urls class 3. define get_watchlists() function in the client.py --- src/tdam_api/client.py | 18 +++++++++++++++++- src/tdam_api/urls.py | 2 ++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/tdam_api/client.py b/src/tdam_api/client.py index 5278cfc..42fde2d 100644 --- a/src/tdam_api/client.py +++ b/src/tdam_api/client.py @@ -32,7 +32,7 @@ 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") @@ -40,6 +40,7 @@ def __init__( 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: @@ -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 diff --git a/src/tdam_api/urls.py b/src/tdam_api/urls.py index d8d8cb5..1c94b21 100644 --- a/src/tdam_api/urls.py +++ b/src/tdam_api/urls.py @@ -17,3 +17,5 @@ class Urls: hours = _base + "marketdata/hours" movers = _base + "marketdata/%s/movers" + + watchlist = _base + "accounts/%s/watchlists" From d5b3260eea546bdb5f05697688d3f1ae1e2eab30 Mon Sep 17 00:00:00 2001 From: sadha chilukoori Date: Sat, 7 Mar 2020 09:00:13 -0800 Subject: [PATCH 2/2] changelog & contributing authors --- AUTHORS.rst | 3 +-- CHANGELOG.rst | 4 ++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/AUTHORS.rst b/AUTHORS.rst index 043b0fd..7591885 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -6,5 +6,4 @@ Authors Contributors ------------ - -None yet. Why not be the first? +* Sadha Chilukoori - diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 6388e4e..41a9d1a 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -6,3 +6,7 @@ Changelog ------------------ * First release on PyPI. + +0.1.0 (2020-03-07) +------------------ +* Adding get_watchlists method