lorepieri8 / python-poloniex

Poloniex API wrapper for Python 2.7 & 3

Home Page:https://poloniex.com/support/api

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

python licence
release release build
master master build
dev dev build
Inspired by this wrapper written by 'oipminer'

Install latest release:

Python 2:

pip install https://github.com/s4w3d0ff/python-poloniex/archive/v0.4.3.zip

Python 3:

pip3 install https://github.com/s4w3d0ff/python-poloniex/archive/v0.4.3.zip

Features:

  • The first 2 args in the poloniex.Poloniex object (key and secret) are optional when used for public api commands.
  • Api commands have been 'mapped' into methods within the Poloniex class for your convenience.
  • Raises poloniex.PoloniexError if the command supplied does not exist, if the api keys are not defined and attempting to access a private api command, or if Poloniex.com returns an api error.
  • The poloniex.Poloniex(timeout=80) attribute/arg adjusts the number of seconds to wait for a response from poloniex, else requests.exceptions.Timeout is raised (which will be caught by 'poloniex.retry' and attempt the call again).
  • If a requests exception is raised (including Timeouts), signaling that the api call did not go through, the wrapper will attempt to try the call again. The wait pattern between retrys are as follows (in seconds): (0, 2, 5, 30). Once the retry delay list is exausted and the call still throws an error, the list of captured exceptions is raised.
  • A call restrictor (coach) is enabled by default, limiting the api wrapper to 6 calls per second. If you wish, you can deactivate the coach using Poloniex(coach=False) or use an 'external' coach.
  • By default, json floats are parsed as strings (ints are ints), you can define Poloniex(jsonNums=float) to have all numbers (floats and ints) parsed as floats (or import and use decimal.Decimal).
  • poloniex.coach, poloniex.retry, and poloniex have self named loggers.

Usage:

Basic Public Setup (no api Key/Secret):

from poloniex import Poloniex
polo = Poloniex()

Ticker

print(polo('returnTicker')['BTC_ETH'])
# or
print(polo.returnTicker()['BTC_ETH'])

Public trade history:

print(polo.marketTradeHist('BTC_ETH'))

Basic Private Setup (ApiKey/Secret required):

import poloniex
polo = poloniex.Poloniex('your-Api-Key-Here-xxxx','yourSecretKeyHere123456789')
# or
polo.key = 'your-Api-Key-Here-xxxx'
polo.secret = 'yourSecretKeyHere123456789'

Get all your balances

balance = polo.returnBalances()
print("I have %s ETH!" % balance['ETH'])
# or
balance = polo('returnBalances')
print("I have %s BTC!" % balance['BTC'])

Custom/external coach example:

from poloniex import Poloniex, Coach
myCoach = Coach()

public = Poloniex(coach=myCoach)
private = Poloniex(key, secret, coach=myCoach)
# now make calls using both 'private' and 'public' and myCoach will handle both

Examples of WAMP applications using the websocket push API can be found here.

About

Poloniex API wrapper for Python 2.7 & 3

https://poloniex.com/support/api

License:GNU General Public License v2.0


Languages

Language:Python 100.0%