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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for three-commas-websocket-assist-0.2.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27b502bfb20a5466fd8b681ad7eb52c636c572a597e7750e0fcd2a90d60a2b64 |
|
MD5 | 868d26cc4ff51c7d7cfe37d622cef342 |
|
BLAKE2b-256 | 747f5670213f21bbea025a6f758942e666922c2ca1dc86e48cc70c14c6d62b64 |
Close
Hashes for three_commas_websocket_assist-0.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c8aa8c0f7a4edb6a440a39095b00b38e6cfc97d45125a376ecbf0c9eb306dedd |
|
MD5 | 407b3325cf9374445f759eed4f26f3de |
|
BLAKE2b-256 | a798bd291088d4b6388949e0da614269410b010362ee878d771920a406f4b232 |