Bitpanda Global Exchange API asynchronous python client
Project description
bitpanda-aio
bitpanda-aio is a Python library providing access to Bitpanda Global Exchange API. Library implements bitpanda's REST API as well as websockets.
bitpanda-aio is designed as an asynchronous library utilizing modern features of Python and of supporting asynchronous libraries (mainly async websockets and aiohttp).
Features
- access to complete Bitpanda's REST API (account details, market data, order management, ...) and websockets (account feed, market data feed, orderbook feed, ...)
- automatic connection management (reconnecting after remote termination, ...)
- lean architecture setting ground for the future extensions and customizations
- fully asynchronous design aiming for the best performance
Installation
pip install bitpanda-aio
Prerequisites
Due to dependencies and Python features used by the library please make sure you use Python 3.7.
Before starting using bitpanda-aio, it is necessary to take care of:
- downloading your Bitpanda API key from your Bitpanda Global Exchange account
- generating your certificate that will be used to secure SSL connections. Certificate
certificate.pemcan be generated easily by
openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -keyout key.pem -out certificate.pem
Examples
REST API
import asyncio
import pathlib
import logging
import datetime
from bitpanda.BitpandaClient import BitpandaClient
from bitpanda.Pair import Pair
from bitpanda.enums import OrderSide, TimeUnit
logger = logging.getLogger("bitpanda")
logger.setLevel(logging.DEBUG)
logger.addHandler(logging.StreamHandler())
async def run():
certificate_path = pathlib.Path(__file__).with_name("certificate.pem")
api_key = "<YOUR_API_KEY>"
client = BitpandaClient(certificate_path, api_key)
print("Account balance:")
await client.get_account_balances()
print("Account fees:")
await client.get_account_fees()
print("Account orders:")
await client.get_account_orders()
print("Account order:")
await client.get_account_order("1")
print("Create market order:")
await client.create_market_order(Pair("BTC", "EUR"), OrderSide.BUY, "1")
print("Create limit order:")
await client.create_limit_order(Pair("BTC", "EUR"), OrderSide.BUY, "10", "10")
print("Create stop loss order:")
await client.create_stop_limit_order(Pair("BTC", "EUR"), OrderSide.BUY, "10", "10", "10")
print("Delete orders:")
await client.delete_account_orders(Pair("BTC", "EUR"))
print("Delete order:")
await client.delete_account_order("1")
print("Order trades:")
await client.get_account_order_trades("1")
print("Trades:")
await client.get_account_trades()
print("Trade:")
await client.get_account_trade("1")
print("Trading volume:")
await client.get_account_trading_volume()
print("Currencies:")
await client.get_currencies()
print("Candlesticks:")
await client.get_candlesticks(Pair("BTC", "EUR"), TimeUnit.DAYS, "1", datetime.datetime.now() - datetime.timedelta(days=7), datetime.datetime.now())
print("Fees:")
await client.get_account_fees()
print("Instruments:")
await client.get_instruments()
print("Order book:")
await client.get_order_book(Pair("BTC", "EUR"))
print("Time:")
await client.get_time()
await client.close()
if __name__ == "__main__":
asyncio.run(run())
WEBSOCKETS
import asyncio
import pathlib
import logging
from bitpanda.BitpandaClient import BitpandaClient
from bitpanda.Pair import Pair
from bitpanda.websockets import CandlesticksSubscriptionParams
from bitpanda.enums import TimeUnit
logger = logging.getLogger("bitpanda")
logger.setLevel(logging.DEBUG)
logger.addHandler(logging.StreamHandler())
async def order_book_update(response : dict) -> None:
print(f"Callback {order_book_update.__name__}: [{response}]")
async def run():
certificate_path = pathlib.Path(__file__).with_name("certificate.pem")
api_key = "<YOUR_API_KEY>"
client = BitpandaClient(certificate_path, api_key)
client.subscribe_prices_ws([Pair("BTC", "EUR")])
client.subscribe_order_book_ws([Pair("BTC", "EUR")], "50", callbacks = [order_book_update])
client.subscribe_account_ws()
client.subscribe_candlesticks_ws([CandlesticksSubscriptionParams(Pair("BTC", "EUR"), TimeUnit.MINUTES, 1)])
client.subscribe_market_ticker_ws([Pair("BTC", "EUR")])
await client.start_websockets()
await client.close()
if __name__ == "__main__":
asyncio.run(run())
All examples are available in client-example/client.py.
Support
If you like the library and you feel like you want to support its further development, enhancements and bugfixing, then it will be of great help and most appreciated if you:
- file bugs, proposals, pull requests, ...
- spread the word
- donate an arbitrary tip
- BTC: 15JUgVq3YFoPedEj5wgQgvkZRx5HQoKJC4
- ETH: 0xf29304b6af5831030ba99aceb290a3a2129b993d
- ADA: DdzFFzCqrhshyLV3wktXFvConETEr9mCfrMo9V3dYz4pz6yNq9PjJusfnn4kzWKQR91pWecEbKoHodPaJzgBHdV2AKeDSfR4sckrEk79
- XRP: rhVWrjB9EGDeK4zuJ1x2KXSjjSpsDQSaU6 + tag 599790141
Contact
If you feel you want to get in touch, then please
- use Github Issues if it is related to the development, or
- send an e-mail to
Affiliation
In case you are interested in an automated trading bot that will utilize bitpanda-aio in the near future, then feel free to visit my other project creten.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bitpanda-aio-0.0.1.tar.gz.
File metadata
- Download URL: bitpanda-aio-0.0.1.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
478e0f38283098aef87ef0774ace0011caa4ff7a92d95b89367a86abf6bca059
|
|
| MD5 |
8dbfda362331f6ec1a550d17b91e3f97
|
|
| BLAKE2b-256 |
178d3f22cea0c8f92a55480fa3f0d629d2b11e37a8702699ded81cd39e0d6994
|
File details
Details for the file bitpanda_aio-0.0.1-py3-none-any.whl.
File metadata
- Download URL: bitpanda_aio-0.0.1-py3-none-any.whl
- Upload date:
- Size: 9.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cab0365762d05d062848abe7c87f65d20d95c968545162c030897d142525f20e
|
|
| MD5 |
266bd990ae80b099e638bd6183c5af0d
|
|
| BLAKE2b-256 |
529985017e043dcc5e17118834af6e06039d2b479eb29b4a1af488da4efaed65
|