Skip to content

Commit 62b7b80

Browse files
authored
Merge pull request #151 from hegusung/master
Support status param in get_orders
2 parents 4335499 + e0612e2 commit 62b7b80

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

gdax/authenticated_client.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,23 +100,32 @@ def get_order(self, order_id):
100100
# r.raise_for_status()
101101
return r.json()
102102

103-
def get_orders(self, product_id=''):
103+
def get_orders(self, product_id='', status=[]):
104104
result = []
105105
url = self.url + '/orders/'
106+
params = {}
106107
if product_id:
107-
url += "?product_id={}&".format(product_id)
108-
r = requests.get(url, auth=self.auth, timeout=30)
108+
params["product_id"] = product_id
109+
if status:
110+
params["status"] = status
111+
r = requests.get(url, auth=self.auth, params=params, timeout=30)
109112
# r.raise_for_status()
110113
result.append(r.json())
111114
if 'cb-after' in r.headers:
112-
self.paginate_orders(product_id, result, r.headers['cb-after'])
115+
self.paginate_orders(product_id, status, result, r.headers['cb-after'])
113116
return result
114117

115-
def paginate_orders(self, product_id, result, after):
116-
url = self.url + '/orders?after={}&'.format(str(after))
118+
def paginate_orders(self, product_id, status, result, after):
119+
url = self.url + '/orders'
120+
121+
params = {
122+
"after": str(after),
123+
}
117124
if product_id:
118-
url += "product_id={}&".format(product_id)
119-
r = requests.get(url, auth=self.auth, timeout=30)
125+
params["product_id"] = product_id
126+
if status:
127+
params["status"] = status
128+
r = requests.get(url, auth=self.auth, params=params, timeout=30)
120129
# r.raise_for_status()
121130
if r.json():
122131
result.append(r.json())
@@ -289,4 +298,4 @@ def get_report(self, report_id=""):
289298
def get_trailing_volume(self):
290299
r = requests.get(self.url + "/users/self/trailing-volume", auth=self.auth, timeout=30)
291300
# r.raise_for_status()
292-
return r.json()
301+
return r.json()

0 commit comments

Comments
 (0)