Skip to content

Instantly share code, notes, and snippets.

@ralphtheninja
Created May 3, 2013 01:04
Show Gist options
  • Select an option

  • Save ralphtheninja/5506567 to your computer and use it in GitHub Desktop.

Select an option

Save ralphtheninja/5506567 to your computer and use it in GitHub Desktop.
import threading, websocket, json
class mtgox( threading.Thread ):
def run( self ):
websocket.enableTrace( True )
url = 'wss://websocket.mtgox.com'
self.socket = websocket.WebSocketApp( url, on_open = self.on_open )
self.socket.run_forever( )
def subscribe( self, channel ):
output = { 'op': 'mtgox.subscribe', 'type': channel }
self.socket.send(json.dumps(output))
def on_open( self, socket ):
self.subscribe( 'ticker' )
if __name__ == '__main__':
mtgox = mtgox( )
mtgox.start( )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment