Skip to content

Latest commit

 

History

History
157 lines (134 loc) · 4.04 KB

README.md

File metadata and controls

157 lines (134 loc) · 4.04 KB

pyexchange - Consistent API wrapper for cryptocurrency exchanges.

Requirements

Installation

$ pip install -e git+https://github.com/coderiot/pyexchange.git#egg=pyexchange

Supported exchanges

Exchange Name Public Api Private Api
Bitcurex Yes No
Bitfinex Yes No
Bitstamp Yes No
BTCChina Yes No
BTC-e Yes No
CampBX Yes No
Crypto-Trade Yes Yes (not tested)
Cryptsy Yes Yes (not tested)
Intersango (removed) Yes No
Justcoin Yes No
localbitcions Yes No
mtgox (removed) Yes No
The Rock Trading Yes No
Bter Yes Yes (without tests)
Coins-e Yes Yes (not tested)
Vircurex Yes No
CoinEx Yes No

runnning tests

tested with python2.7 and python3

python -m pyexchange.tests -v

Usage

list supported exchanges

>>> import pyexchange
>>> pyexchange.exchanges()

example Result:

['bitcurex',
 'bitfinex',
 'bitstamp',
 'btcchina',
 'btce',
 'campbx',
 'cryptotrade',
 'cryptsy',
 'intersango',
 'justcoin',
 'localbitcoins',
 'mtgox',
 'rocktrading']

create exchange by name with default market

>>> import pyexchange
>>> ex = pyexchange.new_exchange('mtgox')

create exchange by name and market

>>> import pyexchange
>>> ex = pyexchange.new_exchange('mtgox', 'btc_eur')

find available markets

>>> import pyexchange
>>> pyexchange.find_market('btc_usd')

list markets by exchange

>>> import pyexchange
>>> ex = pyexchange.new_exchange('bitfinex')
>>> ex.markets()

or

>>> pyexchange.exchange.bitfinex.markets()

Result:

['ltc_btc', 'ltc_usd', 'btc_usd']

set market for exchange

>>> import pyexchange
>>> ex = pyexchange.new_exchange('mtgox')
>>> ex.market = 'btc_eur' # set market
>>> print ex.market # current market

get exchange ticker

>>> import pyexchange
>>> ex = pyexchange.new_exchange('mtgox')
>>> print ex.ticker()

Result:

Ticker(avg=Decimal('157.19387'), high=Decimal('163.0'), low=Decimal('151.13324'), last=Decimal('160.0'), buy=Decimal('160.00001'), sell=Decimal('160.16'), vol=Decimal('22805.9081')

get exchange orderbook

>>> import pyexchange
>>> ex = pyexchange.new_exchange('mtgox')
>>> asks, bids = ex.depth()
>>> print asks

Result:

[Order(price=Decimal('160.22457'), amount=Decimal('0.01')),
 Order(price=Decimal('160.22458'), amount=Decimal('0.12521962')),
 Order(price=Decimal('160.29347'), amount=Decimal('1')),
 Order(price=Decimal('160.36999'), amount=Decimal('2.56417803')),
 Order(price=Decimal('160.37'), amount=Decimal('7.98')),],
 ...
]

get exchange trades

>>> import pyexchange
>>> ex = pyexchange.new_exchange('mtgox')
>>> trades = ex.trades()
>>> print trades

Result:

[Order(price=Decimal('160.22457'), amount=Decimal('0.01')),
 Order(price=Decimal('160.22458'), amount=Decimal('0.12521962')),
 Order(price=Decimal('160.29347'), amount=Decimal('1')),
 Order(price=Decimal('160.36999'), amount=Decimal('2.56417803')),
 Order(price=Decimal('160.37'), amount=Decimal('7.98')),
 ...
]