Author

Topic: MtGox websocket API: I get ticker and depth messages, but no trade or lag (Read 4646 times)

newbie
Activity: 30
Merit: 0
I'm not sure whether anyone is still reading here, but I'll give it a try. I ran the above code in python 2.7.6 - using wss instead of ws - and get the following response:

Code:
--- request header ---
GET /mtgox?Currency=USD HTTP/1.1

Upgrade: websocket

Connection: Upgrade

Host: websocket.mtgox.com:443

Origin: http://websocket.mtgox.com:443

Sec-WebSocket-Key: 81DMJF11Qdm5wmo2mtVKjw==

Sec-WebSocket-Version: 13




-----------------------
--- response header ---
HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: pu7sv8PRAVRv/5VknsU2qMvbfhI=
-----------------------
send: '\x81\xaa\xc6\x00\x86\xa9\xbd"\xf2\xd0\xb6e\xa4\x93\xe6"\xe2\xcc\xb6t\xee\x8b\xea \xa4\xc6\xb6"\xbc\x89\xe4m\xf2\xce\xa9x\xa8\xda\xb3b\xf5\xca\xb4i\xe4\xcc\xe4}'
send: '\x81\xa8\x91\xbf\xdc\xc1\xea\x9d\xa8\xb8\xe1\xda\xfe\xfb\xb1\x9d\xb0\xa0\xf6\x9d\xf0\xe1\xb3\xd0\xac\xe3\xab\x9f\xfe\xac\xe5\xd8\xb3\xb9\xbf\xcc\xa9\xa3\xe2\xdc\xae\xa8\xf3\xda\xfe\xbc'
send: "\x81\xab\x05\xc5!#~\xe7UZu\xa0\x03\x19%\xe7UJf\xaeDQ'\xe9\x01\x01j\xb5\x03\x19%\xe7LWb\xaaY\rv\xb0CPf\xb7HA`\xe7\\"
send: '\x81\xab\x9ddq\xaa\xe6F\x05\xd3\xed\x01S\x90\xbdF\x05\xd8\xfc\x00\x14\xd9\xbfHQ\x88\xf2\x14S\x90\xbdF\x1c\xde\xfa\x0b\t\x84\xee\x11\x13\xd9\xfe\x16\x18\xc8\xf8F\x0c'

Does anyone know whether this is what I should get? How do I interpret this response? How do I get the ticker / depth / etc. updates?
Thanks
newbie
Activity: 14
Merit: 0
Try changing ws into wss.
newbie
Activity: 3
Merit: 0
Same here and using the same python code. Bad request 400. What's going on?
newbie
Activity: 1
Merit: 0
Hello I am trying to do the same thing you are and yet when I run the code I made I get.

-----------------------
--- response header ---
HTTP/1.1 400 Bad Request
-----------------------
Handshake Status 400
### closed ###

This is very frustrating would you happen to know what I am doing wrong?
newbie
Activity: 14
Merit: 0
It seems to be working now. Now I also get trade and lag messages. Apparently it was something at MtGox's side.
newbie
Activity: 42
Merit: 0
I've been experiencing the same thing from the websocket. A stream of Ticker messages, and occasional depth message and I haven't seen a trade message yet.
I'd really like to figure this out!
newbie
Activity: 14
Merit: 0
I'm experimenting with the MtGox websocket API. This API is documented here https://en.bitcoin.it/wiki/MtGox/API/Streaming and discussed here https://bitcointalksearch.org/topic/m.86219. However since I'm a newbie I can't post my question there, so I have to ask it here. I'm using Python with the websocket module from https://pypi.python.org/pypi/websocket-client. See example code below

Code:
import threading
import websocket
import json

class mtgox( threading.Thread ):

    def run( self ):
        websocket.enableTrace( True )
        url = 'ws://websocket.mtgox.com/mtgox?Currency=USD'
        self.socket = websocket.WebSocketApp( url, on_open = self.on_open )
        self.socket.run_forever( )

    def subscribe( self, channel ):
        output = { 'op': 'mtgox.subscribe', 'type': channel }
        output = json.dumps( output )
        self.socket.send( output )

    def on_open( self, socket ):
        self.subscribe( 'depth' )
        self.subscribe( 'lag' )        
        self.subscribe( 'ticker' )
        self.subscribe( 'trades' )

if __name__ == '__main__':
    mtgox = mtgox( )
    mtgox.start( )

When I run this code I receive ticker and depth messages, but no lag or trade messages. Also I do not get any replies to my mtgox.subscribe commands, that the documentation seems to promise. However when I send a mtgox.subscribe command with a wrong type parameter, I get an error message "Unknown mtgox message type", so it seems my subscribe commands are received and accepted.

Could somebody please tell me why I'm not receiving trade and lag messages?
Jump to: