Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problem getting data #30

Open
hippylover opened this issue Sep 15, 2017 · 1 comment
Open

problem getting data #30

hippylover opened this issue Sep 15, 2017 · 1 comment

Comments

@hippylover
Copy link

hippylover commented Sep 15, 2017

Hello. I would like to get live orderbook updates as outlined in attached doc.
WebSocketAPI_MarketTracking_bittrex.docx

But i can't figure out how to do it.

from requests import Session
from signalr import Connection
import time

markets = ['BTC-DGB', 'BTC-STRAT']

with Session() as session:
	connection = Connection('http://socket.bittrex.com/signalr', session)

	corehub = connection.register_hub('coreHub')
	connection.start()

	#create new chat message handler
	def print_received_message(data):
		print(data)
		# if data['Nounce'] is not None:
		# 	print('Nounce', data['Nounce'])

		# if data['Deltas'] is not None:
		# 	for value in data['Deltas']:
		# 		print(value)

		

	#create error handler
	def print_error(error):
		print('error: ', error)

	# debug information, show all data
	def print_raw_data(*args, **kwargs):
		print (args, kwargs)
	
	connection.received += print_raw_data

	with connection:
		corehub.server.invoke('SubscribeToExchangeDeltas', ['BTC-ETH'])

	#corehub.client.on('updateSummaryState', print_received_message)

	connection.error += print_error

	connection.wait(1)
 
while True:
	pass

Do anyone know what is wrong?

@rchiossi
Copy link

With pr #33 I'm able to connect to bittrex with the following code:

from requests import Session
from signalr import Connection

def handle_received(**data):
    print(data)

def print_error(error):
    print('error: ', error)


def main():
    with Session() as session:
        connection = Connection("https://www.bittrex.com/signalR/", session)
        corehub = connection.register_hub('corehub')
        connection.start()

        connection.received += handle_received
        connection.error += print_error

        for market in ["BTC-ETH"]:
            corehub.server.invoke('SubscribeToExchangeDeltas', market)

        while True:
            connection.wait(1)

if __name__ == "__main__":
    main()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants