Skip to content

Instantly share code, notes, and snippets.

@darden1
Created December 7, 2016 11:37
Show Gist options
  • Save darden1/ac94f3f0682416c65da7824df87963c9 to your computer and use it in GitHub Desktop.
Save darden1/ac94f3f0682416c65da7824df87963c9 to your computer and use it in GitHub Desktop.
from twisted.internet.defer import inlineCallbacks
from autobahn.twisted.wamp import ApplicationSession, ApplicationRunner
import json
def onTick(*args): # everytime we get a push message from the polo ticker
print(json.dumps(args)) # send json string to stdout
class Subscribe2Ticker(ApplicationSession):
@inlineCallbacks
def onJoin(self, details):
yield self.subscribe(onTick, 'ticker')
if __name__ == "__main__":
subscriber = ApplicationRunner(u"wss://api.poloniex.com:443", u"realm1")
subscriber.run(Subscribe2Ticker)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment