[英]Poloniex Python Wrapper
我對Python相當陌生,我一直在嘗試使Python Poloniex包裝器能夠正常工作,但對用法不確定。 該守則發布在Github上
有人可以首先闡明我將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')
為例?
我認為很多人可以為此提供一些指導和幫助!
根據您的代碼 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
首先,在使用Poloniex API密鑰之前,您必須先修復代碼。 僅當您使用Pyton 2.x且不與Python 3.x一起使用時,python包裝器才起作用。 要使其可用的主要更改是將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'])
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.