我是Python的新手,我一直在尝试让Python Poloniex包装器工作,但我对它的用法有点不确定。代码发布在Github here上
有没有人能先解释一下我把API密钥和密码放在哪里?
我在想它会进入这个部分吗?
class poloniex:
def __init__(self, APIKey, Secret):
self.APIKey = APIKey # Key here?
self.Secret = Secret # Secret here?一旦我把所有的密钥和密钥都设置好了,调用各种函数的正确语法是什么?
这只是api_query('returnBalances') or poloniex.returnBalances('returnBalances')的一个例子吗?
我想很多人在这方面需要一些指导和帮助!
发布于 2018-03-22 22:15:27
根据your code poloniex是一个类,api_key和secret必须在初始化时给出,因此您可以尝试以下代码:
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发布于 2018-10-19 04:59:37
首先,在使用Poloniex API密钥之前,您必须修复代码。只有在使用Pyton 2.x时,python包装器才能工作,而它不能与Python 3.x一起工作。使其可用的主要更改是将urlib2库替换为Python3.x的相应urlib.request库。总体而言,包装器是垃圾,它将需要大量的知识和时间来修复它,以满足您的需求,只有这样,您才需要您的API密钥和密码。继续学习Python是值得的,即使只是修复包装器也是值得的。与使用包装器相比,您可能从Python知识中获得更多好处。我试着在不太了解Python的情况下使用包装器,这非常令人沮丧。我继续阅读,并用我自己的代码完全替换了包装器,感觉很棒。祝好运。
发布于 2019-01-01 02:07:58
我重写了poloniex几年前在github上的api页面上链接的包装器:https://github.com/s4w3d0ff/python-poloniex
pip install https://github.com/s4w3d0ff/python-poloniex/archive/v0.4.7.zip它可以在python2.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'])https://stackoverflow.com/questions/47965077
复制相似问题