Skip to content

Commit 84bbd98

Browse files
authored
Merge pull request #223 from davidmmiller7/master
Issue #210: Unsupported granularity
2 parents cf1109b + dd236f8 commit 84bbd98

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

gdax/public_client.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,11 @@ def get_product_historic_rates(self, product_id, start=None, end=None,
187187
if end is not None:
188188
params['end'] = end
189189
if granularity is not None:
190+
acceptedGrans = [60, 300, 900, 3600, 21600, 86400]
191+
if granularity not in acceptedGrans:
192+
newGranularity = min(acceptedGrans, key=lambda x:abs(x-granularity))
193+
print(granularity,' is not a valid granularity level, using',newGranularity,' instead.')
194+
granularity = newGranularity
190195
params['granularity'] = granularity
191196

192197
return self._get('/products/{}/candles'.format(str(product_id)), params=params)

0 commit comments

Comments
 (0)