This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Python2 in Python 3

Hello, How can I change the code Python2 to Python 3? And with the parameter nonce, can I do something to not select it every time?

import httplib
import urllib
import json
import hashlib
import hmac
import time

api_key = ''
api_secret = ''

def trade(bORs,xrate,hm):
nonce=int(round(time.time()-1371212178.84)*10)
parms={"method":"Trade",
"pair":"usd_rur",
"type":bORs,
"rate":xrate,
"amount":hm,
"nonce":nonce}
parms=urllib.urlencode(parms)
hashed=hmac.new(api_secret,digestmod=hashlib.sha512)
hashed.update(parms)
signature=hashed.hexdigest()

headers={"Content-type":"application/x-www-form-urlencoded",
"Key":api_key,
"Sign":signature}

conn=httplib.HTTPSConnection("btc-e.nz")
conn.request("POST","/tapi",parms,headers)

response=conn.getresponse()
print(response.status,response.reason)

resp=json.load(response)
print resp

orderID=resp["return"]["order_id"]
print(orderID)

rur=resp["return"]["funds"]["rur"]
print(rur) 
trade ('buy',30,1)
python nonce

Hello cristyrdickerson!

We believe that this post does not fit the main topic of this site.

This is unrelated to bioinformatics

For this reason we have closed your question. This allows us to keep the site focused on the topics that the community can help with.

If you disagree please tell us why in a reply below, we'll be happy to talk about it.

Cheers!

0 answers

No answers yet.

Log in to answer this question.