Package com.barchart.feed.api

Examples of com.barchart.feed.api.Marketplace


    if (args == null || args.length < 3) {
      throw new RuntimeException("Bad arguments passed to main");
    }
   
    final Marketplace feed = new BarchartMarketplace(args[0], args[1]);

    final MarketObserver<Market> observer = new MarketObserver<Market>() {

      @Override
      public void onNext(Market value) {
       
        final StringBuilder sb = new StringBuilder(value.instrument().marketGUID())
          .append(" ")
          .append(" EventTime=")
          .append(value.updated());

        final Top top = value.book().top();
       
        Entry entry = top.ask();
       
        if (!entry.isNull()) {
          sb.append(" ASK TOP").append(" price=")
              .append(entry.price().asDouble())
              .append(" qty=").append(entry.size().asDouble());
        }
       
        entry = top.bid();
       
        if (!entry.isNull()) {
          sb.append(" BID TOP").append(" price=")
              .append(entry.price().asDouble())
              .append(" qty=").append(entry.size().asDouble());
        }

        System.out.println(sb.toString());

       
      }
     
    };
   
    feed.startup();
   
    final Agent myAgent = feed.newAgent(Market.class, observer);
   
    for(int i = 2; i < args.length; i++) {
      myAgent.include(args[i]);
    }

    System.in.read();
    feed.shutdown();
    System.exit(0);

  }
View Full Code Here


    if (args == null || args.length < 3) {
      throw new RuntimeException("Bad arguments passed to main");
    }
   
    final Marketplace feed = new BarchartMarketplace(args[0], args[1]);

    final MarketObserver<Market> observer = new MarketObserver<Market>() {

      @Override
      public void onNext(Market value) {
       
        final StringBuilder sb = new StringBuilder(value.instrument().marketGUID())
          .append(" ")
          .append(" EventTime=")
          .append(value.updated());

        final Top top = value.book().top();
       
        Entry entry = top.ask();
       
        if (!entry.isNull()) {
          sb.append(" ASK TOP").append(" price=")
              .append(entry.price().asDouble())
              .append(" qty=").append(entry.size().asDouble());
        }
       
        entry = top.bid();
       
        if (!entry.isNull()) {
          sb.append(" BID TOP").append(" price=")
              .append(entry.price().asDouble())
              .append(" qty=").append(entry.size().asDouble());
        }

        System.out.println(sb.toString());

       
      }

    };
   
    feed.startup();
   
    final Agent myAgent = feed.newAgent(Market.class, observer);
   
    for(int i = 2; i < args.length; i++) {
      myAgent.include(args[i]);
    }

    System.in.read();
    feed.shutdown();
    System.exit(0);

  }
View Full Code Here

TOP

Related Classes of com.barchart.feed.api.Marketplace

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.