THIS HAS BEEN ANSWERED THANKS ANYWAYS!
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( )