Skip to main content

3commas websocket stream assist

Project description

three-commas-websocket-assist

GNU General Public License v3.0

pip install three-commas-websocket-assist

Import

from three-commas-websocket-assist import ThreeCommasWebsocketHandler

Supports seperate threading. pass seperate_thread=True to start_listener() to run it on a seperate thread (i.e. when running along side flask or mutliple streams)

1. Setting up the listener

Pass 3commas api key/secret and the channel you desire to ThreeCommasWebsocketHandler:

st = ThreeCommasWebsocketHandler(
    api_key=API_KEY,
    api_secret=API_SECRET,
    channel="DealsChannel",
)
st.start_listener()

ThreeCommasWebsocketHandler automatically generates the stream identifier and uses that for the stream

2. Handle event

Pass a custom event handler to the ThreeCommasWebsocketHandler to handle any event based on your deal channel: Event handler is Callable[[Dict], None]

st = ThreeCommasWebsocketHandler(
    api_key=API_KEY,
    api_secret=API_SECRET,
    channel="DealsChannel",
    external_event_handler=sample_event_handler
)
st.start_listener()

Sample event handler:

def sample_event_handler(data:Dict) -> None:
    """
    Sample Event Handler for websocket
    """
    _LOGGER.debug("Bot_id: %s", data['bot_id'])

    # Do something with the data here

3. Run it on seperate thread:

st = ThreeCommasWebsocketHandler(
    api_key=API_KEY,
    api_secret=API_SECRET,
    channel="DealsChannel",
    external_event_handler=sample_event_handler
)
st.start_listener(seperate_thread=True)

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

three-commas-websocket-assist-0.2.0.tar.gz (16.6 kB view details)

Uploaded Source

Built Distribution

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

three_commas_websocket_assist-0.2.0-py3-none-any.whl (17.0 kB view details)

Uploaded Python 3

File details

Details for the file three-commas-websocket-assist-0.2.0.tar.gz.

File metadata

File hashes

Hashes for three-commas-websocket-assist-0.2.0.tar.gz
Algorithm Hash digest
SHA256 f6a73fa293051adb2a79c004d0a31f58057db296acc65b3b2711b3729616e7f8
MD5 087aeba6e219cb11374e7d4ec48f2348
BLAKE2b-256 60aed58eeea67acdf44b1a7cd683c67082d32420149c0a48aa163c3c83abe45e

See more details on using hashes here.

File details

Details for the file three_commas_websocket_assist-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for three_commas_websocket_assist-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0ebbad79bfdd17ab7af573e9a739f48340abb45aad5396736c430e0b9f75b4e0
MD5 6deb65dc19482eebaf8be7cfd310e560
BLAKE2b-256 e43e3451507d6e110f13943e4337f43fbdd73a017512d372b4aed81b737370c1

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