Skip to main content

ssc2ce

A set of simple connectors for access to few cryptocurrency Exchanges via websocket based on aiohttp.

Supported Exchanges:

  • Bitfinex - only public API,
  • CEX.io,
  • Coinbase Pro
  • Deribit

This is more of a pilot project, if you have any wishes for adding exchanges or expanding functionality, please register issues.

Installation

Install ssc2ce with:

$ pip install ssc2ce

You can run some examples with

Bitfinex

Description

API description look at Websocket API v2

Basic example

import asyncio

from ssc2ce import Bitfinex

conn = Bitfinex()


def handle_subscription(data, connector: Bitfinex):
    print(data, f"received:{connector.receipt_time}")


async def subscribe():
    await conn.subscribe({
        "channel": "ticker",
        "symbol": "tBTCUSD"
    }, handler=handle_subscription)


conn.on_connect_ws = subscribe

loop = asyncio.get_event_loop()

try:
    loop.run_until_complete(conn.run_receiver())
except KeyboardInterrupt:
    print("Application closed by KeyboardInterrupt.")

Deribit

Description

API description look at Deribit API v2 websocket

Basic example

import asyncio
from ssc2ce import Deribit

conn = Deribit()


async def subscribe():
    await conn.send_public(request={
        "method": "public/subscribe",
        "params": {
            "channels": ["deribit_price_index.btc_usd"]
        }
    })


def handle_subscription(data):
    method = data.get("method")
    if method and method == "subscription":
        if data["params"]["channel"].startswith("deribit_price_index"):
            index_name = data["params"]["data"]["index_name"]
            price = data["params"]["data"]["price"]
            print(f" Deribit Price Index {index_name.upper()}: {price}")


conn.on_connect_ws = subscribe
conn.method_routes += [("subscription", handle_subscription)]

loop = asyncio.get_event_loop()


try:
    loop.run_until_complete(conn.run_receiver())
except KeyboardInterrupt:
    print("Application closed by KeyboardInterrupt.")

Run examples from a clone

If you clone repository you can run examples in docker container.

make run cmd='python examples/bitfinex/bitfinex_basic_example.py'

To run the private.py example, you must create and fill in the .env file, look at .env.example

make run cmd='python examples/deribit/deribit_private.py'

Metadata

Release files for ssc2ce 0.14.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ssc2ce 0.14.4
File Size Uploaded Provenance Actions
ssc2ce-0.14.4.tar.gz 23.1 kB Without provenance Details for ssc2ce-0.14.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ssc2ce 0.14.4
File Interpreter ABI Platform Actions
ssc2ce-0.14.4-py3-none-any.whl Python 3 none any Details for ssc2ce-0.14.4-py3-none-any.whl

Total release size: 61.8 kB

Release files / ssc2ce-0.14.4.tar.gz

Download URL ssc2ce-0.14.4.tar.gz
Size 23.1 kB
Tags Source
SHA-256 checksum
How to use checksums
2bf3a56cd8af9918a7fbacf50830784d5bab95242b0b658d722f927b93860a8e
BLAKE2b-256 checksum
How to use checksums
cfb290ef282cc07763c6cc3b95942c5b87da43e3c78b69def2e30b7b1e2e2e4a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.1

Release files / ssc2ce-0.14.4-py3-none-any.whl

Download URL ssc2ce-0.14.4-py3-none-any.whl
Size 38.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ace719f8175d3bb75e7f308f77cbce9b613268bcb72c676a294187a6d4987277
BLAKE2b-256 checksum
How to use checksums
e66db68e4c4f0824acf7e363c0a18111b5fff78fab426cdb8a0ff35e39681a95
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.1

Security for ssc2ce 0.14.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page