Je veux créer un client WAMP (Web Application Messaging Protocol) pour m'abonner au ticker de poloniex. Il y a quelques infomation utiles dans le document API de poloniex comme suit:Comment puis-je créer un client de protocole WAMP pour le sous-scannage dans Python2?
The best way to get public data updates on markets is via the push API,
which pushes live ticker, order book, trade, and Trollbox updates over
WebSockets using the WAMP protocol. In order to use the push API,
connect to wss://api.poloniex.com and subscribe to the desired feed.
In order to receive ticker updates, subscribe to "ticker".
Mais ils ne disent pas comment utiliser python pour vous abonner it.Then je tente de recherche dans Google, je coundn't quoi que ce soit l'aide. Est-ce que quelqu'un peut me montrer comment construire un client WAMP pour sous-traiter le ticker de poloniex? Merci!
----------- -------------- mise à jour j'ai trouvé le code suivant ce qui semble faire ce que je veux:
from autobahn.asyncio.wamp import ApplicationSession
from autobahn.asyncio.wamp import ApplicationRunner
from asyncio import coroutine
class PoloniexComponent(ApplicationSession):
def onConnect(self):
self.join(self.config.realm)
@coroutine
def onJoin(self, details):
def onTicker(*args):
print("Ticker event received:", args)
try:
yield from self.subscribe(onTicker, 'ticker')
except Exception as e:
print("Could not subscribe to topic:", e)
def main():
runner = ApplicationRunner(u"wss://api.poloniex.com:443", "realm1")
runner.run(PoloniexComponent)
if __name__ == "__main__":
main()
Mais il montre l'erreur suivante:
Traceback (most recent call last):
File "wamp.py", line 5, in <module>
from autobahn.asyncio.wamp import ApplicationSession
File "/usr/lib/python2.7/site-packages/autobahn/asyncio/__init__.py", line 36, in <module>
from autobahn.asyncio.websocket import \
File "/usr/lib/python2.7/site-packages/autobahn/asyncio/websocket.py", line 32, in <module>
txaio.use_asyncio()
File "/usr/lib/python2.7/site-packages/txaio/__init__.py", line 122, in use_asyncio
from txaio import aio
File "/usr/lib/python2.7/site-packages/txaio/aio.py", line 47, in <module>
import asyncio
File "/usr/lib/python2.7/site-packages/asyncio/__init__.py", line 9, in <module>
from . import selectors
File "/usr/lib/python2.7/site-packages/asyncio/selectors.py", line 39
"{!r}".format(fileobj)) from None
^
SyntaxError: invalid syntax
J'ai trouvé quelques indices qui semble un certain module ne fonctionne correctement dans python3. Quelle déception!
Rechercher un abonnement de socket Web. Je suis tombé sur ce paquet - https://pypi.python.org/pypi/websocket-client. Vous recherchez peut-être quelque chose de trop spécifique avec poloniex. – PressingOnAlways
@PressingOnAlways Je ne suis pas sûr de la différence entre websocket-client et WAMP. Est-ce la même chose quand je m'abonne à partir du serveur WAMP? –
Lire http://wamp-proto.org/. https://github.com/crossbario/autobahn-python. http://wamp-proto.org/implementations/ https://github.com/noisyboiler/wampy. Vous devez améliorer vos compétences googling si vous voulez être un développeur sérieux! – PressingOnAlways