Bitpanda Global Exchange API异步Python客户端
项目描述
bitpanda-aio 2.0.2
公告:bitpanda-aio
已被新的库 cryptoxlib-aio
取代。 cryptoxlib-aio
提供了与 bitpanda-aio
相同的功能,并且还提供了访问多个加密交易所和其他(主要是技术性)新功能。您可以继续使用 bitpanda-aio
,但请注意,将不会实现新的功能/错误修复。我们建议迁移到 cryptoxlib-aio
。
bitpanda-aio
是一个Python库,提供对 Bitpanda Pro API(前身为Bitpanda Global Exchange)的访问。该库实现了bitpanda的REST API以及websockets。
bitpanda-aio
被设计为一个异步库,利用Python和异步库的现代功能(主要是async websockets 和 aiohttp)。
有关更改,请参阅变更日志。
功能
- 访问Bitpanda的完整REST API(账户详情、市场数据、订单管理等)和websockets(账户流、市场数据流、订单簿流等)
- 自动连接管理(在远程终止后重新连接等)
- 将多个通道捆绑在一个或多个websockets中并行处理
- 精简的架构为未来的扩展和定制奠定基础
- 完全异步设计,旨在实现最佳性能
安装
pip install bitpanda-aio
先决条件
由于库依赖和使用的Python特性,请确保您使用Python 3.6
或 3.7
。
在开始使用 bitpanda-aio
之前,您需要从Bitpanda Pro账户中下载您的Bitpanda API密钥。
示例
REST API
import asyncio
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():
api_key = "<YOUR_API_KEY>"
client = BitpandaClient(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 logging
from bitpanda.BitpandaClient import BitpandaClient
from bitpanda.Pair import Pair
from bitpanda.subscriptions import AccountSubscription, PricesSubscription, OrderbookSubscription, \
CandlesticksSubscription, MarketTickerSubscription, 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():
api_key = "<YOUR_API_KEY>"
client = BitpandaClient(api_key)
# Bundle several subscriptions into a single websocket
client.compose_subscriptions([
AccountSubscription(),
PricesSubscription([Pair("BTC", "EUR")]),
OrderbookSubscription([Pair("BTC", "EUR")], "50", callbacks = [order_book_update]),
CandlesticksSubscription([CandlesticksSubscriptionParams(Pair("BTC", "EUR"), TimeUnit.MINUTES, 1)]),
MarketTickerSubscription([Pair("BTC", "EUR")])
])
# Bundle another subscriptions into a separate websocket
client.compose_subscriptions([
OrderbookSubscription([Pair("ETH", "EUR")], "50", callbacks = [order_book_update]),
])
# Execute all websockets asynchronously
await client.start_subscriptions()
await client.close()
if __name__ == "__main__":
asyncio.run(run())
所有示例均可在GitHub仓库中的 client-example/client.py
文件中找到。
支持
如果您喜欢这个库,并希望支持其进一步的开发、增强和错误修复,那么如果您
- 提交错误、建议、拉取请求等,将非常有帮助并受到高度赞赏
- 传播信息
- 捐赠任意小费
- BTC: 15JUgVq3YFoPedEj5wgQgvkZRx5HQoKJC4
- ETH: 0xf29304b6af5831030ba99aceb290a3a2129b993d
- ADA: DdzFFzCqrhshyLV3wktXFvConETEr9mCfrMo9V3dYz4pz6yNq9PjJusfnn4kzWKQR91pWecEbKoHodPaJzgBHdV2AKeDSfR4sckrEk79
- XRP: rhVWrjB9EGDeK4zuJ1x2KXSjjSpsDQSaU6 + 标签 599790141
联系
如果您想取得联系,请
- 如果您的问题是关于开发,请使用Github Issues,或者
- 发送电子邮件至
隶属关系
如果您对自动化交易机器人感兴趣,请查看我们的其他项目 creten。
项目详情
下载文件
下载您平台上的文件。如果您不确定选择哪一个,请了解有关 安装包 的更多信息。
源分发
bitpanda-aio-2.0.2.tar.gz (9.1 kB 查看哈希值)
构建分发
bitpanda_aio-2.0.2-py3-none-any.whl (10.2 kB 查看哈希值)