本文整理汇总了Python中autobahn.twisted.websocket.WebSocketClientFactory.coinbaseClient方法的典型用法代码示例。如果您正苦于以下问题:Python WebSocketClientFactory.coinbaseClient方法的具体用法?Python WebSocketClientFactory.coinbaseClient怎么用?Python WebSocketClientFactory.coinbaseClient使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类autobahn.twisted.websocket.WebSocketClientFactory
的用法示例。
在下文中一共展示了WebSocketClientFactory.coinbaseClient方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: onTicker
# 需要导入模块: from autobahn.twisted.websocket import WebSocketClientFactory [as 别名]
# 或者: from autobahn.twisted.websocket.WebSocketClientFactory import coinbaseClient [as 别名]
def onTicker(self, data):
"""
Called upon reception of the initial 'ticker' data, triggers WebSocket market data subscription
"""
self.log('onTicker, data[{0}'.format(data))
ticker = json.loads(data)
self.log('received ticker from exchange {0}'.format(data))
price = ticker.get("price", None)
if price is None:
self.fatal("could not retrieve price")
self.basePrice = Decimal(price)
self.log('retrieved base price for {0}: {1}'.format(self.product, self.basePrice))
self.log('starting websocket connection')
factory = WebSocketClientFactory(self.wsAddress)
factory.protocol = CoinbaseWebSocketClient
factory.coinbaseClient = self
connectWS(factory)