Ejemplo n.º 1
0
  public static void main(final String[] args) {
    MamaTransport transport = null;
    MamaTransport mDictTransport = null;
    MamaDictionary dictionary = null;
    CommandLineProcessor options = new CommandLineProcessor(args);

    Level level = options.getLogLevel();
    if (level != null) {
      theLogger.setLevel(level);
      Mama.enableLogging(level);
    }
    theLogger.info("Source: " + options.getSource());

    try {
      // Initialize MAMDA
      mBridge = options.getBridge();
      Mama.open();
      transport = new MamaTransport();
      transport.create(options.getTransport(), mBridge);

      mDictTransportName = options.getDictTransport();

      if (mDictTransportName != null) {
        mDictTransport = new MamaTransport();
        mDictTransport.create(mDictTransportName, mBridge);
      } else {
        mDictTransport = transport;
      }

      // Get the Data dictionary.....
      dictionary = buildDataDictionary(mDictTransport, options.getDictSource());

      MamdaFundamentalFields.setDictionary(dictionary, null);
      MamdaCommonFields.setDictionary(dictionary, null);

      for (Iterator iterator = options.getSymbolList().iterator(); iterator.hasNext(); ) {
        final String symbol = (String) iterator.next();
        MamdaSubscription aSubscription = new MamdaSubscription();
        MamdaFundamentalListener aFundamentalListener = new MamdaFundamentalListener();
        FundamentalTicker aTicker = new FundamentalTicker();

        aFundamentalListener.addHandler(aTicker);
        aSubscription.addMsgListener(aFundamentalListener);
        aSubscription.addStaleListener(aTicker);
        aSubscription.addErrorListener(aTicker);

        aSubscription.create(
            transport, Mama.getDefaultQueue(mBridge), options.getSource(), symbol, null);

        theLogger.fine("Subscribed to: " + symbol);
      }

      Mama.start(mBridge);
      Thread.currentThread().join();
    } catch (Exception e) {
      e.printStackTrace();
      System.exit(1);
    }
  }
Ejemplo n.º 2
0
 public void onFundamentals(
     MamdaSubscription subscription,
     MamdaFundamentalListener listener,
     MamaMsg msg,
     MamdaFundamentals fundas) {
   System.out.println(
       "Fundamental update ("
           + subscription.getSymbol()
           + "    wDivFreq: "
           + fundas.getDividendFrequency()
           + "    wMarketSegment: "
           + fundas.getMarketSegment()
           + "    wMarketSector: "
           + fundas.getMarketSector()
           + ")");
 }
Ejemplo n.º 3
0
 public void onError(
     MamdaSubscription subscription, short severity, short errorCode, String errorStr) {
   System.out.println("Error (" + subscription.getSymbol() + "): ");
 }
Ejemplo n.º 4
0
 public void onStale(MamdaSubscription subscription, short quality) {
   System.out.println("Stale (" + subscription.getSymbol() + "): ");
 }