我是Python的新手,我一直试图让Python Poloniex包装器工作,但我对它的使用有点不确定。该准则发布在Github here上
有人能够首先阐明我放置API Key&Secret的地方吗?
我想它会进入这一部分?
class poloniex:
def __init__(self, APIKey, Secret):
self.APIKey = APIKey # Key here?
self.Secret = Secret # Secret here?
一旦我设置了密钥和密钥,调用各种功能的正确语法是什么,例如平衡呼叫或买入呼叫?
这只是api_query('returnBalances') or poloniex.returnBalances('returnBalances')
as的一个例子吗?
我想很多人都可以使用一些指导并帮助解决这个问题!
根据your code poloniex
是一个类,api_key和秘密必须在初始化时给出,所以你可以试试这个代码:
p_api=poloniex("your_api_key_here","your_secret_here") #initialize the poloniex class with api key & secret
balance=p_api.returnBalances() #get balance
print(balance) #show balance
首先,在您使用Poloniex API密钥之前,必须修复代码。 python包装器只有在你使用Pyton 2.x并且它不能使用Python 3.x时才能工作。使其可用的主要变化是将urlib2库替换为Python 3.x的相应urlib.request库。总的来说,包装器是垃圾,需要大量的知识和时间来根据您的需要进行修复,只有这样您才需要API密钥和密码。值得继续学习Python甚至修复包装器。与使用包装器相比,您可能从Python知识中获益更多。我试着在不知道太多Python的情况下使用包装器而且非常令人沮丧。我一直在阅读并用我自己的代码完全替换了包装器,感觉很棒。祝好运。
几年前我在github上重写了poloniex在api页面上链接的包装器:https://github.com/s4w3d0ff/python-poloniex
pip install https://github.com/s4w3d0ff/python-poloniex/archive/v0.4.7.zip
它适用于python 2.7和3.x.
from poloniex import Poloniex
polo = Poloniex('your-Api-Key-Here-xxxx','yourSecretKeyHere123456789')
balance = polo('returnBalances')
print("I have %s BTC!" % balance['BTC'])