Hi all,
I am having an issue whereby my subscriptions work fine without the options argument (handler gets called), but the handler is not called when I provide options. I have checked that the options are a valid SubcriptionOption object, and that I am using 'none' for the match type. I have tried giving the handler 1, 2, and 3 arguments, as the documentation states that three are required, but I could not see what the other one would be (working in python, so no types), and it just isn't working. Would it be possible for somebody to look over my code, and see whether they can see anything obviously dumb?
Any input would be greatly appreciated. Thank you for your time.
--Cass
Code follows. This is the beginnings of a cryptocurrency trading platform.
from autobahn.asyncio.wamp import ApplicationSession
from autobahn.asyncio.wamp import ApplicationRunner
from autobahn.wamp.types import SubscribeOptions
from asyncio import coroutine
import sys
import json
from io import StringIO
poloniex_URL = "wss://
api.poloniex.com"
class TradeClient(ApplicationSession):
exchange = "NULL"
def eventProcessor(self, event):
print("eventProcessor called")
print("market event received: {}".format(event))
def onJoin(self, details):
print("{} client session ready".format(self.exchange))
def marketEvent(args, kwargs, details):
print("marketEvent called")#: {}".format(pair))
# Read in configuration files
try:
pairs = [line.strip() for line in open("conf/" + self.exchange + ".conf")]
except:
print("Configuration file not found for {}!".format(self.exchange))
sys.exit(1)
# Subscribe to each currency pair / topic in the conf file
for pair in pairs:
try:
# provide currency pair name to handler
options = SubscribeOptions(details_arg = pair)
yield from self.subscribe(marketEvent, pair, options)
print("subscribed to {} on {}".format(pair, self.exchange))
except Exception as e:
print("could not subscribe to {} on {}: {}".format(pair, exchange, e))
sys.exit(1)
class PoloniexClient(TradeClient):
exchange = "poloniex"
poloniex_runner = ApplicationRunner(url = poloniex_URL, realm = "realm1")
poloniex_runner.run(PoloniexClient)