Skip to content

new functions transfer_history and withdraw_aud #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
21 changes: 18 additions & 3 deletions btcmarkets.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,14 @@ def request(action, key, signature, timestamp, path, data):
return json.load(response)


def get_request(key, secret, path):
def get_request(key, secret, path, queryString=None):

nowInMilisecond = str(int(time.time() * 1000))
stringToSign = path + "\n" + nowInMilisecond + "\n"
stringToSign = path + "\n"
if queryString:
stringToSign += queryString + '\n'
path += '?'+queryString
stringToSign += nowInMilisecond + "\n"

signature = base64.b64encode(hmac.new(secret, stringToSign, digestmod=hashlib.sha512).digest())

Expand Down Expand Up @@ -70,14 +74,16 @@ def order_history(self, currency, instrument, limit, since):
postData = json.dumps(data, separators=(',', ':'))
return post_request(self.key, self.secret, '/order/history', postData)



def order_open(self, currency, instrument, limit, since):

data = OrderedDict([('currency', currency),('instrument', instrument),('limit', limit),('since', since)])
postData = json.dumps(data, separators=(',', ':'))
return post_request(self.key, self.secret, '/order/open', postData)

def order_detail(self, order_ids):
data_obj = {'orderIds':order_ids}
data_obj = {'orderIds':order_ids}
postData = json.dumps(data_obj, separators=(',', ':'))
return post_request(self.key, self.secret, '/order/detail', postData)

Expand All @@ -97,6 +103,15 @@ def get_market_trades(self,currency_in,currency_out):

return get_request(self.key, self.secret, '/market/%s/%s/trades' % (currency_in,currency_out))

def transfer_history(self,limit=20):

return get_request(self.key, self.secret, '/fundtransfer/history', 'limit=%d' % limit)

def withdraw_aud(self, name, bank, bsb, account_no, amount):
data = OrderedDict([("accountName",name),("accountNumber",account_no),("bankName",bank),("bsbNumber",bsb),("amount",int(amount*100)*1000000),("currency","AUD")])
postData = json.dumps(data, separators=(',', ':'))

return post_request(self.key, self.secret, '/fundtransfer/withdrawEFT', postData)

def account_balance(self):
return get_request(self.key, self.secret, '/account/balance')