0

私は現在、Python で暗号通貨取引プラットフォームを構築しており、アウトバーンを使用して市場イベントを受信して​​います。サブスクリプション オプションの使用で問題が発生しています。

(ハンドラー、トピック) 引数だけでサブスクリプションを作成し、ハンドラーが単一の引数を取るようにすると、すべて正常に動作します。ただし、(ハンドラー、トピック、オプション) 引数を使用してサブスクリプションを作成し、ハンドラーが 2 つの引数を取るようにすると、ハンドラーが呼び出されません。ドキュメントでは、この場合、ハンドラーには args、kwargs、および details の 3 つの引数が必要であると記載されています。ハンドラーに 3 つの引数を取るようにすると、それも機能しません。私は絶望的に、0から5の引数の間のすべてを試しました。

つまり、サブスクリプション オプションを使用せず、ハンドラーに 1 つの引数を指定すると、問題なく動作します。サブスクリプション オプションを使用すると、使用する引数の数に関係なく、ハンドラーがトリガーされません。

ペアを出力しようとしましたが、これは有効な文字列であり、オプションを出力しようとしましたが、これは有効なサブスクリプション オプション オブジェクトです。一致基準に「なし」を使用していることに注意してください。私はまだサブスクリプションの確認を取得しており、エラーはありません.

任意の提案をいただければ幸いです。

コードは次のとおりです。

def onJoin(self, details):
    print("{} client session ready".format(self.exchange))

    def marketEvent(args, kwargs, details):
        print("marketEvent called")

    # 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)
4

1 に答える 1

0

私の友人の助けを借りて、修正しました。marketEvent に必要な署名は次のとおりです。

marketEvent(イベント, **詳細)

于 2014-11-18T01:13:36.227 に答える