Skip to main content

An advanced api client for python botters.

Project description

[BETA] pybotters

An advanced api client for python botters.

📌 Description

pybotters仮想通貨botter向けのPythonライブラリです。

複数取引所に対応した非同期I/OのAPIクライアントであり、bot開発により素晴らしいDXを提供します。

👩‍💻👨‍💻 In development

pybotters は現在 ** BETAバージョン ** です。 一部機能は開発中です。

開発状況については こちら(Issues) を参照してください。

🚀 Features

  • ✨ HTTP / WebSocket Client
    • 複数取引所のプライベートAPIを自動認証
    • aiohttpライブラリを基盤とした非同期通信
    • WebSocketの自動再接続、自動ハートビート
  • ✨ DataStore
    • WebSocket用の自動データ保管クラス
    • 参照渡しによる高速なデータ参照
    • 取引所別データモデルの実装
  • ✨ Developer Experience
    • asyncioライブラリを利用した非同期プログラミング
    • typingモジュールによる型ヒントのサポート

🏦 Exchanges

Name API auth DataStore API docs
Bybit LINK
Binance WIP LINK
FTX LINK
BTCMEX LINK
BitMEX WIP LINK
bitFlyer WIP LINK
GMO Coin WIP LINK
Liquid WIP LINK
bitbank WIP LINK

🐍 Requires

Python 3.7+

🛠 Installation

pip install pybotters

🔰 Usage

Single exchange

import asyncio
import pybotters

apis = {
    'bybit': ['BYBIT_API_KEY', 'BYBIT_API_SECRET'],
}

async def main():
    async with pybotters.Client(apis=apis, base_url='https://api.bybit.com') as client:
        # REST API
        resp = await client.get('/v2/private/position/list', params={'symbol': 'BTCUSD'})
        data = await resp.json()
        print(data)

        # WebSocket API (with print handler)
        ws = await client.ws_connect(
            url='wss://stream.bybit.com/realtime',
            send_json={'op': 'subscribe', 'args': ['trade.BTCUSD', 'order', 'position']},
            hdlr_json=lambda msg, ws: print(msg),
        )
        await ws # this await is wait forever (for usage)

try:
    asyncio.run(main())
except KeyboardInterrupt:
    pass

Multiple exchanges

apis = {
    'bybit': ['BYBIT_API_KEY', 'BYBIT_API_SECRET'],
    'btcmex': ['BTCMEX_API_KEY', 'BTCMEX_API_SECRET'],
    'binance': ['BINANCE_API_KEY', 'BINANCE_API_SECRET'],
}

async def main():
    async with pybotters.Client(apis=apis) as client:
        await client.post('https://api.bybit.com/v2/private/order/create', data={'symbol': 'BTCUSD', ...: ...})
        ...
        await client.post('https://www.btcmex.com/api/v1/order', data={'symbol': 'XBTUSD', ...: ...})
        ...
        await client.post('https://dapi.binance.com/dapi/v1/order', data={'symbol': 'BTCUSD_PERP', ...: ...})
        ...

📖 Wiki

詳しい利用方法は👉Wikiページへ

🗽 License

MIT

💖 Author

https://twitter.com/MtkN1XBt

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pybotters-0.3.0.tar.gz (14.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pybotters-0.3.0-py3-none-any.whl (16.8 kB view details)

Uploaded Python 3

File details

Details for the file pybotters-0.3.0.tar.gz.

File metadata

  • Download URL: pybotters-0.3.0.tar.gz
  • Upload date:
  • Size: 14.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.5 CPython/3.7.9 Linux/4.18.0-301.1.el8.x86_64

File hashes

Hashes for pybotters-0.3.0.tar.gz
Algorithm Hash digest
SHA256 e795127eb3e00f4d1a7addbd6c41e3959436738ae49341f24e0780132aa67b7c
MD5 7632cad208bbe80e41b6273b4e8881fd
BLAKE2b-256 a1c0093a6f5ca429d97120d1a5edfc1fed7db4b3f0c67757cd4ffb8636852377

See more details on using hashes here.

File details

Details for the file pybotters-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: pybotters-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 16.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.5 CPython/3.7.9 Linux/4.18.0-301.1.el8.x86_64

File hashes

Hashes for pybotters-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bc3e9097aeeffbe725996444ffe4232fe1fb87fd31e27250abcfaad9259de163
MD5 02a6113ffee584778ff078540add3725
BLAKE2b-256 8a82d77d0d0019571c6ef19868fe8812b982d5a10d7215b9e6cc49156c31899e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page