Created
November 2, 2015 17:15
-
-
Save hitbtc-com/e265a49c38a86c610294 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
import hashlib | |
import hmac | |
import random | |
import string | |
import time | |
import unirest as unirest | |
key = "da01c7e1f0dc4f166c6aa3d56add3293" | |
secret = "XXXXXXXXXXXXXXXXXXXXXXXXXX" | |
nonce = str(int(time.mktime(datetime.datetime.now().timetuple()) * 1000 + datetime.datetime.now().microsecond / 1000)) | |
clientOrderId = "".join(random.choice(string.digits + string.ascii_lowercase) for _ in range(30)) | |
path = "/api/1/trading/new_order?apikey=" + key + "&nonce=" + nonce | |
newOrder = "clientOrderId=" + clientOrderId + "&symbol=BTCUSD&side=buy&price=250&quantity=100&type=limit" | |
signature = hmac.new(secret, path + newOrder, hashlib.sha512).hexdigest() | |
result = unirest.post("http://api.hitbtc.com" + path, headers={"Api-Signature": signature}, params=newOrder) | |
print result.body['ExecutionReport'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment