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.1.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.1-py3-none-any.whl (17.0 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for three-commas-websocket-assist-0.2.1.tar.gz
Algorithm Hash digest
SHA256 27b502bfb20a5466fd8b681ad7eb52c636c572a597e7750e0fcd2a90d60a2b64
MD5 868d26cc4ff51c7d7cfe37d622cef342
BLAKE2b-256 747f5670213f21bbea025a6f758942e666922c2ca1dc86e48cc70c14c6d62b64

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for three_commas_websocket_assist-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c8aa8c0f7a4edb6a440a39095b00b38e6cfc97d45125a376ecbf0c9eb306dedd
MD5 407b3325cf9374445f759eed4f26f3de
BLAKE2b-256 a798bd291088d4b6388949e0da614269410b010362ee878d771920a406f4b232

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