Skip to main content

A library providing a clients for interacting with various APIs of cryptocurrency exchanges for trading and accessing market data

Project description

PyCryptoEx

GitHub license PyPi package version Supported python versions linting - Ruff types - Mypy

[!CAUTION] This project is currently in alpha version and may have critical changes

A Python library providing a clients for interacting with various APIs of cryptocurrency exchanges for trading and accessing market data.

Installation

pip install -U pycryptoex

Choose and install one or more supported crypto exchanges:

pycryptoex [names ...]

For example:

pycryptoex bybit kucoin

Install from Github main

pip install -U git+https://github.com/ren3104/pycryptoex@main
pycryptoex [names ...] --update --version main

Quick Start

import asyncio

from pycryptoex import KuCoin, Bybit


async def handler(json_data):
    print(json_data)


async def main():
    # Request to public endpoints
    kucoin = KuCoin()
    async with kucoin:
        await kucoin.request(...)

    # Request to private endpoints
    bybit = Bybit(
        api_key="YOUR_API_KEY",
        secret="YOUR_API_SECRET"
    )
    async with bybit:
        await bybit.request(..., signed=True)

    # Start the public websocket
    kucoin_public_ws = await kucoin.create_websocket_stream()
    await kucoin_public_ws.start()
    # Subscribe handler to a public channel
    topic = "/market/candles:BTC-USDT_1min"
    await kucoin_public_ws.subscribe_callback(topic, handler)
    # Unsubscribe handler from a public channel
    await kucoin_public_ws.unsubscribe_callback(topic, handler)
    # Unsubscribe all handlers from a public channel
    await kucoin_public_ws.unsubscribe(topic)
    # Stop the public websocket
    await kucoin_public_ws.close()

    # Start the private websocket
    kucoin_private_ws = await kucoin.create_websocket_stream(private=True)
    await kucoin_private_ws.start()
    # Subscribe to private channels
    await kucoin_private_ws.subscribe_callback("/account/balance", handler)

    # Block until websockets close
    while not kucoin_public_ws.closed or not kucoin_private_ws.closed:
        await asyncio.sleep(0.1)

Supported Crypto Exchanges

Exchange Api Client Websocket Stream Manager
Bybit + -
KuCoin + +

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

pycryptoex-0.6.2.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

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

pycryptoex-0.6.2-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file pycryptoex-0.6.2.tar.gz.

File metadata

  • Download URL: pycryptoex-0.6.2.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.27.0

File hashes

Hashes for pycryptoex-0.6.2.tar.gz
Algorithm Hash digest
SHA256 1bfa51e29bf1fab5335a8807f39387f8c530e0e0f1790d2e5d8aa8fbc09fe8c8
MD5 e1f1edfdd85e8e162b9199afe1340d40
BLAKE2b-256 0dd8cb2f2d0065cb5e2b6d0517e6342bc773c6f9b5cd1a79960d90116ce8129f

See more details on using hashes here.

File details

Details for the file pycryptoex-0.6.2-py3-none-any.whl.

File metadata

  • Download URL: pycryptoex-0.6.2-py3-none-any.whl
  • Upload date:
  • Size: 10.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.27.0

File hashes

Hashes for pycryptoex-0.6.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e2d4e72da9d1a74ebb65de8502d1b40d59abeba33db6044abfb25f456b89e56c
MD5 5775fa9561281499314b42531d488415
BLAKE2b-256 b4232d3d5205ce82675cbc9a5e5656d61544eed3ed601bf1d64d21c4b73eb01c

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