Skip to content

Commit

Permalink
Add proxy support #167
Browse files Browse the repository at this point in the history
  • Loading branch information
s4w3d0ff authored Nov 6, 2017
1 parent ef1d89b commit 64b43a3
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions poloniex/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class Poloniex(object):

def __init__(
self, key=False, secret=False,
timeout=None, coach=True, jsonNums=False):
timeout=None, coach=True, jsonNums=False, proxies=None):
"""
key = str api key supplied by Poloniex
secret = str secret hash supplied by Poloniex
Expand All @@ -120,9 +120,10 @@ def __init__(
# Time Placeholders: (MONTH == 30*DAYS)
self.MINUTE, self.HOUR, self.DAY, self.WEEK, self.MONTH, self.YEAR
"""
# set logger and coach
# set logger, coach, and proxies
self.logger = logger
self.coach = coach
self.proxies = proxies
if self.coach is True:
self.coach = Coach()
# create nonce
Expand Down Expand Up @@ -201,7 +202,10 @@ def __call__(self, command, args={}):
# add headers to payload
payload['headers'] = {'Sign': sign.hexdigest(),
'Key': self.key}

# add proxies if needed
if self.proxies:
payload['proxies'] = self.proxies

# send the call
ret = _post(**payload)

Expand All @@ -216,7 +220,9 @@ def __call__(self, command, args={}):
# wait for coach
if self.coach:
self.coach.wait()

# add proxies if needed
if self.proxies:
payload['proxies'] = self.proxies
# send the call
ret = _get(**payload)

Expand Down

0 comments on commit 64b43a3

Please sign in to comment.