Python signalR client using asyncio. It's mainly based on TargetProcess signalR client which uses gevent.
I am mainly developing the client for my Python Bittrex Websocket project, however I would make it as universal as possible.
- Error handling
None right now.
- For better performance users can install
uvloop
andujson
which are automatically detected. - Users can pass a custom session to the client, i.e a
cfscrape
session in order to bypass Cloudflare.
Asyncio requires Python 3.5+.
For Python2.X compatibility try TargetProcess' gevent based SignalR client.
pip install signalr-client-aio
pip install git+https://github.com/slazarov/python-signalr-client.git
pip install git+https://github.com/slazarov/python-signalr-client.git@next-version-number
from signalr_aio import Connection
from base64 import b64decode
from zlib import decompress, MAX_WBITS
import json
def process_message(message):
deflated_msg = decompress(b64decode(message), -MAX_WBITS)
return json.loads(deflated_msg.decode())
# Create debug message handler.
async def on_debug(**msg):
# In case of 'queryExchangeState'
if 'R' in msg and type(msg['R']) is not bool:
decoded_msg = process_message(msg['R'])
print(decoded_msg)
# Create error handler
async def on_error(msg):
print(msg)
# Create hub message handler
async def on_message(msg):
decoded_msg = process_message(msg[0])
print(decoded_msg)
if __name__ == "__main__":
# Create connection
# Users can optionally pass a session object to the client, e.g a cfscrape session to bypass cloudflare.
connection = Connection('https://beta.bittrex.com/signalr', session=None)
# Register hub
hub = connection.register_hub('c2')
# Assign debug message handler. It streams unfiltered data, uncomment it to test.
connection.received += on_debug
# Assign error handler
connection.error += on_error
# Assign hub message handler
hub.client.on('uE', on_message)
hub.client.on('uS', on_message)
# Send a message
hub.server.invoke('SubscribeToExchangeDeltas', 'BTC-ETH')
hub.server.invoke('SubscribeToSummaryDeltas')
hub.server.invoke('queryExchangeState', 'BTC-NEO')
# Start the client
connection.start()
0.0.1.6.2 - 16/04/2018:
-
- Removed
uvloop
as a requirement. However, it will be detected and utilized if installed.
- Removed
0.0.1.5 - 06/04/2018:
- Removed
cfscrape
from package. Users can optionally pass acfscrape
session to clients. - Removed
ujson
. The package will automatically detect if the user chooses to useujson
.
0.0.1.0 - Initial release.
Python websocket client for getting live streaming data from Bittrex Exchange.
Python CLI tool to auto sell coins on Bittrex.
It is used in the cases when you want to auto sell a specific coin for another, but there is no direct market, so you have to use an intermediate market.