Skip to main content

Ccxw - CryptoCurrency eXchange Websocket Library

Project description

CCXW - CryptoCurrency eXchange Websocket Library

This library is designed to fetch data from exchange WebSocket APIs and store or update data in a temporary SQLite database in the background, making it readily accessible for retrieval.

Currently, it is available for several exchanges, including Binance, Bybit, and more. You can find a complete list of supported exchanges using Ccxw.get_supported_exchanges().

Furthermore, the library supports a variety of endpoints, such as order_book, kline, and more. A comprehensive list of supported endpoints can be found via Ccxw.get_supported_endpoints().

Example

Install

pip install ccxw

Use

import time
import pprint
from ccxw import Ccxw

symbol = 'BTC/USDT'

streams = [\
                {\
                    'endpoint': 'order_book',\
                    'symbol': symbol
                },\
                {\
                    'endpoint': 'kline',\
                    'symbol': symbol,\
                    'interval': interval\
                },\
                {\
                    'endpoint': 'trades',\
                    'symbol': symbol
                },\
                {\
                    'endpoint': 'ticker',\
                    'symbol': symbol
                }\
        ]

wsm = Ccxw('binance',\
            streams,\
            result_max_len=5,\
            data_max_len=10)

wsm.start()  # Start getting data

time.sleep(2)  # Wait for available data

for i in range(0, 10):
    for stream in streams:
        interval = 'none'
        if 'interval' in stream:
            interval = stream['interval']
        data = wsm.get_current_data(stream['endpoint'], stream['symbol'], interval)
        pprint.pprint(data, sort_dicts=False)
        print('----------------------------------')
        time.sleep(1)
    print('============================================================')

wsm.stop()  # Stop getting data

Important Information

Please be aware that each instance opens a new connection to websockets. If you create multiple instances for the same exchange, you may exceed the websockets connection limits set by exchanges. Make sure to check the connection limits of exchanges before opening numerous instances.

View License

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

ccxw-0.2.36.tar.gz (52.9 kB view details)

Uploaded Source

Built Distribution

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

ccxw-0.2.36-py3-none-any.whl (51.8 kB view details)

Uploaded Python 3

File details

Details for the file ccxw-0.2.36.tar.gz.

File metadata

  • Download URL: ccxw-0.2.36.tar.gz
  • Upload date:
  • Size: 52.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for ccxw-0.2.36.tar.gz
Algorithm Hash digest
SHA256 a59b205352cbb1117534563bb4f1ba6e4d103634fe3a66e36928264c6b3315ab
MD5 3388d1e965e8a544c7618f0b2f0c8392
BLAKE2b-256 9fce8b82954d9ca8e81cc91d8dfd824acdf0f1d8e885a7ed7d1b90053276a033

See more details on using hashes here.

File details

Details for the file ccxw-0.2.36-py3-none-any.whl.

File metadata

  • Download URL: ccxw-0.2.36-py3-none-any.whl
  • Upload date:
  • Size: 51.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for ccxw-0.2.36-py3-none-any.whl
Algorithm Hash digest
SHA256 2abb9a53c5b416b1375c29beec286e433af35a6e599e5f9d0cd5c902418dfbcf
MD5 b045c7cf4a9b47c2322be7c0970f0895
BLAKE2b-256 c78ccd5f8fd75fbd85ed5c2b49e62db9acd5fb0f1fc47a33f4eab9f4ce0f19a8

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