# PyCryptoEx
<p align="center">
<a href="https://github.com/ren3104/pycryptoex/blob/main/LICENSE"><img src="https://img.shields.io/github/license/ren3104/pycryptoex" alt="GitHub license"></a>
<a href="https://pypi.org/project/pycryptoex"><img src="https://img.shields.io/pypi/v/pycryptoex?color=blue" alt="PyPi package version"></a>
<a href="https://pypi.org/project/pycryptoex"><img src="https://img.shields.io/pypi/pyversions/pycryptoex.svg" alt="Supported python versions"></a>
<a href="https://github.com/astral-sh/ruff"><img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json" alt="linting - Ruff"></a>
<a href="https://github.com/python/mypy"><img src="https://img.shields.io/badge/types-Mypy-blue.svg" alt="types - Mypy"></a>
</p>
> [!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
```shell
pip install -U pycryptoex
```
Choose and install one or more supported crypto exchanges:
```shell
pycryptoex [names ...]
```
For example:
```shell
pycryptoex bybit kucoin
```
### Install from Github main
```shell
pip install -U git+https://github.com/ren3104/pycryptoex@main
```
```shell
pycryptoex [names ...] --update --version main
```
## Quick Start
```python
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](https://www.bybit.com/invite?ref=0WXGNA5) | + | - |
| [KuCoin](https://www.kucoin.com/r/rf/QBAAD3Y5) | + | + |
Raw data
{
"_id": null,
"home_page": null,
"name": "pycryptoex",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "altcoin, api, api-client, async, bitcoin, crypto, cryptocurrency, exchange, trade, trading, websocket",
"author": null,
"author_email": "ren3104 <2ren3104@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/d6/d0/96f583d409d6b45b95c158d46e405c32a95688755327664fc09fea23b173/pycryptoex-0.6.0.tar.gz",
"platform": null,
"description": "# PyCryptoEx\n<p align=\"center\">\n <a href=\"https://github.com/ren3104/pycryptoex/blob/main/LICENSE\"><img src=\"https://img.shields.io/github/license/ren3104/pycryptoex\" alt=\"GitHub license\"></a>\n <a href=\"https://pypi.org/project/pycryptoex\"><img src=\"https://img.shields.io/pypi/v/pycryptoex?color=blue\" alt=\"PyPi package version\"></a>\n <a href=\"https://pypi.org/project/pycryptoex\"><img src=\"https://img.shields.io/pypi/pyversions/pycryptoex.svg\" alt=\"Supported python versions\"></a>\n <a href=\"https://github.com/astral-sh/ruff\"><img src=\"https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json\" alt=\"linting - Ruff\"></a>\n <a href=\"https://github.com/python/mypy\"><img src=\"https://img.shields.io/badge/types-Mypy-blue.svg\" alt=\"types - Mypy\"></a>\n</p>\n\n> [!CAUTION]\n> This project is currently in alpha version and may have critical changes\n\nA Python library providing a clients for interacting with various APIs of cryptocurrency exchanges for trading and accessing market data.\n\n## Installation\n```shell\npip install -U pycryptoex\n```\n\nChoose and install one or more supported crypto exchanges:\n```shell\npycryptoex [names ...]\n```\n\nFor example:\n```shell\npycryptoex bybit kucoin\n```\n\n### Install from Github main\n```shell\npip install -U git+https://github.com/ren3104/pycryptoex@main\n```\n\n```shell\npycryptoex [names ...] --update --version main\n```\n\n## Quick Start\n```python\nimport asyncio\n\nfrom pycryptoex import KuCoin, Bybit\n\n\nasync def handler(json_data):\n print(json_data)\n\n\nasync def main():\n # Request to public endpoints\n kucoin = KuCoin()\n async with kucoin:\n await kucoin.request(...)\n\n # Request to private endpoints\n bybit = Bybit(\n api_key=\"YOUR_API_KEY\",\n secret=\"YOUR_API_SECRET\"\n )\n async with bybit:\n await bybit.request(..., signed=True)\n\n # Start the public websocket\n kucoin_public_ws = await kucoin.create_websocket_stream()\n await kucoin_public_ws.start()\n # Subscribe handler to a public channel\n topic = \"/market/candles:BTC-USDT_1min\"\n await kucoin_public_ws.subscribe_callback(topic, handler)\n # Unsubscribe handler from a public channel\n await kucoin_public_ws.unsubscribe_callback(topic, handler)\n # Unsubscribe all handlers from a public channel\n await kucoin_public_ws.unsubscribe(topic)\n # Stop the public websocket\n await kucoin_public_ws.close()\n\n # Start the private websocket\n kucoin_private_ws = await kucoin.create_websocket_stream(private=True)\n await kucoin_private_ws.start()\n # Subscribe to private channels\n await kucoin_private_ws.subscribe_callback(\"/account/balance\", handler)\n\n # Block until websockets close\n while not kucoin_public_ws.closed or not kucoin_private_ws.closed:\n await asyncio.sleep(0.1)\n```\n\n## Supported Crypto Exchanges\n| Exchange | Api Client | Websocket Stream Manager\n| --- | --- | --- |\n| [Bybit](https://www.bybit.com/invite?ref=0WXGNA5) | + | - |\n| [KuCoin](https://www.kucoin.com/r/rf/QBAAD3Y5) | + | + |\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A library providing a clients for interacting with various APIs of cryptocurrency exchanges for trading and accessing market data",
"version": "0.6.0",
"project_urls": {
"Bug Tracker": "https://github.com/ren3104/pycryptoex/issues",
"Homepage": "https://github.com/ren3104/pycryptoex",
"Repository": "https://github.com/ren3104/pycryptoex"
},
"split_keywords": [
"altcoin",
" api",
" api-client",
" async",
" bitcoin",
" crypto",
" cryptocurrency",
" exchange",
" trade",
" trading",
" websocket"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "9d28e5b20b02f7aeeaed3ff5ba110bef63b5b63a9ee317e9eaa7a5854cf6a6dc",
"md5": "a10c8b0feb9716a5904f28ade29f09aa",
"sha256": "afd4d3a504031051ef0473bf14ca92080c12f1c3d9fbaa7e9d18a8887dc5675d"
},
"downloads": -1,
"filename": "pycryptoex-0.6.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a10c8b0feb9716a5904f28ade29f09aa",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 10713,
"upload_time": "2024-11-22T15:01:29",
"upload_time_iso_8601": "2024-11-22T15:01:29.157387Z",
"url": "https://files.pythonhosted.org/packages/9d/28/e5b20b02f7aeeaed3ff5ba110bef63b5b63a9ee317e9eaa7a5854cf6a6dc/pycryptoex-0.6.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "d6d096f583d409d6b45b95c158d46e405c32a95688755327664fc09fea23b173",
"md5": "14e3faba38d091cd93d7b53541ba52cb",
"sha256": "bc240ebb706ee905e040961cc81efe7825cc47457d766aaf32b1a92edcba51bb"
},
"downloads": -1,
"filename": "pycryptoex-0.6.0.tar.gz",
"has_sig": false,
"md5_digest": "14e3faba38d091cd93d7b53541ba52cb",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 12149,
"upload_time": "2024-11-22T15:01:28",
"upload_time_iso_8601": "2024-11-22T15:01:28.112665Z",
"url": "https://files.pythonhosted.org/packages/d6/d0/96f583d409d6b45b95c158d46e405c32a95688755327664fc09fea23b173/pycryptoex-0.6.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-22 15:01:28",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "ren3104",
"github_project": "pycryptoex",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "pycryptoex"
}