Crypto-toolbox / btfxwss

Bitfinex Websocket API Client written in Python3
MIT License
284 stars 125 forks source link

Error message output #90

Closed Michshelle closed 6 years ago

Michshelle commented 6 years ago

Hello @nlsdfnbch ,

When I was testing order function, an issue occurs but the error message only appeared in Browser instead of the cmd window or the log.

Morder = {          
"cid":123456,
"type": "LIMIT",  #Need to change to "EXCHANGE LIMIT" concerning my user account in bitfinex.
"symbol": "tBTCUSD",
"amount": "0.01",
"price": 7499,
"hidden": 0
}
wss.new_order(**Morder)

The issue is with the type in Morder. I should change it to EXCHANGE LIMIT to work, otherwise I got reminded in the browser no enough balance to support the order (it may keep popping out there all the time, only I just noticed it).

Is there a way I can output such error message to the log?

Currently, the test log looks like,

INFO:btfxwss.connection:Connection opened
DEBUG:btfxwss.client:_subscribe: {'event': 'subscribe', 'channel': 'ticker', 'symbol': 'BTCUSD'}
DEBUG:btfxwss.client:_subscribe: {'event': 'subscribe', 'channel': 'book', 'symbol': 'BTCUSD'}
INFO:btfxwss.queue_processor:Subscription succesful for channel ('ticker', 'BTCUSD')
INFO:btfxwss.queue_processor:Subscription succesful for channel ('book', 'BTCUSD')
INFO:btfxwss.connection:Connection closed

You may check up the entire code piece in issue #89.

Best regards,

Michelle

deepbrook commented 6 years ago

Hey @Michshelle !

The btfxwss class takes a kwarg named log_level if you pass it logging.DEBUG, you'll see all the messages sent and received by the client:

import logging

c = btfxwss(log_level=logging.DEBUG)
Michshelle commented 6 years ago

Thank you @nlsdfnbch . It works. However some of the string seem to compressed. b"\x81\xf2\x0bY\x95\x8ePi\xb9\xae)6\xfb\xac'y\xfb\xfbg5\xb9\xaep{\xe1\xf7{<\xb7\xb4+{\xd0\xd6H\x11\xd4\xc0L\x1c\xb5\xc2B\x14\xdc\xda)u\xb5\xac{+\xfc\xedn{\xaf\xae)l\xa6\xbf;i\xa5\xac'y\xb7\xeff6\xe0\xe0\x7f{\xaf\xae)i\xbb\xbe:{\xb9\xae)1\xfc\xeao<\xfb\xac1y\xa5"

deepbrook commented 6 years ago

@Michshelle , yes, that's the output of the websocket-client component, but you should also see byte strings for all later method calls! Glad I was of help!

Nils